Ninja Pirate Marksman

    level-promisify

    2.0.1 • Public • Published

    Level-promisify

    Leveldb with promises

    Skinny wrapper around leveldb that adds promises instead of callbacks.

    Getting Started

    Installation

    npm i -S level-promisify

    The constructor takes one argument, the leveldb instance to use.

    var level = require( 'level' )( path );
    var db = require( 'level-promisify' )( level );
     
    db.put( 'foo', 'bar' )
      .then( function() {
        db.get( 'foo' )
          .then( function( res ) {
            console.log( res ); // 'bar'
          })
      })
      .catch( function( err ) {
        console.log( err );
      });

    API

    • put
    • get
    • del
    • batch Array form

    The API doesn’t change, you just handle the responses using promises.

    If you want access to the underlying database then it’s exposed via db.root, for example, if you pass it a db using the hooks plugin then that’s still available:

    var level = require( 'level' )( path );
    var hookdb = require( 'level-hooks' )( db );
    var db = require( 'level-promisify' )( hookdb );
     
    db.root.hooks.pre( … );

    License

    ISC

    Install

    npm i level-promisify

    DownloadsWeekly Downloads

    1

    Version

    2.0.1

    License

    ISC

    Last publish

    Collaborators

    • mattstyles