(buf)
| 40 | } |
| 41 | } |
| 42 | write(buf) { |
| 43 | if (typeof buf === "string") return buf; |
| 44 | const u8 = buf instanceof Uint8Array |
| 45 | ? buf : new Uint8Array(buf.buffer ?? buf); |
| 46 | if (this.__td) return this.__td.decode(u8, { stream: true }); |
| 47 | let bytes = u8; |
| 48 | if (this.__rem !== undefined) { |
| 49 | const joined = this.__rem |
| 50 | ? Buffer.concat([this.__rem, u8]) : Buffer.from(u8); |
| 51 | const keep = joined.length % 3; |
| 52 | this.__rem = keep ? joined.slice(joined.length - keep) : null; |
| 53 | bytes = joined.slice(0, joined.length - keep); |
| 54 | } |
| 55 | return Buffer.from( |
| 56 | bytes.buffer, bytes.byteOffset, bytes.byteLength, |
| 57 | ).toString(this.encoding); |
| 58 | } |
| 59 | end(buf) { |
| 60 | let out = buf !== undefined && buf.length ? this.write(buf) : ""; |
| 61 | if (this.__td) out += this.__td.decode(); |
no test coverage detected