native-level-promise
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

Native Level Promise

A proper, Class-based, Promisified, Node 8 Native wrapper around level.

Installation

npm i native-level-promise

Usage

Most native Level features should work the same in promisified versions. Here are a few examples:

const Level = require('native-level-promise');
 
db = new Level('./data/mydb');
 
db.put("test", "thing").then(() => console.log("Value inserted"));
 
db.del(key).then(() => console.log("Value deleted"));

Note that streams remain the same:

const stream = db.keyStream();
stream.on('data', (key) => {
  this.db.get(key, (err, value) => {
    if (err) console.log(err);
    // do something with value.
  });
});
stream.on('end', () => {
  console.log("Key Stream has ended");
});

And finally

db.close().then(() => {
  console.log("DB has been closed!");
});

I feel I don't need to say this all works with async/await but I'll say it anyway because... because.

Package Sidebar

Install

npm i native-level-promise

Weekly Downloads

9

Version

0.0.5

License

MIT

Unpacked Size

12.8 kB

Total Files

8

Last publish

Collaborators

  • eslachance