IF Commons GitHub

governance/expect

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

What a write or a delete expects of the object it changes: any state, no object, or the object at one revision. The expectation is part of every change, so that two writers who do not know of each other cannot silently overwrite one another. Whether a store accepts a revision is in its type: ExpectFor names the expectations a store of some capabilities takes.

import { expectAbsent, expectAny } from "./expect.ts";
expectAny.kind; // "any"
expectAbsent.kind; // "absent"

Source: commons/anyfs/src/governance/expect.ts

4 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.

Expecttypeno test imports it
type Expect = { readonly kind: "any" } | { readonly kind: "absent" } | { readonly kind: "rev"; readonly rev: Revision };

What a change expects of the object: any state, no object, or one revision.

expectAnyconst
const expectAny: { readonly kind: "any"; }

Expect nothing: make or replace.

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

expectAbsentconst
const expectAbsent: { readonly kind: "absent"; }

Expect no object: make it only where it is absent.

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

expectRevconst
const expectRev: (rev: Revision) => Expect

Expect the object at a revision.

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

ExpectFortype
type ExpectFor<C extends Capability> = "cas" extends C ? Expect : Exclude<Expect, { readonly kind: "rev" }>;

The expectations a store of capabilities C takes: a revision only where C has cas.

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

describeExpectfunctionno test imports it
function describeExpect(expect: Expect): string

An expectation in a few words.

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