deferred-leveldown
Advanced tools
Comparing version 2.0.3 to 3.0.0
var util = require('util') | ||
var AbstractLevelDOWN = require('abstract-leveldown').AbstractLevelDOWN | ||
var DeferredIterator = require('./deferred-iterator') | ||
var deferrables = 'put get del batch approximateSize'.split(' ') | ||
var deferrables = 'put get del batch'.split(' ') | ||
@@ -11,2 +11,3 @@ function DeferredLevelDOWN (db) { | ||
this._iterators = [] | ||
closed(this) | ||
} | ||
@@ -45,17 +46,30 @@ | ||
function open (obj) { | ||
function open (self) { | ||
deferrables.concat('iterator').forEach(function (m) { | ||
obj['_' + m] = function () { | ||
self['_' + m] = function () { | ||
return this._db[m].apply(this._db, arguments) | ||
} | ||
}) | ||
if (self._db.approximateSize) { | ||
self.approximateSize = function () { | ||
return this._db.approximateSize.apply(this._db, arguments) | ||
} | ||
} | ||
} | ||
function closed (obj) { | ||
function closed (self) { | ||
deferrables.forEach(function (m) { | ||
obj['_' + m] = function () { | ||
self['_' + m] = function () { | ||
this._operations.push({ method: m, args: arguments }) | ||
} | ||
}) | ||
obj._iterator = function (options) { | ||
if (typeof self._db.approximateSize === 'function') { | ||
self.approximateSize = function () { | ||
this._operations.push({ | ||
method: 'approximateSize', | ||
args: arguments | ||
}) | ||
} | ||
} | ||
self._iterator = function (options) { | ||
var it = new DeferredIterator(options) | ||
@@ -67,8 +81,2 @@ this._iterators.push(it) | ||
closed(DeferredLevelDOWN.prototype) | ||
DeferredLevelDOWN.prototype._isBuffer = function (obj) { | ||
return Buffer.isBuffer(obj) | ||
} | ||
DeferredLevelDOWN.prototype._serializeKey = function (key) { | ||
@@ -75,0 +83,0 @@ return key |
The MIT License (MIT) | ||
===================== | ||
Copyright (c) 2013-2017 Rod Vagg | ||
Copyright (c) 2013-2018 Rod Vagg | ||
--------------------------- | ||
@@ -6,0 +6,0 @@ |
{ | ||
"name": "deferred-leveldown", | ||
"description": "For handling delayed-open on LevelDOWN compatible libraries", | ||
"version": "2.0.3", | ||
"version": "3.0.0", | ||
"contributors": [ | ||
@@ -33,3 +33,3 @@ "Rod Vagg <r@va.gg> (https://github.com/rvagg)", | ||
"dependencies": { | ||
"abstract-leveldown": "~3.0.0" | ||
"abstract-leveldown": "~4.0.0" | ||
}, | ||
@@ -36,0 +36,0 @@ "devDependencies": { |
@@ -34,5 +34,6 @@ # deferred-leveldown | ||
Contributing | ||
------------ | ||
**If you are upgrading:** please see [UPGRADING.md](UPGRADING.md). | ||
## Contributing | ||
`deferred-leveldown` is an **OPEN Open Source Project**. This means that: | ||
@@ -42,3 +43,3 @@ | ||
See the [CONTRIBUTING.md](https://github.com/Level/levelup/blob/master/CONTRIBUTING.md) file for more details. | ||
See the [CONTRIBUTING.md](https://github.com/Level/community/blob/master/CONTRIBUTING.md) file for more details. | ||
@@ -65,10 +66,8 @@ ### Contributors | ||
<a name="license"></a> | ||
License & copyright | ||
------------------- | ||
## License | ||
Copyright (c) 2013-2017 `deferred-leveldown` contributors (listed above). | ||
Copyright (c) 2013-2018 `deferred-leveldown` contributors (listed above). | ||
`deferred-leveldown` is licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details. | ||
`deferred-leveldown` is licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included [LICENSE.md](LICENSE.md) file for more details. | ||
[level-badge]: http://leveldb.org/img/badge.svg |
@@ -235,2 +235,10 @@ var test = require('tape') | ||
}) | ||
t.test('store not supporting approximateSize', function (t) { | ||
var ld = Db('FOO', function () {}) | ||
t.throws(function () { | ||
ld.approximateSize('key', 'key', noop) | ||
}, /approximateSize is not a function/) | ||
t.end() | ||
}) | ||
}) | ||
@@ -237,0 +245,0 @@ |
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
23534
360
0
71
+ Addedabstract-leveldown@4.0.3(transitive)
- Removedabstract-leveldown@3.0.0(transitive)
Updatedabstract-leveldown@~4.0.0