Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
A tiny & fast key value store with append-only disk log. Ideal for apps with < 1 million records.
A tiny & fast key value store with append-only disk log. Ideal for apps with < 1 million records.
npm install dirty
This module is called dirty because:
forEach
through all recordsSo dirty means that you will hit a very hard wall with this database after ~1 million records, but it is a wonderful solution for anything smaller than that.
var Dirty = require('dirty');
var db = new Dirty('user.db');
db.on('load', function() {
db.set('john', {eyes: 'blue'});
console.log('Added john, he has %s eyes.', db.get('john').eyes);
db.set('bob', {eyes: 'brown'}, function() {
console.log('User bob is now saved on disk.')
});
db.forEach(function(key, val) {
console.log('Found key: %s, val: %j', key, val);
});
});
db.on('drain', function() {
console.log('All records are saved on disk now.');
});
Output:
Added john, he has blue eyes.
Found key: john, val: {"eyes":"blue"}
Found key: bob, val: {"eyes":"brown"}
User bob is now saved on disk.
All records are saved on disk now.
Creates a new dirty database. If path
does not exist yet, it is created. You
can also omit the path
if you don't want disk persistence (useful for testing).
The path of the dirty database.
Set's the given key
/ val
pair. The state of the database is affected instantly,
the optional cb
callback is fired when the record was written to disk.
val
can be any JSON-serializable type, it does not have to be an object.
Retrieves the value for the given key
.
Removes the record with the given key
. This is identical to setting the key
's value
to undefined
.
Updates the record of the given key
with the given updater
which is a function
that is passed the current value of the key.
The optional cb
callback is passed to dirty.set
.
Calls the given fn
function for every document in the database. The passed
arguments are key
and val
. You can return false
to abort a query (useful
if you are only interested in a limited number of records).
This function is blocking and runs at ~4 Mhz.
Close the dirty db file handle.
Emitted once the database file has finished loading. It is not safe to access records before this event fires. Writing records however should be fine.
length
is the amount of records the database is holding. This only counts each
key once, even if it had been overwritten.
You can chain the on load to the contructor as follows:
var db = dirty(file).on('load', function() { ... });
Emitted whenever all records have been written to disk.
Emitted once the database file read stream closed.
Emitted once the database file write stream closed.
Dirty utilizes the Mocha test framework.
git clone https://github.com/felixge/node-dirty
cd node-dirty
npm install
npm test
node-dirty is licensed under the MIT license.
FAQs
A tiny & fast key value store with append-only disk log. Ideal for apps with < 1 million records.
The npm package dirty receives a total of 4,389 weekly downloads. As such, dirty popularity was classified as popular.
We found that dirty demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.