MCPcopy
hub / github.com/baidu/amis / EncodeUTF8

Class EncodeUTF8

packages/office-viewer/src/util/fflate.ts:2555–2580  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2553 * Streaming UTF-8 encoding
2554 */
2555export 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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected