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

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

    The PositiveInt32 type represents a positive integer in [1, 2^31). Division (div) uses floor division.

    Type Declaration

    • add: (x: WithSmallInt, y: WithSmallInt) => PositiveInt32

      Adds two positive integers, returning a + b as a PositiveInt32.

    • div: (x: WithSmallInt, y: ToNonZeroIntWithSmallInt<PositiveInt32>) => PositiveInt32

      Divides two positive integers using floor division (⌊a / b⌋): the result is a / b rounded toward negative infinity, as a PositiveInt32.

    • fromNumber: (x: number) => PositiveInt32

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

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

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

      Type guard that checks if a value is a positive integer in [1, 2^31).

      isPositiveInt32 for usage examples

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

      Returns the largest of the given positive integers.

    • MAX_VALUE: number

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

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

      Returns the smallest of the given positive integers.

    • MIN_VALUE: 1

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

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

      Multiplies two positive integers, returning a * b as a PositiveInt32.

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

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

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

      Generates a random PositiveInt32 within the given range.

      The range is inclusive on both ends.

    • sub: (x: WithSmallInt, y: WithSmallInt) => PositiveInt32

      Subtracts two positive integers, returning a - b as a PositiveInt32.