From 4f9eefd91b825c1acb3389d5295bdc7dc8999342 Mon Sep 17 00:00:00 2001 From: Vincent Weevers Date: Sun, 20 Apr 2025 18:23:41 +0200 Subject: [PATCH 1/2] Breaking: upgrade to abstract-level 3 Category: change --- UPGRADING.md | 39 +++++++++++++++++++++++++++++++++++++++ package.json | 6 +++--- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/UPGRADING.md b/UPGRADING.md index 4b7ca91..e7ed721 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -2,6 +2,45 @@ This document describes breaking changes and how to upgrade. For a complete list of changes including minor and patch releases, please refer to the [changelog](CHANGELOG.md). +## 10.0.0 + +This release upgrades to `abstract-level` 3. Please see its [upgrade guide](https://github.com/Level/abstract-level/blob/v3.0.0/UPGRADING.md) for details. On this end we'll only summarize its new features, because they're not supported in all environments. + +In Node.js (but not browsers) you can now create "explicit snapshots" to read previous versions of a database: + +```js +await db.put('example', 'before') +const snapshot = db.snapshot() +await db.put('example', 'after') +await db.get('example', { snapshot })) // Returns 'before' +await snapshot.close() +``` + +In Node.js with TypeScript (5.2) that last `close()` call can be skipped because we added support of [`Symbol.asyncDispose`](https://github.com/tc39/proposal-explicit-resource-management) on databases, iterators and snapshots: + +```ts +await db.put('example', 'before') +await using snapshot = db.snapshot() +await db.put('example', 'after') +await db.get('example', { snapshot })) // Returns 'before' +``` + +In Node.js and browsers you can use newly-added `has()` and `hasMany()` methods to check if keys exist without the cost of fetching values: + +```js +if (await db.has('fruit')) { + console.log('We have fruit') +} +``` + +In Node.js you can (in certain cases) improve application performance using a new `getSync()` method that blocks the event loop but can be significantly faster than the asynchronous `db.get()` method: + +```js +const value = db.getSync('example') +``` + +Lastly, `has()`, `hasMany()` and `getSync()` also support explicit snapshots. Bon appétit! + ## 9.0.0 This release upgrades to `abstract-level` 2.0.0 which adds [hooks](https://github.com/Level/abstract-level#hooks) and drops callbacks and not-found errors. Please refer to the [upgrade guide of `abstract-level`](https://github.com/Level/abstract-level/blob/v2.0.0/UPGRADING.md) for details. The only thing to add is that this release ends support of Node.js < 18 and Electron < 30. diff --git a/package.json b/package.json index 4d9b8cd..4419094 100644 --- a/package.json +++ b/package.json @@ -19,9 +19,9 @@ ], "browser": "browser.js", "dependencies": { - "abstract-level": "^2.0.1", - "browser-level": "^2.0.0", - "classic-level": "^2.0.0" + "abstract-level": "^3.1.0", + "browser-level": "^3.0.0", + "classic-level": "^3.0.0" }, "devDependencies": { "@babel/preset-env": "^7.26.9", From 13ea8b614a56cb00ea1581990a6ef867be144326 Mon Sep 17 00:00:00 2001 From: Vincent Weevers Date: Sun, 20 Apr 2025 22:19:34 +0200 Subject: [PATCH 2/2] Don't make people read the same thing twice --- UPGRADING.md | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-) diff --git a/UPGRADING.md b/UPGRADING.md index e7ed721..e9868fa 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -4,42 +4,15 @@ This document describes breaking changes and how to upgrade. For a complete list ## 10.0.0 -This release upgrades to `abstract-level` 3. Please see its [upgrade guide](https://github.com/Level/abstract-level/blob/v3.0.0/UPGRADING.md) for details. On this end we'll only summarize its new features, because they're not supported in all environments. +This release upgrades to `abstract-level` 3. Please see its [upgrade guide](https://github.com/Level/abstract-level/blob/v3.0.0/UPGRADING.md). -In Node.js (but not browsers) you can now create "explicit snapshots" to read previous versions of a database: - -```js -await db.put('example', 'before') -const snapshot = db.snapshot() -await db.put('example', 'after') -await db.get('example', { snapshot })) // Returns 'before' -await snapshot.close() -``` - -In Node.js with TypeScript (5.2) that last `close()` call can be skipped because we added support of [`Symbol.asyncDispose`](https://github.com/tc39/proposal-explicit-resource-management) on databases, iterators and snapshots: - -```ts -await db.put('example', 'before') -await using snapshot = db.snapshot() -await db.put('example', 'after') -await db.get('example', { snapshot })) // Returns 'before' -``` - -In Node.js and browsers you can use newly-added `has()` and `hasMany()` methods to check if keys exist without the cost of fetching values: - -```js -if (await db.has('fruit')) { - console.log('We have fruit') -} -``` - -In Node.js you can (in certain cases) improve application performance using a new `getSync()` method that blocks the event loop but can be significantly faster than the asynchronous `db.get()` method: +Not mentioned in that guide is the later addition of `db.getSync()`. This new method blocks the event loop but can be significantly faster than `db.get()`: ```js const value = db.getSync('example') ``` -Lastly, `has()`, `hasMany()` and `getSync()` also support explicit snapshots. Bon appétit! +It is only supported in Node.js (via `classic-level`) and not in browsers. ## 9.0.0