Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Store.prototype.createWriteStream = function (key, opts) {
if (!opts) opts = {};
var index = this._getIndex(opts.index, key);
var input = through(function (chunk) {
this.queue({
key: index.newKey(),
value: chunk
});
}).pause();
var ws = new WriteStream(opts, this.db);
var dpl = duplexer(input, ws);
input.pipe(ws);
if (typeof opts.capped != 'undefined') {
var capped = cap(this.db, key, opts.capped);
ws.on('end', capped.end.bind(capped));
}
if (opts.append) {
if (index.initialize) index.initialize(ready);
else ready();
} else {
this.reset(key, ready);
}