{"id":13555605,"url":"https://github.com/Level/level-js","last_synced_at":"2025-04-03T08:31:34.692Z","repository":{"id":8275002,"uuid":"9764166","full_name":"Level/level-js","owner":"Level","description":"An abstract-leveldown compliant store on top of IndexedDB.","archived":false,"fork":false,"pushed_at":"2023-06-01T09:57:51.000Z","size":281,"stargazers_count":543,"open_issues_count":1,"forks_count":44,"subscribers_count":16,"default_branch":"master","last_synced_at":"2024-10-30T00:00:36.257Z","etag":null,"topics":["abstract-leveldown","browser","indexeddb","level","levelup"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Level.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"open_collective":"level"}},"created_at":"2013-04-30T04:42:48.000Z","updated_at":"2024-10-19T05:44:02.000Z","dependencies_parsed_at":"2023-09-28T23:20:34.562Z","dependency_job_id":null,"html_url":"https://github.com/Level/level-js","commit_stats":{"total_commits":273,"total_committers":26,"mean_commits":10.5,"dds":0.4945054945054945,"last_synced_commit":"41358efc539e46ff06904098eeb7706f8033d770"},"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Level%2Flevel-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Level%2Flevel-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Level%2Flevel-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Level%2Flevel-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Level","download_url":"https://codeload.github.com/Level/level-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246877283,"owners_count":20848336,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["abstract-leveldown","browser","indexeddb","level","levelup"],"created_at":"2024-08-01T12:03:18.488Z","updated_at":"2025-04-03T08:31:34.672Z","avatar_url":"https://github.com/Level.png","language":"JavaScript","funding_links":["https://opencollective.com/level"],"categories":["JavaScript","others"],"sub_categories":[],"readme":"# level-js\n\n**Superseded by [`browser-level`](https://github.com/Level/browser-level). Please see [Frequently Asked Questions](https://github.com/Level/community#faq).**\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 string and [`Buffer`][buffer] keys and values\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.\n\n## Example\n\n**If you are upgrading:** please see [UPGRADING.md](UPGRADING.md).\n\n```js\nconst levelup = require('levelup')\nconst leveljs = require('level-js')\nconst 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\nWith `async/await`:\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## Type Support\n\nKeys and values can be a string or [`Buffer`][buffer]. Any other type will be irreversibly stringified. The only exceptions are `null` and `undefined`. Keys and values of that type are rejected.\n\nIn order to sort string and Buffer keys the same way, for compatibility with `leveldown` and the larger ecosystem, `level-js` internally converts keys and values to binary before passing them to IndexedDB.\n\nIf you desire non-destructive encoding (e.g. to store and retrieve numbers as-is), wrap `level-js` with [`encoding-down`][encoding-down]. Alternatively install [`level`][level] which conveniently bundles [`levelup`][levelup], `level-js` and `encoding-down`. Such an approach is also recommended if you want to achieve universal (isomorphic) behavior. For example, you could have [`leveldown`][leveldown] in a backend and `level-js` in the frontend. The `level` package does exactly that.\n\nWhen getting or iterating keys and values, regardless of the type with which they were stored, keys and values will return as a Buffer unless the `asBuffer`, `keyAsBuffer` or `valueAsBuffer` options are set, in which case strings are returned. Setting these options is not needed when `level-js` is wrapped with `encoding-down`, which determines the optimal return type by the chosen encoding.\n\n```js\ndb.get('key', { asBuffer: false })\ndb.iterator({ keyAsBuffer: false, valueAsBuffer: false })\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## 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\u003e 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[indexeddb]: https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API\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[levelup]: https://github.com/Level/levelup\n\n[leveldown]: https://github.com/Level/leveldown\n\n[level]: https://github.com/Level/level\n\n[encoding-down]: https://github.com/Level/encoding-down\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLevel%2Flevel-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLevel%2Flevel-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLevel%2Flevel-js/lists"}