(text: string, encoding: string)
| 67 | } |
| 68 | |
| 69 | encode(text: string, encoding: string): Uint8Array { |
| 70 | if (encoding !== 'utf-8' && encoding !== 'utf8') { |
| 71 | throw new Error( |
| 72 | `Node built-in encoder only supports utf-8, but got ${encoding}`); |
| 73 | } |
| 74 | return this.textEncoder.encode(text); |
| 75 | } |
| 76 | decode(bytes: Uint8Array, encoding: string): string { |
| 77 | if (bytes.length === 0) { |
| 78 | return ''; |