{"bugs":{"url":"https://github.com/Level/level-js/issues"},"dist":{"shasum":"fa51527fa38b87c4d111b0d0334de47fcda38f21","tarball":"https://registry.npmjs.org/level-js/-/level-js-4.0.2.tgz","fileCount":13,"integrity":"sha512-PeGjZsyMG4O89KHiez1zoMJxStnkM+oBIqgACjoo5PJqFiSUUm3GNod/KcbqN5ktyZa8jkG7I1T0P2u6HN9lIg==","signatures":[{"sig":"MEUCIQDtIwz3ctc8Yms+dLQUWY0Co9L2e4mim39bT6GlXwW9IgIgJwhuvYN2A8sOQSN4opMsiNNrwzYWJVLMi7f+Kv0HE+A=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":64400,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJd4RZNCRA9TVsSAnZWagAA0/YP/iqj7/Z4Vz+T+IlI7WE4\nP5S4UX8HoMi0q3chi21RmFaV18/qeq2rmmdviLQ6gsGZDrv2IpJ5ajHKD0kf\nWiH99h08SLpjMQv+XyxA7yV8JvTXCKBFTRQ7Tp2JPW3u8Ivv02sZncicY+Oo\ncnIBOML6xcRZqo0jOji0luBFc1GoDA+FmmXuw8i9vYl8dQH/iaR047GquNCb\nINbyOiMbCpKQ4OmgTvZ/lROocBZASGLZW7reHL+YtlVLTQrEc965lE3/4Whj\nkpKpHCY3xxcfRLRv8a3w7yxe8Ab1fcDXJAmgQ/WIfgwsjWzbjiygTWJqZO5p\nYQhlYl2NMJttNlzGk7PSpha6+NxJOKq3vTerJu/AMmDFsGho+SRtSASOcZbx\nSUTPncbhMNXr771glB2yVBJLbimiRVG1Ldy+7HcW6RHNiZbEtPEVf/RB4gDi\n74DFWDPf2sIpiJ2rdcP+052fSg6XIxhxkVNVeSryjTqvttn7lJPxapynQ3XO\nPCnbcc8qZWaDd8QhlLTl3Z5YnG6JnthnjNxCYNKS6oFM9tw9waoECHvwWe17\nHoQcbGP/joGJnwxFXH50l+0FvrWWxHrNfQMhrP9YP5hczJWMZhE61pbvcMQ3\ntbJqRGXCvXYIeqXHtJfEeHj1REjwsLldJ1TRExdu3c9rmW5dP3Vb5K3vifsM\nhQHG\r\n=HO6L\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","name":"level-js","author":{"name":"max ogden"},"readme":"# level-js\n\n> An [`abstract-leveldown`][abstract-leveldown] compliant store on top of [IndexedDB][indexeddb], which is in turn implemented on top of [LevelDB][leveldb] which brings this whole shebang full circle.\n\n[![level badge][level-badge]][awesome]\n[![npm](https://img.shields.io/npm/v/level-js.svg?label=&logo=npm)](https://www.npmjs.com/package/level-js)\n[![Travis](https://img.shields.io/travis/Level/level-js.svg?logo=travis&label=)](https://travis-ci.org/Level/level-js)\n[![npm](https://img.shields.io/npm/dm/level-js.svg?label=dl)](https://www.npmjs.com/package/level-js)\n[![Coverage Status](https://coveralls.io/repos/github/Level/level-js/badge.svg)](https://coveralls.io/github/Level/level-js)\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## Table of Contents\n\n<details><summary>Click to expand</summary>\n\n- [Background](#background)\n- [Example](#example)\n- [Browser Support](#browser-support)\n- [Type Support](#type-support)\n- [Install](#install)\n- [API](#api)\n- [Running Tests](#running-tests)\n- [Big Thanks](#big-thanks)\n- [Contributing](#contributing)\n- [Donate](#donate)\n- [License](#license)\n\n</details>\n\n## Background\n\nHere are the goals of `level-js`:\n\n- Store large amounts of data in modern browsers\n- Pass the full [`abstract-leveldown`][abstract-leveldown] test suite\n- Support [`Buffer`][buffer] keys and values\n- Support all key types of IndexedDB Second Edition\n- Support all value types of the [structured clone algorithm][structured-clone-algorithm] except for `null` and `undefined`\n- Be as fast as possible\n- Sync with [multilevel](https://github.com/juliangruber/multilevel) over ASCII or binary transports.\n\nBeing `abstract-leveldown` compliant means you can use many of the [Level modules][awesome] on top of this library. For some demos of it working, see [**@brycebaril**](https://github.com/brycebaril)'s presentation [Path of the NodeBases Jedi](http://brycebaril.github.io/nodebase_jedi/#/vanilla).\n\n## Example\n\n**If you are upgrading:** please see [UPGRADING.md](UPGRADING.md).\n\n```js\nvar levelup = require('levelup')\nvar leveljs = require('level-js')\nvar db = levelup(leveljs('bigdata'))\n\ndb.put('hello', Buffer.from('world'), function (err) {\n  if (err) throw err\n\n  db.get('hello', function (err, value) {\n    if (err) throw err\n\n    console.log(value.toString()) // 'world'\n  })\n})\n```\n\nIn ES6 browsers:\n\n```js\nconst levelup = require('levelup')\nconst leveljs = require('level-js')\nconst db = levelup(leveljs('bigdata'))\n\nawait db.put('hello', Buffer.from('world'))\nconst value = await db.get('hello')\n```\n\n## Browser Support\n\n[![Sauce Test Status](https://saucelabs.com/browser-matrix/level-js.svg)](https://saucelabs.com/u/level-js)\n\n## Type Support\n\nUnlike [`leveldown`][leveldown], `level-js` does not stringify keys or values. This means that in addition to strings and Buffers you can store almost any JavaScript type without the need for [`encoding-down`][encoding-down].\n\n### Values\n\nAll value types of the [structured clone algorithm][structured-clone-algorithm] are supported except for `null` and `undefined`. Depending on the environment, this includes:\n\n- Number, including `NaN`, `Infinity` and `-Infinity`\n- String, Boolean, Date, RegExp, Array, Object\n- ArrayBuffer or a view thereof (typed arrays);\n- Map, Set, Blob, File, FileList, ImageData (limited support).\n\nIn addition `level-js` stores [`Buffer`][buffer] values without transformation. This works in all target environments because `Buffer` is a subclass of `Uint8Array`, meaning such values can be passed to `IndexedDB` as-is.\n\nWhen getting or iterating binary values, regardless of whether they were stored as a `Buffer`, `ArrayBuffer` or a view thereof, values will return as a `Buffer`. This behavior can be disabled, in which case `ArrayBuffer` returns as `ArrayBuffer`, typed arrays return as typed arrays and `Buffer` returns as `Uint8Array`:\n\n```js\ndb.get('key', { asBuffer: false })\ndb.iterator({ valueAsBuffer: false })\n```\n\nIf the environment does not support a type, it will throw an error which `level-js` catches and passes to the callbacks of `put` or `batch`. For example, IE does not support typed array values. At the time of writing, Chrome is the only browser that supports all types listed above.\n\n### Keys\n\nAll key types of IndexedDB Second Edition are supported. Depending on the environment, this includes:\n\n- Number, including `Infinity` and `-Infinity`, but not `NaN`\n- Date, except invalid (`NaN`)\n- String\n- ArrayBuffer or a view thereof (typed arrays);\n- Array, except cyclical, empty and sparse arrays. Elements must be valid types themselves.\n\nIn addition you can use [`Buffer`][buffer] keys, giving `level-js` the same power as implementations like `leveldown` and `memdown`. When iterating binary keys, regardless of whether they were stored as `Buffer`, `ArrayBuffer` or a view thereof, keys will return as a `Buffer`. This behavior can be disabled, in which case binary keys will always return as `ArrayBuffer`:\n\n```js\ndb.iterator({ keyAsBuffer: false })\n```\n\nNote that this behavior is slightly different from values due to the way that IndexedDB works. IndexedDB stores binary _values_ using the structured clone algorithm, which preserves views, but it stores binary _keys_ as an array of octets, so that it is able to compare and sort differently typed keys.\n\nIf the environment does not support a type, it will throw an error which `level-js` catches and passes to the callbacks of `get`, `put`, `del`, `batch` or an iterator. Exceptions are:\n\n- `null` and `undefined`: rejected early by `abstract-leveldown`\n- Binary and array keys: if not supported by the environment, `level-js` falls back to `String(key)`.\n\n### Normalization\n\nIf you desire normalization for keys and values (e.g. to stringify numbers), wrap `level-js` with [`encoding-down`][encoding-down]. Alternatively install [`level-browserify`][level-browserify] which conveniently bundles [`levelup`][levelup], `level-js` and `encoding-down`. Such an approach is also recommended if you want to achieve universal (isomorphic) behavior or to smooth over type differences between browsers. For example, you could have [`leveldown`][leveldown] in a backend and `level-js` in the frontend.\n\nAnother reason you might want to use `encoding-down` is that the structured clone algorithm, while rich in types, can be slower than `JSON.stringify`.\n\n### Sort Order\n\nUnless `level-js` is wrapped with [`encoding-down`][encoding-down], IndexedDB will sort your keys in the following order:\n\n1. number (numeric)\n2. date (numeric, by epoch offset)\n3. binary (bitwise)\n4. string (lexicographic)\n5. array (componentwise).\n\nYou can take advantage of this fact with `levelup` streams. For example, if your keys are dates, you can select everything greater than a specific date (let's be happy and ignore timezones for a moment):\n\n```js\nconst db = levelup(leveljs('time-db'))\n\ndb.createReadStream({ gt: new Date('2019-01-01') })\n  .pipe(..)\n```\n\nOr if your keys are arrays, you can do things like:\n\n```js\nconst db = levelup(leveljs('books-db'))\n\nawait db.put(['Roald Dahl', 'Charlie and the Chocolate Factory'], {})\nawait db.put(['Roald Dahl', 'Fantastic Mr Fox'], {})\n\n// Select all books by Roald Dahl\ndb.createReadStream({ gt: ['Roald Dahl'], lt: ['Roald Dahl', '\\xff'] })\n  .pipe(..)\n```\n\nTo achieve this on other `abstract-leveldown` implementations, wrap them with [`encoding-down`][encoding-down] and [`charwise`][charwise] (or similar).\n\n#### Known Browser Issues\n\nIE11 and Edge yield incorrect results for `{ gte: '' }` if the database contains any key types other than strings.\n\n### Buffer vs ArrayBuffer\n\nFor interoperability it is recommended to use `Buffer` as your binary type. While we recognize that Node.js core modules are moving towards supporting `ArrayBuffer` and views thereof, `Buffer` remains the primary binary type in the Level ecosystem.\n\nThat said: if you want to `put()` an `ArrayBuffer` you can! Just know that it will come back as a `Buffer` by default. If you want to `get()` or iterate stored `ArrayBuffer` data as an `ArrayBuffer`, you have a few options. Without `encoding-down`:\n\n```js\nconst db = levelup(leveljs('mydb'))\n\n// Yields an ArrayBuffer, Buffer and ArrayBuffer\nconst value1 = await db.get('key', { asBuffer: false })\nconst value2 = await db.get('key')\nconst value3 = value2.buffer\n```\n\nWith `encoding-down` (or `level-browserify`) you can use the `id` encoding to selectively bypass encodings:\n\n```js\nconst encode = require('encoding-down')\nconst db = levelup(encode(leveljs('mydb'), { valueEncoding: 'binary' }))\n\n// Yields an ArrayBuffer, Buffer and ArrayBuffer\nconst value1 = await db.get('key', { valueEncoding: 'id' })\nconst value2 = await db.get('key')\nconst value3 = value2.buffer\n```\n\n## Install\n\nWith [npm](https://npmjs.org) do:\n\n```bash\nnpm install level-js\n```\n\nNot to be confused with [leveljs](https://www.npmjs.com/package/leveljs).\n\nThis library is best used with [browserify](http://browserify.org).\n\n## API\n\n### `db = leveljs(location[, options])`\n\nReturns a new `leveljs` instance. `location` is the string name of the [`IDBDatabase`](https://developer.mozilla.org/en-US/docs/Web/API/IDBDatabase) to be opened, as well as the object store within that database. The database name will be prefixed with `options.prefix`.\n\n#### `options`\n\nThe optional `options` argument may contain:\n\n- `prefix` _(string, default: `'level-js-'`)_: Prefix for `IDBDatabase` name.\n- `version` _(string | number, default: `1`)_: The version to open the database with.\n\nSee [`IDBFactory#open`](https://developer.mozilla.org/en-US/docs/Web/API/IDBFactory/open) for more details.\n\n## Running Tests\n\n```sh\ngit clone git@github.com:Level/level-js.git\ncd level-js\nnpm install\nnpm test\n```\n\nIt will print out a URL to open in a browser of choice.\n\n## Big Thanks\n\nCross-browser Testing Platform and Open Source ♥ Provided by [Sauce Labs](https://saucelabs.com).\n\n[![Sauce Labs logo](./sauce-labs.svg)](https://saucelabs.com)\n\n## Contributing\n\n[`Level/level-js`](https://github.com/Level/level-js) 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), [npm](https://www.npmjs.com/) packages and (soon) [our website](http://leveldb.org). 💖\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 [Max Ogden](https://github.com/maxogden) and [Contributors](CONTRIBUTORS.md).\n\n[level-badge]: http://leveldb.org/img/badge.svg\n\n[indexeddb]: https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API\n\n[leveldb]: https://github.com/google/leveldb\n\n[buffer]: https://nodejs.org/api/buffer.html\n\n[awesome]: https://github.com/Level/awesome\n\n[abstract-leveldown]: https://github.com/Level/abstract-leveldown\n\n[charwise]: https://github.com/dominictarr/charwise\n\n[levelup]: https://github.com/Level/levelup\n\n[leveldown]: https://github.com/Level/leveldown\n\n[level-browserify]: https://github.com/Level/level-browserify\n\n[encoding-down]: https://github.com/Level/encoding-down\n\n[structured-clone-algorithm]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm\n","browser":{"./util/immediate.js":"./util/immediate-browser.js"},"gitHead":"d3ba9c29d9ec39c5b98f5ea77191d498b7418a0b","license":"MIT","scripts":{"test":"standard && hallmark && airtap --local --coverage test/index.js","coverage":"nyc report --reporter=text-lcov | coveralls","hallmark":"hallmark --fix","test-browsers":"standard && airtap --sauce-connect --loopback airtap.local --coverage test/index.js","prepublishOnly":"npm run dependency-check","dependency-check":"dependency-check . test/*.js"},"_npmUser":{"name":"vweevers","email":"dev@vincentweevers.nl"},"hallmark":{"community":"level-community"},"homepage":"https://github.com/Level/level-js","keywords":["level","leveldb","indexeddb","abstract-leveldown"],"deprecated":"Superseded by browser-level (https://github.com/Level/community#faq)","repository":{"url":"git+https://github.com/Level/level-js.git","type":"git"},"_npmVersion":"6.11.3","description":"An abstract-leveldown compliant store on top of IndexedDB","directories":{},"maintainers":[{"name":"matteo.collina","email":"hello@matteocollina.com"},{"name":"ralphtheninja","email":"ralphtheninja@riseup.net"},{"name":"vweevers","email":"dev@vincentweevers.nl"}],"_nodeVersion":"12.11.1","dependencies":{"ltgt":"^2.1.2","inherits":"^2.0.3","immediate":"~3.2.3","abstract-leveldown":"~6.0.1","typedarray-to-buffer":"~3.1.5"},"publishConfig":{"tag":"latest-4"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"nyc":"^13.1.0","tape":"^4.0.0","uuid":"^3.3.2","airtap":"^2.0.0","hallmark":"^0.1.0","standard":"^12.0.1","coveralls":"^3.0.2","level-community":"^3.0.0","dependency-check":"^3.3.0","level-concat-iterator":"^2.0.0"},"_npmOperationalInternal":{"tmp":"tmp/level-js_4.0.2_1575032396779_0.27703162732648634","host":"s3://npm-registry-packages"},"_id":"level-js@4.0.2","version":"4.0.2"}