Socket
Socket
Sign inDemoInstall

encoding-down

Package Overview
Dependencies
Maintainers
3
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

encoding-down - npm Package Compare versions

Comparing version 6.2.0 to 6.3.0

9

CHANGELOG.md
# Changelog
## [6.3.0] - 2019-10-13
### Added
- Add manifest ([Level/community#83](https://github.com/Level/community/issues/83)) and encode `compactRange()` ([#93](https://github.com/Level/encoding-down/issues/93)) ([**@vweevers**](https://github.com/vweevers))
- Add `type` property for `reachdown` ([Level/community#82](https://github.com/Level/community/issues/82)) ([`8a23848`](https://github.com/Level/encoding-down/commit/8a23848)) ([**@vweevers**](https://github.com/vweevers))
## [6.2.0] - 2019-09-06

@@ -315,2 +322,4 @@

[6.3.0]: https://github.com/Level/encoding-down/compare/v6.2.0...v6.3.0
[6.2.0]: https://github.com/Level/encoding-down/compare/v6.1.0...v6.2.0

@@ -317,0 +326,0 @@

2

CONTRIBUTORS.md

@@ -6,5 +6,5 @@ # Contributors

| **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) |
| **Vincent Weevers** | [**@vweevers**](https://github.com/vweevers) | [**@vweevers@twitter**](https://twitter.com/vweevers) |
| **Meirion Hughes** | [**@MeirionHughes**](https://github.com/MeirionHughes) | |
| **Huan LI** | [**@zixia**](https://github.com/zixia) | [**@zixia@twitter**](https://twitter.com/zixia) |

@@ -9,2 +9,3 @@ 'use strict'

var EncodingError = require('level-errors').EncodingError
var rangeMethods = ['approximateSize', 'compactRange']

@@ -15,4 +16,26 @@ module.exports = DB.default = DB

if (!(this instanceof DB)) return new DB(db, opts)
AbstractLevelDOWN.call(this, '')
var manifest = db.supports || {}
var additionalMethods = manifest.additionalMethods || {}
AbstractLevelDOWN.call(this, manifest)
this.supports.encodings = true
this.supports.additionalMethods = {}
rangeMethods.forEach(function (m) {
// TODO (future major): remove this fallback
var fallback = typeof db[m] === 'function'
if (additionalMethods[m] || fallback) {
this.supports.additionalMethods[m] = true
this[m] = function (start, end, opts, cb) {
start = this.codec.encodeKey(start, opts)
end = this.codec.encodeKey(end, opts)
return this.db[m](start, end, opts, cb)
}
}
}, this)
opts = opts || {}

@@ -28,2 +51,4 @@ if (typeof opts.keyEncoding === 'undefined') opts.keyEncoding = 'utf8'

DB.prototype.type = 'encoding-down'
DB.prototype._serializeKey =

@@ -88,8 +113,2 @@ DB.prototype._serializeValue = function (datum) {

DB.prototype.approximateSize = function (start, end, opts, cb) {
start = this.codec.encodeKey(start, opts)
end = this.codec.encodeKey(end, opts)
return this.db.approximateSize(start, end, opts, cb)
}
function Iterator (db, opts) {

@@ -96,0 +115,0 @@ AbstractIterator.call(this, db)

{
"name": "encoding-down",
"version": "6.2.0",
"version": "6.3.0",
"description": "LevelDOWN wrapper supporting levelup@1 encodings",

@@ -15,3 +15,3 @@ "license": "MIT",

"dependencies": {
"abstract-leveldown": "^6.1.1",
"abstract-leveldown": "^6.2.1",
"inherits": "^2.0.3",

@@ -18,0 +18,0 @@ "level-codec": "^9.0.0",

@@ -8,3 +8,3 @@ # encoding-down

[![Node version](https://img.shields.io/node/v/encoding-down.svg)](https://www.npmjs.com/package/encoding-down)
[![Travis](https://img.shields.io/travis/Level/encoding-down.svg?logo=travis&label=)](https://travis-ci.org/Level/encoding-down)
[![Travis](https://img.shields.io/travis/Level/com/encoding-down.svg?logo=travis&label=)](https://travis-ci.com/Level/encoding-down)
[![Coverage Status](https://coveralls.io/repos/github/Level/encoding-down/badge.svg)](https://coveralls.io/github/Level/encoding-down)

@@ -11,0 +11,0 @@ [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

@@ -582,15 +582,66 @@ var test = require('tape')

test('approximateSize() encodes start and end', function (t) {
t.plan(2)
test('proxies approximateSize() if it exists', function (t) {
t.is(typeof encdown({ approximateSize: noop }).approximateSize, 'function')
t.ok(encdown({ approximateSize: noop }).supports.additionalMethods.approximateSize)
t.is(encdown({}).approximateSize, undefined)
t.notOk(encdown({}).supports.additionalMethods.approximateSize)
t.end()
})
var down = {
test('proxies compactRange() if it exists', function (t) {
t.is(typeof encdown({ compactRange: noop }).compactRange, 'function')
t.ok(encdown({ compactRange: noop }).supports.additionalMethods.compactRange)
t.is(encdown({}).compactRange, undefined)
t.notOk(encdown({}).supports.additionalMethods.compactRange)
t.end()
})
test('encodes start and end of approximateSize()', function (t) {
var db = encdown({
approximateSize: function (start, end) {
t.is(start, '1')
t.is(end, '2')
t.end()
}
}
})
encdown(down).approximateSize(1, 2, noop)
db.approximateSize(1, 2, noop)
})
test('encodes start and end of compactRange()', function (t) {
var db = encdown({
compactRange: function (start, end) {
t.is(start, '1')
t.is(end, '2')
t.end()
}
})
db.compactRange(1, 2, noop)
})
test('encodes start and end of approximateSize() with custom encoding', function (t) {
var db = encdown({
approximateSize: function (start, end) {
t.is(start, '"a"')
t.is(end, '"b"')
t.end()
}
})
db.approximateSize('a', 'b', { keyEncoding: 'json' }, noop)
})
test('encodes start and end of compactRange() with custom encoding', function (t) {
var db = encdown({
compactRange: function (start, end) {
t.is(start, '"a"')
t.is(end, '"b"')
t.end()
}
})
db.compactRange('a', 'b', { keyEncoding: 'json' }, noop)
})
test('encodes seek target', function (t) {

@@ -597,0 +648,0 @@ t.plan(1)

Sorry, the diff of this file is not supported yet

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