Staquia API
    Preparing search index...

    Type Alias IPositionError

    IPositionError: Error & (
        | { isOverflow: boolean; position: IPosition }
        | { isDangerous: boolean; position: IPosition }
        | { isMismatch: boolean; position: IPosition }
        | { index: number; isInvalid: boolean; string: string }
    )

    Any error returned by the position functions: an OverflowError, a ThresholdReachedError, a SystemMismatchError or an InvalidCharacterError. Use instanceof with the error classes (or their true discriminator fields) to know which one it is.

    Type Declaration

    • { isOverflow: boolean; position: IPosition }
      • ReadonlyisOverflow: boolean

        true if the generated position overflowed, false otherwise.

      • Readonlyposition: IPosition

        The position that overflowed.

    • { isDangerous: boolean; position: IPosition }
      • ReadonlyisDangerous: boolean

        true if the generated position reached the threshold, false otherwise.

      • Readonlyposition: IPosition

        The position that reached the threshold.

    • { isMismatch: boolean; position: IPosition }
      • ReadonlyisMismatch: boolean

        true if the position was created by another number system, false otherwise.

      • Readonlyposition: IPosition

        The position created by another system.

    • { index: number; isInvalid: boolean; string: string }
      • Readonlyindex: number

        The index of the first invalid character.

      • ReadonlyisInvalid: boolean

        true if the string contains a character that is not a digit of the system, false otherwise.

      • Readonlystring: string

        The string that was forged.

    import Staquia, { InvalidCharacterError, ThresholdReachedError } from "staquia";

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

    const result = system.forge("abC");
    if (!result.ok) {
    if (result.error instanceof InvalidCharacterError) console.log("Not a digit at", result.error.index);
    else if (result.error instanceof ThresholdReachedError) console.log("Valid, but rebalance soon");
    else console.log(result.error.message);
    }