From 8ae29e6006592d10a0968e504d174f415b7c8960 Mon Sep 17 00:00:00 2001 From: C-3PO Date: Sun, 21 Jul 2019 16:22:50 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=91=EF=B8=8F=20Remove=20old=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ssn/streams/arrayBufferToStream.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) 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);