Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
deferred-leveldown
Advanced tools
The deferred-leveldown npm package is a wrapper for LevelDOWN that defers operations until the underlying store is ready. This is particularly useful for scenarios where you need to queue operations while waiting for the database to be initialized or opened.
Deferred Operations
This feature allows you to queue operations like 'put' and 'get' until the underlying LevelDOWN store is ready. The operations will be executed once the store is initialized.
const levelup = require('levelup');
const leveldown = require('leveldown');
const deferredLeveldown = require('deferred-leveldown');
const db = levelup(deferredLeveldown(leveldown('./mydb')));
db.put('key', 'value', (err) => {
if (err) return console.error('Error:', err);
console.log('Put operation completed');
});
db.get('key', (err, value) => {
if (err) return console.error('Error:', err);
console.log('Got value:', value);
});
Error Handling
This feature demonstrates how deferred-leveldown handles errors. If an operation fails, the error is passed to the callback, allowing you to handle it appropriately.
const levelup = require('levelup');
const leveldown = require('leveldown');
const deferredLeveldown = require('deferred-leveldown');
const db = levelup(deferredLeveldown(leveldown('./mydb')));
db.put('key', 'value', (err) => {
if (err) return console.error('Error:', err);
console.log('Put operation completed');
});
db.get('nonexistentKey', (err, value) => {
if (err) return console.error('Error:', err);
console.log('Got value:', value);
});
LevelUP is a higher-level module for working with LevelDB, providing a more user-friendly API. Unlike deferred-leveldown, LevelUP does not defer operations but can be used in conjunction with deferred-leveldown to achieve similar functionality.
SublevelDOWN is a package that provides namespaced sublevels for LevelDB. It allows you to create isolated sub-databases within a LevelDB instance. While it does not defer operations, it can be used alongside deferred-leveldown for more complex database structures.
MemDOWN is an in-memory backend for LevelUP, useful for testing and temporary data storage. It does not provide deferred operations but can be used as a fast, in-memory alternative to LevelDOWN.
A mock LevelDOWN implementation that queues operations while a real LevelDOWN instance is being opened.
DeferredLevelDOWN implements the basic AbstractLevelDOWN API so it can be used as a drop-in replacement where LevelDOWN is needed.
put()
, get()
, del()
and batch()
operations are all queued and kept in memory until a new LevelDOWN-compatible object can be supplied.
The setDb(db)
method is used to supply a new LevelDOWN object. Once received, all queued operations are replayed against that object, in order.
batch()
operations will all be replayed as the array form. Chained-batch operations are converted before being stored.
DeferredLevelDOWN 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 CONTRIBUTING.md file for more details.
DeferredLevelDOWN is only possible due to the excellent work of the following contributors:
Rod Vagg | GitHub/rvagg | Twitter/@rvagg |
---|---|---|
John Chesley | GitHub/chesles | Twitter/@chesles |
Jake Verbaten | GitHub/raynos | Twitter/@raynos2 |
Dominic Tarr | GitHub/dominictarr | Twitter/@dominictarr |
Max Ogden | GitHub/maxogden | Twitter/@maxogden |
Lars-Magnus Skog | GitHub/ralphtheninja | Twitter/@ralphtheninja |
David Björklund | GitHub/kesla | Twitter/@david_bjorklund |
Julian Gruber | GitHub/juliangruber | Twitter/@juliangruber |
Paolo Fragomeni | GitHub/hij1nx | Twitter/@hij1nx |
Anton Whalley | GitHub/No9 | Twitter/@antonwhalley |
Matteo Collina | GitHub/mcollina | Twitter/@matteocollina |
Pedro Teixeira | GitHub/pgte | Twitter/@pgte |
James Halliday | GitHub/substack | Twitter/@substack |
Copyright (c) 2013-2015 DeferredLevelDOWN contributors (listed above).
DeferredLevelDOWN is licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details.
[0.3.0] - 2015-04-16
MIT
license (@andrewrk)FAQs
A mock abstract-leveldown implementation that queues operations while a real abstract-leveldown instance is being opened
The npm package deferred-leveldown receives a total of 583,265 weekly downloads. As such, deferred-leveldown popularity was classified as popular.
We found that deferred-leveldown demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.