Skip to content
This repository has been archived by the owner on Mar 31, 2019. It is now read-only.
/ lazy-open Public archive

This project has been abandoned.

License

Notifications You must be signed in to change notification settings

Level/lazy-open

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

level-lazy-open

This project has been abandoned. There will be no further releases. If you wish to revive level-lazy-open, please open an issue in Level/community to discuss a way forward. Thank you! ❤️


Lazily open a leveldown compatible backend.

NOTE: This doesn't work with levelup. This can only be useful to you if you're using leveldown directly.

JavaScript Style Guide Backers on Open Collective Sponsors on Open Collective

Example

var lazy = require('level-lazy-open');
var down = require('leveldown');

// a function that returns an open backend
function factory(cb){
  var db = down('./db');
  db.open(function(err){
    cb(err, db);
  });
}

var db = lazy(factory);

// db is closed and won't be opened, unless
// you do something with it:

db.put('foo', 'bar', function(err){
  // db is open now

  // you can manually close the db again:
  db.close(function(err){
    // the end
  });
});
// db is opening now

Installation

$ npm install level-lazy-open

API

lazy(factory)

Create a new abstract-leveldown compatible db that calls factory to get a db whenever it hasn't yet and you perform an operation against it.

Contributing

Level/lazy-open is an OPEN Open Source Project. This means that:

Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project.

See the Contribution Guide for more details.

Donate

To sustain Level and its activities, become a backer or sponsor on Open Collective. Your logo or avatar will be displayed on our 28+ GitHub repositories, npm packages and (soon) our website. 💖

Backers

Open Collective backers

Sponsors

Open Collective sponsors

License

MIT © 2012-present Contributors.