{"name":"subleveldown","version":"6.0.1","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","test-browsers-local":"airtap test/index.js","coverage":"nyc report -r lcovonly","hallmark":"hallmark --fix","dependency-check":"dependency-check --no-dev .","prepublishOnly":"npm run dependency-check"},"dependencies":{"abstract-leveldown":"^7.2.0","encoding-down":"^7.1.0","inherits":"^2.0.3","level-option-wrap":"^1.1.0","levelup":"^5.1.1","reachdown":"^1.1.0"},"devDependencies":{"after":"^0.8.2","airtap":"^4.0.3","airtap-playwright":"^1.0.1","dependency-check":"^4.1.0","faucet":"^0.0.1","hallmark":"^3.1.0","level-concat-iterator":"^3.0.0","memdown":"^6.1.0","nyc":"^15.1.0","standard":"^16.0.3","tape":"^5.0.1"},"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":">=10"},"gitHead":"214473341e7bbf0734eb5e2a1f6fdd721db2bc79","_id":"subleveldown@6.0.1","_nodeVersion":"16.9.1","_npmVersion":"7.21.1","dist":{"integrity":"sha512-Cnf+cn2wISXU2xflY1SFIqfX4hG2d6lFk2P5F8RDQLmiqN9Ir4ExNfUFH6xnmizMseM/t+nMsDUKjN9Kw6ShFA==","shasum":"6fce7a2339d6acd0b44fe9881190c14b61703835","tarball":"http://registry-npm.ywwl.com/subleveldown/download/subleveldown-6.0.1.tgz","fileCount":8,"unpackedSize":37823,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh28VTCRA9TVsSAnZWagAAYbsP/jSLwYDFytSrsJ2mR3SH\nMRjMwxiMx7cc+60p0+iz5XCF93aQPwdmbVFmzBBdrr4MhQxWbWOl6hIcNyOc\nvr1qPIptfkI/GCqjHFMwGeqUngVTbk8h1nW2JSUURB23e5ZEXcYZyVQEzVzr\nN0BvYT/SueG3WykGRtos9a3lU4Whu6PdE43DCQ+vr+LitDWcwwdBr0ECAISy\n8gXTWEwU70D587arnLRAWsYAqUhaKw6K0bgI94TkPor1vEjfClmpJG0Q+hjB\n86vbSrkEkFZ+9oSR3aabPmvh020znkWMUyCdT4eE4iko3wr5J9Qta2EwyfLs\nckNFihbteSj8/5yBRdPJS8a1IZt140u2dX5QM8hd10YpHXJ3ZhIX5d75i1JT\nBDaWkiULSUpRw4vyTKvrfScgQB+4KNcJIfZgXIImnXXY0kIpb2vuAPc+CAgn\nQBgq7FyIsOq9KAJpkKnbaOVUbsezjwnSCxwdGidRQBux5L+1yMI6BGFpgfo8\n6xOwHf4G4h/jrVhhksk37bdRj+RP6bEcNcIzsmOUi7Aj39f257e5IexB6kbr\n+xhT16ZQi/FK4aRtyxdzvZ5ew8ss1cZPSbkp8xrxWVnd0FcfyTs9EjCf1e2e\n4rhHcFbGkwvADB3pZ2ajPc0BmV45KZPxj/7gHcM29AFAq5aRbE4gmr/BTYST\nQiyG\r\n=QO2O\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGeKWK2Twf+IKyH193AEmtDeS5GoMUJSo7GTjxY94d7KAiBxhN/Xls5MKNSq+cPR7GEMJp0jt+Kjgd5c56bIddGb3w=="}],"size":10651,"noattachment":false,"key":"/subleveldown/-/subleveldown-6.0.1.tgz"},"_npmUser":{"name":"vweevers","email":"dev@vincentweevers.nl"},"directories":{},"maintainers":[{"name":"vweevers","email":"dev@vincentweevers.nl"},{"name":"mafintosh","email":"mathiasbuus@gmail.com"},{"name":"ralphtheninja","email":"ralphtheninja@riseup.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/subleveldown_6.0.1_1633169915550_0.7723007193935201"},"_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":1633169915698,"deprecated":"Superseded by abstract-level (https://github.com/Level/community#faq)","_cnpm_publish_time":1633169915698,"dist-tags":{"latest":"6.0.1"}}