{"name":"level-codec","version":"9.0.2","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","coverage":"nyc report --reporter=text-lcov | coveralls","hallmark":"hallmark --fix","dependency-check":"dependency-check . test/*.js","prepublishOnly":"npm run dependency-check"},"dependencies":{"buffer":"^5.6.0"},"devDependencies":{"coveralls":"^3.0.2","dependency-check":"^3.3.0","hallmark":"^2.0.0","level-community":"^3.0.0","nyc":"^14.0.0","standard":"^14.0.0","tape":"^4.10.0"},"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":">=6"},"gitHead":"fdb2c4fb2db2fe0f51be7d221fd74ee70794a794","bugs":{"url":"https://github.com/Level/codec/issues"},"_id":"level-codec@9.0.2","_nodeVersion":"12.11.1","_npmVersion":"6.11.3","_npmUser":{"name":"vweevers","email":"dev@vincentweevers.nl"},"maintainers":[{"email":"julian@juliangruber.com","name":"juliangruber"},{"email":"ralphtheninja@riseup.net","name":"ralphtheninja"},{"email":"dev@vincentweevers.nl","name":"vweevers"}],"dist":{"integrity":"sha512-UyIwNb1lJBChJnGfjmO0OR+ezh2iVu1Kas3nvBS/BzGnx79dv6g7unpKIDNPMhfdTEGoc7mC8uAu51XEtX+FHQ==","shasum":"fd60df8c64786a80d44e63423096ffead63d8cbc","tarball":"http://registry-npm.ywwl.com/level-codec/download/level-codec-9.0.2.tgz","fileCount":15,"unpackedSize":32812,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe9aP3CRA9TVsSAnZWagAAE6MP/iwh0iu5Sg2wofqgpKd+\nM+Z5FE47wPJv0JRvA7hH6+ik/9fH599vT/OMRDaeK7uh5iq4jGZk8oJYdK6L\n70YRNFhyGO94WB8JDkpw74tcovmCrlmIReNiGOyNfm7bJlMDeA/hN6G6z9yF\nPnoGhWJ9SHdF3SpftgrABw0PstHZ23WE0UPme8k/aAv5KvObfjMa301XUKfd\nhETHSuSYu+1miASKL7Xr7j6MTxhq+YbA4FqWV/oaaBh0J1xyQpiblZgeO8kg\nnJzg7kTga0lvBXoAKugxxs1L5ZrCMJ07KOFOH3zFRaFThD1dTGbaQszCMbNS\nPHOTt0/dKs7guX0779gyyroVofUvqeWF6iheF0MOb/X5fMUyx/JIkfs+II1S\nlLYj+m8ZiS0ge22Ew5L3mO0dMXcvMaIGbOaxvnH6iDv76HZiS9NecLLx2BDl\nIkYTRWv+P/nLYYUPUnIXTzU0cMZamfkhuOSspUjTDFxTSSZdbcZRgotFeuC3\n++uNxLiwYm0DDrEF8oKJ4QEadQyCmphyJUmiNWHTHJkKeUxUljP+S/uLl1GW\nPixGpNiS8P3InK9nh99uEDgCujCKSBUZiwvOk2m8FKhjTJrbptAIxmyFWAE4\nAmEuA1rH+JOAF5iRtfKEtMhxjYBNlo9PxHpYprPdnI2tCXAgBUFZteBB1dN6\n8A2T\r\n=jpBe\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD5gvIsE3WGWlqw9nim6dY9R9NGMiZv4ZXmUB/CVS1JYAIhALdYZUn/Z23ceoLpubehP4ojuDLljupGwSPnEoXp4WLP"}],"size":8190,"noattachment":false,"key":"/level-codec/-/level-codec-9.0.2.tgz"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/level-codec_9.0.2_1593156599371_0.22573172872307845"},"_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":1593156599514,"deprecated":"Superseded by level-transcoder (https://github.com/Level/community#faq)","_cnpm_publish_time":1593156599514,"dist-tags":{"latest":"10.0.0"}}