| 2553 | * Streaming UTF-8 encoding |
| 2554 | */ |
| 2555 | export class EncodeUTF8 { |
| 2556 | private d: boolean; |
| 2557 | /** |
| 2558 | * Creates a UTF-8 decoding stream |
| 2559 | * @param cb The callback to call whenever data is encoded |
| 2560 | */ |
| 2561 | constructor(cb?: FlateStreamHandler) { |
| 2562 | this.ondata = cb; |
| 2563 | } |
| 2564 | |
| 2565 | /** |
| 2566 | * Pushes a chunk to be encoded to UTF-8 |
| 2567 | * @param chunk The string data to push |
| 2568 | * @param final Whether this is the last chunk |
| 2569 | */ |
| 2570 | push(chunk: string, final?: boolean) { |
| 2571 | if (!this.ondata) err(5); |
| 2572 | if (this.d) err(4); |
| 2573 | this.ondata(strToU8(chunk), (this.d = final || false)); |
| 2574 | } |
| 2575 | |
| 2576 | /** |
| 2577 | * The handler to call whenever data is available |
| 2578 | */ |
| 2579 | ondata: FlateStreamHandler; |
| 2580 | } |
| 2581 | |
| 2582 | /** |
| 2583 | * Converts a string into a Uint8Array for use with compression/decompression methods |
nothing calls this directly
no outgoing calls
no test coverage detected