rename scan.ts to scan-from-raw.ts and give it a simple cli for byteoffset

This commit is contained in:
Charlotte Som 2024-11-29 06:26:41 +00:00
parent 1e0ff83f8b
commit e9af92c00f

View file

@ -2,18 +2,18 @@ import { TextLineStream } from "jsr:@std/streams@1/text-line-stream";
import { ExportEntry } from "./directory-tailer.ts"; import { ExportEntry } from "./directory-tailer.ts";
import { tailer } from "./main.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 }); using exports = await Deno.open("./data/exports.jsonl", { read: true });
// interrupted at 2024-11-12T21:33:47.118Z if (fromByteOffset) {
// byte offset await exports.seek(fromByteOffset, Deno.SeekMode.Start);
await exports.seek(13526812085, Deno.SeekMode.Start); }
const lineStream = exports.readable const lineStream = exports.readable
.pipeThrough(new TextDecoderStream()) .pipeThrough(new TextDecoderStream())
.pipeThrough(new TextLineStream()); .pipeThrough(new TextLineStream());
{ if (fromByteOffset) {
const reader = lineStream.getReader(); const reader = lineStream.getReader();
const line = await reader.read(); const line = await reader.read();
console.log("dropping: " + line.value); 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);
}