Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

In-memory abstract-level database for Node.js and browsers.

License

NotificationsYou must be signed in to change notification settings

Level/memory-level

Repository files navigation

In-memoryabstract-level database for Node.js and browsers, backed by afully persistent red-black tree. The successor tomemdown andlevel-mem.

📌 Wondering what happened tolevelup? VisitFrequently Asked Questions.

level badgenpmNode versionTestCoverageStandardCommon ChangelogDonate

Usage

If you are upgrading: please seeUPGRADING.md.

const{ MemoryLevel}=require('memory-level')// Create a databaseconstdb=newMemoryLevel({valueEncoding:'json'})// Add an entry with key 'a' and value 1awaitdb.put('a',1)// Add multiple entriesawaitdb.batch([{type:'put',key:'b',value:2}])// Get value of key 'a': 1constvalue=awaitdb.get('a')// Iterate entries with keys that are greater than 'a'forawait(const[key,value]ofdb.iterator({gt:'a'})){console.log(value)// 2}

API

The API ofmemory-level follows that ofabstract-level with one additional constructor option (see below). ThecreateIfMissing anderrorIfExists options ofabstract-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 isnot copied: when storing a Buffer value for example, subsequent mutations to that Buffer will affect the stored data too.

db = new MemoryLevel([options])

Besidesabstract-level options, the optionaloptions object may contain:

  • 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 thebuffer shim. Or if there's no need to store binary data, then'utf8' (String). Regardless of thestoreEncoding,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.

Install

Withnpm do:

npm install memory-level

Contributing

Level/memory-level is anOPEN Open Source Project. This means that:

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.

See theContribution Guide for more details.

License

MIT


[8]ページ先頭

©2009-2025 Movatter.jp