Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

abstract-level

Package Overview
Dependencies
Maintainers
0
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abstract-level

Abstract class for a lexicographically sorted key-value database

  • 2.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
150K
increased by15.85%
Maintainers
0
Weekly downloads
 
Created

What is abstract-level?

The abstract-level package is a high-level interface for creating and managing key-value stores. It provides a consistent API for various types of storage backends, making it easier to switch between different storage solutions without changing your application code.

What are abstract-level's main functionalities?

Basic CRUD Operations

This feature allows you to perform basic Create, Read, Update, and Delete (CRUD) operations on the key-value store.

const { Level } = require('abstract-level');
const db = new Level('my-db');

// Put a value
await db.put('key', 'value');

// Get a value
const value = await db.get('key');
console.log(value); // 'value'

// Delete a value
await db.del('key');

Batch Operations

Batch operations allow you to execute multiple operations in a single atomic action, which can improve performance and ensure consistency.

const { Level } = require('abstract-level');
const db = new Level('my-db');

await db.batch([
  { type: 'put', key: 'key1', value: 'value1' },
  { type: 'put', key: 'key2', value: 'value2' },
  { type: 'del', key: 'key3' }
]);

Streams

Streams provide a way to read data from the store in a continuous flow, which is useful for processing large datasets.

const { Level } = require('abstract-level');
const db = new Level('my-db');

const stream = db.createReadStream();

stream.on('data', ({ key, value }) => {
  console.log(key, value);
});

Custom Encoding

Custom encoding allows you to store and retrieve data in different formats, such as JSON, buffers, or custom encodings.

const { Level } = require('abstract-level');
const db = new Level('my-db', { valueEncoding: 'json' });

await db.put('key', { foo: 'bar' });
const value = await db.get('key');
console.log(value); // { foo: 'bar' }

Other packages similar to abstract-level

Keywords

FAQs

Package last updated on 09 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc