How to use the dirty.Dirty function in dirty

To help you get started, we’ve selected a few dirty examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DaVarga / slingxdcc / lib / cleandb.js View on Github external
var cleanDirty = function (dbfile, cb){
    var dirty = require("dirty");
    var fs = require('fs');

    var db = dirty.Dirty(dbfile);
    var cleandb = dirty.Dirty(dbfile + ".tmp");

    db.once("load", function (length){
        db.forEach(function (key, val){
            if (typeof val !== "undefined"){
                cleandb.set(key, val);
            }
        });
        cleandb.once("drain", function (){
            delete db;
            delete cleandb;
            fs.unlink(dbfile, function (){
                fs.rename(dbfile + ".tmp", dbfile, cb);
            });
            delete fs;
        });
github DaVarga / slingxdcc / lib / cleandb.js View on Github external
var cleanDirty = function (dbfile, cb){
    var dirty = require("dirty");
    var fs = require('fs');

    var db = dirty.Dirty(dbfile);
    var cleandb = dirty.Dirty(dbfile + ".tmp");

    db.once("load", function (length){
        db.forEach(function (key, val){
            if (typeof val !== "undefined"){
                cleandb.set(key, val);
            }
        });
        cleandb.once("drain", function (){
            delete db;
            delete cleandb;
            fs.unlink(dbfile, function (){
                fs.rename(dbfile + ".tmp", dbfile, cb);
            });
            delete fs;
        });
    });

dirty

A tiny & fast key value store with append-only disk log. Ideal for apps with < 1 million records.

MIT
Latest version published 3 years ago

Package Health Score

54 / 100
Full package analysis

Popular dirty functions