Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise((resolve) => {
if (!db.createWriteStream) {
db = levelws(db);
}
this
// @ts-ignore FIXME, we need to properly check the full file
.createScratchReadStream(scratch)
// @ts-ignore FIXME, we need to properly check the full file
.pipe(
// @ts-ignore FIXME, we need to properly check the full file
db.createWriteStream(encoder.options)
)
.on('close', resolve);
});
})
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);
}