Nutty Peanut Marshmallow
Unleash awesomeness. Private packages, team management tools, and powerful integrations. Get started with npm Orgs »

This package has been deprecated

Author message:

Unsupported & Obsolete


0.0.4 • Public • Published


This is a simple key-value database, which secretly uses the filesystem for all storage.

To ensure that the user may use key-names which contain characters not permitted in filenames all keys are hashed, via SHA1, prior to being used on the filesystem. This behaviour can be disabled if you need to enumerate the keys which have previously been used.


You should be able to install this module by executing:

$ npm install fs_db

If that does not suit then you may clone the main repository, and load the module via the following:

require( "./fs_db" );


var DB = require( "fs_db" );

// Create a new store, writing data beneath /tmp.
var store = new DB( "/tmp" );

// This will write the value "kemp" to the key "steve".
store.set( "steve", "kemp" );

// This will return the value set previously.
store.get( "steve", function( error, value ) {
    console.log("Value is " + value );


As previously mentioned the files used on-disk will default to being based upon the SHA1 hash of the key-name.

If you leave this default behavior in-place then the original key-name is lost - so you cannot enumerate all the keys that have previously been used. If you trust all the key-names that will be used you can disable the default and use keys literally - providing that the key-names contain no characters which are disallowed in filenames.

The choice really becomes between :

  • Allowing keys such as "/../../etc/passwd", or "#&.:/\moi", via the use of hash of some kind.
  • Allowing keys to be bare/naked and enumerable, but accepting that not all key-names are valid.

To change the default option simply pass the no_hash parameter to the constructor:

var DB = require( "fs_db" );

// Default behavior - keys are hashed, so this writes the value "kemp" to
// the file /tmp/9ce5770b3bb4b2a1d59be2d97e34379cd192299f
var store = new DB( "/tmp" );
store.set( "steve", "kemp" );

// Disable the use of hashing, so this example writes "kemp" to the
// file /tmp/steve.
var store = new DB( "/tmp", { "no_hash": true } )
store.set( "steve", "kemp" )

This code was abstracted from the blogspam.js repository.


Please consider this licensed under the two-clause BSD license, included in the file LICENSE.



npm i fs_db

Downloadsweekly downloads









last publish


  • avatar
Report a vulnerability