{"library":"memory-level","title":"Memory-Level Database","description":"memory-level is an in-memory database implementation that adheres to the `abstract-level` API specification, designed for both Node.js and browser environments. It is currently at version 3.1.0 and is actively maintained, with releases often coinciding with upgrades to its underlying `abstract-level` interface. This package serves as the modern successor to earlier in-memory Level implementations like `memdown` and `level-mem`. A key differentiator is its backing by a fully persistent red-black tree, providing reliable in-memory data storage that supports implicit and explicit snapshots. Unlike disk-backed databases, closing or reopening a `memory-level` instance does not affect its stored data, which is only discarded when all references to the database are released. It offers flexible `storeEncoding` options to optimize for Buffer, Uint8Array, or UTF8 string storage, impacting how data types are handled internally for consistency and performance.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install memory-level"],"cli":null},"imports":["import { MemoryLevel } from 'memory-level'","const { MemoryLevel } = require('memory-level')","import type { MemoryLevelOptions } from 'memory-level'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { MemoryLevel } from 'memory-level'\n\nasync function runDbExample() {\n  // Create a database with JSON value encoding\n  const db = new MemoryLevel({ valueEncoding: 'json' })\n\n  // Add an entry with key 'a' and value 1\n  await db.put('a', 1)\n\n  // Add multiple entries using a batch operation\n  await db.batch([{ type: 'put', key: 'b', value: 2 }])\n\n  // Get value of key 'a': 1\n  const valueA = await db.get('a')\n  console.log('Value of key \"a\":', valueA) // Expected: 1\n\n  // Iterate entries with keys that are greater than 'a'\n  console.log('Entries greater than \"a\":')\n  for await (const [key, value] of db.iterator({ gt: 'a' })) {\n    console.log('Key:', key, 'Value:', value) // Expected: Key: b Value: 2\n  }\n\n  // Clean up resources (optional for in-memory, but good practice)\n  await db.close()\n}\n\nrunDbExample().catch(console.error);","lang":"typescript","description":"Demonstrates initializing an in-memory `MemoryLevel` database, performing basic `put`, `batch`, `get`, and `iterator` operations, and closing the database.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}