Hittypeno test imports ittype Hit = { readonly line: number; readonly text: string };A line that holds the text.
The text search of grep, and the name and size tests of find (commons anyfs-cli 0003-anyfs-cli-logical FR-007): a literal text, never a pattern a caller wrote (so a search cannot be made to run for ever), with a case option; a wildcard of * and ? for names; and a size test written as +N, -N or N with the units K, M and G. Pure functions over text and numbers.
import { matchingLines, wildcard } from "./grep.ts";
matchingLines("a\nHello\n", "hello", true); // [{ line: 2, text: "Hello" }]
wildcard("*.ts", "a.ts"); // trueHittypeno test imports ittype Hit = { readonly line: number; readonly text: string };A line that holds the text.
looksLikeTextfunctionfunction looksLikeText(bytes: Uint8Array<ArrayBufferLike>): booleanWhether bytes look like text: no NUL in the first 8 KiB.
matchingLinesfunctionfunction matchingLines(text: string, needle: string, ignoreCase: boolean): readonly Hit[]The lines of a text that hold needle, with their numbers from 1.
wildcardfunctionfunction wildcard(pattern: string, name: string): booleanWhether a name matches a wildcard: * is any run of characters but a slash, ? is one.
SizeTesttypeno test imports ittype SizeTest = { readonly kind: "over" | "under" | "equal"; readonly bytes: number };A test of a size in bytes.
parseSizeTestfunctionfunction parseSizeTest(text: string): Result<SizeTest, string>A size test from text: +10K is over ten KiB, -1M under a MiB, 512 exactly that many bytes.
sizePassesfunctionfunction sizePasses(test: SizeTest, size: number): booleanWhether a size passes a test.