| 836 | } |
| 837 | |
| 838 | #writeUtf8(data) { |
| 839 | if (this.#destroyed) { |
| 840 | throw new ERR_INVALID_STATE('Utf8Stream is destroyed'); |
| 841 | } |
| 842 | validateString(data, 'data'); |
| 843 | |
| 844 | const len = this.#len + data.length; |
| 845 | const bufs = this.#bufs; |
| 846 | |
| 847 | if (this.#maxLength && len > this.#maxLength) { |
| 848 | this.emit('drop', data); |
| 849 | return this.#len < this.#hwm; |
| 850 | } |
| 851 | |
| 852 | if ( |
| 853 | bufs.length === 0 || |
| 854 | bufs[bufs.length - 1].length + data.length > this.#maxWrite |
| 855 | ) { |
| 856 | ArrayPrototypePush(bufs, '' + data); |
| 857 | } else { |
| 858 | bufs[bufs.length - 1] += data; |
| 859 | } |
| 860 | |
| 861 | this.#len = len; |
| 862 | |
| 863 | if (!this.#writing && this.#len >= this.#minLength) { |
| 864 | this.#actualWrite(); |
| 865 | } |
| 866 | |
| 867 | return this.#len < this.#hwm; |
| 868 | } |
| 869 | } |
| 870 | |
| 871 | /** |