Ende.Inflater
class
class Ende.InflaterInflates one compressed stream, synchronously, from chunks of input.
Unlike DecompressionStream, an Inflater stops at the end of the
stream and reports how many bytes of each chunk it used, so the stream
can be followed by other data, as entries are in a git pack file.
const stream = Ende.deflateSync(new TextEncoder().encode("hello"));
const input = new Uint8Array([...stream, 1, 2, 3]);
const { consumed, data, done } = new Ende.Inflater().push(input);
console.log(new TextDecoder().decode(data)); // "hello"
console.log(done); // true
console.log(input.subarray(consumed)); // Uint8Array(3) [ 1, 2, 3 ]
Constructors
constructor
new Inflater(options?: { format?: ZlibFormat; maxOutputBytes?: number })Creates an inflater for one stream.
options?: { format?: ZlibFormat; maxOutputBytes?: number }
Methods
push
push(chunk: AllowSharedBufferSource): { consumed: number; data: Uint8Array<ArrayBuffer>; done: boolean }Inflates chunk, the next part of the stream.
Inflates ONE stream; bytes after its end are not consumed. Once the stream has ended, further pushes consume nothing and return no data.
Throws a TypeError if the data is not a valid stream (including a
checksum that doesn't match), after which the inflater is unusable.
Returns
consumed, how many bytes of chunk were used; data, the
bytes inflated from them; and done, whether the stream has ended.
Until it has, consumed is the whole chunk.