zlib-streams 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -72,7 +72,6 @@ function _make(isCompress, type, options = {}) {
72
72
  if (!this.out || !this.in) {
73
73
  throw new Error("allocation failed");
74
74
  }
75
- this._scratch = new Uint8Array(outBufferSize);
76
75
  if (isCompress) {
77
76
  this._process = wasm.deflate_process;
78
77
  this._last_consumed = wasm.deflate_last_consumed;
@@ -121,7 +120,6 @@ function _make(isCompress, type, options = {}) {
121
120
  const process = this._process;
122
121
  const last_consumed = this._last_consumed;
123
122
  const out = this.out;
124
- const scratch = this._scratch;
125
123
  let offset = 0;
126
124
  while (offset < buffer.length) {
127
125
  const toRead = Math.min(buffer.length - offset, 32 * 1024);
@@ -146,8 +144,7 @@ function _make(isCompress, type, options = {}) {
146
144
  }
147
145
  const prod = result & 0x00ffffff;
148
146
  if (prod) {
149
- scratch.set(heap.subarray(out, out + prod), 0);
150
- controller.enqueue(scratch.slice(0, prod));
147
+ controller.enqueue(heap.slice(out, out + prod));
151
148
  }
152
149
  const consumed = last_consumed(this.streamHandle);
153
150
  if (consumed === 0 && prod === 0) {
@@ -165,7 +162,6 @@ function _make(isCompress, type, options = {}) {
165
162
  const heap = new Uint8Array(memory.buffer);
166
163
  const process = this._process;
167
164
  const out = this.out;
168
- const scratch = this._scratch;
169
165
  while (true) {
170
166
  const result = process(this.streamHandle, 0, 0, out, outBufferSize, 4);
171
167
  const code = (result >> 24) & 0xff;
@@ -175,8 +171,7 @@ function _make(isCompress, type, options = {}) {
175
171
  }
176
172
  const produced = result & 0x00ffffff;
177
173
  if (produced) {
178
- scratch.set(heap.subarray(out, out + produced), 0);
179
- controller.enqueue(scratch.slice(0, produced));
174
+ controller.enqueue(heap.slice(out, out + produced));
180
175
  }
181
176
  if (code === 1 || produced === 0) {
182
177
  break;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "WASM-based Compression Streams API implementation using zlib, with support for deflate64 decompression.",
4
4
  "author": "Gildas Lormeau",
5
5
  "license": "BSD-3-Clause",
6
- "version": "1.2.1",
6
+ "version": "1.2.2",
7
7
  "type": "module",
8
8
  "keywords": [
9
9
  "deflate",
@@ -72,7 +72,6 @@ function _make(isCompress, type, options = {}) {
72
72
  if (!this.out || !this.in) {
73
73
  throw new Error("allocation failed");
74
74
  }
75
- this._scratch = new Uint8Array(outBufferSize);
76
75
  if (isCompress) {
77
76
  this._process = wasm.deflate_process;
78
77
  this._last_consumed = wasm.deflate_last_consumed;
@@ -121,7 +120,6 @@ function _make(isCompress, type, options = {}) {
121
120
  const process = this._process;
122
121
  const last_consumed = this._last_consumed;
123
122
  const out = this.out;
124
- const scratch = this._scratch;
125
123
  let offset = 0;
126
124
  while (offset < buffer.length) {
127
125
  const toRead = Math.min(buffer.length - offset, 32 * 1024);
@@ -146,8 +144,7 @@ function _make(isCompress, type, options = {}) {
146
144
  }
147
145
  const prod = result & 0x00ffffff;
148
146
  if (prod) {
149
- scratch.set(heap.subarray(out, out + prod), 0);
150
- controller.enqueue(scratch.slice(0, prod));
147
+ controller.enqueue(heap.slice(out, out + prod));
151
148
  }
152
149
  const consumed = last_consumed(this.streamHandle);
153
150
  if (consumed === 0 && prod === 0) {
@@ -165,7 +162,6 @@ function _make(isCompress, type, options = {}) {
165
162
  const heap = new Uint8Array(memory.buffer);
166
163
  const process = this._process;
167
164
  const out = this.out;
168
- const scratch = this._scratch;
169
165
  while (true) {
170
166
  const result = process(this.streamHandle, 0, 0, out, outBufferSize, 4);
171
167
  const code = (result >> 24) & 0xff;
@@ -175,8 +171,7 @@ function _make(isCompress, type, options = {}) {
175
171
  }
176
172
  const produced = result & 0x00ffffff;
177
173
  if (produced) {
178
- scratch.set(heap.subarray(out, out + produced), 0);
179
- controller.enqueue(scratch.slice(0, produced));
174
+ controller.enqueue(heap.slice(out, out + produced));
180
175
  }
181
176
  if (code === 1 || produced === 0) {
182
177
  break;