Staquia API
    Preparing search index...

    Type Alias Result<T, E>

    Result: { ok: true; value: T } | { error: E; ok: false }

    The outcome of an operation that can fail: a success with a value, or a failure with an error.

    The library never throws: every function that can fail returns a Result. Check ok first, then TypeScript lets you read value or error.

    Type Parameters

    • T

      The type of the successful value.

    • E

      The type of the error.

    import Staquia, { OverflowError } from "staquia";

    const system = Staquia.create("!", "a", "z", 5, 15, 0.15);

    const result = system.next(system.forge("zzzzz"));
    if (result.ok) {
    console.log(result.value.toString()); // the position
    } else if (result.error instanceof OverflowError) {
    console.log(result.error.message); // explains that "zzzzz" is already the last value of N
    }