ts-fortress
    Preparing search index...

    Variable NonZeroSafeInt

    NonZeroSafeInt: {
        abs: (
            x: WithSmallInt<NonZeroSafeInt, 40>,
        ) => IntersectBrand<NonZeroSafeInt, PositiveNumber>;
        fromNumber: (x: number) => NonZeroSafeInt;
        is: (a: number) => a is NonZeroSafeInt;
        max: (
            ...values: readonly WithSmallInt<NonZeroSafeInt, 40>[],
        ) => NonZeroSafeInt;
        MAX_VALUE: SafeUint;
        min: (
            ...values: readonly WithSmallInt<NonZeroSafeInt, 40>[],
        ) => NonZeroSafeInt;
        MIN_VALUE: SafeInt;
        mul: (
            x: WithSmallInt<NonZeroSafeInt, 40>,
            y: WithSmallInt<NonZeroSafeInt, 40>,
        ) => NonZeroSafeInt;
        pow: (
            x: WithSmallInt<NonZeroSafeInt, 40>,
            y: WithSmallInt<NonZeroSafeInt, 40>,
        ) => NonZeroSafeInt;
        random: (
            min?: WithSmallInt<NonZeroSafeInt, 40>,
            max?: WithSmallInt<NonZeroSafeInt, 40>,
        ) => NonZeroSafeInt;
    }

    Namespace providing type-safe operations for the NonZeroSafeInt branded type.

    The NonZeroSafeInt type represents a non-zero safe integer. Division (div) uses floor division.

    Type Declaration

    • Readonlyabs: (
          x: WithSmallInt<NonZeroSafeInt, 40>,
      ) => IntersectBrand<NonZeroSafeInt, PositiveNumber>

      Returns the absolute value of a non-zero safe integer.

      The result is non-negative and keeps the NonZeroSafeInt brand.

    • ReadonlyfromNumber: (x: number) => NonZeroSafeInt

      Converts an arbitrary number into a NonZeroSafeInt, rounding to the nearest integer and saturating the result into the range [MIN_VALUE, MAX_VALUE].

      Unlike asNonZeroSafeInt, this is total: out-of-range inputs are clamped to the nearest representable NonZeroSafeInt instead of throwing.

    • Readonlyis: (a: number) => a is NonZeroSafeInt

      Type guard that checks if a value is a non-zero safe integer.

      isNonZeroSafeInt for usage examples

    • Readonlymax: (...values: readonly WithSmallInt<NonZeroSafeInt, 40>[]) => NonZeroSafeInt

      Returns the largest of the given non-zero safe integers.

    • ReadonlyMAX_VALUE: SafeUint

      The largest value representable as NonZeroSafeInt (the upper saturation target of fromNumber).

    • Readonlymin: (...values: readonly WithSmallInt<NonZeroSafeInt, 40>[]) => NonZeroSafeInt

      Returns the smallest of the given non-zero safe integers.

    • ReadonlyMIN_VALUE: SafeInt

      The smallest value representable as NonZeroSafeInt (the lower saturation target of fromNumber).

    • Readonlymul: (
          x: WithSmallInt<NonZeroSafeInt, 40>,
          y: WithSmallInt<NonZeroSafeInt, 40>,
      ) => NonZeroSafeInt

      Multiplies two non-zero safe integers, returning a * b as a NonZeroSafeInt.

    • Readonlypow: (
          x: WithSmallInt<NonZeroSafeInt, 40>,
          y: WithSmallInt<NonZeroSafeInt, 40>,
      ) => NonZeroSafeInt

      Raises a to the power b, returning a ** b as a NonZeroSafeInt (floored to an integer).

    • Readonlyrandom: (
          min?: WithSmallInt<NonZeroSafeInt, 40>,
          max?: WithSmallInt<NonZeroSafeInt, 40>,
      ) => NonZeroSafeInt

      Generates a random NonZeroSafeInt within the given range.

      The range is inclusive on both ends.