| 4682 | if (this._bufferOffset = 0, this._didUserInput) return this._didUserInput = false, this._pendingData += e3.length, this._writeBuffer.push(e3), this._callbacks.push(t3), void this._innerWrite(); |
| 4683 | setTimeout((() => this._innerWrite())); |
| 4684 | } |
| 4685 | this._pendingData += e3.length, this._writeBuffer.push(e3), this._callbacks.push(t3); |
| 4686 | } |
| 4687 | _innerWrite(e3 = 0, t3 = true) { |
| 4688 | const i3 = e3 || Date.now(); |
| 4689 | for (; this._writeBuffer.length > this._bufferOffset; ) { |
| 4690 | const e4 = this._writeBuffer[this._bufferOffset], s3 = this._action(e4, t3); |
| 4691 | if (s3) { |
| 4692 | const e5 = (e6) => Date.now() - i3 >= 12 ? setTimeout((() => this._innerWrite(0, e6))) : this._innerWrite(i3, e6); |
| 4693 | return void s3.catch(((e6) => (queueMicrotask((() => { |
| 4694 | throw e6; |
| 4695 | })), Promise.resolve(false)))).then(e5); |
| 4696 | } |
| 4697 | const r2 = this._callbacks[this._bufferOffset]; |
| 4698 | if (r2 && r2(), this._bufferOffset++, this._pendingData -= e4.length, Date.now() - i3 >= 12) break; |
| 4699 | } |
| 4700 | this._writeBuffer.length > this._bufferOffset ? (this._bufferOffset > 50 && (this._writeBuffer = this._writeBuffer.slice(this._bufferOffset), this._callbacks = this._callbacks.slice(this._bufferOffset), this._bufferOffset = 0), setTimeout((() => this._innerWrite()))) : (this._writeBuffer.length = 0, this._callbacks.length = 0, this._pendingData = 0, this._bufferOffset = 0), this._onWriteParsed.fire(); |
| 4701 | } |