TOC Toolkit API - v0.1.0
    Preparing search index...

    toc-toolkit/foundation

    The base of every other package. It fixes how a function reports an expected failure, how a computation is bounded, how a problem in user input is described, and how data from outside the program is checked. It depends on no other package and reads no clock or random number.

    • Hierarchical resource budgets. A budget gives each resource a limit, charges abstract steps as work proceeds, and splits into child budgets with their own caps and shares. A watchdog checks the clock and cancellation every WATCHDOG_INTERVAL charges. (rootBudget, attempt)
    • FNV-1a hashing. Gives a text a 64-bit hash written as 16 hexadecimal digits, the same on every machine. The hash is not cryptographic. (hashText)
    • Combinator decoding. Builds decoders for scalars, objects, arrays, records, tagged unions and enums, and reports every problem with its path. (objectDecoder, taggedUnionDecoder, arrayDecoder, recordDecoder, enumDecoder, booleanDecoder, literalDecoder, numberDecoder, stringDecoder)
    • Decoder wrappers. Make a decoder accept null, or freeze the value that a decoder returns, as a shallow copy for a record. (maybeDecoder, frozenDecoder, frozenRecordDecoder, frozenArrayDecoder)
    • Seeded random numbers. A deterministic mulberry32 generator that draws words, bounded integers, chances, lists and items from a seed. (SeededRandom)
    • Assertions. Throw when a condition that the code relies on fails, or when a value is missing or a case is unhandled. A failure is a bug. (assert, defined, assertNever)
    • Map default. Returns the value of a key, and inserts a made value first when the key is missing. (getOrInsert)
    • Result collection. Joins a list of results into one result, or into all the errors. (collect)
    • Result. A success or failure value that a caller tests by its isOk field. (Result, ok, err)
    • Branded types. Nominal types over plain values. (Brand)
    • Artifact cache. Memoizes a computed artifact under a typed key and an owner object. A caller can hand rootBudget a cache of its own, so that several decisions reuse the artifacts of the same model. (ArtifactCache, artifactKey)
    • Issues and traces. Describe a problem in the input with a severity, a span and an optional text fix, and record the steps of a computation. (Issue, Span, TextFix, applyTextFix, TargetedIssue, Trace, Traced, FrameText, spanDecoder, textFixDecoder, targetedIssueDecoder, traceDecoder, frameTextDecoder)
    • Exhaustion. Says which resource ran out, its limit, the amount spent and the budget scope. (Exhaustion, Limits, Resource)
    • Codecs. Pair a decoder with an encoder for exhaustion, limits and counted amounts. (Codec, encodeExhaustion, exhaustionDecoder, encodeLimits, limitsDecoder, encodeCountedAmount, countedAmountDecoder)
    • Enumerations. Name the closed sets of strings that the types and the wire data of the package use. (DecodeIssueCode, Severity, StopReason)
    • Constants. Fix the limits and tables that the package exports. (DEFAULT_LIMITS)
    • Record test. Tells whether unknown input is an object that is not an array. (isRecord)
    • Field removal. Copies a record without one key, for a record that must lack the key, such as a test record of a decoder. (omitField)