Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

subleveldown

Package Overview
Dependencies
Maintainers
3
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

subleveldown - npm Package Compare versions

Comparing version 5.0.1 to 6.0.0

LICENSE

141

CHANGELOG.md
# Changelog
_**If you are upgrading:** please see [`UPGRADING.md`](UPGRADING.md)._
## [6.0.0] - 2021-10-01
_If you are upgrading: please see [`UPGRADING.md`](UPGRADING.md)._
### Changed
- **Breaking:** bump `abstract-leveldown`, `encoding-down`, `levelup` ([`60bd660`](https://github.com/Level/subleveldown/commit/60bd660)) (Vincent Weevers)
- **Breaking:** hide private properties with Symbol ([`1f9d550`](https://github.com/Level/subleveldown/commit/1f9d550)) (Vincent Weevers)
- Refactor: use `addRestOptions()` for iterator ([`717066e`](https://github.com/Level/subleveldown/commit/717066e)) (Vincent Weevers)
- Modernize syntax and bump standard ([`0bd41cc`](https://github.com/Level/subleveldown/commit/0bd41cc)) (Vincent Weevers)
### Added
- Add `db.getMany(keys)` ([#107](https://github.com/Level/subleveldown/issues/107)) ([`0ff2b68`](https://github.com/Level/subleveldown/commit/0ff2b68)) (Vincent Weevers)
- Add manifest ([Level/community#83](https://github.com/Level/community/issues/83)) ([`f7ee1e3`](https://github.com/Level/subleveldown/commit/f7ee1e3)) (Vincent Weevers)
- Clarify scope of keys in README examples ([`58a628a`](https://github.com/Level/subleveldown/commit/58a628a)) (Vincent Weevers)
### Removed
- **Breaking:** drop Node.js 6 and 8 ([`ab713d1`](https://github.com/Level/subleveldown/commit/ab713d1)) (Vincent Weevers).
## [5.0.1] - 2020-06-26

@@ -9,18 +28,20 @@

- Run `abstract-leveldown` tests on `levelup` interface ([#90](https://github.com/level/subleveldown/issues/90)) ([`8928189`](https://github.com/level/subleveldown/commit/8928189)) ([**@vweevers**](https://github.com/vweevers))
- Run `abstract-leveldown` tests on `levelup` interface ([#90](https://github.com/Level/subleveldown/issues/90)) ([`8928189`](https://github.com/Level/subleveldown/commit/8928189)) ([**@vweevers**](https://github.com/vweevers))
### Fixed
- Don't mutate arguments object, which fails in strict mode ([#93](https://github.com/level/subleveldown/issues/93)) ([`5513c83`](https://github.com/level/subleveldown/commit/5513c83)) ([**@andymatuschak**](https://github.com/andymatuschak))
- Don't mutate arguments object, which fails in strict mode ([#93](https://github.com/Level/subleveldown/issues/93)) ([`5513c83`](https://github.com/Level/subleveldown/commit/5513c83)) ([**@andymatuschak**](https://github.com/andymatuschak))
## [5.0.0] - 2020-04-05
_If you are upgrading: please see [`UPGRADING.md`](UPGRADING.md)._
### Changed
- **Breaking:** parent db must support deferredOpen ([#89](https://github.com/level/subleveldown/issues/89)) ([**@vweevers**](https://github.com/vweevers))
- Upgrade `dependency-check` devDependency from `^3.3.0` to `^4.1.0` ([`b47f991`](https://github.com/level/subleveldown/commit/b47f991)) ([**@vweevers**](https://github.com/vweevers))
- **Breaking:** parent db must support deferredOpen ([#89](https://github.com/Level/subleveldown/issues/89)) ([**@vweevers**](https://github.com/vweevers))
- Upgrade `dependency-check` devDependency from `^3.3.0` to `^4.1.0` ([`b47f991`](https://github.com/Level/subleveldown/commit/b47f991)) ([**@vweevers**](https://github.com/vweevers))
### Fixed
- **Breaking:** fix iterating buffer keys that contain bytes 196-255 ([#88](https://github.com/level/subleveldown/issues/88)) ([**@vweevers**](https://github.com/vweevers))
- **Breaking:** fix iterating buffer keys that contain bytes 196-255 ([#88](https://github.com/Level/subleveldown/issues/88)) ([**@vweevers**](https://github.com/vweevers))

@@ -31,4 +52,4 @@ ## [4.1.4] - 2019-10-08

- Fix double prefixes ([#81](https://github.com/level/subleveldown/issues/81)) ([**@vweevers**](https://github.com/vweevers))
- Fix `open()` test ([#80](https://github.com/level/subleveldown/issues/80)) ([**@vweevers**](https://github.com/vweevers))
- Fix double prefixes ([#81](https://github.com/Level/subleveldown/issues/81)) ([**@vweevers**](https://github.com/vweevers))
- Fix `open()` test ([#80](https://github.com/Level/subleveldown/issues/80)) ([**@vweevers**](https://github.com/vweevers))

@@ -39,3 +60,3 @@ ## [4.1.3] - 2019-09-17

- Use `reachdown` package ([Level/community#82](https://github.com/Level/community/issues/82)) ([#75](https://github.com/level/subleveldown/issues/75)) ([**@vweevers**](https://github.com/vweevers))
- Use `reachdown` package ([Level/community#82](https://github.com/Level/community/issues/82)) ([#75](https://github.com/Level/subleveldown/issues/75)) ([**@vweevers**](https://github.com/vweevers))

@@ -46,12 +67,12 @@ ## [4.1.2] - 2019-09-12

- Upgrade `standard` devDependency from `^13.0.1` to `^14.0.0` ([#71](https://github.com/level/subleveldown/issues/71)) ([**@vweevers**](https://github.com/vweevers))
- Upgrade `hallmark` devDependency from `^1.0.0` to `^2.0.0` ([#72](https://github.com/level/subleveldown/issues/72)) ([**@vweevers**](https://github.com/vweevers))
- Upgrade `standard` devDependency from `^13.0.1` to `^14.0.0` ([#71](https://github.com/Level/subleveldown/issues/71)) ([**@vweevers**](https://github.com/vweevers))
- Upgrade `hallmark` devDependency from `^1.0.0` to `^2.0.0` ([#72](https://github.com/Level/subleveldown/issues/72)) ([**@vweevers**](https://github.com/vweevers))
### Removed
- Remove outdated `example.js` ([`3ef72c9`](https://github.com/level/subleveldown/commit/3ef72c9)) ([**@vweevers**](https://github.com/vweevers))
- Remove outdated `example.js` ([`3ef72c9`](https://github.com/Level/subleveldown/commit/3ef72c9)) ([**@vweevers**](https://github.com/vweevers))
### Fixed
- Polish `clear()` ([#74](https://github.com/level/subleveldown/issues/74)) ([**@vweevers**](https://github.com/vweevers))
- Polish `clear()` ([#74](https://github.com/Level/subleveldown/issues/74)) ([**@vweevers**](https://github.com/vweevers))
- Bump `levelup`, `abstract-leveldown` and `encoding-down` to prevent dedupe

@@ -65,9 +86,9 @@ - Opt-in to new `clear()` tests

- Upgrade `memdown` devDependency from `^4.0.0` to `^5.0.0` ([#70](https://github.com/level/subleveldown/issues/70)) ([**@vweevers**](https://github.com/vweevers))
- Upgrade `hallmark` devDependency from `^0.1.0` to `^1.0.0` ([#68](https://github.com/level/subleveldown/issues/68)) ([**@vweevers**](https://github.com/vweevers))
- Upgrade `standard` devDependency from `^12.0.1` to `^13.0.1` ([#67](https://github.com/level/subleveldown/issues/67)) ([**@vweevers**](https://github.com/vweevers))
- Upgrade `memdown` devDependency from `^4.0.0` to `^5.0.0` ([#70](https://github.com/Level/subleveldown/issues/70)) ([**@vweevers**](https://github.com/vweevers))
- Upgrade `hallmark` devDependency from `^0.1.0` to `^1.0.0` ([#68](https://github.com/Level/subleveldown/issues/68)) ([**@vweevers**](https://github.com/vweevers))
- Upgrade `standard` devDependency from `^12.0.1` to `^13.0.1` ([#67](https://github.com/Level/subleveldown/issues/67)) ([**@vweevers**](https://github.com/vweevers))
### Fixed
- Relax `isAbstract()` check ([`fbbf525`](https://github.com/level/subleveldown/commit/fbbf525)) ([**@vweevers**](https://github.com/vweevers))
- Relax `isAbstract()` check ([`fbbf525`](https://github.com/Level/subleveldown/commit/fbbf525)) ([**@vweevers**](https://github.com/vweevers))

@@ -78,37 +99,39 @@ ## [4.1.0] - 2019-06-28

- Upgrade `nyc` devDependency from `^13.3.0` to `^14.0.0` ([#63](https://github.com/level/subleveldown/issues/63)) ([**@vweevers**](https://github.com/vweevers))
- Upgrade `nyc` devDependency from `^13.3.0` to `^14.0.0` ([#63](https://github.com/Level/subleveldown/issues/63)) ([**@vweevers**](https://github.com/vweevers))
### Added
- Support seeking ([#66](https://github.com/level/subleveldown/issues/66)) ([**@MeirionHughes**](https://github.com/MeirionHughes))
- Support seeking ([#66](https://github.com/Level/subleveldown/issues/66)) ([**@MeirionHughes**](https://github.com/MeirionHughes))
## [4.0.0] - 2019-04-06
_If you are upgrading: please see [`UPGRADING.md`](UPGRADING.md)._
### Changed
- Upgrade `abstract-leveldown` from `^5.0.0` to `^6.0.2` ([#61](https://github.com/level/subleveldown/issues/61)) ([**@vweevers**](https://github.com/vweevers))
- Upgrade `encoding-down` from `^5.0.3` to `^6.0.1` ([#61](https://github.com/level/subleveldown/issues/61)) ([**@vweevers**](https://github.com/vweevers))
- Upgrade `levelup` from `^3.0.1` to `^4.0.1` ([#61](https://github.com/level/subleveldown/issues/61)) ([**@vweevers**](https://github.com/vweevers))
- Avoid unnecessary copy of batch operations ([#61](https://github.com/level/subleveldown/issues/61)) ([**@vweevers**](https://github.com/vweevers))
- Invoke abstract tests from single function ([#61](https://github.com/level/subleveldown/issues/61)) ([**@vweevers**](https://github.com/vweevers))
- Add mandatory `db` argument to abstract iterator ([#61](https://github.com/level/subleveldown/issues/61)) ([**@vweevers**](https://github.com/vweevers))
- Upgrade `memdown` devDependency from `^3.0.0` to `^4.0.0` ([#61](https://github.com/level/subleveldown/issues/61)) ([**@vweevers**](https://github.com/vweevers))
- Upgrade `nyc` devDependency from `^12.0.2` to `^13.3.0` ([#61](https://github.com/level/subleveldown/issues/61)) ([**@vweevers**](https://github.com/vweevers))
- Upgrade `standard` devDependency from `^11.0.1` to `^12.0.1` ([#61](https://github.com/level/subleveldown/issues/61)) ([**@vweevers**](https://github.com/vweevers))
- Apply common project tweaks ([#58](https://github.com/level/subleveldown/issues/58), [#59](https://github.com/level/subleveldown/issues/59)) ([**@vweevers**](https://github.com/vweevers))
- Upgrade `abstract-leveldown` from `^5.0.0` to `^6.0.2` ([#61](https://github.com/Level/subleveldown/issues/61)) ([**@vweevers**](https://github.com/vweevers))
- Upgrade `encoding-down` from `^5.0.3` to `^6.0.1` ([#61](https://github.com/Level/subleveldown/issues/61)) ([**@vweevers**](https://github.com/vweevers))
- Upgrade `levelup` from `^3.0.1` to `^4.0.1` ([#61](https://github.com/Level/subleveldown/issues/61)) ([**@vweevers**](https://github.com/vweevers))
- Avoid unnecessary copy of batch operations ([#61](https://github.com/Level/subleveldown/issues/61)) ([**@vweevers**](https://github.com/vweevers))
- Invoke abstract tests from single function ([#61](https://github.com/Level/subleveldown/issues/61)) ([**@vweevers**](https://github.com/vweevers))
- Add mandatory `db` argument to abstract iterator ([#61](https://github.com/Level/subleveldown/issues/61)) ([**@vweevers**](https://github.com/vweevers))
- Upgrade `memdown` devDependency from `^3.0.0` to `^4.0.0` ([#61](https://github.com/Level/subleveldown/issues/61)) ([**@vweevers**](https://github.com/vweevers))
- Upgrade `nyc` devDependency from `^12.0.2` to `^13.3.0` ([#61](https://github.com/Level/subleveldown/issues/61)) ([**@vweevers**](https://github.com/vweevers))
- Upgrade `standard` devDependency from `^11.0.1` to `^12.0.1` ([#61](https://github.com/Level/subleveldown/issues/61)) ([**@vweevers**](https://github.com/vweevers))
- Apply common project tweaks ([#58](https://github.com/Level/subleveldown/issues/58), [#59](https://github.com/Level/subleveldown/issues/59)) ([**@vweevers**](https://github.com/vweevers))
### Added
- Test that errors from `open()` and iterators bubble up ([#61](https://github.com/level/subleveldown/issues/61)) ([**@vweevers**](https://github.com/vweevers))
- Test without a user-provided `levelup` layer ([#61](https://github.com/level/subleveldown/issues/61)) ([**@vweevers**](https://github.com/vweevers))
- Gitignore `coverage` directory ([#61](https://github.com/level/subleveldown/issues/61)) ([**@vweevers**](https://github.com/vweevers))
- Test that errors from `open()` and iterators bubble up ([#61](https://github.com/Level/subleveldown/issues/61)) ([**@vweevers**](https://github.com/vweevers))
- Test without a user-provided `levelup` layer ([#61](https://github.com/Level/subleveldown/issues/61)) ([**@vweevers**](https://github.com/vweevers))
- Gitignore `coverage` directory ([#61](https://github.com/Level/subleveldown/issues/61)) ([**@vweevers**](https://github.com/vweevers))
### Removed
- Remove obsolete `_batch()` checks ([#61](https://github.com/level/subleveldown/issues/61)) ([**@vweevers**](https://github.com/vweevers))
- Remove dummy location from `abstract-leveldown` constructor call ([#61](https://github.com/level/subleveldown/issues/61)) ([**@vweevers**](https://github.com/vweevers))
- Remove obsolete `_batch()` checks ([#61](https://github.com/Level/subleveldown/issues/61)) ([**@vweevers**](https://github.com/vweevers))
- Remove dummy location from `abstract-leveldown` constructor call ([#61](https://github.com/Level/subleveldown/issues/61)) ([**@vweevers**](https://github.com/vweevers))
### Fixed
- Serialize non-buffer keys to strings ([#61](https://github.com/level/subleveldown/issues/61)) ([**@vweevers**](https://github.com/vweevers))
- Serialize non-buffer keys to strings ([#61](https://github.com/Level/subleveldown/issues/61)) ([**@vweevers**](https://github.com/vweevers))

@@ -131,2 +154,4 @@ ## [3.0.1] - 2018-07-27

_If you are upgrading: please see [`UPGRADING.md`](UPGRADING.md)._
### Added

@@ -255,44 +280,48 @@

## 1.0.0 - 2014-12-23
## [1.0.0] - 2014-12-23
:seedling: Initial release.
[5.0.1]: https://github.com/level/subleveldown/compare/v5.0.0...v5.0.1
[6.0.0]: https://github.com/Level/subleveldown/releases/tag/v6.0.0
[5.0.0]: https://github.com/level/subleveldown/compare/v4.1.4...v5.0.0
[5.0.1]: https://github.com/Level/subleveldown/releases/tag/v5.0.1
[4.1.4]: https://github.com/level/subleveldown/compare/v4.1.3...v4.1.4
[5.0.0]: https://github.com/Level/subleveldown/releases/tag/v5.0.0
[4.1.3]: https://github.com/level/subleveldown/compare/v4.1.2...v4.1.3
[4.1.4]: https://github.com/Level/subleveldown/releases/tag/v4.1.4
[4.1.2]: https://github.com/level/subleveldown/compare/v4.1.1...v4.1.2
[4.1.3]: https://github.com/Level/subleveldown/releases/tag/v4.1.3
[4.1.1]: https://github.com/level/subleveldown/compare/v4.1.0...v4.1.1
[4.1.2]: https://github.com/Level/subleveldown/releases/tag/v4.1.2
[4.1.0]: https://github.com/level/subleveldown/compare/v4.0.0...v4.1.0
[4.1.1]: https://github.com/Level/subleveldown/releases/tag/v4.1.1
[4.0.0]: https://github.com/level/subleveldown/compare/v3.0.1...v4.0.0
[4.1.0]: https://github.com/Level/subleveldown/releases/tag/v4.1.0
[3.0.1]: https://github.com/level/subleveldown/compare/v3.0.0...v3.0.1
[4.0.0]: https://github.com/Level/subleveldown/releases/tag/v4.0.0
[3.0.0]: https://github.com/level/subleveldown/compare/v3.0.0-rc1...v3.0.0
[3.0.1]: https://github.com/Level/subleveldown/releases/tag/v3.0.1
[3.0.0-rc1]: https://github.com/level/subleveldown/compare/v2.1.0...v3.0.0-rc1
[3.0.0]: https://github.com/Level/subleveldown/releases/tag/v3.0.0
[2.1.0]: https://github.com/level/subleveldown/compare/v2.0.0...v2.1.0
[3.0.0-rc1]: https://github.com/Level/subleveldown/releases/tag/v3.0.0-rc1
[2.0.0]: https://github.com/level/subleveldown/compare/v1.1.0...v2.0.0
[2.1.0]: https://github.com/Level/subleveldown/releases/tag/v2.1.0
[1.1.0]: https://github.com/level/subleveldown/compare/v1.0.6...v1.1.0
[2.0.0]: https://github.com/Level/subleveldown/releases/tag/v2.0.0
[1.0.6]: https://github.com/level/subleveldown/compare/v1.0.5...v1.0.6
[1.1.0]: https://github.com/Level/subleveldown/releases/tag/v1.1.0
[1.0.5]: https://github.com/level/subleveldown/compare/v1.0.4...v1.0.5
[1.0.6]: https://github.com/Level/subleveldown/releases/tag/v1.0.6
[1.0.4]: https://github.com/level/subleveldown/compare/v1.0.3...v1.0.4
[1.0.5]: https://github.com/Level/subleveldown/releases/tag/v1.0.5
[1.0.3]: https://github.com/level/subleveldown/compare/v1.0.2...v1.0.3
[1.0.4]: https://github.com/Level/subleveldown/releases/tag/v1.0.4
[1.0.2]: https://github.com/level/subleveldown/compare/v1.0.1...v1.0.2
[1.0.3]: https://github.com/Level/subleveldown/releases/tag/v1.0.3
[1.0.1]: https://github.com/level/subleveldown/compare/v1.0.0...v1.0.1
[1.0.2]: https://github.com/Level/subleveldown/releases/tag/v1.0.2
[1.0.1]: https://github.com/Level/subleveldown/releases/tag/v1.0.1
[1.0.0]: https://github.com/Level/subleveldown/releases/tag/v1.0.0

@@ -1,5 +0,7 @@

var subdown = require('./leveldown')
var levelup = require('levelup')
var encoding = require('encoding-down')
'use strict'
const subdown = require('./leveldown')
const levelup = require('levelup')
const encoding = require('encoding-down')
module.exports = function (db, prefix, opts) {

@@ -9,3 +11,11 @@ if (typeof prefix === 'object' && !opts) return module.exports(db, null, prefix)

return levelup(encoding(subdown(db, prefix, opts), opts), opts)
const wrapped = levelup(encoding(subdown(db, prefix, opts), opts), opts)
// Workaround for abstract-leveldown tests that expect db._nextTick
// TODO: fix tests or add _nextTick to levelup for API parity
if (!wrapped._nextTick) {
wrapped._nextTick = subdown.prototype._nextTick
}
return wrapped
}

@@ -1,11 +0,18 @@

var inherits = require('inherits')
var abstract = require('abstract-leveldown')
var wrap = require('level-option-wrap')
var reachdown = require('reachdown')
var matchdown = require('./matchdown')
'use strict'
var rangeOptions = 'start end gt gte lt lte'.split(' ')
var defaultClear = abstract.AbstractLevelDOWN.prototype._clear
var hasOwnProperty = Object.prototype.hasOwnProperty
const inherits = require('inherits')
const abstract = require('abstract-leveldown')
const wrap = require('level-option-wrap')
const reachdown = require('reachdown')
const matchdown = require('./matchdown')
const rangeOptions = ['gt', 'gte', 'lt', 'lte']
const defaultClear = abstract.AbstractLevelDOWN.prototype._clear
const hasOwnProperty = Object.prototype.hasOwnProperty
const nextTick = abstract.AbstractLevelDOWN.prototype._nextTick
const kIterator = Symbol('iterator')
const kPrefix = Symbol('prefix')
const kBeforeOpen = Symbol('beforeOpen')
function concat (prefix, key, force) {

@@ -20,4 +27,4 @@ if (typeof key === 'string' && (force || key.length)) return prefix + key

function SubIterator (db, ite, prefix) {
this.iterator = ite
this.prefix = prefix
this[kIterator] = ite
this[kPrefix] = prefix

@@ -32,6 +39,5 @@ abstract.AbstractIterator.call(this, db)

var self = this
this.iterator.next(function (err, key, value) {
this[kIterator].next((err, key, value) => {
if (err) return cb(err)
if (key) key = key.slice(self.prefix.length)
if (key) key = key.slice(this[kPrefix].length)
cb(err, key, value)

@@ -42,3 +48,3 @@ })

SubIterator.prototype._seek = function (key) {
this.iterator.seek(concat(this.prefix, key))
this[kIterator].seek(concat(this[kPrefix], key))
}

@@ -48,3 +54,3 @@

if (maybeError(this.db.leveldown, cb)) return
this.iterator.end(cb)
this[kIterator].end(cb)
}

@@ -57,3 +63,3 @@

var separator = opts.separator
let separator = opts.separator

@@ -65,4 +71,4 @@ if (!prefix) prefix = ''

var code = separator.charCodeAt(0) + 1
var ceiling = String.fromCharCode(code)
const code = separator.charCodeAt(0) + 1
const ceiling = String.fromCharCode(code)

@@ -77,6 +83,5 @@ Buffer.from(prefix).forEach(function (byte) {

this.prefix = separator + prefix + separator
this._beforeOpen = opts.open
this[kBeforeOpen] = opts.open
var self = this
var manifest = db.supports || {}
let manifest = db.supports || {}

@@ -89,3 +94,3 @@ // The parent db must open itself or be (re)opened by the user because a

var subdb = reachdown(db, 'subleveldown')
const subdb = reachdown(db, 'subleveldown')

@@ -113,10 +118,10 @@ if (subdb) {

this._wrap = {
gt: function (x) {
return concat(self.prefix, x || '', true)
gt: (x) => {
return concat(this.prefix, x || '', true)
},
lt: function (x) {
lt: (x) => {
if (!x || isEmptyBuffer(x)) {
return self.prefix.slice(0, -1) + ceiling
return this.prefix.slice(0, -1) + ceiling
} else {
return concat(self.prefix, x)
return concat(this.prefix, x)
}

@@ -126,3 +131,22 @@ }

abstract.AbstractLevelDOWN.call(this)
manifest = {
// Inherit manifest from parent db
...manifest,
// We support this on the levelup interface, but not on the
// abstract-leveldown interface.
deferredOpen: false,
// Disable unsupported features
keyIterator: false,
valueIterator: false,
iteratorNextv: false,
iteratorAll: false,
// Unset additional methods (like approximateSize) which we can't support
// here and should typically be called on the underlying store instead.
additionalMethods: {}
}
abstract.AbstractLevelDOWN.call(this, manifest)
}

@@ -136,10 +160,17 @@

// because that means we can always do operations on this.leveldown.
// Alternatively have the sublevel follow the open state of this.db.
SubDown.prototype._open = function (opts, cb) {
var self = this
// TODO: start using db.status (added to levelup recently) in a next major.
const m = typeof this.db.isOpening === 'function' ? 'isOpening' : '_isOpening'
// TODO: make _isOpening public in levelup or add a method like
// ready(cb) which waits for - but does not initiate - a state change.
var m = typeof this.db.isOpening === 'function' ? 'isOpening' : '_isOpening'
const onopen = () => {
// TODO: start using db.status (added to levelup recently) in a next major.
if (!this.db.isOpen()) return cb(new Error('Parent database is not open'))
if (this.leveldown.status !== 'open') return cb(new Error('Inner database is not open'))
// TODO: add hooks to abstract-leveldown
if (this[kBeforeOpen]) return this[kBeforeOpen](cb)
cb()
}
if (this.db[m]()) {

@@ -150,12 +181,2 @@ this.db.once('open', onopen)

}
function onopen () {
if (!self.db.isOpen()) return cb(new Error('Parent database is not open'))
if (self.leveldown.status !== 'open') return cb(new Error('Inner database is not open'))
// TODO: add hooks to abstract-leveldown
if (self._beforeOpen) return self._beforeOpen(cb)
cb()
}
}

@@ -177,2 +198,8 @@

SubDown.prototype._getMany = function (keys, opts, cb) {
// maybeError is not necessary here, abstract-leveldown does that
keys = keys.map(key => concat(this.prefix, key))
this.leveldown.getMany(keys, opts, cb)
}
SubDown.prototype._del = function (key, opts, cb) {

@@ -187,3 +214,3 @@ if (maybeError(this.leveldown, cb)) return

// No need to make a copy of the array, abstract-leveldown does that
for (var i = 0; i < operations.length; i++) {
for (let i = 0; i < operations.length; i++) {
operations[i].key = concat(this.prefix, operations[i].key)

@@ -209,3 +236,3 @@ }

function addRestOptions (target, opts) {
for (var k in opts) {
for (const k in opts) {
if (hasOwnProperty.call(opts, k) && !isRangeOption(k)) {

@@ -234,3 +261,3 @@ target[k] = opts[k]

// TODO: use require('level-errors').ReadError
process.nextTick(callback, new Error('Database is not open'))
;(leveldown._nextTick || nextTick)(callback, new Error('Database is not open'))
return true

@@ -242,26 +269,4 @@ }

// TODO (refactor): use addRestOptions instead
function extend (xopts, opts) {
xopts.keys = opts.keys
xopts.values = opts.values
xopts.createIfMissing = opts.createIfMissing
xopts.errorIfExists = opts.errorIfExists
xopts.keyEncoding = opts.keyEncoding
xopts.valueEncoding = opts.valueEncoding
xopts.compression = opts.compression
xopts.db = opts.db
xopts.limit = opts.limit
xopts.keyAsBuffer = opts.keyAsBuffer
xopts.valueAsBuffer = opts.valueAsBuffer
xopts.reverse = opts.reverse
xopts.fillCache = opts.fillCache
return xopts
}
function fixRange (opts) {
return (!opts.reverse || (!opts.end && !opts.start)) ? opts : { start: opts.end, end: opts.start }
}
SubDown.prototype._iterator = function (opts) {
var xopts = extend(wrap(fixRange(opts), this._wrap), opts)
const xopts = addRestOptions(wrap(opts, this._wrap), opts)
return new SubIterator(this, this.leveldown.iterator(xopts), this.prefix)

@@ -268,0 +273,0 @@ }

@@ -0,1 +1,3 @@

'use strict'
module.exports = function matchdown (db, type) {

@@ -2,0 +4,0 @@ // Skip layers that we handle ourselves

{
"name": "subleveldown",
"version": "5.0.1",
"version": "6.0.0",
"description": "Split a levelup database into sublevels with their own keyspace, encoding and events",

@@ -10,3 +10,4 @@ "author": "Mathias Buus (@mafintosh)",

"test": "standard && hallmark && (nyc -s node test | faucet) && nyc report",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"test-browsers-local": "airtap test/index.js",
"coverage": "nyc report -r lcovonly",
"hallmark": "hallmark --fix",

@@ -16,11 +17,15 @@ "dependency-check": "dependency-check --no-dev .",

},
"directories": {
"test": "test"
},
"files": [
"index.js",
"leveldown.js",
"matchdown.js",
"CHANGELOG.md",
"UPGRADING.md"
],
"dependencies": {
"abstract-leveldown": "^6.3.0",
"encoding-down": "^6.2.0",
"abstract-leveldown": "^7.2.0",
"encoding-down": "^7.1.0",
"inherits": "^2.0.3",
"level-option-wrap": "^1.1.0",
"levelup": "^4.4.0",
"levelup": "^5.1.0",
"reachdown": "^1.1.0"

@@ -30,23 +35,20 @@ },

"after": "^0.8.2",
"coveralls": "^3.0.2",
"airtap": "^4.0.3",
"airtap-playwright": "^1.0.1",
"dependency-check": "^4.1.0",
"faucet": "^0.0.1",
"hallmark": "^2.0.0",
"level-community": "^3.0.0",
"level-concat-iterator": "^2.0.1",
"memdown": "^5.0.0",
"nyc": "^14.0.0",
"standard": "^14.0.0",
"tape": "^4.9.0"
"hallmark": "^3.1.0",
"level-concat-iterator": "^3.0.0",
"memdown": "^6.1.0",
"nyc": "^15.1.0",
"standard": "^16.0.3",
"tape": "^5.0.1"
},
"hallmark": {
"community": "level-community"
},
"repository": {
"type": "git",
"url": "https://github.com/level/subleveldown.git"
"url": "https://github.com/Level/subleveldown.git"
},
"homepage": "https://github.com/level/subleveldown",
"homepage": "https://github.com/Level/subleveldown",
"bugs": {
"url": "https://github.com/level/subleveldown/issues"
"url": "https://github.com/Level/subleveldown/issues"
},

@@ -57,4 +59,4 @@ "keywords": [

"engines": {
"node": ">=6"
"node": ">=10"
}
}

@@ -6,10 +6,9 @@ # subleveldown

[![level badge][level-badge]](https://github.com/Level/awesome)
[![npm](https://img.shields.io/npm/v/subleveldown.svg?label=&logo=npm)](https://www.npmjs.com/package/subleveldown)
[![npm](https://img.shields.io/npm/v/subleveldown.svg)](https://www.npmjs.com/package/subleveldown)
[![Node version](https://img.shields.io/node/v/subleveldown.svg)](https://www.npmjs.com/package/subleveldown)
[![Travis](https://img.shields.io/travis/com/Level/subleveldown.svg?logo=travis&label=)](https://travis-ci.com/Level/subleveldown)
[![npm](https://img.shields.io/npm/dm/subleveldown.svg?label=dl)](https://www.npmjs.com/package/subleveldown)
[![Coverage Status](https://coveralls.io/repos/github/Level/subleveldown/badge.svg)](https://coveralls.io/github/Level/subleveldown)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
[![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/subleveldown/Test?label=test)](https://github.com/Level/subleveldown/actions/workflows/test.yml)
[![Coverage](https://img.shields.io/codecov/c/github/Level/subleveldown?label=&logo=codecov&logoColor=fff)](https://codecov.io/gh/Level/subleveldown)
[![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)

@@ -23,2 +22,3 @@ ## Table of Contents

- [API](#api)
- [`subdb = sub(db[, prefix][, options])`](#subdb--subdb-prefix-options)
- [Install](#install)

@@ -33,11 +33,11 @@ - [Contributing](#contributing)

**If you are upgrading:** please see [UPGRADING.md](UPGRADING.md).
_If you are upgrading: please see [UPGRADING.md](UPGRADING.md)._
```js
var sub = require('subleveldown')
var level = require('level')
const sub = require('subleveldown')
const level = require('level')
var db = level('db')
var example = sub(db, 'example')
var nested = sub(example, 'nested')
const db = level('db')
const example = sub(db, 'example')
const nested = sub(example, 'nested')
```

@@ -50,4 +50,4 @@

nested.put('hi', 'welt', function () {
// will print {key:'hello', value:'world'}
example.createReadStream().on('data', console.log)
// Prints { key: 'hi', value: 'welt' }
nested.createReadStream().on('data', console.log)
})

@@ -57,2 +57,23 @@ })

Or with promises and iterators:
```js
await example.put('hello', 'world')
await nested.put('hi', 'welt')
for await (const [key, value] of nested.iterator()) {
// Prints ['hi', 'welt']
console.log([key, value])
}
```
Sublevels see their own keys as well as keys of any nested sublevels:
```js
// Prints:
// { key: '!nested!hi', value: 'welt' }
// { key: 'hello', value: 'world' }
example.createReadStream().on('data', console.log)
```
They also support `db.clear()` which is very useful to empty a bucket of stuff:

@@ -66,3 +87,3 @@

// For believers
// With promises
await example.clear()

@@ -119,15 +140,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) © 2014-present [Mathias Buus](https://github.com/mafintosh) and [Contributors](CONTRIBUTORS.md).
[MIT](LICENSE)

@@ -134,0 +147,0 @@ [level-badge]: https://leveljs.org/img/badge.svg

@@ -5,4 +5,29 @@ # Upgrade Guide

## v5
## 6.0.0
Legacy range options have been removed ([Level/community#86](https://github.com/Level/community/issues/86)). If you previously did:
```js
db.createReadStream({ start: 'a', end: 'z' })
```
An error would now be thrown and you must instead do:
```js
db.createReadStream({ gte: 'a', lte: 'z' })
```
The same applies to `db.iterator()`, `db.createKeyStream()` and `db.createValueStream()`.
This release also drops support of legacy runtime environments ([Level/community#98](https://github.com/Level/community/issues/98)):
- Node.js 6 and 8
- Internet Explorer 11
- Safari 9-11
- Stock Android browser (AOSP).
Some private properties have been replaced with Symbols ([`1f9d550`](https://github.com/Level/subleveldown/commit/1f9d550)). Lastly, in browsers, `process.nextTick()` has been replaced with [`queue-microtask`](https://github.com/feross/queue-microtask), except in streams.
## 5.0.0
### Fixes iterating buffer keys that contain bytes 196-255 ([#88](https://github.com/level/subleveldown/issues/88))

@@ -61,3 +86,3 @@

## v4
## 4.0.0

@@ -71,3 +96,3 @@ Upgraded to `abstract-leveldown@6`, `encoding-down@6` and `levelup@4`. We recommend to pair `subleveldown@4` with `level` >= 5 or when using a custom store, one that is based on `abstract-leveldown` >= 6. For details please see:

## v3
## 3.0.0

@@ -74,0 +99,0 @@ Dropped support for node 4.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc