fix TextDecoder finalization in older chrome

text-decoder-finalize
Niklas Fiekas 2021-10-22 16:35:09 +02:00
parent 2cd883ebf7
commit 9b04e2e03d
1 changed files with 1 additions and 1 deletions

View File

@ -23,7 +23,7 @@ export const readNdJson =
const loop = (): Promise<Error | true> =>
stream.read().then(({ done, value }) => {
buf += decoder.decode(value, { stream: !done });
buf += decoder.decode(value || new Uint8Array(), { stream: !done });
const parts = buf.split(matcher);
if (!done) buf = parts.pop()!;
for (const part of parts) if (part) processLine(JSON.parse(part));