From 1908e7525d5604572b11d9ca66c2b6b7af5a69c3 Mon Sep 17 00:00:00 2001 From: Oscar <71343264+0scvr@users.noreply.github.com> Date: Thu, 26 Oct 2023 10:15:24 +0000 Subject: [PATCH 1/2] chore: remove deprecated `BytesList` in readDelim Signed-off-by: Oscar <71343264+0scvr@users.noreply.github.com> --- io/read_delim.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/io/read_delim.ts b/io/read_delim.ts index 6e3de5cb8d28..97a62a511954 100644 --- a/io/read_delim.ts +++ b/io/read_delim.ts @@ -1,7 +1,7 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. // This module is browser compatible. -import { BytesList } from "../bytes/bytes_list.ts"; +import { concat } from "https://deno.land/std@$STD_VERSION/bytes/concat.ts"; import type { Reader } from "../types.d.ts"; /** Generate longest proper prefix which is also suffix array. */ @@ -37,7 +37,7 @@ export async function* readDelim( // Avoid unicode problems const delimLen = delim.length; const delimLPS = createLPS(delim); - const chunks = new BytesList(); + let chunks = new Uint8Array(); const bufSize = Math.max(1024, delimLen + 1); // Modified KMP @@ -48,15 +48,15 @@ export async function* readDelim( const result = await reader.read(inspectArr); if (result === null) { // Yield last chunk. - yield chunks.concat(); + yield chunks; return; } else if (result < 0) { // Discard all remaining and silently fail. return; } - chunks.add(inspectArr, 0, result); + chunks = concat(chunks, inspectArr.slice(0, result)); let localIndex = 0; - while (inspectIndex < chunks.size()) { + while (inspectIndex < chunks.length) { if (inspectArr[localIndex] === delim[matchIndex]) { inspectIndex++; localIndex++; @@ -67,7 +67,7 @@ export async function* readDelim( const readyBytes = chunks.slice(0, matchEnd); yield readyBytes; // Reset match, different from KMP. - chunks.shift(inspectIndex); + chunks = chunks.slice(inspectIndex); inspectIndex = 0; matchIndex = 0; } From 5cd24fe9ada9b7088d7cd4f1256a518020231daf Mon Sep 17 00:00:00 2001 From: Asher Gomez Date: Sun, 29 Oct 2023 06:13:10 +0900 Subject: [PATCH 2/2] fix --- io/read_delim.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io/read_delim.ts b/io/read_delim.ts index 97a62a511954..40dca977c2a8 100644 --- a/io/read_delim.ts +++ b/io/read_delim.ts @@ -1,7 +1,7 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. // This module is browser compatible. -import { concat } from "https://deno.land/std@$STD_VERSION/bytes/concat.ts"; +import { concat } from "../bytes/concat.ts"; import type { Reader } from "../types.d.ts"; /** Generate longest proper prefix which is also suffix array. */