@blockchaincommons/rand - v1.0.0-beta.3
    Preparing search index...

    Thrown for an argument outside its width, an empty or over-long range, a full-width draw that does not fit, a malformed seed or state, a generator that breaks the contract, and a missing Web Crypto API. Branch on code; the messages are the port's own (the reference panics with compiler and core strings).

    Instances come from the static factories only.

    try {
    nextInClosedRangeI8(rng, -128, 127);
    } catch (e) {
    if (RandError.isRandError(e) && e.is("RangeTooLong")) {
    // the length must fit i8, as in the reference
    }
    }

    Hierarchy

    • Error
      • RandError
    Index
    name: "RandError"

    Always "RandError"; the cross-copy identity RandError.isRandError checks.

    The discriminant; equals details.code.

    The structured payload, discriminated by code.

    • Type guard for a RandError, including one from another copy of this package.

      Parameters

      • value: unknown

      Returns value is RandError

    • start >= end for a half-open range, or start > end for a closed one.

      Parameters

      • start: number | bigint
      • end: number | bigint
      • closed: boolean

      Returns RandError

    • A signed range's end - start exceeds the width's MAX ([0, MAX] for a closed range, [1, MAX] for a half-open one), where the reference's arithmetic overflows.

      Parameters

      • length: number | bigint
      • max: number | bigint
      • closed: boolean

      Returns RandError

    • The generator has no callable method; value is the member found, or the undefined/null generator itself. Public so that a consumer calling a member this package does not (fillBytesPacked) reports the same error.

      Parameters

      Returns RandError

    • method returned value, which is outside its contract: nextU64 must return a bigint in [0, 2^64 - 1]; nextU32 and nextU64Low32 an integer in [0, 2^32 - 1].

      Parameters

      • method: "nextU32" | "nextU64" | "nextU64Low32"
      • value: unknown

      Returns RandError