simple kv store for streams
Latest commit fd4b64f Mar 14, 2013 @dominictarr 1.1.1
Failed to load latest commit information.
test test that can handle / Oct 25, 2012
.gitignore initial May 20, 2012
client.js add localStorage based implementation for client Jun 12, 2012
endpoints-client.js remove \n from client endpoint Nov 13, 2012
endpoints.js use pause-stream instead of gate Oct 24, 2012
index.js add localStorage based implementation for client Jun 12, 2012
package.json 1.1.1 Mar 14, 2013
redis.js Include kv-redis Dec 17, 2012



super simple key-value store, intended for keeping appendable files.

works on the server, with files or redis and in the browser with localStorage.

on the server, it keeps the files in prefixed subdirectories, so that the directories do not get too large.

(see ls .git/objects/* for a similar example)


create an instance

kv(path/prefix/connectString, setup)

path is where to create/connect to the store.

setup is optional. setup is passed the stream created by put and get, may replace the stream passed to put/get by default, the stream is handled as newline seperated json.

var kv = require('kv')('/tmp/kv')
var kv = require('kv/redis')('redis://password@localhost:6379/prefix')
var kv = require('kv')('kv:') //this will be prefixed to keys when saving in localStorage.

put a stream

opts is optional. see fs.createWriteStream

stream.pipe(kv.put(key, opts))

kv.createWriteStream is a synonym for kv.put

get a stream

opts is optional. see fs.createReadStream

kv.get(key, opts).pipe(stream) 

kv.createReadStream is a synonym for kv.get

del a stream

kv.del(key, callback)

list of keys



check if db has a key

  kv.has(key, function (err, stat) {
    //return the stat of the stream, if it exists.


to handle other types of streams than newline separated json, pass in a stream setup function to kv.

var rawKV = require('kv')(dir, function (stream, key) {
  return stream //just use raw streams, do not parse!


there is also a cli tool!

npm install kv -g

echo hello | kv put hello --base /tmp/kv
kv get hello --base /tmp/k