Socket
Socket
Sign inDemoInstall

levelup

Package Overview
Dependencies
Maintainers
3
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

levelup

Fast & simple storage - a Node.js-style LevelDB wrapper


Version published
Weekly downloads
344K
decreased by-45.89%
Maintainers
3
Weekly downloads
 
Created

What is levelup?

LevelUP is a Node.js library that provides a simple interface for interacting with LevelDB, a fast key-value storage library. It allows for efficient storage and retrieval of data, making it suitable for applications that require high-performance data operations.

What are levelup's main functionalities?

Basic Put and Get

This feature allows you to store and retrieve key-value pairs in the database. The `put` method is used to store a value with a specific key, and the `get` method is used to retrieve the value associated with a key.

const level = require('level');
const db = level('./mydb');

// Put a key-value pair
await db.put('name', 'LevelUP');

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

Batch Operations

Batch operations allow you to perform multiple put and delete operations in a single atomic action. This is useful for making multiple changes to the database efficiently.

const level = require('level');
const db = level('./mydb');

// Perform batch operations
await db.batch()
  .put('name', 'LevelUP')
  .put('type', 'database')
  .del('oldKey')
  .write();

Streams

Streams provide a way to read and write data in a continuous flow. The `createReadStream` method allows you to read all key-value pairs in the database as a stream, which is useful for processing large datasets.

const level = require('level');
const db = level('./mydb');

// Create a read stream
const stream = db.createReadStream();

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

Sublevel

Sublevel allows you to create isolated sub-databases within a LevelDB instance. This is useful for organizing data into different namespaces.

const level = require('level');
const sublevel = require('subleveldown');
const db = level('./mydb');
const subdb = sublevel(db, 'sub');

// Put and get in sublevel
await subdb.put('name', 'SubLevelUP');
const value = await subdb.get('name');
console.log(value); // 'SubLevelUP'

Other packages similar to levelup

Keywords

FAQs

Package last updated on 26 Jul 2017

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc