| 577 | } |
| 578 | |
| 579 | #actualWriteBuffer() { |
| 580 | this.#writing = true; |
| 581 | this.#writingBuf = this.#writingBuf.length ? this.#writingBuf : mergeBuf(this.#bufs.shift(), this.#lens.shift()); |
| 582 | |
| 583 | if (this.#sync) { |
| 584 | try { |
| 585 | const written = this.#fs.writeSync(this.#fd, this.#writingBuf); |
| 586 | this.#release(null, written); |
| 587 | } catch (err) { |
| 588 | this.#release(err); |
| 589 | } |
| 590 | } else { |
| 591 | // fs.write will need to copy string to buffer anyway so |
| 592 | // we do it here to avoid the overhead of calculating the buffer size |
| 593 | // in releaseWritingBuf. |
| 594 | this.#writingBuf = Buffer.from(this.#writingBuf); |
| 595 | this.#fs.write(this.#fd, this.#writingBuf, (...args) => this.#release(...args)); |
| 596 | } |
| 597 | } |
| 598 | |
| 599 | #actualWriteUtf8() { |
| 600 | this.#writing = true; |