logical.stripJsoncfunctionno test imports itfunction stripJsonc(text: string): stringThe text of a JSON with comments and trailing commas as JSON: comments and the commas before } and ] are removed, and strings are left as they are.
The facts of a repository for the hygiene check, gathered through the ports (commons repoctl 0007-repoctl-hygiene FR-003; commons 0036-distribution FR-011): the lockfiles read as data (bun.lock is JSON with comments and trailing commas, package-lock.json is JSON of lockfile versions 2 and 3), the package.json files outside node_modules, the packages installed under node_modules (a folder of the scope, nested ones and Bun's .bun store) and the relative imports of the sources. The parsers are pure; only gatherHygieneFacts of this module reads, and only through Files.
import { parseNpmLock } from "./hygiene-facts.ts";
const r = parseNpmLock('{ "packages": { "node_modules/@intellectual-frontiers/core": { "version": "0.1.5" } } }', "package-lock.json");
r.kind; // "read"logical.stripJsoncfunctionno test imports itfunction stripJsonc(text: string): stringThe text of a JSON with comments and trailing commas as JSON: comments and the commas before } and ] are removed, and strings are left as they are.
logical.parseBunLockfunctionno test imports itfunction parseBunLock(source: string, file: string, scope: string): LockFactsThe copies of the packages of commons a bun.lock holds: each entry of packages is [ "name@version", ... ] under a key that says where it is nested.
logical.parseNpmLockfunctionno test imports itfunction parseNpmLock(source: string, file: string, scope: string): LockFactsThe copies of the packages of commons a package-lock.json (versions 2 and 3: packages keyed by path) holds.
logical.parsePackagefunctionno test imports itfunction parsePackage(source: string, path: string): Result<{ readonly facts: PackageFacts; readonly workspaces: readonly string[]; }, string>The facts of one package.json's text: its name and its dependencies of every section; the workspaces it declares are the second part.
logical.relativeImportsfunctionno test imports itfunction relativeImports(source: string): readonly string[]The relative specifiers a source imports, with the specifier as written.
logical.IGNORED_FOLDERSconstno test imports itconst IGNORED_FOLDERS: readonly string[]The folders that hold only what is made or fetched, never read for a lockfile or a package: a path with one of these segments is left out. node_modules is never walked at all.
logical.gatherHygieneFactsfunctionno test imports itfunction gatherHygieneFacts(w: Pick<World, "files" | "repo">, policy: HygienePolicy): Promise<HygieneFacts>Gathers the facts of the repository of a world: the only reads of the check. Every folder with a package.json is a tree of its own, with the lockfiles next to it and its own node_modules.
stripJsoncfunctionfunction stripJsonc(text: string): stringThe text of a JSON with comments and trailing commas as JSON: comments and the commas before } and ] are removed, and strings are left as they are.
parseBunLockfunctionfunction parseBunLock(source: string, file: string, scope: string): LockFactsThe copies of the packages of commons a bun.lock holds: each entry of packages is [ "name@version", ... ] under a key that says where it is nested.
parseNpmLockfunctionfunction parseNpmLock(source: string, file: string, scope: string): LockFactsThe copies of the packages of commons a package-lock.json (versions 2 and 3: packages keyed by path) holds.
parsePackagefunctionno test imports itfunction parsePackage(source: string, path: string): Result<{ readonly facts: PackageFacts; readonly workspaces: readonly string[]; }, string>The facts of one package.json's text: its name and its dependencies of every section; the workspaces it declares are the second part.
relativeImportsfunctionfunction relativeImports(source: string): readonly string[]The relative specifiers a source imports, with the specifier as written.
IGNORED_FOLDERSconstno test imports itconst IGNORED_FOLDERS: readonly string[]The folders that hold only what is made or fetched, never read for a lockfile or a package: a path with one of these segments is left out. node_modules is never walked at all.
gatherHygieneFactsfunctionfunction gatherHygieneFacts(w: Pick<World, "files" | "repo">, policy: HygienePolicy): Promise<HygieneFacts>Gathers the facts of the repository of a world: the only reads of the check. Every folder with a package.json is a tree of its own, with the lockfiles next to it and its own node_modules.