var stream = require('stream');
var util = require('util');

function GetKeyOfValue (db, getopts) {
    if (!this instanceof GetKeyOfValue) {
        return new GetKeyOfValue(db, getopts);
    }
    stream.Transform.call(this, {objectMode: true});

    this.db = db;
    this.getopts = getopts;
}

util.inherits(GetKeyOfValue, stream.Transform);

(function () {

    this._transform = function (chunk, e, next) {
        this.db.get(chunk.value, this.getopts, function (err, value) {
            chunk.key = chunk.value;
            chunk.value = value;
            this.push(chunk);
            next();
        }.bind(this));
    };

}).call(GetKeyOfValue.prototype);

module.exports = {
    createPrefixReadStream: function (db, prefix, opts) {
        opts = opts || {};
        opts.start = opts.end = prefix;
        if (opts.reverse) {
            opts.start += '~';
        } else {
            opts.end += '~';
        }
        return db.createReadStream(opts);
    },

    GetKeyOfValue: GetKeyOfValue,
};

@@ -663,16 +663,323 @@
 type);%0A%0A
+//==================%0A%0Afunction OnEach(onEach) %7B%0A    this.onEach = onEach;%0A    stream.Writable.call(this, %7BobjectMode: true%7D);%0A%7D%0A%0Autil.inherits(OnEach, stream.Writable);%0A%0A(function () %7B%0A    this._write = function (chunk, encoding, next) %7B%0A        this.onEach(chunk, next);%0A    %7D;%0A%7D).call(OnEach.prototype);%0A%0A
 module.e
@@ -1313,11 +1313,31 @@
 fValue,%0A
+    OnEach: OnEach,%0A
 %7D;%0A

add OnEach