{"name":"subleveldown","version":"5.0.0","description":"Split a levelup database into sublevels with their own keyspace, encoding and events","author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","main":"index.js","scripts":{"test":"standard && hallmark && (nyc -s node test | faucet) && nyc report","coverage":"nyc report --reporter=text-lcov | coveralls","hallmark":"hallmark --fix","dependency-check":"dependency-check --no-dev .","prepublishOnly":"npm run dependency-check"},"directories":{"test":"test"},"dependencies":{"abstract-leveldown":"^6.2.3","encoding-down":"^6.2.0","inherits":"^2.0.3","level-option-wrap":"^1.1.0","levelup":"^4.3.1","reachdown":"^1.1.0"},"devDependencies":{"after":"^0.8.2","coveralls":"^3.0.2","dependency-check":"^4.1.0","faucet":"^0.0.1","hallmark":"^2.0.0","level-community":"^3.0.0","level-concat-iterator":"^2.0.1","memdown":"^5.0.0","nyc":"^14.0.0","standard":"^14.0.0","tape":"^4.9.0"},"hallmark":{"community":"level-community"},"repository":{"type":"git","url":"git+https://github.com/level/subleveldown.git"},"homepage":"https://github.com/level/subleveldown","bugs":{"url":"https://github.com/level/subleveldown/issues"},"keywords":["level"],"engines":{"node":">=6"},"gitHead":"b53770cb5d3267867fd8353dc2d0815cf90a35e4","_id":"subleveldown@5.0.0","_nodeVersion":"12.11.1","_npmVersion":"6.11.3","_npmUser":{"name":"vweevers","email":"dev@vincentweevers.nl"},"maintainers":[{"email":"mathiasbuus@gmail.com","name":"mafintosh"},{"email":"ralphtheninja@riseup.net","name":"ralphtheninja"},{"email":"dev@vincentweevers.nl","name":"vweevers"}],"dist":{"integrity":"sha512-DotbiAIyOWSsidM06/m+EsBHXRyP7EgPlDDD5GVn6JcoDFcVZbp+VN9bOdErNtDWwgR+lJDuKwcJ8nKqSq9Ixg==","shasum":"40449c28b418d83569efdb48acebe29d7b55b557","tarball":"http://registry-npm.ywwl.com/subleveldown/download/subleveldown-5.0.0.tgz","fileCount":11,"unpackedSize":54528,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeikKFCRA9TVsSAnZWagAA6YMP/3Ii8jyV3zWXOoudJolz\n3PNo3xQxHgZxxRt6a4pqhpveFWav6tCoXakAFJGOC9wlgYw+mqd4fwUJTU1P\nTS93TGzODD8GhMfrOKU6B+hqA3wFWdBl8P2HIRVJmN6MciagwvY++KAvrzL1\n37hUK61aeqL/OERBSlXZSVjueCRdbPUys5lHKvsZ8p6/eQacL7BCsggxzxSf\nSusIntcWwErjDYhWAmWPL6y3tkZOKwT5YhrDZlGHEdUXvjaq+EQ6ru76OJJ8\ntkVn9qjx5dIcLnazIWnu4u17GViTz8X/1/jrVfauUYoYEVMvtsXtuBe8jvtA\n7toljIL6g5CqkLU0pdnjXgpLp04cXAeMmkYtmrpMLbr6MvaSJsgz+1KYZ9Bb\nbnVPddCGKSqkj88NYqsc+bAmsxEof11JL7HP8sh3RJTSyXWXVHM7wpYZ1yPd\n1neR/S+3+mTh4sxi9HBtsp9Tp1RFhnpms7cbhUqC9ugH0194HRhMK5wRo0oC\nAdbiLShGFB9I1I5Yk+lmVAInaptwKxiDHb1aBRE2y989TGANe44Gh6A9eA0Y\nRim+mU/f53QoISl+KRVk9+a4m8D+aJkX6VpHC4xdW+VXD17LBsIxflOb7aG/\nTeJgeVT30ZueAjwhM2TrZigmbukH1yESQbc10G/7uwaEIPee2r9Wg80vUbUF\nMLhM\r\n=CCZr\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD8+y8JLcIIjp7CmwjxxZ/4tw/rewNwYTPY8T6vQuPssgIhAIh5g/L3uN/BxnkJ9AMiAS2lGkia5kDYJgryuYKDPtTC"}],"size":13994,"noattachment":false,"key":"/subleveldown/-/subleveldown-5.0.0.tgz"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/subleveldown_5.0.0_1586119300732_0.12072510030288774"},"_hasShrinkwrap":false,"readme":"# subleveldown\n\n> Split a [`levelup`][levelup] database into _sublevels_ with their own keyspace, encoding and events.\n\n[![level badge][level-badge]](https://github.com/Level/awesome)\n[![npm](https://img.shields.io/npm/v/subleveldown.svg)](https://www.npmjs.com/package/subleveldown)\n[![Node version](https://img.shields.io/node/v/subleveldown.svg)](https://www.npmjs.com/package/subleveldown)\n[![Test](https://img.shields.io/github/workflow/status/Level/subleveldown/Test?label=test)](https://github.com/Level/subleveldown/actions/workflows/test.yml)\n[![Coverage](https://img.shields.io/codecov/c/github/Level/subleveldown?label=&logo=codecov&logoColor=fff)](https://codecov.io/gh/Level/subleveldown)\n[![Standard](https://img.shields.io/badge/standard-informational?logo=javascript&logoColor=fff)](https://standardjs.com)\n[![Common Changelog](https://common-changelog.org/badge.svg)](https://common-changelog.org)\n[![Donate](https://img.shields.io/badge/donate-orange?logo=open-collective&logoColor=fff)](https://opencollective.com/level)\n\n## Table of Contents\n\n<details><summary>Click to expand</summary>\n\n- [Usage](#usage)\n- [Background](#background)\n- [API](#api)\n  - [`subdb = sub(db[, prefix][, options])`](#subdb--subdb-prefix-options)\n- [Install](#install)\n- [Contributing](#contributing)\n- [Donate](#donate)\n- [License](#license)\n\n</details>\n\n## Usage\n\n_If you are upgrading: please see [UPGRADING.md](UPGRADING.md)._\n\n```js\nconst sub = require('subleveldown')\nconst level = require('level')\n\nconst db = level('db')\nconst example = sub(db, 'example')\nconst nested = sub(example, 'nested')\n```\n\nThe `example` and `nested` db's are just regular [`levelup`][levelup] instances:\n\n```js\nexample.put('hello', 'world', function () {\n  nested.put('hi', 'welt', function () {\n    // Prints { key: 'hi', value: 'welt' }\n    nested.createReadStream().on('data', console.log)\n  })\n})\n```\n\nOr with promises and iterators:\n\n```js\nawait example.put('hello', 'world')\nawait nested.put('hi', 'welt')\n\nfor await (const [key, value] of nested.iterator()) {\n  // Prints ['hi', 'welt']\n  console.log([key, value])\n}\n```\n\nSublevels see their own keys as well as keys of any nested sublevels:\n\n```js\n// Prints:\n// { key: '!nested!hi', value: 'welt' }\n// { key: 'hello', value: 'world' }\nexample.createReadStream().on('data', console.log)\n```\n\nThey also support `db.clear()` which is very useful to empty a bucket of stuff:\n\n```js\nexample.clear(function (err) {})\n\n// Or delete a range within `example`\nexample.clear({ gt: 'hello' }, function (err) {})\n\n// With promises\nawait example.clear()\n```\n\n## Background\n\n`subleveldown` separates a [`levelup`][levelup] database into sections - or _sublevels_ from here on out. Think SQL tables, but evented, ranged and realtime!\n\nEach sublevel is a `levelup` of its own. This means it has the exact same interface as its parent database, but its own keyspace and [events](https://github.com/Level/levelup#events). In addition, sublevels are individually wrapped with [`encoding-down`][encoding-down], giving us per-sublevel encodings. For example, it's possible to have one sublevel with Buffer keys and another with `'utf8'` encoded keys. The same goes for values. Like so:\n\n```js\nsub(db, 'one', { valueEncoding: 'json' })\nsub(db, 'two', { keyEncoding: 'binary' })\n```\n\nThere is one limitation, however: keys must _encode to_ either strings or Buffers. This is not likely to affect you, unless you use custom encodings or the `id` encoding (which bypasses encodings and thus makes it your responsibility to ensure keys are either strings or Buffers). If in that case you do pass in a key that is not a string or Buffer, it will be irreversibly converted to a string.\n\nAuthored by [@mafintosh](https://github.com/mafintosh) and inspired by [`level-sublevel`][level-sublevel] by [@dominictarr](https://github.com/dominictarr), `subleveldown` has become an official part of [Level][level-org]. As `level-sublevel` is no longer under active development, we recommend switching to `subleveldown` to get the latest and greatest of the Level ecosystem. These two modules largely offer the same functionality, except for [hooks](https://github.com/dominictarr/level-sublevel#hooks) and [per-batch prefixes](https://github.com/dominictarr/level-sublevel#batches).\n\n## API\n\n### `subdb = sub(db[, prefix][, options])`\n\nReturns a `levelup` instance that uses subleveldown to prefix the keys of the underlying store of `db`. The required `db` parameter must be a `levelup` instance. Any layers that this instance may have (like `encoding-down` or `subleveldown` itself) are peeled off to get to the innermost [`abstract-leveldown`][abstract-leveldown] compliant store (like `leveldown`). This ensures there is no double encoding step.\n\nThe `prefix` must be a string. If omitted, the effective prefix is two separators, e.g. `'!!'`. If `db` is already a subleveldown-powered instance, the effective prefix is a combined prefix, e.g. `'!one!!two!'`.\n\nThe optional `options` parameter has the following `subleveldown` specific properties:\n\n- `separator` _(string, default: `'!'`)_ Character for separating sublevel prefixes from user keys and each other. Must sort before characters used in prefixes. An error will be thrown if that's not the case.\n- `open` _(function)_ Optional open hook called when the underlying `levelup` instance has been opened. The hook receives a callback which must be called to finish opening.\n\nAny other `options` are passed along to the underlying [`levelup`][levelup] and [`encoding-down`][encoding-down] constructors. See their documentation for further details.\n\n## Install\n\nWith [npm](https://npmjs.org) do:\n\n```\nnpm i subleveldown -S\n```\n\n## Contributing\n\n[`Level/subleveldown`](https://github.com/Level/subleveldown) 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\nSupport us with a monthly donation on [Open Collective](https://opencollective.com/level) and help us continue our work.\n\n## License\n\n[MIT](LICENSE)\n\n[level-badge]: https://leveljs.org/img/badge.svg\n\n[levelup]: https://github.com/Level/levelup\n\n[encoding-down]: https://github.com/Level/encoding-down\n\n[abstract-leveldown]: https://github.com/Level/abstract-leveldown\n\n[level-sublevel]: https://github.com/dominictarr/level-sublevel\n\n[level-org]: https://github.com/Level\n","publish_time":1586119300857,"deprecated":"Superseded by abstract-level (https://github.com/Level/community#faq)","_cnpm_publish_time":1586119300857,"dist-tags":{"latest":"6.0.1"}}