MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / inflate

Function inflate

tests/modules/data/zlib/deflateinflate.js:81–111  ·  view source on GitHub ↗
(data, options)

Source from the content-addressed store, hash-verified

79}
80
81function inflate(data, options) {
82 const inflate = new Inflate(options);
83 const chunkSize = options.chunkSize;
84 if (undefined === chunkSize)
85 inflate.push(data, true);
86 else if ((data.byteLength / chunkSize) <= 8) {
87 for (let offset = 0; offset < data.byteLength; offset += chunkSize) {
88 const use = Math.min(chunkSize, data.byteLength - offset);
89 const last = (offset + chunkSize) >= data.byteLength;
90 inflate.push(data.slice(offset, offset + use), last);
91 }
92 }
93 else { // combine partial chunks to minimize heap
94 inflate.result = new Uint8Array(options.expected);
95 let position = 0;
96 inflate.onData = function(chunk) {
97 this.result.set(new Uint8Array(chunk), position);
98 position += chunk.byteLength;
99 }
100 inflate.onEnd = function() {
101 }
102
103 for (let offset = 0; offset < data.byteLength; offset += chunkSize) {
104 const use = Math.min(chunkSize, data.byteLength - offset);
105 const last = (offset + chunkSize) >= data.byteLength;
106 inflate.push(data.slice(offset, offset + use), last);
107 }
108 }
109 inflate.close();
110 return inflate.result;
111}

Callers 3

xs_inflate_pushFunction · 0.85
xs_PNG_readFunction · 0.85
testInflateFunction · 0.85

Calls 4

pushMethod · 0.95
closeMethod · 0.95
sliceMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected