Comparing version 7.0.0 to 7.0.1
111
CHANGELOG.md
# Changelog | ||
_**If you are upgrading:** please see [`UPGRADING.md`](UPGRADING.md)._ | ||
## [7.0.1] - 2021-10-02 | ||
### Added | ||
- Document new features ([#207](https://github.com/Level/level/issues/207)) ([`ad8f924`](https://github.com/Level/level/commit/ad8f924)) (Vincent Weevers) | ||
### Fixed | ||
- Bump dependencies to prevent dedupe ([`7083ec6`](https://github.com/Level/level/commit/7083ec6)) (Vincent Weevers) | ||
- Clarify `close()` documentation ([#197](https://github.com/Level/level/issues/197)) ([`c82fdbc`](https://github.com/Level/level/commit/c82fdbc)) (Vincent Weevers) | ||
## [7.0.0] - 2021-04-17 | ||
_If you are upgrading: please see [`UPGRADING.md`](UPGRADING.md)._ | ||
### Changed | ||
@@ -34,2 +45,4 @@ | ||
_If you are upgrading: please see [`UPGRADING.md`](UPGRADING.md)._ | ||
### Changed | ||
@@ -59,2 +72,4 @@ | ||
_If you are upgrading: please see [`UPGRADING.md`](UPGRADING.md)._ | ||
### Changed | ||
@@ -87,2 +102,4 @@ | ||
_If you are upgrading: please see [`UPGRADING.md`](UPGRADING.md)._ | ||
### Changed | ||
@@ -121,2 +138,4 @@ | ||
_If you are upgrading: please see [`UPGRADING.md`](UPGRADING.md)._ | ||
### Added | ||
@@ -162,2 +181,4 @@ | ||
_If you are upgrading: please see [`UPGRADING.md`](UPGRADING.md)._ | ||
### Added | ||
@@ -312,2 +333,4 @@ | ||
_0.17.0 and 0.17.0-1 are listed out of order here, due to 0.17.0-1 not adhering to the semver rules that we follow today._ | ||
### Changed | ||
@@ -318,4 +341,2 @@ | ||
**Historical Note** 0.17.0 and 0.17.0-1 are listed out of order here, due to 0.17.0-1 not adhering to the semver rules that we follow today. | ||
## [0.17.0-1] - 2013-10-09 | ||
@@ -396,82 +417,86 @@ | ||
## 0.8.0 - 2013-05-19 | ||
## [0.8.0] - 2013-05-19 | ||
:seedling: Initial release. | ||
[7.0.0]: https://github.com/Level/level/compare/v6.0.1...v7.0.0 | ||
[7.0.1]: https://github.com/Level/level/releases/tag/v7.0.1 | ||
[6.0.1]: https://github.com/Level/level/compare/v6.0.0...v6.0.1 | ||
[7.0.0]: https://github.com/Level/level/releases/tag/v7.0.0 | ||
[6.0.0]: https://github.com/Level/level/compare/v5.0.1...v6.0.0 | ||
[6.0.1]: https://github.com/Level/level/releases/tag/v6.0.1 | ||
[5.0.1]: https://github.com/Level/level/compare/v5.0.0...v5.0.1 | ||
[6.0.0]: https://github.com/Level/level/releases/tag/v6.0.0 | ||
[5.0.0]: https://github.com/Level/level/compare/v4.0.0...v5.0.0 | ||
[5.0.1]: https://github.com/Level/level/releases/tag/v5.0.1 | ||
[4.0.0]: https://github.com/Level/level/compare/v3.0.2...v4.0.0 | ||
[5.0.0]: https://github.com/Level/level/releases/tag/v5.0.0 | ||
[3.0.2]: https://github.com/Level/level/compare/v3.0.1...v3.0.2 | ||
[4.0.0]: https://github.com/Level/level/releases/tag/v4.0.0 | ||
[3.0.1]: https://github.com/Level/level/compare/v3.0.0...v3.0.1 | ||
[3.0.2]: https://github.com/Level/level/releases/tag/v3.0.2 | ||
[3.0.0]: https://github.com/Level/level/compare/v2.1.2...v3.0.0 | ||
[3.0.1]: https://github.com/Level/level/releases/tag/v3.0.1 | ||
[2.1.2]: https://github.com/Level/level/compare/v2.1.1...v2.1.2 | ||
[3.0.0]: https://github.com/Level/level/releases/tag/v3.0.0 | ||
[2.1.1]: https://github.com/Level/level/compare/v2.1.0...v2.1.1 | ||
[2.1.2]: https://github.com/Level/level/releases/tag/v2.1.2 | ||
[2.1.0]: https://github.com/Level/level/compare/v2.0.1...v2.1.0 | ||
[2.1.1]: https://github.com/Level/level/releases/tag/v2.1.1 | ||
[2.0.1]: https://github.com/Level/level/compare/v2.0.0...v2.0.1 | ||
[2.1.0]: https://github.com/Level/level/releases/tag/v2.1.0 | ||
[2.0.0]: https://github.com/Level/level/compare/v2.0.0-rc3...v2.0.0 | ||
[2.0.1]: https://github.com/Level/level/releases/tag/v2.0.1 | ||
[2.0.0-rc3]: https://github.com/Level/level/compare/v2.0.0-rc2...v2.0.0-rc3 | ||
[2.0.0]: https://github.com/Level/level/releases/tag/v2.0.0 | ||
[2.0.0-rc2]: https://github.com/Level/level/compare/v2.0.0-rc1...v2.0.0-rc2 | ||
[2.0.0-rc3]: https://github.com/Level/level/releases/tag/v2.0.0-rc3 | ||
[2.0.0-rc1]: https://github.com/Level/level/compare/v1.7.0...v2.0.0-rc1 | ||
[2.0.0-rc2]: https://github.com/Level/level/releases/tag/v2.0.0-rc2 | ||
[1.7.0]: https://github.com/Level/level/compare/v1.6.0...v1.7.0 | ||
[2.0.0-rc1]: https://github.com/Level/level/releases/tag/v2.0.0-rc1 | ||
[1.6.0]: https://github.com/Level/level/compare/v1.5.0...v1.6.0 | ||
[1.7.0]: https://github.com/Level/level/releases/tag/v1.7.0 | ||
[1.5.0]: https://github.com/Level/level/compare/v1.4.0...v1.5.0 | ||
[1.6.0]: https://github.com/Level/level/releases/tag/v1.6.0 | ||
[1.4.0]: https://github.com/Level/level/compare/v1.3.0...v1.4.0 | ||
[1.5.0]: https://github.com/Level/level/releases/tag/v1.5.0 | ||
[1.3.0]: https://github.com/Level/level/compare/v1.2.0...v1.3.0 | ||
[1.4.0]: https://github.com/Level/level/releases/tag/v1.4.0 | ||
[1.2.0]: https://github.com/Level/level/compare/v1.1.0...v1.2.0 | ||
[1.3.0]: https://github.com/Level/level/releases/tag/v1.3.0 | ||
[1.1.0]: https://github.com/Level/level/compare/v1.0.0...v1.1.0 | ||
[1.2.0]: https://github.com/Level/level/releases/tag/v1.2.0 | ||
[1.0.0]: https://github.com/Level/level/compare/v1.0.0-0...v1.0.0 | ||
[1.1.0]: https://github.com/Level/level/releases/tag/v1.1.0 | ||
[1.0.0-0]: https://github.com/Level/level/compare/v0.19.1...v1.0.0-0 | ||
[1.0.0]: https://github.com/Level/level/releases/tag/v1.0.0 | ||
[0.19.1]: https://github.com/Level/level/compare/v0.19.0...v0.19.1 | ||
[1.0.0-0]: https://github.com/Level/level/releases/tag/v1.0.0-0 | ||
[0.19.0]: https://github.com/Level/level/compare/0.18.0...v0.19.0 | ||
[0.19.1]: https://github.com/Level/level/releases/tag/v0.19.1 | ||
[0.18.0]: https://github.com/Level/level/compare/0.17.0...0.18.0 | ||
[0.19.0]: https://github.com/Level/level/releases/tag/v0.19.0 | ||
[0.17.0]: https://github.com/Level/level/compare/0.17.0-1...0.17.0 | ||
[0.18.0]: https://github.com/Level/level/releases/tag/0.18.0 | ||
[0.17.0-1]: https://github.com/Level/level/compare/0.16.0...0.17.0-1 | ||
[0.17.0]: https://github.com/Level/level/releases/tag/0.17.0 | ||
[0.16.0]: https://github.com/Level/level/compare/0.15.0...0.16.0 | ||
[0.17.0-1]: https://github.com/Level/level/releases/tag/0.17.0-1 | ||
[0.15.0]: https://github.com/Level/level/compare/0.14.0...0.15.0 | ||
[0.16.0]: https://github.com/Level/level/releases/tag/0.16.0 | ||
[0.14.0]: https://github.com/Level/level/compare/0.13.0...0.14.0 | ||
[0.15.0]: https://github.com/Level/level/releases/tag/0.15.0 | ||
[0.13.0]: https://github.com/Level/level/compare/0.12.0...0.13.0 | ||
[0.14.0]: https://github.com/Level/level/releases/tag/0.14.0 | ||
[0.12.0]: https://github.com/Level/level/compare/0.11.0...0.12.0 | ||
[0.13.0]: https://github.com/Level/level/releases/tag/0.13.0 | ||
[0.11.0]: https://github.com/Level/level/compare/0.10.0...0.11.0 | ||
[0.12.0]: https://github.com/Level/level/releases/tag/0.12.0 | ||
[0.10.0]: https://github.com/Level/level/compare/0.9.0...0.10.0 | ||
[0.11.0]: https://github.com/Level/level/releases/tag/0.11.0 | ||
[0.9.0]: https://github.com/Level/level/compare/0.8.0...0.9.0 | ||
[0.10.0]: https://github.com/Level/level/releases/tag/0.10.0 | ||
[0.9.0]: https://github.com/Level/level/releases/tag/0.9.0 | ||
[0.8.0]: https://github.com/Level/level/releases/tag/0.8.0 |
{ | ||
"name": "level", | ||
"version": "7.0.0", | ||
"version": "7.0.1", | ||
"description": "Fast & simple storage - a Node.js-style LevelDB wrapper (a convenience package bundling LevelUP & LevelDOWN)", | ||
@@ -10,3 +10,3 @@ "license": "MIT", | ||
"test-browsers-local": "airtap --verbose test-browser.js", | ||
"coverage": "nyc report --reporter=text-lcov | coveralls", | ||
"coverage": "nyc report -r lcovonly", | ||
"hallmark": "hallmark --fix", | ||
@@ -20,4 +20,2 @@ "dependency-check": "dependency-check --no-dev . browser.js", | ||
"CHANGELOG.md", | ||
"CONTRIBUTORS.md", | ||
"LICENSE.md", | ||
"UPGRADING.md" | ||
@@ -27,5 +25,5 @@ ], | ||
"dependencies": { | ||
"level-js": "^6.0.0", | ||
"level-packager": "^6.0.0", | ||
"leveldown": "^6.0.0" | ||
"level-js": "^6.1.0", | ||
"level-packager": "^6.0.1", | ||
"leveldown": "^6.1.0" | ||
}, | ||
@@ -35,6 +33,4 @@ "devDependencies": { | ||
"airtap-playwright": "^1.0.1", | ||
"coveralls": "^3.0.2", | ||
"dependency-check": "^4.1.0", | ||
"hallmark": "^3.0.0", | ||
"level-community": "^3.0.0", | ||
"nyc": "^15.0.0", | ||
@@ -49,5 +45,2 @@ "standard": "^16.0.3", | ||
}, | ||
"hallmark": { | ||
"community": "level-community" | ||
}, | ||
"repository": { | ||
@@ -54,0 +47,0 @@ "type": "git", |
175
README.md
@@ -6,11 +6,9 @@ # level | ||
[![level badge][level-badge]](https://github.com/Level/awesome) | ||
[![npm](https://img.shields.io/npm/v/level.svg?label=&logo=npm)](https://www.npmjs.com/package/level) | ||
[![npm](https://img.shields.io/npm/v/level.svg)](https://www.npmjs.com/package/level) | ||
[![Node version](https://img.shields.io/node/v/level.svg)](https://www.npmjs.com/package/level) | ||
[![Travis](https://img.shields.io/travis/com/Level/level.svg?logo=travis&label=)](https://travis-ci.com/Level/level) | ||
[![AppVeyor](https://img.shields.io/appveyor/ci/Level/level.svg?logo=appveyor&label=)](https://ci.appveyor.com/project/Level/level) | ||
[![Coverage Status](https://coveralls.io/repos/github/Level/level/badge.svg)](https://coveralls.io/github/Level/level) | ||
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) | ||
[![npm](https://img.shields.io/npm/dm/level.svg?label=dl)](https://www.npmjs.com/package/level) | ||
[![Backers on Open Collective](https://opencollective.com/level/backers/badge.svg?color=orange)](#backers) | ||
[![Sponsors on Open Collective](https://opencollective.com/level/sponsors/badge.svg?color=orange)](#sponsors) | ||
[![Test](https://img.shields.io/github/workflow/status/Level/level/Test?label=test)](https://github.com/Level/level/actions/workflows/test.yml) | ||
[![Coverage](https://img.shields.io/codecov/c/github/Level/level?label=&logo=codecov&logoColor=fff)](https://codecov.io/gh/Level/level) | ||
[![Standard](https://img.shields.io/badge/standard-informational?logo=javascript&logoColor=fff)](https://standardjs.com) | ||
[![Common Changelog](https://common-changelog.org/badge.svg)](https://common-changelog.org) | ||
[![Donate](https://img.shields.io/badge/donate-orange?logo=open-collective&logoColor=fff)](https://opencollective.com/level) | ||
@@ -31,7 +29,8 @@ ## Table of Contents | ||
- [`db.get(key[, options][, callback])`](#dbgetkey-options-callback) | ||
- [`db.getMany(keys[, options][, callback])`](#dbgetmanykeys-options-callback) | ||
- [`db.del(key[, options][, callback])`](#dbdelkey-options-callback) | ||
- [`db.batch(array[, options][, callback])` _(array form)_](#dbbatcharray-options-callback-array-form) | ||
- [`db.batch()` _(chained form)_](#dbbatch-chained-form) | ||
- [`db.isOpen()`](#dbisopen) | ||
- [`db.isClosed()`](#dbisclosed) | ||
- [`db.status`](#dbstatus) | ||
- [`db.isOperational()`](#dbisoperational) | ||
- [`db.createReadStream([options])`](#dbcreatereadstreamoptions) | ||
@@ -46,4 +45,2 @@ - [`db.createKeyStream([options])`](#dbcreatekeystreamoptions) | ||
- [Donate](#donate) | ||
- [Backers](#backers) | ||
- [Sponsors](#sponsors) | ||
- [License](#license) | ||
@@ -57,3 +54,3 @@ | ||
- exports a function that returns a [`levelup`](https://github.com/Level/levelup#ctor) instance when invoked | ||
- exports a function that returns a [`levelup`](https://github.com/Level/levelup) instance when invoked | ||
- bundles the current release of [`leveldown`][leveldown] and [`level-js`][level-js] | ||
@@ -106,21 +103,2 @@ - leverages encodings using [`encoding-down`][encoding-down]. | ||
- <a href="#ctor"><code><b>level()</b></code></a> | ||
- <a href="#supports"><code>db.<b>supports</b></code></a> | ||
- <a href="#open"><code>db.<b>open()</b></code></a> | ||
- <a href="#close"><code>db.<b>close()</b></code></a> | ||
- <a href="#put"><code>db.<b>put()</b></code></a> | ||
- <a href="#get"><code>db.<b>get()</b></code></a> | ||
- <a href="#del"><code>db.<b>del()</b></code></a> | ||
- <a href="#batch"><code>db.<b>batch()</b></code></a> _(array form)_ | ||
- <a href="#batch_chained"><code>db.<b>batch()</b></code></a> _(chained form)_ | ||
- <a href="#isOpen"><code>db.<b>isOpen()</b></code></a> | ||
- <a href="#isClosed"><code>db.<b>isClosed()</b></code></a> | ||
- <a href="#createReadStream"><code>db.<b>createReadStream()</b></code></a> | ||
- <a href="#createKeyStream"><code>db.<b>createKeyStream()</b></code></a> | ||
- <a href="#createValueStream"><code>db.<b>createValueStream()</b></code></a> | ||
- <a href="#iterator"><code>db.<b>iterator()</b></code></a> | ||
- <a href="#clear"><code>db.<b>clear()</b></code></a> | ||
<a name="ctor"></a> | ||
### `db = level(location[, options[, callback]])` | ||
@@ -173,7 +151,5 @@ | ||
<a name="supports"></a> | ||
### `db.supports` | ||
A read-only [manifest](https://github.com/Level/supports). Not [widely supported yet](https://github.com/Level/community/issues/83). Might be used like so: | ||
A read-only [manifest](https://github.com/Level/supports). Might be used like so: | ||
@@ -190,27 +166,19 @@ ```js | ||
<a name="open"></a> | ||
### `db.open([callback])` | ||
Opens the underlying store. In general you should never need to call this method directly as it's automatically called by <a href="#ctor"><code>levelup()</code></a>. | ||
Opens the underlying store. In general you shouldn't need to call this method directly as it's automatically called by [`level()`](#db--levellocation-options-callback). However, it is possible to reopen the store after it has been closed with [`close()`](#dbclosecallback). | ||
However, it is possible to _reopen_ the store after it has been closed with <a href="#close"><code>close()</code></a>, although this is not generally advised. | ||
If no callback is passed, a promise is returned. | ||
<a name="close"></a> | ||
### `db.close([callback])` | ||
<code>close()</code> closes the underlying store. The callback will receive any error encountered during closing as the first argument. | ||
`close()` closes the underlying store. The callback will receive any error encountered during closing as the first argument. | ||
You should always clean up your `levelup` instance by calling `close()` when you no longer need it to free up resources. A store cannot be opened by multiple instances of `levelup` simultaneously. | ||
A `levelup` instance has associated resources like file handles and locks. When you no longer need your `levelup` instance (for the remainder of your program) call `close()` to free up resources. The underlying store cannot be opened by multiple instances of `levelup` simultaneously. | ||
If no callback is passed, a promise is returned. | ||
<a name="put"></a> | ||
### `db.put(key, value[, options][, callback])` | ||
<code>put()</code> is the primary method for inserting data into the store. Both `key` and `value` can be of any type as far as `levelup` is concerned. | ||
`put()` is the primary method for inserting data into the store. Both `key` and `value` can be of any type as far as `levelup` is concerned. | ||
@@ -222,7 +190,5 @@ - `options` is passed on to the underlying store | ||
<a name="get"></a> | ||
### `db.get(key[, options][, callback])` | ||
<code>get()</code> is the primary method for fetching data from the store. The `key` can be of any type. If it doesn't exist in the store then the callback or promise will receive an error. A not-found err object will be of type `'NotFoundError'` so you can `err.type == 'NotFoundError'` or you can perform a truthy test on the property `err.notFound`. | ||
Get a value from the store by `key`. The `key` can be of any type. If it doesn't exist in the store then the callback or promise will receive an error. A not-found err object will be of type `'NotFoundError'` so you can `err.type == 'NotFoundError'` or you can perform a truthy test on the property `err.notFound`. | ||
@@ -249,7 +215,13 @@ ```js | ||
<a name="del"></a> | ||
### `db.getMany(keys[, options][, callback])` | ||
Get multiple values from the store by an array of `keys`. The optional `options` object is the same as for [`get()`](#dbgetkey-options-callback). | ||
The `callback` function will be called with an `Error` if the operation failed for any reason. If successful the first argument will be `null` and the second argument will be an array of values with the same order as `keys`. If a key was not found, the relevant value will be `undefined`. | ||
If no callback is provided, a promise is returned. | ||
### `db.del(key[, options][, callback])` | ||
<code>del()</code> is the primary method for removing data from the store. | ||
`del()` is the primary method for removing data from the store. | ||
@@ -268,7 +240,5 @@ ```js | ||
<a name="batch"></a> | ||
### `db.batch(array[, options][, callback])` _(array form)_ | ||
<code>batch()</code> can be used for very fast bulk-write operations (both _put_ and _delete_). The `array` argument should contain a list of operations to be executed sequentially, although as a whole they are performed as an atomic operation inside the underlying store. | ||
`batch()` can be used for fast bulk-write operations (both _put_ and _delete_). The `array` argument should contain a list of operations to be executed sequentially, although as a whole they are performed as an atomic operation inside the underlying store. | ||
@@ -297,7 +267,5 @@ Each operation is contained in an object having the following properties: `type`, `key`, `value`, where the _type_ is either `'put'` or `'del'`. In the case of `'del'` the `value` property is ignored. Any entries with a `key` of `null` or `undefined` will cause an error to be returned on the `callback` and any `type: 'put'` entry with a `value` of `null` or `undefined` will return an error. | ||
<a name="batch_chained"></a> | ||
### `db.batch()` _(chained form)_ | ||
<code>batch()</code>, when called with no arguments will return a `Batch` object which can be used to build, and eventually commit, an atomic batch operation. Depending on how it's used, it is possible to obtain greater performance when using the chained form of `batch()` over the array form. | ||
`batch()`, when called with no arguments will return a `Batch` object which can be used to build, and eventually commit, an atomic batch operation. Depending on how it's used, it is possible to obtain greater performance when using the chained form of `batch()` over the array form. | ||
@@ -343,24 +311,16 @@ ```js | ||
<a name="isOpen"></a> | ||
### `db.status` | ||
### `db.isOpen()` | ||
A readonly string that is one of: | ||
A `levelup` instance can be in one of the following states: | ||
- `new` - newly created, not opened or closed | ||
- `opening` - waiting for the underlying store to be opened | ||
- `open` - successfully opened the store, available for use | ||
- `closing` - waiting for the store to be closed | ||
- `closed` - store has been successfully closed. | ||
- _"new"_ - newly created, not opened or closed | ||
- _"opening"_ - waiting for the underlying store to be opened | ||
- _"open"_ - successfully opened the store, available for use | ||
- _"closing"_ - waiting for the store to be closed | ||
- _"closed"_ - store has been successfully closed, should not be used | ||
### `db.isOperational()` | ||
`isOpen()` will return `true` only when the state is "open". | ||
Returns `true` if the store accepts operations, which in the case of `level(up)` means that `status` is either `opening` or `open`, because it opens itself and queues up operations until opened. | ||
<a name="isClosed"></a> | ||
### `db.isClosed()` | ||
`isClosed()` will return `true` only when the state is "closing" _or_ "closed", it can be useful for determining if read and write operations are permissible. | ||
<a name="createReadStream"></a> | ||
### `db.createReadStream([options])` | ||
@@ -402,7 +362,5 @@ | ||
<a name="createKeyStream"></a> | ||
### `db.createKeyStream([options])` | ||
Returns a [Readable Stream](https://nodejs.org/docs/latest/api/stream.html#stream_readable_streams) of keys rather than key-value pairs. Use the same options as described for <a href="#createReadStream"><code>createReadStream</code></a> to control the range and direction. | ||
Returns a [Readable Stream](https://nodejs.org/docs/latest/api/stream.html#stream_readable_streams) of keys rather than key-value pairs. Use the same options as described for [`createReadStream()`](#dbcreatereadstreamoptions) to control the range and direction. | ||
@@ -424,7 +382,5 @@ You can also obtain this stream by passing an options object to `createReadStream()` with `keys` set to `true` and `values` set to `false`. The result is equivalent; both streams operate in [object mode](https://nodejs.org/docs/latest/api/stream.html#stream_object_mode). | ||
<a name="createValueStream"></a> | ||
### `db.createValueStream([options])` | ||
Returns a [Readable Stream](https://nodejs.org/docs/latest/api/stream.html#stream_readable_streams) of values rather than key-value pairs. Use the same options as described for <a href="#createReadStream"><code>createReadStream</code></a> to control the range and direction. | ||
Returns a [Readable Stream](https://nodejs.org/docs/latest/api/stream.html#stream_readable_streams) of values rather than key-value pairs. Use the same options as described for [`createReadStream()`](#dbcreatereadstreamoptions) to control the range and direction. | ||
@@ -446,14 +402,16 @@ You can also obtain this stream by passing an options object to `createReadStream()` with `values` set to `true` and `keys` set to `false`. The result is equivalent; both streams operate in [object mode](https://nodejs.org/docs/latest/api/stream.html#stream_object_mode). | ||
<a name="iterator"></a> | ||
### `db.iterator([options])` | ||
Returns an [`abstract-leveldown` iterator](https://github.com/Level/abstract-leveldown/#iterator), which is what powers the readable streams above. Options are the same as the range options of <a href="#createReadStream"><code>createReadStream</code></a> and are passed to the underlying store. | ||
Returns an [`abstract-leveldown` iterator](https://github.com/Level/abstract-leveldown/#iterator), which is what powers the readable streams above. Options are the same as the range options of [`createReadStream()`](#dbcreatereadstreamoptions) and are passed to the underlying store. | ||
<a name="clear"></a> | ||
These iterators support [`for await...of`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of): | ||
```js | ||
for await (const [key, value] of db.iterator()) { | ||
console.log(value) | ||
} | ||
``` | ||
### `db.clear([options][, callback])` | ||
**This method is experimental. Not all underlying stores support it yet. Consult [Level/community#79](https://github.com/Level/community/issues/79) to find out if your (combination of) dependencies support `db.clear()`.** | ||
Delete all entries or a range. Not guaranteed to be atomic. Accepts the following range options (with the same rules as on iterators): | ||
@@ -472,15 +430,4 @@ | ||
`level(up)` ships with native `Promise` support out of the box. | ||
Each function taking a callback can also be used as a promise, if the callback is omitted. The only exception is the `level` constructor itself, which if no callback is passed will lazily open the underlying store in the background. | ||
Each function taking a callback also can be used as a promise, if the callback is omitted. This applies for: | ||
- `db.get(key[, options])` | ||
- `db.put(key, value[, options])` | ||
- `db.del(key[, options])` | ||
- `db.batch(ops[, options])` | ||
- `db.batch().write()` | ||
- `db.clear(options)` | ||
The only exception is the `level` constructor itself, which if no callback is passed will lazily open the underlying store in the background. | ||
Example: | ||
@@ -490,20 +437,6 @@ | ||
const db = level('my-db') | ||
db.put('foo', 'bar') | ||
.then(function () { return db.get('foo') }) | ||
.then(function (value) { console.log(value) }) | ||
.catch(function (err) { console.error(err) }) | ||
await db.put('foo', 'bar') | ||
console.log(await db.get('foo')) | ||
``` | ||
Or using `async/await`: | ||
```js | ||
const main = async () => { | ||
const db = level('my-db') | ||
await db.put('foo', 'bar') | ||
console.log(await db.get('foo')) | ||
} | ||
``` | ||
## Events | ||
@@ -543,15 +476,7 @@ | ||
To sustain [`Level`](https://github.com/Level) and its activities, become a backer or sponsor on [Open Collective](https://opencollective.com/level). Your logo or avatar will be displayed on our 28+ [GitHub repositories](https://github.com/Level) and [npm](https://www.npmjs.com/) packages. 💖 | ||
Support us with a monthly donation on [Open Collective](https://opencollective.com/level) and help us continue our work. | ||
### Backers | ||
[![Open Collective backers](https://opencollective.com/level/backers.svg?width=890)](https://opencollective.com/level) | ||
### Sponsors | ||
[![Open Collective sponsors](https://opencollective.com/level/sponsors.svg?width=890)](https://opencollective.com/level) | ||
## License | ||
[MIT](LICENSE.md) © 2013-present Rod Vagg and [Contributors](CONTRIBUTORS.md). | ||
[MIT](LICENSE) | ||
@@ -558,0 +483,0 @@ [level-badge]: https://leveljs.org/img/badge.svg |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8
49635
7
472
Updatedlevel-js@^6.1.0
Updatedlevel-packager@^6.0.1
Updatedleveldown@^6.1.0