{"_id":"browser-level","_rev":"4210327","name":"browser-level","description":"An abstract-level database for browsers, backed by IndexedDB","dist-tags":{"latest":"3.0.0"},"maintainers":[{"name":"vweevers","email":""}],"time":{"modified":"2026-03-04T17:05:22.000Z","created":"2022-03-05T15:19:42.260Z","3.0.0":"2025-04-20T15:50:43.709Z","2.0.0":"2024-12-01T13:42:30.522Z","1.0.1":"2022-03-06T13:44:06.800Z","1.0.0":"2022-03-05T15:19:42.260Z"},"users":{},"author":{"name":"max ogden"},"repository":{"type":"git","url":"git+https://github.com/Level/browser-level.git"},"versions":{"3.0.0":{"name":"browser-level","version":"3.0.0","description":"An abstract-level database for browsers, backed by IndexedDB","author":{"name":"max ogden"},"license":"MIT","main":"index.js","types":"./index.d.ts","scripts":{"test":"standard && hallmark && airtap --coverage test/index.js && nyc report","coverage":"nyc report -r lcovonly"},"dependencies":{"abstract-level":"^3.1.0"},"devDependencies":{"@babel/preset-env":"^7.26.9","@voxpelli/tsconfig":"^15.1.2","airtap":"^5.0.0","airtap-playwright":"^1.0.1","babelify":"^10.0.0","hallmark":"^5.0.1","nyc":"^17.1.0","standard":"^17.0.0","tape":"^5.5.2","typescript":"^5.8.3","uuid":"^11.1.0"},"repository":{"type":"git","url":"git+https://github.com/Level/browser-level.git"},"homepage":"https://github.com/Level/browser-level","keywords":["level","leveldb","indexeddb","abstract-level"],"_id":"browser-level@3.0.0","gitHead":"7ae3bae52ec48f2979b48516f2546863054dad89","bugs":{"url":"https://github.com/Level/browser-level/issues"},"_nodeVersion":"22.7.0","_npmVersion":"10.8.2","dist":{"shasum":"158287e21f44051cc06bf05abc235b385e66d264","size":11205,"noattachment":false,"key":"/browser-level/-/browser-level-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/browser-level/download/browser-level-3.0.0.tgz"},"_npmUser":{"name":"vweevers","email":"dev@vincentweevers.nl"},"directories":{},"maintainers":[{"name":"vweevers","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/browser-level_3.0.0_1745164243508_0.4800709787880444"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-04-20T15:50:43.709Z","publish_time":1745164243709,"_source_registry_name":"default","_cnpm_publish_time":1745164243709},"2.0.0":{"name":"browser-level","version":"2.0.0","description":"An abstract-level database for browsers, backed by IndexedDB","author":{"name":"max ogden"},"license":"MIT","main":"index.js","types":"./index.d.ts","scripts":{"test":"standard && hallmark && airtap --coverage test/index.js && nyc report","coverage":"nyc report -r lcovonly"},"dependencies":{"abstract-level":"^2.0.1"},"devDependencies":{"@voxpelli/tsconfig":"^4.0.0","airtap":"^5.0.0","airtap-playwright":"^1.0.1","hallmark":"^4.1.0","nyc":"^15.0.0","standard":"^17.0.0","tape":"^5.5.2","typescript":"^4.5.5","uuid":"^3.3.2"},"repository":{"type":"git","url":"git+https://github.com/Level/browser-level.git"},"homepage":"https://github.com/Level/browser-level","keywords":["level","leveldb","indexeddb","abstract-level"],"_id":"browser-level@2.0.0","gitHead":"07f0e65d468a377fcf516e2077712224df937c4c","bugs":{"url":"https://github.com/Level/browser-level/issues"},"_nodeVersion":"22.7.0","_npmVersion":"10.8.2","dist":{"shasum":"cc63eb1322e67c44489d7fbdda5c30a2db7b59da","size":10940,"noattachment":false,"key":"/browser-level/-/browser-level-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/browser-level/download/browser-level-2.0.0.tgz"},"_npmUser":{"name":"vweevers","email":"dev@vincentweevers.nl"},"directories":{},"maintainers":[{"name":"vweevers","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/browser-level_2.0.0_1733060550310_0.2282011038089964"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-12-01T13:42:30.522Z","publish_time":1733060550522,"_source_registry_name":"default","_cnpm_publish_time":1733060550522},"1.0.1":{"name":"browser-level","version":"1.0.1","description":"An abstract-level database for browsers, backed by IndexedDB","author":{"name":"max ogden"},"license":"MIT","main":"index.js","types":"./index.d.ts","scripts":{"test":"standard && ts-standard *.ts && hallmark && airtap -p local --coverage test/index.js && nyc report","test-browsers":"standard && airtap --coverage test/index.js","coverage":"nyc report -r lcovonly","dependency-check":"dependency-check --no-dev .","prepublishOnly":"npm run dependency-check"},"dependencies":{"abstract-level":"^1.0.2","catering":"^2.1.1","module-error":"^1.0.2","run-parallel-limit":"^1.1.0"},"devDependencies":{"@voxpelli/tsconfig":"^3.1.0","airtap":"^4.0.4","airtap-playwright":"^1.0.1","airtap-sauce":"^1.1.0","dependency-check":"^4.1.0","hallmark":"^4.1.0","nyc":"^15.0.0","standard":"^16.0.4","tape":"^5.5.2","ts-standard":"^11.0.0","typescript":"^4.5.5","uuid":"^3.3.2"},"repository":{"type":"git","url":"git+https://github.com/Level/browser-level.git"},"homepage":"https://github.com/Level/browser-level","keywords":["level","leveldb","indexeddb","abstract-level"],"gitHead":"5f7585e8cf025d9c9bb36da2425322130104bbb0","bugs":{"url":"https://github.com/Level/browser-level/issues"},"_id":"browser-level@1.0.1","_nodeVersion":"16.9.1","_npmVersion":"7.21.1","dist":{"shasum":"36e8c3183d0fe1c405239792faaab5f315871011","size":13385,"noattachment":false,"key":"/browser-level/-/browser-level-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/browser-level/download/browser-level-1.0.1.tgz"},"_npmUser":{"name":"vweevers","email":"dev@vincentweevers.nl"},"directories":{},"maintainers":[{"name":"vweevers","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/browser-level_1.0.1_1646574246707_0.16722342304360938"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-03-06T13:44:09.892Z","publish_time":1646574246800,"_cnpm_publish_time":1646574246800},"1.0.0":{"name":"browser-level","version":"1.0.0","description":"An abstract-level database for browsers, backed by IndexedDB","author":{"name":"max ogden"},"license":"MIT","main":"index.js","types":"./index.d.ts","scripts":{"test":"standard && ts-standard *.ts && hallmark && airtap -p local --coverage test/index.js && nyc report","test-browsers":"standard && airtap --coverage test/index.js","coverage":"nyc report -r lcovonly","dependency-check":"dependency-check --no-dev .","prepublishOnly":"npm run dependency-check"},"dependencies":{"abstract-level":"^1.0.1","catering":"^2.1.1","module-error":"^1.0.2","run-parallel-limit":"^1.1.0"},"devDependencies":{"@voxpelli/tsconfig":"^3.1.0","airtap":"^4.0.4","airtap-playwright":"^1.0.1","airtap-sauce":"^1.1.0","dependency-check":"^4.1.0","hallmark":"^4.1.0","nyc":"^15.0.0","standard":"^16.0.4","tape":"^5.5.2","ts-standard":"^11.0.0","typescript":"^4.5.5","uuid":"^3.3.2"},"repository":{"type":"git","url":"git+https://github.com/Level/browser-level.git"},"homepage":"https://github.com/Level/browser-level","keywords":["level","leveldb","indexeddb","abstract-level"],"gitHead":"3f8488003d93ed8cf4252e19b670ec2a3ff9ad79","bugs":{"url":"https://github.com/Level/browser-level/issues"},"_id":"browser-level@1.0.0","_nodeVersion":"16.9.1","_npmVersion":"7.21.1","dist":{"shasum":"585a854b1d566bd94999295762752852d6e4b6c3","size":12998,"noattachment":false,"key":"/browser-level/-/browser-level-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/browser-level/download/browser-level-1.0.0.tgz"},"_npmUser":{"name":"vweevers","email":"dev@vincentweevers.nl"},"directories":{},"maintainers":[{"name":"vweevers","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/browser-level_1.0.0_1646493582094_0.21036697169157614"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-03-05T15:19:45.313Z","publish_time":1646493582260,"_cnpm_publish_time":1646493582260}},"readme":"# browser-level\n\n**An [`abstract-level`][abstract-level] database for browsers, backed by [IndexedDB][indexeddb].** The successor to [`level-js`](https://github.com/Level/level-js). If you are upgrading, please see [UPGRADING.md](UPGRADING.md).\n\n> :pushpin: Which module should I use? What is `abstract-level`? Head over to the [FAQ](https://github.com/Level/community#faq).\n\n[![level badge][level-badge]][awesome]\n[![npm](https://img.shields.io/npm/v/browser-level.svg)](https://www.npmjs.com/package/browser-level)\n[![Test](https://img.shields.io/github/actions/workflow/status/Level/browser-level/test.yml?branch=main\\&label=test)](https://github.com/Level/browser-level/actions/workflows/test.yml)\n[![Coverage](https://img.shields.io/codecov/c/github/Level/browser-level?label=\\&logo=codecov\\&logoColor=fff)](https://codecov.io/gh/Level/browser-level)\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## Usage\n\n```js\nconst { BrowserLevel } = require('browser-level')\n\n// Create a database called 'example'\nconst db = new BrowserLevel('example', { valueEncoding: 'json' })\n\n// Add an entry with key 'a' and value 1\nawait db.put('a', 1)\n\n// Add multiple entries\nawait db.batch([{ type: 'put', key: 'b', value: 2 }])\n\n// Get value of key 'a': 1\nconst value = await db.get('a')\n\n// Iterate entries with keys that are greater than 'a'\nfor await (const [key, value] of db.iterator({ gt: 'a' })) {\n  console.log(value) // 2\n}\n```\n\n## API\n\nThe API of `browser-level` follows that of [`abstract-level`](https://github.com/Level/abstract-level) with just two additional constructor options (see below) and one additional method (see below). As such, the majority of the API is documented in `abstract-level`. The `db.getSync()` method is not supported here and neither are the `createIfMissing` and `errorIfExists` options.\n\nLike other implementations of `abstract-level`, `browser-level` has first-class support of binary keys and values, using either [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) or [Buffer](https://nodejs.org/api/buffer.html). In order to sort string and binary keys the same way as other databases, `browser-level` internally converts data to a Uint8Array before passing them to IndexedDB. If you have no need to work with `Buffer` keys or values, you can choose to omit the [`buffer`](https://github.com/feross/buffer) shim from a JavaScript bundle (through configuration of Webpack, Browserify or other bundlers).\n\nDue to limitations of IndexedDB, `browser-level` does not offer snapshot guarantees. Such a guarantee would mean that an iterator does not see the data of simultaneous writes - it would be reading from a snapshot in time. In contrast, a `browser-level` iterator reads a few entries ahead and then opens a new IndexedDB transaction on the next read. A \"few\" means all entries for `iterator.all()`, `size` amount of entries for `iterator.nextv(size)` and a hardcoded 100 entries for `iterator.next()`. Individual calls to those methods have snapshot guarantees but repeated calls do not.\n\nThe result is that an iterator will include the data of simultaneous writes, if `db.put()`, `db.del()` or `db.batch()` are called in between creating the iterator and consuming the iterator, or in between calls to `iterator.next()` or `iterator.nextv()`. For example:\n\n```js\nconst iterator = db.iterator()\nawait db.put('abc', '123')\n\nfor await (const [key, value] of iterator) {\n  // This might be 'abc'\n  console.log(key)\n}\n```\n\nIf snapshot guarantees are a must for your application then use `iterator.all()` and call it immediately after creating the iterator:\n\n```js\nconst entries = await db.iterator({ limit: 50 }).all()\n\n// Synchronously iterate the result\nfor (const [key, value] of entries) {\n  console.log(key)\n}\n```\n\n### `db = new BrowserLevel(location[, options])`\n\nCreate a new database or open an existing one. The required `location` argument is the string name of the [`IDBDatabase`](https://developer.mozilla.org/en-US/docs/Web/API/IDBDatabase) to be opened, as well as the name of the object store within that database. The name of the `IDBDatabase` will be prefixed with `options.prefix`.\n\nBesides `abstract-level` options, the optional `options` argument may contain:\n\n- `prefix` (string, default: `'level-js-'`): Prefix for the `IDBDatabase` name. Can be set to an empty string. The default is compatible with `level-js`.\n- `version` (string or number, default: `1`): The version to open the `IDBDatabase` with.\n\nSee [`IDBFactory#open()`](https://developer.mozilla.org/en-US/docs/Web/API/IDBFactory/open) for more details about database name and version.\n\n### `BrowserLevel.destroy(location[, prefix])`\n\nDelete the IndexedDB database at the given `location`. Returns a promise. If `prefix` is not given, it defaults to the same value as the `BrowserLevel` constructor does. This method is an additional method that is not part of the [`abstract-level`](https://github.com/Level/abstract-level) interface.\n\nBefore calling `destroy()`, close a database if it's using the same `location` and `prefix`:\n\n```js\nconst db = new BrowserLevel('example')\nawait db.close()\nawait BrowserLevel.destroy('example')\n```\n\n## Install\n\nWith [npm](https://npmjs.org) do:\n\n```bash\nnpm install browser-level\n```\n\nThis module is best used with [`browserify`](http://browserify.org) or similar bundlers.\n\n## Contributing\n\n[`Level/browser-level`](https://github.com/Level/browser-level) 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[indexeddb]: https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API\n\n[awesome]: https://github.com/Level/awesome\n\n[abstract-level]: https://github.com/Level/abstract-level\n","_attachments":{},"homepage":"https://github.com/Level/browser-level","bugs":{"url":"https://github.com/Level/browser-level/issues"},"license":"MIT"}