IF Commons GitHub

governance/glob

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0002-bridge-plans FR-006

The patterns of a filter: a small glob with no regular expression in it, so that a pattern from a person can never take a long time to match. A pattern is /-separated segments. In a segment * is any run of characters and ? any one character; a segment that is ** is any number of segments, none included. A pattern with no / matches wherever a segment of the path matches it, so that node_modules or *.tmp leaves out a whole subtree; a pattern with a / is anchored at the root of the endpoint.

import { globMatches, parseGlob } from "./glob.ts";
const g = parseGlob("*.tmp");
g.kind === "ok" && globMatches(g.value, "a/b/c.tmp"); // true

Source: commons/anyfs-bridge/src/governance/glob.ts

4 of 4 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

Globtype
type Glob = Brand<string, "anyfs-bridge glob">;

A pattern, made only by parseGlob: its segments and whether it is anchored.

Imported by 15 tests of the run (15 passed, 0 failed): the library's results

parseGlobfunction
function parseGlob(text: string): Result<Glob, string>

A glob from text, or why it is not one: not empty, at most 512 characters, no NUL, no backslash, no empty segment, and ** only as a whole segment.

Imported by 21 tests of the run (21 passed, 0 failed): the library's results

globMatchesfunction
function globMatches(glob: Glob, path: Path): boolean

Whether a glob matches a path: anchored where it holds a /, and at any segment where it holds none.

Imported by 6 tests of the run (6 passed, 0 failed): the library's results

anyGlobMatchesfunction
function anyGlobMatches(globs: readonly Glob[], path: Path): boolean

Whether any of the globs matches the path.

Imported by 6 tests of the run (6 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.