number positive integer - nberlette/is GitHub Wiki
function isPositiveInteger<N = number>(it: N): it is PositiveInteger<N>;
Checks if a given value is a positive integer.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a positive integer, false
otherwise.
Numbers
import { isPositiveInteger } from "jsr:@nick/is/integer";
console.log(isPositiveInteger(0)); // true
console.log(isPositiveInteger(1)); // true
console.log(isPositiveInteger(-1)); // false
console.log(isPositiveInteger(1.5)); // false
console.log(isPositiveInteger(NaN)); // false
console.log(isPositiveInteger(Infinity)); // false
function isPositiveInteger(it: unknown): it is PositiveInteger;
Checks if a given value is a positive integer.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a positive integer, false
otherwise.
Numbers
import { isPositiveInteger } from "jsr:@nick/is/integer";
console.log(isPositiveInteger(0)); // true
console.log(isPositiveInteger(1)); // true
console.log(isPositiveInteger(-1)); // false
console.log(isPositiveInteger(1.5)); // false
console.log(isPositiveInteger(NaN)); // false
console.log(isPositiveInteger(Infinity)); // false
export type PositiveInteger<N = number> = Cast<N, POSITIVE & INTEGER>;
Casts a value into a positive finite type. If the value is not a number, it will
resolve to never
.
-
N
(default:number
)
Numbers