(data, options)
| 79 | } |
| 80 | |
| 81 | function 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 | } |
no test coverage detected