@dcmjs-org/parser 1.0.0-beta.10 → 1.0.0-beta.12

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.
package/dist/index.cjs CHANGED
@@ -1821,14 +1821,9 @@ async function fromPart10StreamImpl(input, listener, options, parseState) {
1821
1821
  chunkSize: INFLATE_CHUNK_SIZE
1822
1822
  });
1823
1823
  inflater.onData = chunk => {
1824
- // chunk is a Uint8Array (pako 2.x). Slice to an owned
1825
- // ArrayBuffer so bodyStream's view doesn't alias pako's buffer.
1826
- bodyStream.addBuffer(
1827
- chunk.buffer.slice(
1828
- chunk.byteOffset,
1829
- chunk.byteOffset + chunk.byteLength
1830
- )
1831
- );
1824
+ // chunk is a Uint8Array (pako 2.x); addBuffer copies a view,
1825
+ // so bodyStream doesn't alias pako's buffer.
1826
+ bodyStream.addBuffer(chunk);
1832
1827
  };
1833
1828
 
1834
1829
  let relayPos = relayStartPos;
@@ -3118,16 +3113,12 @@ async function* readableStreamToAsyncIterable(stream) {
3118
3113
  * arrays, and plain ArrayBuffers.
3119
3114
  *
3120
3115
  * @param {Uint8Array|ArrayBuffer} chunk
3121
- * @returns {ArrayBuffer}
3116
+ * @returns {Uint8Array|ArrayBuffer} the chunk, after the type check
3122
3117
  */
3123
3118
  function toArrayBuffer(chunk) {
3124
- if (chunk instanceof ArrayBuffer) return chunk;
3125
- if (ArrayBuffer.isView(chunk)) {
3126
- // Typed array (Uint8Array, Buffer, etc.): slice to own ArrayBuffer.
3127
- return chunk.buffer.slice(
3128
- chunk.byteOffset,
3129
- chunk.byteOffset + chunk.byteLength
3130
- );
3119
+ // addBuffer copies a view (Uint8Array, Buffer, etc.) itself
3120
+ if (chunk instanceof ArrayBuffer || ArrayBuffer.isView(chunk)) {
3121
+ return chunk;
3131
3122
  }
3132
3123
  throw new TypeError(
3133
3124
  `fromPart10Stream: expected Uint8Array|ArrayBuffer chunk from iterable, ` +