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

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

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

    Type Declaration

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

      Adds two non-positive safe integers, returning a + b as a NonPositiveSafeInt.

    • fromNumber: (x: number) => NonPositiveSafeInt

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

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

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

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

      isNonPositiveSafeInt for usage examples

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

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

    • MAX_VALUE: 0

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

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

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

    • MIN_VALUE: number

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

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

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

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

      Generates a random NonPositiveSafeInt within the given range.

      The range is inclusive on both ends.

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

      Subtracts two non-positive safe integers, returning a - b as a NonPositiveSafeInt.