From e9af92c00fd48d5ec2bbf9d6cfb1720a0784197a Mon Sep 17 00:00:00 2001 From: Charlotte Som Date: Fri, 29 Nov 2024 06:26:41 +0000 Subject: [PATCH] rename scan.ts to scan-from-raw.ts and give it a simple cli for byteoffset --- scan.ts => scan-from-raw.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) rename scan.ts => scan-from-raw.ts (64%) diff --git a/scan.ts b/scan-from-raw.ts similarity index 64% rename from scan.ts rename to scan-from-raw.ts index aad2b5e..3eb0ca4 100644 --- a/scan.ts +++ b/scan-from-raw.ts @@ -2,18 +2,18 @@ import { TextLineStream } from "jsr:@std/streams@1/text-line-stream"; import { ExportEntry } from "./directory-tailer.ts"; import { tailer } from "./main.ts"; -export const fullScan = async () => { +export const fullScan = async (fromByteOffset?: number) => { using exports = await Deno.open("./data/exports.jsonl", { read: true }); - // interrupted at 2024-11-12T21:33:47.118Z - // byte offset - await exports.seek(13526812085, Deno.SeekMode.Start); + if (fromByteOffset) { + await exports.seek(fromByteOffset, Deno.SeekMode.Start); + } const lineStream = exports.readable .pipeThrough(new TextDecoderStream()) .pipeThrough(new TextLineStream()); - { + if (fromByteOffset) { const reader = lineStream.getReader(); const line = await reader.read(); console.log("dropping: " + line.value); @@ -26,4 +26,11 @@ export const fullScan = async () => { } }; -await fullScan(); +if (import.meta.main) { + const fromByteOffsetStr = Deno.args.at(0); + const fromByteOffset = fromByteOffsetStr + ? parseInt(fromByteOffsetStr) + : undefined; + + await fullScan(fromByteOffset); +}