0.1.1 • Published 11 years ago

shade v0.1.1

Weekly downloads
17
License
-
Repository
-
Last release
11 years ago

shade

A file system data store using SHA1 keys

Build Status

example

save

var shade = require('shade');

shade('/tmp/mydata', function (err, db) {
    db.save('ChBZvReWjm5YcTXTMK1GZausXZaCn', function (err, key) {
        console.log(key) // ecef0937
    })
});

load

var shade = require('shade');

shade('/tmp/mydata', function (err, db) {
    db.load('ecef0937', function (err, data) {
        if (!err) {
            console.log(data); // ChBZvReWjm5YcTXTMK1GZausXZaCn
        }
    })
});

methods

shade(dir, cb)

Creates a new data store rooted in the specified directory. cb(err, db) is called with either an error or a handle to the data store.

db.save(s, cb)

Saves a string s into the data store. cb(err, key) is called with wither an error or the 8-character key that can be used to retireve the data from the load method.

db.load(key, cb)

Loads a string from the data store using the specified key. cb(err, data) is called with either an error or the previously saved string.

install

Using npm:

npm install shade

license

MIT