ts-data-forge
    Preparing search index...
    NonZeroInt32: {
        abs: (x: WithSmallInt) => IntersectBrand<NonZeroInt32>;
        fromNumber: (x: number) => NonZeroInt32;
        is: (a: number) => a is NonZeroInt32;
        max: (...values: readonly WithSmallInt<NonZeroInt32>[]) => NonZeroInt32;
        MAX_VALUE: number;
        min: (...values: readonly WithSmallInt<NonZeroInt32>[]) => NonZeroInt32;
        MIN_VALUE: number;
        mul: (x: WithSmallInt, y: WithSmallInt) => NonZeroInt32;
        pow: (x: WithSmallInt, y: WithSmallInt) => NonZeroInt32;
        random: (
            min?: WithSmallInt<NonZeroInt32>,
            max?: WithSmallInt<NonZeroInt32>,
        ) => NonZeroInt32;
    }

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

    The NonZeroInt32 type represents a non-zero integer in [-2^31, 2^31). Division (div) uses floor division.

    Type Declaration

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

      Returns the absolute value of a non-zero integer in [-2^31, 2^31).

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

    • fromNumber: (x: number) => NonZeroInt32

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

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

    • is: (a: number) => a is NonZeroInt32

      Type guard that checks if a value is a non-zero integer in [-2^31, 2^31).

      isNonZeroInt32 for usage examples

    • Readonlymax: (...values: readonly WithSmallInt<NonZeroInt32>[]) => NonZeroInt32

      Returns the largest of the given non-zero integers.

    • MAX_VALUE: number

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

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

      Returns the smallest of the given non-zero integers.

    • MIN_VALUE: number

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

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

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

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

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

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

      Generates a random NonZeroInt32 within the given range.

      The range is inclusive on both ends.