Modify a level(up) datastore to treat a null "put" as a "del"


See https://github.com/rvagg/node-levelup/issues/191.

A small patch to a levelup database object, so that you can use a single put style interface for additions, modifications, and deletions.

var levelup = require('levelup');
var nulldel = require('level-nulldel');
var db = levelup('./mydb');
db.put('somekey', 'foo', function (err) {...});  // unaffected 
db.put('somekey', null, function (err) {...});   // stores null as value 
nulldel(db);  // monkey-patches this db object 
db.put('somekey', 'bar', function (err) {...});  // unaffected, changes to bar 
db.put('somekey', null, function (err) {...});   // deletes somekey 

It unifies "change" requests, just as access requests all use get. This can simplify your code, and everything built on top of it.

Note that this prevents storing null as value with JSON encoding (undefined was already a no-no). For simple string encodings you can still use '' (the empty string) as value to represent emptiness.

This module was suggested by Rod Vagg, levelup's author, in a brief discussion on github, issue #191.