npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

node-leveldb

v1.0.1

Published

Node.js bindings for LevelDB

Readme

node-leveldb

This package provides a simple, lightweight binding for LevelDB to Node.js. LevelDB is an implementation of a log-structured merge-tree that provides fast key-value storage and lookup.

Installation

$ npm install node-leveldb

Documentation

LevelDB

A LevelDB object is constructed and returned when you require('node-leveldb'). This object can be used for all operations on a single LevelDB database.

    var LevelDB = require('node-leveldb');

LevelDB.open(databasePath)

Before operating on a LevelDB object, you have to specify which database those operations apply to. If the specified database doesn't already exist, a new one will be created. If your process doesn't have the necessary permissions to create or open the database, this function will throw an exception.

    LevelDB.open('path/to/my/database');

LevelDB.close()

Closes the database opened by a previous successful call to LevelDB.open(...).

    LevelDB.close();

LevelDB.get(key)

Returns the value associated with key. If key doesn't exist in the database, this function returns null.

    console.log(LevelDB.get('myKey'));

LevelDB.set(key, value)

Inserts data into the database. If there isn't already a value for key in the database, this function creates a new entry and maps key to value. If key already exists, it replaces the old value with value.

    LevelDB.set('Ann Leckie', 'Ancillary Justice');

LevelDB.list([start], [end], callback)

Enumerates data stored in the database. This function takes two optional arguments, the start and end of the range of keys to enumerate. If start is not specified, it is assumed to be from the first item. If end is not specified, it is assumed to be until the last item. Both start and end are inclusive. It's not possible to specify end without first specifying start.

    LevelDB.list('a', 'z', function(key, value) {
        console.log('key: ' + key + ', value: ' + value);
    });

LevelDB.delete(key)

Removes data from the database. If key is found in the database, this function deletes the mapping from key to its value. This function returns true if key was found and a mapping was deleted, false otherwise.

    LevelDB.delete('Ann Leckie');

Example

    var LevelDB = require('node-leveldb');
    LevelDB.open('authors_database');

    LevelDB.set('Frank Herbert', 'Dune');
    LevelDB.set('Ursula K. Le Guin', 'The Left Hand of Darkness');
    LevelDB.set('Larry Niven', 'Ringworld');
    LevelDB.set('Isaac Asimov', 'The Gods Themselves');

    // Print the value associated with 'Frank Herbert'.
    console.log(LevelDB.get('Frank Herbert'));

    LeveLDB.delete('Frank Herbert');

    // Print all items stored in the database.
    LevelDB.list(function(key, value) {
        console.log(key + ': ' + value);
    });

    // Print all items with 'F' <= key <= 'T'.
    LevelDB.list('F', 'T', function(key, value) {
        console.log(key + ': ' + value);
    });

    LevelDB.close();

License

Apache 2.0