encoding-down
Advanced tools
Comparing version 6.3.0 to 7.0.0
# Changelog | ||
## [7.0.0] - 2021-04-09 | ||
### Changed | ||
- **Breaking:** drop node 6 and 8 ([Level/community#98](https://github.com/Level/community/issues/98)) ([`5c6752f`](https://github.com/Level/encoding-down/commit/5c6752f)) (Vincent Weevers) | ||
- **Breaking:** modernize syntax and bump `standard` ([Level/community#98](https://github.com/Level/community/issues/98)) ([`404f20f`](https://github.com/Level/encoding-down/commit/404f20f)) (Vincent Weevers) | ||
- Bump `abstract-leveldown`, `level-codec` and `level-errors` ([`83556fd`](https://github.com/Level/encoding-down/commit/83556fd)) (Vincent Weevers) | ||
- Add `files` to `package.json` ([`103fe95`](https://github.com/Level/encoding-down/commit/103fe95)) (Vincent Weevers) | ||
### Added | ||
- Support encoding options on chained batch `put()` and `del()` ([`9690e52`](https://github.com/Level/encoding-down/commit/9690e52)) ([Level/levelup#633](https://github.com/Level/levelup/issues/633)) (Vincent Weevers) | ||
### Removed | ||
- Remove default export ([Level/community#87](https://github.com/Level/community/issues/87)) ([`1111866`](https://github.com/Level/encoding-down/commit/1111866)) (Vincent Weevers) | ||
## [6.3.0] - 2019-10-13 | ||
@@ -322,2 +339,4 @@ | ||
[7.0.0]: https://github.com/Level/encoding-down/compare/v6.3.0...v7.0.0 | ||
[6.3.0]: https://github.com/Level/encoding-down/compare/v6.2.0...v6.3.0 | ||
@@ -324,0 +343,0 @@ |
# Contributors | ||
| Name | GitHub | Social | | ||
| :------------------- | :----------------------------------------------------- | :------------------------------------------------------------ | | ||
| **Lars-Magnus Skog** | [**@ralphtheninja**](https://github.com/ralphtheninja) | [**@ralph@social.weho.st**](https://social.weho.st/@ralph) | | ||
| **Vincent Weevers** | [**@vweevers**](https://github.com/vweevers) | [**@vweevers@twitter**](https://twitter.com/vweevers) | | ||
| **Julian Gruber** | [**@juliangruber**](https://github.com/juliangruber) | [**@juliangruber@twitter**](https://twitter.com/juliangruber) | | ||
| **Meirion Hughes** | [**@MeirionHughes**](https://github.com/MeirionHughes) | | | ||
| **Huan LI** | [**@zixia**](https://github.com/zixia) | [**@zixia@twitter**](https://twitter.com/zixia) | | ||
| Name | GitHub | Social | | ||
| :------------------- | :----------------------------------------------------------- | :------------------------------------------------------------ | | ||
| **Vincent Weevers** | [**@vweevers**](https://github.com/vweevers) | [**@vweevers@twitter**](https://twitter.com/vweevers) | | ||
| **Lars-Magnus Skog** | [**@ralphtheninja**](https://github.com/ralphtheninja) | [**@ralph@social.weho.st**](https://social.weho.st/@ralph) | | ||
| **Julian Gruber** | [**@juliangruber**](https://github.com/juliangruber) | [**@juliangruber@twitter**](https://twitter.com/juliangruber) | | ||
| **Meirion Hughes** | [**@MeirionHughes**](https://github.com/MeirionHughes) | | | ||
| **Huan LI** | [**@zixia**](https://github.com/zixia) | [**@zixia@twitter**](https://twitter.com/zixia) | |
53
index.js
'use strict' | ||
var AbstractLevelDOWN = require('abstract-leveldown').AbstractLevelDOWN | ||
var AbstractChainedBatch = require('abstract-leveldown').AbstractChainedBatch | ||
var AbstractIterator = require('abstract-leveldown').AbstractIterator | ||
var inherits = require('inherits') | ||
var Codec = require('level-codec') | ||
var EncodingError = require('level-errors').EncodingError | ||
var rangeMethods = ['approximateSize', 'compactRange'] | ||
const AbstractLevelDOWN = require('abstract-leveldown').AbstractLevelDOWN | ||
const AbstractChainedBatch = require('abstract-leveldown').AbstractChainedBatch | ||
const AbstractIterator = require('abstract-leveldown').AbstractIterator | ||
const inherits = require('inherits') | ||
const Codec = require('level-codec') | ||
const EncodingError = require('level-errors').EncodingError | ||
const rangeMethods = ['approximateSize', 'compactRange'] | ||
module.exports = DB.default = DB | ||
module.exports = DB | ||
@@ -16,4 +16,4 @@ function DB (db, opts) { | ||
var manifest = db.supports || {} | ||
var additionalMethods = manifest.additionalMethods || {} | ||
const manifest = db.supports || {} | ||
const additionalMethods = manifest.additionalMethods || {} | ||
@@ -27,3 +27,3 @@ AbstractLevelDOWN.call(this, manifest) | ||
// TODO (future major): remove this fallback | ||
var fallback = typeof db[m] === 'function' | ||
const fallback = typeof db[m] === 'function' | ||
@@ -73,12 +73,14 @@ if (additionalMethods[m] || fallback) { | ||
DB.prototype._get = function (key, opts, cb) { | ||
var self = this | ||
key = this.codec.encodeKey(key, opts) | ||
opts.asBuffer = this.codec.valueAsBuffer(opts) | ||
this.db.get(key, opts, function (err, value) { | ||
this.db.get(key, opts, (err, value) => { | ||
if (err) return cb(err) | ||
try { | ||
value = self.codec.decodeValue(value, opts) | ||
value = this.codec.decodeValue(value, opts) | ||
} catch (err) { | ||
return cb(new EncodingError(err)) | ||
} | ||
cb(null, value) | ||
@@ -125,8 +127,8 @@ }) | ||
Iterator.prototype._next = function (cb) { | ||
var self = this | ||
this.it.next(function (err, key, value) { | ||
this.it.next((err, key, value) => { | ||
if (err) return cb(err) | ||
try { | ||
if (self.keys && typeof key !== 'undefined') { | ||
key = self.codec.decodeKey(key, self.opts) | ||
if (this.keys && typeof key !== 'undefined') { | ||
key = this.codec.decodeKey(key, this.opts) | ||
} else { | ||
@@ -136,4 +138,4 @@ key = undefined | ||
if (self.values && typeof value !== 'undefined') { | ||
value = self.codec.decodeValue(value, self.opts) | ||
if (this.values && typeof value !== 'undefined') { | ||
value = this.codec.decodeValue(value, this.opts) | ||
} else { | ||
@@ -145,2 +147,3 @@ value = undefined | ||
} | ||
cb(null, key, value) | ||
@@ -167,10 +170,10 @@ }) | ||
Batch.prototype._put = function (key, value) { | ||
key = this.codec.encodeKey(key) | ||
value = this.codec.encodeValue(value) | ||
Batch.prototype._put = function (key, value, options) { | ||
key = this.codec.encodeKey(key, options) | ||
value = this.codec.encodeValue(value, options) | ||
this.batch.put(key, value) | ||
} | ||
Batch.prototype._del = function (key) { | ||
key = this.codec.encodeKey(key) | ||
Batch.prototype._del = function (key, options) { | ||
key = this.codec.encodeKey(key, options) | ||
this.batch.del(key) | ||
@@ -177,0 +180,0 @@ } |
{ | ||
"name": "encoding-down", | ||
"version": "6.3.0", | ||
"description": "LevelDOWN wrapper supporting levelup@1 encodings", | ||
"version": "7.0.0", | ||
"description": "An abstract-leveldown implementation that wraps another store to encode keys and values", | ||
"license": "MIT", | ||
@@ -9,2 +9,3 @@ "main": "index.js", | ||
"test": "standard && hallmark && nyc node test", | ||
"test-browsers-local": "airtap --coverage test/index.js", | ||
"coverage": "nyc report --reporter=text-lcov | coveralls", | ||
@@ -15,18 +16,26 @@ "hallmark": "hallmark --fix", | ||
}, | ||
"files": [ | ||
"index.js", | ||
"CHANGELOG.md", | ||
"CONTRIBUTORS.md", | ||
"LICENSE.md", | ||
"UPGRADING.md" | ||
], | ||
"dependencies": { | ||
"abstract-leveldown": "^6.2.1", | ||
"abstract-leveldown": "^7.0.0", | ||
"inherits": "^2.0.3", | ||
"level-codec": "^9.0.0", | ||
"level-errors": "^2.0.0" | ||
"level-codec": "^10.0.0", | ||
"level-errors": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"airtap": "^4.0.3", | ||
"airtap-playwright": "^1.0.1", | ||
"coveralls": "^3.0.2", | ||
"dependency-check": "^3.3.0", | ||
"hallmark": "^2.0.0", | ||
"hallmark": "^3.1.0", | ||
"level-community": "^3.0.0", | ||
"memdown": "^5.0.0", | ||
"nyc": "^14.0.0", | ||
"safe-buffer": "^5.1.1", | ||
"standard": "^14.0.0", | ||
"tape": "^4.8.0" | ||
"nyc": "^15.1.0", | ||
"standard": "^16.0.3", | ||
"tape": "^5.0.1" | ||
}, | ||
@@ -42,4 +51,4 @@ "hallmark": { | ||
"engines": { | ||
"node": ">=6" | ||
"node": ">=10" | ||
} | ||
} |
@@ -5,11 +5,32 @@ # Upgrade Guide | ||
## v6 | ||
## 7.0.0 | ||
Legacy range options have been removed ([Level/community#86](https://github.com/Level/community/issues/86)). If you previously did: | ||
```js | ||
db.iterator({ start: 'a', end: 'z' }) | ||
``` | ||
An error would now be thrown and you must instead do: | ||
```js | ||
db.iterator({ gte: 'a', lte: 'z' }) | ||
``` | ||
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). | ||
## 6.0.0 | ||
Upgraded `abstract-leveldown` to `v6.0.0`. Please see the corresponding [changelog entry](https://github.com/Level/abstract-leveldown/blob/master/CHANGELOG.md#600---2018-10-20) for more information. | ||
## v5 | ||
## 5.0.0 | ||
Dropped support for node 4. No other breaking changes. | ||
## v4 | ||
## 4.0.0 | ||
@@ -24,4 +45,4 @@ Dropped support for node 7. | ||
## v3 | ||
## 3.0.0 | ||
Dropped support for node 0.12. No other breaking changes. |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
30921
10
7
141
1
+ Addedabstract-leveldown@7.2.0(transitive)
+ Addedbuffer@6.0.3(transitive)
+ Addedcatering@2.1.1(transitive)
+ Addedis-buffer@2.0.5(transitive)
+ Addedlevel-codec@10.0.0(transitive)
+ Addedlevel-concat-iterator@3.1.0(transitive)
+ Addedlevel-errors@3.0.1(transitive)
+ Addedlevel-supports@2.1.0(transitive)
+ Addedqueue-microtask@1.2.3(transitive)
- Removedabstract-leveldown@6.3.0(transitive)
- Removedbuffer@5.7.1(transitive)
- Removederrno@0.1.8(transitive)
- Removedimmediate@3.3.0(transitive)
- Removedlevel-codec@9.0.2(transitive)
- Removedlevel-concat-iterator@2.0.1(transitive)
- Removedlevel-errors@2.0.1(transitive)
- Removedlevel-supports@1.0.1(transitive)
- Removedprr@1.0.1(transitive)
- Removedxtend@4.0.2(transitive)
Updatedabstract-leveldown@^7.0.0
Updatedlevel-codec@^10.0.0
Updatedlevel-errors@^3.0.0