Socket
Socket
Sign inDemoInstall

abstract-level

Package Overview
Dependencies
Maintainers
1
Versions
6
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


Version published
Weekly downloads
144K
increased by8.28%
Maintainers
1
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 20 Mar 2022

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