IF Commons GitHub

logical/attenuate

Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0003-anyfs-logical FR-004

Attenuation: a store given to a program is made smaller before it is given. readOnly takes away every capability that changes anything, sub shows only what is below a prefix, and only keeps the capabilities named. Each makes a store of a type that has no more than its argument, and each can only narrow: there is no function here that gives a store a capability it did not have. A program that holds a store has no other way to the place, because a store has no ambient file system behind it.

import { readOnly, sub } from "./attenuate.ts";
// const fleet = readOnly(sub(root, prefix)): reads below `prefix` and nothing else

Source: commons/anyfs/src/logical/attenuate.ts

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

MUTATING_CAPABILITIESconstno test imports it
const MUTATING_CAPABILITIES: readonly ["write", "delete", "batch", "rename", "append", "lock", "merge"]

The capabilities that change something.

MutatingCapabilitytypeno test imports it
type MutatingCapability = (typeof MUTATING_CAPABILITIES)[number];

One capability that changes something.

readOnlyfunction
function readOnly<C extends Capability>(store: Store<C>): Store<Exclude<C, "append" | "batch" | "delete" | "lock" | "merge" | "rename" | "watch" | "write">>

A store with none of the capabilities of its argument that change anything.

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

onlyfunction
function only<C extends Capability, K extends C & OpCapability>(store: Store<C>, capabilities: readonly K[]): Store<K>

A store with only the capabilities named, which the argument has: the compiler refuses a capability it lacks.

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

viewfunctionno test imports it
function view<D extends OpCapability>(store: StoreBase, capabilities: readonly D[]): Result<Store<D>, string>

A store of the capabilities named, from a store whose type does not say them (one a function was given as any store): the store has them, or the answer says which it lacks.

subfunction
function sub<C extends Capability>(store: Store<C>, prefix: Prefix): Store<Exclude<Carried<C>, "merge">>

A store of only what is below a prefix of its argument: every path is below the prefix and none can name the way out of it. It has the capabilities of its argument that have an operation.

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

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