/**
 * Minified by jsDelivr using Terser v5.37.0.
 * Original file: /npm/level-ws@4.0.0/level-ws.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";const Writable=require("readable-stream").Writable;class WriteStream extends Writable{constructor(t,s){super({objectMode:!0,highWaterMark:(s=Object.assign({type:"put"},s)).highWaterMark||16,autoDestroy:!0,emitClose:!0}),this._options=s,this._db=t,this._buffer=[],this._flushing=!1,this._maxBufferLength=s.maxBufferLength||1/0,this._flush=this._flush.bind(this)}_write(t,s,e){this.destroyed||(this._flushing||(this._flushing=!0,process.nextTick(this._flush)),this._buffer.length>=this._maxBufferLength?this.once("_flush",(i=>{if(i)return this.destroy(i);this._write(t,s,e)})):(this._buffer.push(Object.assign({type:this._options.type},t)),e()))}_flush(){const t=this._buffer;this.destroyed||(this._buffer=[],this._db.batch(t,(t=>{this._flushing=!1,!this.emit("_flush",t)&&t&&this.destroy(t)})))}_final(t){this._flushing?this.once("_flush",(s=>{if(s)return t(s);this._final(t)})):this._buffer&&this._buffer.length?(this.once("_flush",t),this._flush()):t()}_destroy(t,s){this._buffer=null,s(t)}}module.exports=WriteStream;
//# sourceMappingURL=/sm/436cb1957b120a527ba7052147c14800bab1c8bf1e20f6e0b1031ecfdd887dca.map