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 5.0.4 to 6.0.0

23

CHANGELOG.md

@@ -5,2 +5,21 @@ # Changelog

## [6.0.0] - 2018-12-25
### Changed
- Prefer `const` over `var` in README ([**@ralphtheninja**](https://github.com/ralphtheninja))
- Upgrade `abstract-leveldown` dependency from `^5.0.0` to `^v6.0.0` ([#68](https://github.com/level/encoding-down/issues/68)) ([**@ralphtheninja**](https://github.com/ralphtheninja))
- Upgrade `standard` devDependency from `^11.0.0` to `^v12.0.0` ([**@ralphtheninja**](https://github.com/ralphtheninja))
- Use full link references in README ([#60](https://github.com/level/encoding-down/issues/60)) ([**@vweevers**](https://github.com/vweevers))
### Added
- Explain serialization ([#72](https://github.com/level/encoding-down/issues/72)) ([**@vweevers**](https://github.com/vweevers))
- Add `nyc` and `coveralls` ([#64](https://github.com/level/encoding-down/issues/64)) ([**@ralphtheninja**](https://github.com/ralphtheninja))
### Removed
- Remove node 9 ([**@ralphtheninja**](https://github.com/ralphtheninja))
- Remove now superfluous `_setupIteratorOptions()` ([**@ralphtheninja**](https://github.com/ralphtheninja))
## [5.0.4] - 2018-06-22

@@ -255,4 +274,6 @@

[unreleased]: https://github.com/level/encoding-down/compare/v5.0.4...HEAD
[unreleased]: https://github.com/level/encoding-down/compare/v6.0.0...HEAD
[6.0.0]: https://github.com/level/encoding-down/compare/v5.0.4...v6.0.0
[5.0.4]: https://github.com/level/encoding-down/compare/v5.0.3...v5.0.4

@@ -259,0 +280,0 @@

2

CONTRIBUTORS.md
# Contributors
| Name | GitHub | Social |
| -------------------- | ------------------------------------------------------ | ------------------------------------------------------------- |
| :------------------- | :----------------------------------------------------- | :------------------------------------------------------------ |
| **Lars-Magnus Skog** | [**@ralphtheninja**](https://github.com/ralphtheninja) | [**@ralph@social.weho.st**](https://social.weho.st/@ralph) |

@@ -6,0 +6,0 @@ | **Julian Gruber** | [**@juliangruber**](https://github.com/juliangruber) | [**@juliangruber@twitter**](https://twitter.com/juliangruber) |

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

var inherits = require('inherits')
var xtend = require('xtend')
var Codec = require('level-codec')

@@ -82,13 +81,2 @@ var EncodingError = require('level-errors').EncodingError

DB.prototype._setupIteratorOptions = function (options) {
options = xtend(options)
options.reverse = !!options.reverse
options.keys = options.keys !== false
options.values = options.values !== false
options.limit = 'limit' in options ? options.limit : -1
options.keyAsBuffer = options.keyAsBuffer !== false
options.valueAsBuffer = options.valueAsBuffer !== false
return options
}
DB.prototype.approximateSize = function (start, end, opts, cb) {

@@ -95,0 +83,0 @@ return this.db.approximateSize(start, end, opts, cb)

{
"name": "encoding-down",
"version": "5.0.4",
"version": "6.0.0",
"license": "MIT",

@@ -9,8 +9,11 @@ "repository": "level/encoding-down",

"scripts": {
"test": "standard && node test",
"test": "standard && nyc node test",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"remark": "remark README.md CONTRIBUTORS.md CHANGELOG.md UPGRADING.md -o"
},
"devDependencies": {
"coveralls": "^3.0.2",
"level-community": "^3.0.0",
"memdown": "^3.0.0",
"nyc": "^12.0.2",
"remark-cli": "^5.0.0",

@@ -20,11 +23,10 @@ "remark-git-contributors": "^0.2.1",

"safe-buffer": "^5.1.1",
"standard": "^11.0.0",
"standard": "^12.0.0",
"tape": "^4.8.0"
},
"dependencies": {
"abstract-leveldown": "^5.0.0",
"abstract-leveldown": "^6.0.0",
"inherits": "^2.0.3",
"level-codec": "^9.0.0",
"level-errors": "^2.0.0",
"xtend": "^4.0.1"
"level-errors": "^2.0.0"
},

@@ -31,0 +33,0 @@ "remarkConfig": {

# encoding-down
> An [`abstract-leveldown`] implementation that wraps another store to encode keys and values.
> An [`abstract-leveldown`][abstract-leveldown] implementation that wraps another store to encode keys and values.

@@ -10,2 +10,3 @@ [![level badge][level-badge]](https://github.com/level/awesome)

[![david](https://david-dm.org/Level/encoding-down.svg)](https://david-dm.org/level/encoding-down)
[![Coverage Status](https://coveralls.io/repos/github/Level/encoding-down/badge.svg)](https://coveralls.io/github/Level/encoding-down)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

@@ -16,5 +17,5 @@ [![npm](https://img.shields.io/npm/dm/encoding-down.svg)](https://www.npmjs.com/package/encoding-down)

Stores like [`leveldown`] can only store strings and Buffers. For a richer set of data types you can wrap such a store with `encoding-down`. It allows you to specify an _encoding_ to use for keys and values independently. This not only widens the range of input types, but also limits the range of output types. The encoding is applied to all read and write operations: it encodes writes and decodes reads.
Stores like [`leveldown`][leveldown] can only store strings and Buffers. Other types, though accepted, are [_serialized_](https://github.com/Level/abstract-leveldown#db_serializekeykey) before storage, which is an irreversible type conversion. For a richer set of data types you can wrap such a store with `encoding-down`. It allows you to specify an _encoding_ to use for keys and values independently. This not only widens the range of input types, but also limits the range of output types. The encoding is applied to all read and write operations: it encodes writes and decodes reads.
[Many encodings are builtin][builtin-encodings] courtesy of [`level-codec`]. The default encoding is `utf8` which ensures you'll always get back a string. You can also provide a custom encoding like `bytewise` - [or your own](#custom-encodings)!
[Many encodings are builtin][builtin-encodings] courtesy of [`level-codec`][level-codec]. The default encoding is `utf8` which ensures you'll always get back a string. You can also provide a custom encoding like `bytewise` - [or your own](#custom-encodings)!

@@ -26,7 +27,7 @@ ## Usage

```js
const levelup = require('levelup')
const leveldown = require('leveldown')
const encode = require('encoding-down')
var levelup = require('levelup')
var leveldown = require('leveldown')
var encode = require('encoding-down')
const db = levelup(encode(leveldown('./db1')))
var db = levelup(encode(leveldown('./db1')))

@@ -43,3 +44,3 @@ db.put('example', Buffer.from('encoding-down'), function (err) {

```js
const db = levelup(encode(leveldown('./db2'), { valueEncoding: 'json' }))
var db = levelup(encode(leveldown('./db2'), { valueEncoding: 'json' }))

@@ -57,3 +58,3 @@ db.put('example', { awesome: true }, function (err) {

```js
const db = levelup(encode(leveldown('./db3'), { valueEncoding: 'hex' }))
var db = levelup(encode(leveldown('./db3'), { valueEncoding: 'hex' }))

@@ -70,3 +71,3 @@ db.put('example', Buffer.from([0, 255]), function (err) {

```js
const db = levelup(encode(leveldown('./db4'), { valueEncoding: 'binary' }))
var db = levelup(encode(leveldown('./db4'), { valueEncoding: 'binary' }))

@@ -88,3 +89,3 @@ db.put('example', Buffer.from([0, 255]), function (err) {

```js
const db = levelup(encode(leveldown('./db5'), { keyEncoding: 'json' }))
var db = levelup(encode(leveldown('./db5'), { keyEncoding: 'json' }))

@@ -99,3 +100,3 @@ db.put({ awesome: true }, 'example', function (err) {

```js
const db = levelup(encode(leveldown('./db6'), { keyEncoding: 'binary' }))
var db = levelup(encode(leveldown('./db6'), { keyEncoding: 'binary' }))

@@ -109,9 +110,9 @@ db.put(Buffer.from([0, 255]), 'example', function (err) {

## Usage with [`level`]
## Usage with [`level`][level]
The [`level`] module conveniently bundles `encoding-down` and passes its `options` to `encoding-down`. This means you can simply do:
The [`level`][level] module conveniently bundles `encoding-down` and passes its `options` to `encoding-down`. This means you can simply do:
```js
const level = require('level')
const db = level('./db7', { valueEncoding: 'json' })
var level = require('level')
var db = level('./db7', { valueEncoding: 'json' })

@@ -128,6 +129,6 @@ db.put('example', 42, function (err) {

### `const db = require('encoding-down')(db[, options])`
### `db = require('encoding-down')(db[, options])`
- `db` must be an [`abstract-leveldown`] compliant store
- `options` are passed to [`level-codec`]:
- `db` must be an [`abstract-leveldown`][abstract-leveldown] compliant store
- `options` are passed to [`level-codec`][level-codec]:
- `keyEncoding`: encoding to use for keys

@@ -143,7 +144,7 @@ - `valueEncoding`: encoding to use for values

```js
const level = require('level')
const lexint = require('lexicographic-integer')
var level = require('level')
var lexint = require('lexicographic-integer')
async function main () {
const db = level('./db8', {
var db = level('./db8', {
keyEncoding: {

@@ -170,6 +171,6 @@ type: 'lexicographic-integer',

```js
const level = require('level')
const lexint = require('lexicographic-integer-encoding')('hex')
var level = require('level')
var lexint = require('lexicographic-integer-encoding')('hex')
const db = level('./db8', {
var db = level('./db8', {
keyEncoding: lexint

@@ -185,9 +186,9 @@ })

[`abstract-leveldown`]: https://github.com/level/abstract-leveldown
[abstract-leveldown]: https://github.com/level/abstract-leveldown
[`leveldown`]: https://github.com/level/leveldown
[leveldown]: https://github.com/level/leveldown
[`level`]: https://github.com/level/level
[level]: https://github.com/level/level
[`level-codec`]: https://github.com/level/codec
[level-codec]: https://github.com/level/codec

@@ -194,0 +195,0 @@ [builtin-encodings]: https://github.com/level/codec#builtin-encodings

@@ -5,2 +5,6 @@ # Upgrade Guide

## v6
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

@@ -7,0 +11,0 @@

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