2.0.1 • Published 9 years ago

level-promisify v2.0.1

Weekly downloads
12
License
ISC
Repository
github
Last release
9 years ago

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

2.0.1

9 years ago

2.0.0

9 years ago

2.0.0-rc

9 years ago

1.0.0

9 years ago

0.3.0

9 years ago

0.2.0

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago