{"name":"subleveldown","version":"3.0.1","description":"sublevels implemented using leveldowns","main":"index.js","dependencies":{"abstract-leveldown":"^5.0.0","encoding-down":"^5.0.3","inherits":"^2.0.3","level-option-wrap":"^1.1.0","levelup":"^3.0.1"},"devDependencies":{"coveralls":"^3.0.2","memdown":"^3.0.0","nyc":"^12.0.2","standard":"^11.0.1","tape":"^4.9.0"},"repository":{"type":"git","url":"git+https://github.com/level/subleveldown.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/level/subleveldown/issues"},"homepage":"https://github.com/level/subleveldown","directories":{"test":"test"},"scripts":{"test":"standard && nyc node test","coverage":"nyc report --reporter=text-lcov | coveralls"},"engines":{"node":">=6"},"gitHead":"f0b5646bde3da53a466cd3da93f2d0526e275e42","_id":"subleveldown@3.0.1","_npmVersion":"6.2.0","_nodeVersion":"10.7.0","_npmUser":{"name":"ralphtheninja","email":"ralphtheninja@riseup.net"},"dist":{"integrity":"sha512-d5As5Wo9ghmbEVS81WanpzazAASDaVwETtbEWJV+O95/tipDQ0fl1NOSaEu+0tqL5Lk6YeyGimRLSn7mbYdXMw==","shasum":"b29514755c25e2faeeba9874110d868718bbedb1","tarball":"http://registry-npm.ywwl.com/subleveldown/download/subleveldown-3.0.1.tgz","fileCount":11,"unpackedSize":25628,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbWy6gCRA9TVsSAnZWagAAiK0P/0spjEWy29cTKfEw7Tsg\nyOcIYJZHneptaZ3d8KZ4gL23SSDQeHXjDW2i7yQ+HB9IppkD9QPqQe2AEzkq\nu7gOy7rHijEZpkvXAggyQY9kuLiNv2ASZHnsLEVbKc/JlcTSBA4ef8AVRi3U\nDIl6ADnTDuWTRfhAcNaP6U+8AfcJgoVnOoQYHglcGgQ/E83kTQlEo68zj5eN\nRTW2EuuEYZqIEUEuTzk8h3ci+Tzgz4d7udsb7wBPu79SXmi95kejl6DzPhwU\naQEEbhFG2mS0EtbzoKCW0pF0gaYEp10VESMa3t6mR75TNxxJ0NdkW+EPkva0\nhjRoaZJk73NHcUY5dvySovE4k7Hof0Q5BVauMA8dsezzkib3Q4Scd+Y13DuO\noktjc0MgZJCTQWKH0HwqX0I6jc4EwnTJd7HeZnkiYjnEFXKonWNCH7MRaJPo\nK8RfQey4NwV1hZxELCRnAVyLA1P5fFB5xAlq8KPRRxHWlM+nErdNlPiSmnH+\nlh4fFxV8iXKWnEbhw2fITTm9GohrequBWQi7ouurIExnlzVf94lq22SJLCzM\n5Ebu/ku3/uGTvcyz9RdbwtuEcfJBMHFKMa5r7vM9G4HTGjFVANQk5t7Jl7sg\nkX4/B/M481r7qToK6TulXd1sZZpvSOB6UECoMn0m9Lb4hAD2R7E2AHJ3QooZ\nVHGA\r\n=hvzm\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDgFf7d6xTtqEXChH15PRs/etDRXkqnTU4pnW17jYdj/AIhAMf6Cw4FSITQcnLGqFZjbu5n9Mj0XyEufQRXSjZP1OAb"}],"size":8033,"noattachment":false,"key":"/subleveldown/-/subleveldown-3.0.1.tgz"},"maintainers":[{"email":"julian@juliangruber.com","name":"juliangruber"},{"email":"mathiasbuus@gmail.com","name":"mafintosh"},{"email":"ralphtheninja@riseup.net","name":"ralphtheninja"},{"email":"dev@vincentweevers.nl","name":"vweevers"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/subleveldown_3.0.1_1532702368102_0.14045452224990385"},"_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":1532702368196,"deprecated":"Superseded by abstract-level (https://github.com/Level/community#faq)","_cnpm_publish_time":1532702368196,"dist-tags":{"latest":"6.0.1"}}