diff --git a/src/ssn/streams/arrayBufferToStream.ts b/src/ssn/streams/arrayBufferToStream.ts index 518a08e..1331837 100644 --- a/src/ssn/streams/arrayBufferToStream.ts +++ b/src/ssn/streams/arrayBufferToStream.ts @@ -1,7 +1,5 @@ import * as stream from 'stream'; -const BUFFER_SIZE = 16 * 1024; - export default function arrayBufferToStream(arrayBuffer: ArrayBuffer, offset: number = 0, length?: number): stream.Readable { if (offset < 0 || offset >= arrayBuffer.byteLength - 1) { throw new RangeError('Could not convert ArrayBuffer to ReadableStream; out of bounds.'); @@ -15,7 +13,7 @@ export default function arrayBufferToStream(arrayBuffer: ArrayBuffer, offset: nu const byteArray = new Uint8Array(arrayBuffer); const outStream = new stream.Readable({ read(size) { - const chunkSize = Math.min(size || BUFFER_SIZE, endPosition - position); //TODO: we can probably remove BUFFER_SIZE + const chunkSize = Math.min(size, endPosition - position); let needMoreData: boolean; do { //If end is reached @@ -29,8 +27,6 @@ export default function arrayBufferToStream(arrayBuffer: ArrayBuffer, offset: nu for (let i = 0; i < chunkSize; i += 1) { chunk.writeUInt8(byteArray[position + i], i); } - //chunk.fill(arrayBuffer, position); - //const chunk = Buffer.from(arrayBuffer, position, chunkSize); position += chunk.length; needMoreData = outStream.push(chunk); } while (needMoreData);