{"id":13760895,"url":"https://github.com/Level/memory-level","last_synced_at":"2025-05-10T11:32:11.803Z","repository":{"id":40570933,"uuid":"453500968","full_name":"Level/memory-level","owner":"Level","description":"In-memory abstract-level database for Node.js and browsers.","archived":false,"fork":false,"pushed_at":"2024-10-21T22:28:08.000Z","size":244,"stargazers_count":28,"open_issues_count":2,"forks_count":4,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-10-30T00:00:37.333Z","etag":null,"topics":["abstract-level","database","javascript","level","memory"],"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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"open_collective":"level"}},"created_at":"2022-01-29T19:43:03.000Z","updated_at":"2024-10-21T22:28:12.000Z","dependencies_parsed_at":"2024-11-06T07:23:35.063Z","dependency_job_id":"0ac75a16-37a5-4594-8dd0-39dd437a7c8a","html_url":"https://github.com/Level/memory-level","commit_stats":{"total_commits":322,"total_committers":25,"mean_commits":12.88,"dds":0.5962732919254659,"last_synced_commit":"f3eecfeb2dff7855d3fc618c38b94da75599ea7f"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Level%2Fmemory-level","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Level%2Fmemory-level/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Level%2Fmemory-level/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Level%2Fmemory-level/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Level","download_url":"https://codeload.github.com/Level/memory-level/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224627702,"owners_count":17343224,"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-level","database","javascript","level","memory"],"created_at":"2024-08-03T13:01:25.940Z","updated_at":"2025-05-10T11:32:11.790Z","avatar_url":"https://github.com/Level.png","language":"JavaScript","funding_links":["https://opencollective.com/level"],"categories":["JavaScript"],"sub_categories":[],"readme":"# memory-level\n\n**In-memory [`abstract-level`][abstract-level] database for Node.js and browsers, backed by a [fully persistent red-black tree](https://www.npmjs.com/package/functional-red-black-tree).** The successor to [`memdown`](https://github.com/Level/memdown) and [`level-mem`](https://github.com/Level/mem).\n\n\u003e :pushpin: Wondering what happened to `levelup`? Visit [Frequently Asked Questions](https://github.com/Level/community#faq).\n\n[![level badge][level-badge]](https://github.com/Level/awesome)\n[![npm](https://img.shields.io/npm/v/memory-level.svg)](https://www.npmjs.com/package/memory-level)\n[![Node version](https://img.shields.io/node/v/memory-level.svg)](https://www.npmjs.com/package/memory-level)\n[![Test](https://img.shields.io/github/actions/workflow/status/Level/memory-level/test.yml?branch=main\\\u0026label=test)](https://github.com/Level/memory-level/actions/workflows/test.yml)\n[![Coverage](https://img.shields.io/codecov/c/github/Level/memory-level?label=\u0026logo=codecov\u0026logoColor=fff)](https://codecov.io/gh/Level/memory-level)\n[![Standard](https://img.shields.io/badge/standard-informational?logo=javascript\u0026logoColor=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\u0026logoColor=fff)](https://opencollective.com/level)\n\n## Usage\n\n_If you are upgrading: please see [`UPGRADING.md`](./UPGRADING.md)._\n\n```js\nconst { MemoryLevel } = require('memory-level')\n\n// Create a database\nconst db = new MemoryLevel({ 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 `memory-level` follows that of [`abstract-level`](https://github.com/Level/abstract-level) with one additional constructor option (see below). The `createIfMissing` and `errorIfExists` options of `abstract-level` are not relevant here. Both implicit and explicit snapshots are supported. Data is discarded when the last reference to the database is released (i.e. `db = null`). Closing or reopening the database has no effect on the data. Data is _not_ copied: when storing a Buffer value for example, subsequent mutations to that Buffer will affect the stored data too.\n\n### `db = new MemoryLevel([options])`\n\nBesides `abstract-level` options, the optional `options` object may contain:\n\n- `storeEncoding` (string): one of `'buffer'`, `'view'`, `'utf8'`. How to store data internally. This affects which data types can be stored non-destructively. The default is `'buffer'` (that means Buffer) which is non-destructive. In browsers it may be preferable to use `'view'` (Uint8Array) to be able to exclude the [`buffer`](https://github.com/feross/buffer) shim. Or if there's no need to store binary data, then `'utf8'` (String). Regardless of the `storeEncoding`, `memory-level` supports input that is of any of the aforementioned types, but internally converts it to one type in order to provide a consistent sort order.\n\n## Install\n\nWith [npm](https://npmjs.org) do:\n\n```\nnpm install memory-level\n```\n\n## Contributing\n\n[`Level/memory-level`](https://github.com/Level/memory-level) 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## License\n\n[MIT](LICENSE)\n\n[abstract-level]: https://github.com/Level/abstract-level\n\n[level-badge]: https://leveljs.org/img/badge.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLevel%2Fmemory-level","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLevel%2Fmemory-level","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLevel%2Fmemory-level/lists"}