{"name":"level-codec","version":"10.0.0","description":"Encode keys, values and range options, with built-in or custom encodings","license":"MIT","main":"index.js","scripts":{"test":"standard && hallmark && nyc tape test/*.js","test-browsers-local":"airtap --coverage --verbose test/*.js","coverage":"nyc report --reporter=text-lcov | coveralls","hallmark":"hallmark --fix","dependency-check":"dependency-check . test/*.js","prepublishOnly":"npm run dependency-check"},"dependencies":{"buffer":"^6.0.3"},"devDependencies":{"airtap":"^4.0.3","airtap-playwright":"^1.0.1","coveralls":"^3.0.2","dependency-check":"^3.3.0","hallmark":"^3.1.0","level-community":"^3.0.0","nyc":"^15.1.0","standard":"^16.0.3","tape":"^5.0.1"},"hallmark":{"community":"level-community"},"repository":{"type":"git","url":"git+https://github.com/Level/codec.git"},"homepage":"https://github.com/Level/codec","keywords":["level"],"engines":{"node":">=10"},"gitHead":"0bf9d06d97708c9366f85623e123d1bae734008d","bugs":{"url":"https://github.com/Level/codec/issues"},"_id":"level-codec@10.0.0","_nodeVersion":"12.11.1","_npmVersion":"6.11.3","_npmUser":{"name":"vweevers","email":"dev@vincentweevers.nl"},"maintainers":[{"name":"vweevers","email":"dev@vincentweevers.nl"},{"name":"juliangruber","email":"julian@juliangruber.com"},{"name":"ralphtheninja","email":"ralphtheninja@riseup.net"}],"dist":{"integrity":"sha512-QW3VteVNAp6c/LuV6nDjg7XDXx9XHK4abmQarxZmlRSDyXYk20UdaJTSX6yzVvQ4i0JyWSB7jert0DsyD/kk6g==","shasum":"f9e892770532c6cdcc83529546730791b0c62c12","tarball":"http://registry-npm.ywwl.com/level-codec/download/level-codec-10.0.0.tgz","fileCount":8,"unpackedSize":28057,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgcFLuCRA9TVsSAnZWagAA/pAQAIlKq5pgnPVe4K5nQgMz\nacJPKc4Gkkbvm2D4oB/HdsB7jFTS0TvSWx2Yi86FFZWHCXKuG9f3+MIKCVsK\n3jBQSbRuljbMr8/jh7XtYMYpwHcOVJE93Y6U7nzIC6URiQHbfbbj9Nk2efHW\nc7ecDJmrJip25QnjWWEa9M/zF5rI3LGPx0J3T2sCTci8/TTaBJyJcldTT02U\nIIyhBbC5+ISKyAOcsZZetl802qYoZJSbqZJPkr2eKItXFjAmbgT6w1bjhyRw\ngdSWZ7WcSNc801diyGGbcktbJ7nBkyJaKzvJGqt7G5hpCoqmnWZt1eloDg1n\np8Gk0c4OwVIV0tUTuS9mN3EGQEKop/z5pdVMkZrb5POFTVZRJoowcF1LWCxj\n3Jd+fVL2fiSmlLQ49bnwO1pQ7xmXTtPeH9KSxkPSAWppKmb+hZYZVkgMm/26\nVUHhz5OrIuPnXbDfAXH12TqFgRzi42t59VasDGkQiiSH4VaB4b0JN/pShEU0\nT80xQD+Gfaq7hnYdyuGaVWWGcVjvxs1BRVbLoWYoofX0DKB+9IUf7/K91Ojl\nap5Ueu+P1JUwG2ssqtWFPCG/iIvO63SC6jQhyjgaeFyMjK3q6joBMJiEGnfT\n1w4boiDs/WiRc/+InSbK0RrtbaCFn/nScc2O0ot8vM4HF9PzONDi1HPoWWiL\nkNyQ\r\n=1x9y\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD6K9kwLO4EltVj12RFymDHbUsdyxZAiQNCVfUurLqQiQIhAL2O5ASKamovrF5aZ8zW6UkvQpTk7QGgOQducZ/7i4RH"}],"size":7726,"noattachment":false,"key":"/level-codec/-/level-codec-10.0.0.tgz"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/level-codec_10.0.0_1617973998224_0.3416438135665272"},"_hasShrinkwrap":false,"readme":"# level-codec\n\n> Encode keys, values and range options, with built-in or custom encodings.\n\n[![level badge][level-badge]](https://github.com/Level/awesome)\n[![npm](https://img.shields.io/npm/v/level-codec.svg?label=&logo=npm)](https://www.npmjs.com/package/level-codec)\n[![Node version](https://img.shields.io/node/v/level-codec.svg)](https://www.npmjs.com/package/level-codec)\n[![Travis](https://img.shields.io/travis/com/Level/codec.svg?logo=travis&label=)](https://travis-ci.com/Level/codec)\n[![npm](https://img.shields.io/npm/dm/level-codec.svg?label=dl)](https://www.npmjs.com/package/level-codec)\n[![Coverage Status](https://coveralls.io/repos/github/Level/codec/badge.svg)](https://coveralls.io/github/Level/codec)\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n[![Backers on Open Collective](https://opencollective.com/level/backers/badge.svg?color=orange)](#backers)\n[![Sponsors on Open Collective](https://opencollective.com/level/sponsors/badge.svg?color=orange)](#sponsors)\n\n## Usage\n\n**If you are upgrading:** please see [`UPGRADING.md`](UPGRADING.md).\n\n```js\nconst Codec = require('level-codec')\nconst codec = Codec({ keyEncoding: 'json' })\nconst key = codec.encodeKey({ foo: 'bar' })\nconsole.log(key) // -> '{\"foo\":\"bar\"}'\nconsole.log(codec.decodeKey(key)) // -> { foo: 'bar' }\n```\n\n## API\n\n### `codec = Codec([opts])`\n\nCreate a new codec, with a global options object.\n\n### `codec.encodeKey(key[, opts])`\n\nEncode `key` with given `opts`.\n\n### `codec.encodeValue(value[, opts])`\n\nEncode `value` with given `opts`.\n\n### `codec.encodeBatch(batch[, opts])`\n\nEncode `batch` ops with given `opts`.\n\n### `codec.encodeLtgt(ltgt)`\n\nEncode the ltgt values of option object `ltgt`.\n\n### `codec.decodeKey(key[, opts])`\n\nDecode `key` with given `opts`.\n\n### `codec.decodeValue(value[, opts])`\n\nDecode `value` with given `opts`.\n\n### `codec.createStreamDecoder([opts])`\n\nCreate a function with signature `(key, value)`, that for each key-value pair returned from a levelup read stream returns the decoded value to be emitted.\n\n### `codec.keyAsBuffer([opts])`\n\nCheck whether `opts` and the global `opts` call for a binary key encoding.\n\n### `codec.valueAsBuffer([opts])`\n\nCheck whether `opts` and the global `opts` call for a binary value encoding.\n\n### `codec.encodings`\n\nThe builtin encodings as object of form\n\n```js\n{\n  [type]: encoding\n}\n```\n\nSee below for a list and the format of `encoding`.\n\n## Builtin Encodings\n\n| Type                                                              | Input                        | Stored as        | Output    |\n| :---------------------------------------------------------------- | :--------------------------- | :--------------- | :-------- |\n| `utf8`                                                            | String or Buffer             | String or Buffer | String    |\n| `json`                                                            | Any JSON type                | JSON string      | Input     |\n| `binary`                                                          | Buffer, string or byte array | Buffer           | As stored |\n| `hex`<br>`ascii`<br>`base64`<br>`ucs2`<br>`utf16le`<br>`utf-16le` | String or Buffer             | Buffer           | String    |\n| `none` a.k.a. `id`                                                | Any type (bypass encoding)   | Input\\*          | As stored |\n\n<sup>\\*</sup> Stores may have their own type coercion. Whether type information is preserved depends on the [`abstract-leveldown`] implementation as well as the underlying storage (`LevelDB`, `IndexedDB`, etc).\n\n## Encoding Format\n\nAn encoding is an object of the form:\n\n```js\n{\n  encode: function (data) {\n    return data\n  },\n  decode: function (data) {\n    return data\n  },\n  buffer: Boolean,\n  type: 'example'\n}\n```\n\nAll of these properties are required.\n\nThe `buffer` boolean tells consumers whether to fetch data as a Buffer, before calling your `decode()` function on that data. If `buffer` is true, it is assumed that `decode()` takes a Buffer. If false, it is assumed that `decode` takes any other type (usually a string).\n\nTo explain this in the grand scheme of things, consider a store like [`leveldown`] which has the ability to return either a Buffer or string, both sourced from the same byte array. Wrap this store with [`encoding-down`] and it'll select the most optimal data type based on the `buffer` property of the active encoding. If your `decode()` function needs a string (and the data can legitimately become a UTF8 string), you should set `buffer` to `false`. This avoids the cost of having to convert a Buffer to a string.\n\nThe `type` string should be a unique name.\n\n## Contributing\n\n[`Level/codec`](https://github.com/Level/codec) is an **OPEN Open Source Project**. This means that:\n\n> Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project.\n\nSee the [Contribution Guide](https://github.com/Level/community/blob/master/CONTRIBUTING.md) for more details.\n\n## Donate\n\nTo 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. 💖\n\n### Backers\n\n[![Open Collective backers](https://opencollective.com/level/backers.svg?width=890)](https://opencollective.com/level)\n\n### Sponsors\n\n[![Open Collective sponsors](https://opencollective.com/level/sponsors.svg?width=890)](https://opencollective.com/level)\n\n## License\n\n[MIT](LICENSE.md) © 2012-present [Contributors](CONTRIBUTORS.md).\n\n[level-badge]: https://leveljs.org/img/badge.svg\n\n[`encoding-down`]: https://github.com/Level/encoding-down\n\n[`abstract-leveldown`]: https://github.com/Level/abstract-leveldown\n\n[`leveldown`]: https://github.com/Level/leveldown\n","publish_time":1617973998355,"deprecated":"Superseded by level-transcoder (https://github.com/Level/community#faq)","_cnpm_publish_time":1617973998355,"dist-tags":{"latest":"10.0.0"}}