0.0.1 • Published 6 years ago

promisify-level v0.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

promisify-level

Wraps a leveldb instance's methods with util.promisify and allows you to choose which API you want to use. Bring your own leveldb instance.

installation

yarn add promisify-level

or

npm i --save promisify-level

Using node 8 which has util.promisify implemented. Should work with webpack and in the browser. Feel free to log issues

usage

const level = require('level');
const promisifyLevelDB = require('promisify-level');

async function main() {
  const db = level('./mydb');
  const promisifiedDB = promisifyLevelDB(db);

  try {

    await promisifiedDB.put('foo', 'bar');
    const value = await promisifiedDB.get('foo');
    console.error(value); // -> 'bar'

  } catch (err) {
    // handle errors here
  }
}

main();

license

MIT