ts-data-forge
    Preparing search index...
    NonZeroSafeInt: {
        abs: (x: WithSmallInt) => IntersectBrand<NonZeroSafeInt>;
        fromNumber: (x: number) => NonZeroSafeInt;
        is: (a: number) => a is NonZeroSafeInt;
        max: (...values: readonly WithSmallInt<NonZeroSafeInt>[]) => NonZeroSafeInt;
        MAX_VALUE: SafeUint;
        min: (...values: readonly WithSmallInt<NonZeroSafeInt>[]) => NonZeroSafeInt;
        MIN_VALUE: SafeInt;
        mul: (x: WithSmallInt, y: WithSmallInt) => NonZeroSafeInt;
        pow: (x: WithSmallInt, y: WithSmallInt) => NonZeroSafeInt;
        random: (
            min?: WithSmallInt<NonZeroSafeInt>,
            max?: WithSmallInt<NonZeroSafeInt>,
        ) => 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

    • abs: (x: WithSmallInt) => IntersectBrand<NonZeroSafeInt>

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

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

    • fromNumber: (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.

    • is: (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>[]) => NonZeroSafeInt

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

    • MAX_VALUE: SafeUint

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

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

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

    • MIN_VALUE: SafeInt

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

    • mul: (x: WithSmallInt, y: WithSmallInt) => NonZeroSafeInt

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

    • pow: (x: WithSmallInt, y: WithSmallInt) => NonZeroSafeInt

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

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

      Generates a random NonZeroSafeInt within the given range.

      The range is inclusive on both ends.