Branded numeric type for non-negative integers. Represents integers greater than or equal to zero.
const isNonNegativeInt = (x: number): x is NonNegativeInt => Number.isInteger(x) && x >= 0;const arrayIndex = (arr: readonly unknown[], i: NonNegativeInt) => arr[i];const count = (items: NonNegativeInt) => ({ count: items }); Copy
const isNonNegativeInt = (x: number): x is NonNegativeInt => Number.isInteger(x) && x >= 0;const arrayIndex = (arr: readonly unknown[], i: NonNegativeInt) => arr[i];const count = (items: NonNegativeInt) => ({ count: items });
Branded numeric type for non-negative integers. Represents integers greater than or equal to zero.