-
-
Notifications
You must be signed in to change notification settings - Fork 0
number
function inRange<
V extends number,
R extends Derange,
Min extends number = R extends [infer M extends number, number, Exclusivity?]
? M
: R[1] extends Exclusivity ? 0
: R[0],
Max extends number = R extends [number, infer M extends number, Exclusivity?]
? M
: R[1] extends Exclusivity ? R[0]
: R[1],
Tex extends Exclusivity = Either<
R extends [number, number, infer T extends Exclusivity] ? T
: R[1] extends Exclusivity ? R[1]
: undefined,
"[)"
>,
>(value: V, ...range: [...R] | Derange): value is InRange<V, Min, Max, Tex>;
Checks if a given number is within a given range. The range can be specified in multiple ways:
- As a tuple with the minimum and maximum values, and optional exclusivity string of either "[]", "(]", "[)", or "()".
- As a tuple with a maximum value and an optional exclusivity string. This
assumes a minimum value of
0
. - As a single number, which is assumed to be the maximum value, with an assumed
minimum value of
0
and an assumed exclusivity string of "[]".
Name | Info |
---|---|
value |
The number to check. |
range |
The range to check against. |
true
if the number is within the range, false
otherwise.
Numbers
import { inRange } from "jsr:@nick/is/number/in_range";
console.log(inRange(1, 0, 2)); // true
console.log(inRange(1, 2, 0)); // false
console.log(inRange(1, 2)); // true
console.log(inRange(1, 2, "(]")); // true
function inRange(value: number, ...range: Derange): value is InRange<number>;
Checks if a given number is within a given range. The range can be specified in multiple ways:
- As a tuple with the minimum and maximum values, and optional exclusivity string of either "[]", "(]", "[)", or "()".
- As a tuple with a maximum value and an optional exclusivity string. This
assumes a minimum value of
0
. - As a single number, which is assumed to be the maximum value, with an assumed
minimum value of
0
and an assumed exclusivity string of "[]".
Name | Info |
---|---|
value |
The number to check. |
range |
The range to check against. |
true
if the number is within the range, false
otherwise.
Numbers
import { inRange } from "jsr:@nick/is/number/in_range";
console.log(inRange(1, 0, 2)); // true
console.log(inRange(1, 2, 0)); // false
console.log(inRange(1, 2)); // true
console.log(inRange(1, 2, "(]")); // true
function inRange(value: number, ...range: any[]): undefined;
function isEven<T extends Numeric>(it: T): IsEven<T>;
Checks if a given number / bigint is an even number. Returns true
if it is
divisible by 2
, and false
otherwise. This usually corresponds to numbers
that end in 0
, 2
, 4
, 6
, or 8
.
Name | Info |
---|---|
it |
The number or bigint to check, either literal or in string format. |
true
if the value is even, false
otherwise.
Numeric
import { isEven } from "@nick/is/even";
isEven(0); // true
isEven(1); // false
isEven(2n); // true
isEven(3n); // false
function isEven(it: number | `${number}`): it is Even<number>;
Checks if a given number / numeric string is even. Returns true
if the value
is divisible by 2
, and false
otherwise. This usually corresponds to numbers
that end in 0
, 2
, 4
, 6
, or 8
.
Name | Info |
---|---|
it |
The number or numeric string to check. |
true
if the value is even, false
otherwise.
Numeric
import { isEven } from "@nick/is/even";
isEven(0); // true
isEven(1); // false
isEven(2n); // true
isEven(3n); // false
function isEven(it: bigint | `${bigint}`): it is Even<bigint>;
Checks if a given bigint or bigint string is an even number. Returns true
if
the value is divisible by 2
, and false
otherwise. This usually corresponds
to integers that end in 0
, 2
, 4
, 6
, or 8
.
Name | Info |
---|---|
it |
The bigint or bigint string to check. |
true
if the value is even, false
otherwise.
Numeric
import { isEven } from "@nick/is/even";
isEven(0); // true
isEven(1); // false
isEven(2n); // true
isEven(3n); // false
function isEven(it: unknown): it is Even;
Checks if a given number / bigint is even. Returns true
if the value is not
divisible by 2
, and false
otherwise. This usually corresponds to numbers
that end in 0
, 2
, 4
, 6
, or 8
.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is an even finite integer, false
otherwise.
Numeric
import { isEven } from "@nick/is/even";
isEven(0); // true
isEven(1); // false
isEven(2n); // true
isEven(3n); // false
function isEvenNumber<T extends Numeric>(it: T): IsEven<T>;
Checks if a given number / bigint is an even number. Returns true
if it is
divisible by 2
, and false
otherwise. This usually corresponds to numbers
that end in 0
, 2
, 4
, 6
, or 8
.
Name | Info |
---|---|
it |
The number or bigint to check, either literal or in string format. |
true
if the value is even, false
otherwise.
Numeric
import { isEven } from "@nick/is/even";
isEven(0); // true
isEven(1); // false
isEven(2n); // true
isEven(3n); // false
function isEvenNumber(it: number | `${number}`): it is Even<number>;
Checks if a given number / numeric string is even. Returns true
if the value
is divisible by 2
, and false
otherwise. This usually corresponds to numbers
that end in 0
, 2
, 4
, 6
, or 8
.
Name | Info |
---|---|
it |
The number or numeric string to check. |
true
if the value is even, false
otherwise.
Numeric
import { isEven } from "@nick/is/even";
isEven(0); // true
isEven(1); // false
isEven(2n); // true
isEven(3n); // false
function isEvenNumber(it: bigint | `${bigint}`): it is Even<bigint>;
Checks if a given bigint or bigint string is an even number. Returns true
if
the value is divisible by 2
, and false
otherwise. This usually corresponds
to integers that end in 0
, 2
, 4
, 6
, or 8
.
Name | Info |
---|---|
it |
The bigint or bigint string to check. |
true
if the value is even, false
otherwise.
Numeric
import { isEven } from "@nick/is/even";
isEven(0); // true
isEven(1); // false
isEven(2n); // true
isEven(3n); // false
function isEvenNumber(it: unknown): it is Even;
Checks if a given number / bigint is even. Returns true
if the value is not
divisible by 2
, and false
otherwise. This usually corresponds to numbers
that end in 0
, 2
, 4
, 6
, or 8
.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is an even finite integer, false
otherwise.
Numeric
import { isEven } from "@nick/is/even";
isEven(0); // true
isEven(1); // false
isEven(2n); // true
isEven(3n); // false
function isExclusivity(it: unknown): it is Exclusivity;
Checks if a given value is a valid range exclusivity string (either "[]", "(]", "[)", or "()").
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a valid range exclusivity string, false
otherwise.
Numbers
import { isExclusivity } from "jsr:@nick/is/number/in_range";
console.log(isExclusivity("[]")); // true
console.log(isExclusivity("(]")); // true
console.log(isExclusivity("[)")); // true
console.log(isExclusivity("()")); // true
console.log(isExclusivity("")); // false
console.log(isExclusivity("[")); // false
console.log(isExclusivity("]")); // false
function isFinite<N = number>(it: N): it is Finite<N>;
Checks if a given value is a finite number.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a finite number, false
otherwise.
Numbers
import { isFinite } from "jsr:@nick/is/integer";
console.log(isFinite(0)); // true
console.log(isFinite(1)); // true
console.log(isFinite(-1)); // true
console.log(isFinite(1.5)); // true
console.log(isFinite(NaN)); // false
console.log(isFinite(Infinity)); // false
function isFinite(it: unknown): it is Finite;
Checks if a given value is a finite number.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a finite number, false
otherwise.
Numbers
import { isFinite } from "jsr:@nick/is/integer";
console.log(isFinite(0)); // true
console.log(isFinite(1)); // true
console.log(isFinite(-1)); // true
console.log(isFinite(1.5)); // true
console.log(isFinite(NaN)); // false
console.log(isFinite(Infinity)); // false
function isFiniteInteger<N = number>(it: N): it is FiniteInteger<N>;
Checks if a given value is a finite integer.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a finite integer, false
otherwise.
Numbers
import { isFiniteInteger } from "jsr:@nick/is/integer";
console.log(isFiniteInteger(0)); // true
console.log(isFiniteInteger(1)); // true
console.log(isFiniteInteger(-1)); // true
console.log(isFiniteInteger(1.5)); // false
console.log(isFiniteInteger(NaN)); // false
console.log(isFiniteInteger(Infinity)); // false
function isFiniteInteger(it: unknown): it is FiniteInteger;
Checks if a given value is a finite integer.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a finite integer, false
otherwise.
Numbers
import { isFiniteInteger } from "jsr:@nick/is/integer";
console.log(isFiniteInteger(0)); // true
console.log(isFiniteInteger(1)); // true
console.log(isFiniteInteger(-1)); // true
console.log(isFiniteInteger(1.5)); // false
console.log(isFiniteInteger(NaN)); // false
console.log(isFiniteInteger(Infinity)); // false
function isFiniteNumber<N = number>(it: N): it is Finite<N>;
Checks if a given value is a finite number.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a finite number, false
otherwise.
Numbers
import { isFinite } from "jsr:@nick/is/integer";
console.log(isFinite(0)); // true
console.log(isFinite(1)); // true
console.log(isFinite(-1)); // true
console.log(isFinite(1.5)); // true
console.log(isFinite(NaN)); // false
console.log(isFinite(Infinity)); // false
function isFiniteNumber(it: unknown): it is Finite;
Checks if a given value is a finite number.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a finite number, false
otherwise.
Numbers
import { isFinite } from "jsr:@nick/is/integer";
console.log(isFinite(0)); // true
console.log(isFinite(1)); // true
console.log(isFinite(-1)); // true
console.log(isFinite(1.5)); // true
console.log(isFinite(NaN)); // false
console.log(isFinite(Infinity)); // false
function isFloat<N = number>(it: N): it is Float<N>;
Checks if the value is a floating-point number. Supports both single and double precision floating-point numbers.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a floating-point number, false
otherwise.
Numbers
import { isFloat } from "@nick/is/float";
isFloat(1); // false
isFloat(1.0); // false
isFloat(1.1); // true
isFloat(1.00001e1); // true
function isFloat(it: unknown): it is Float;
Checks if the value is a floating-point number. Supports both single and double precision floating-point numbers.
-
0
,-0
are considered valid floating-point numbers, and returntrue
. -
1
,-1
and other integers (or "non-floating" values) returnfalse
. - Special cases like
Infinity
,-Infinity
, andNaN
returnfalse
.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a floating-point number, false
otherwise.
Numbers
import { isFloat } from "@nick/is/float";
isFloat(0); // true
isFloat(1); // false
isFloat(1.0); // false
isFloat(1.1); // true
isFloat(1.00001e1); // true
function isFloat16<N = number>(it: N): it is Float16<N>;
Checks if a value is a 16-bit half-precision floating-point number, also known
as float16
or binary16
, as defined by the IEEE 754 standard.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a half-precision floating-point number. Otherwise
false
.
Numbers
import { isFloat16 } from "@nick/is/float16";
isFloat16(1); // true
isFloat16(1.5); // true
isFloat16(3.140625); // true
isFloat16(NaN); // false
isFloat16(1.1); // false
isFloat16(Math.PI); // false
isFloat16(Infinity); // false
function isFloat16(it: unknown): it is Float16;
Checks if a value is a 16-bit half-precision floating-point number, also known
as float16
or binary16
, as defined by the IEEE 754 standard.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a half-precision floating-point number. Otherwise
false
.
Numbers
function isFloat16(it: any): it is Float16;
function isFloat32<N = number>(it: N): it is Float32<N>;
Checks if the value is a floating-point number. Supports single-precision floating-point numbers.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a single-precision floating-point number, otherwise
false
.
Numbers
import { isFloat32 } from "@nick/is/float32";
isFloat32(1); // false
isFloat32(1.0); // false
isFloat32(1.1); // true
isFloat32(1.00001e1); // true
function isFloat32(it: unknown): it is Float32;
Checks if the value is a floating-point number. Supports single-precision floating-point numbers.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a single-precision floating-point number, otherwise
false
.
Numbers
import { isFloat32 } from "@nick/is/float32";
isFloat32(1); // false
isFloat32(1.0); // false
isFloat32(1.1); // true
isFloat32(1.00001e1); // true
function isFloat64<N = number>(it: N): it is Float64<N>;
Checks if the value is a float64-precision floating-point number.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a float64-precision floating-point number, false
otherwise.
Numbers
import { isFloat64 } from "jsr:@nick/is/float64";
console.log(isFloat64(1.5)); // true
console.log(isFloat64(0)); // false
console.log(isFloat64(1)); // false
console.log(isFloat64(-1)); // false
console.log(isFloat64(NaN)); // false
console.log(isFloat64(Infinity)); // false
function isFloat64(it: unknown): it is Float64;
Checks if the value is a float64-precision floating-point number.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a float64-precision floating-point number, false
otherwise.
Numbers
import { isFloat64 } from "jsr:@nick/is/float64";
console.log(isFloat64(1.5)); // true
console.log(isFloat64(0)); // false
console.log(isFloat64(1)); // false
console.log(isFloat64(-1)); // false
console.log(isFloat64(NaN)); // false
console.log(isFloat64(Infinity)); // false
function isInfinity(it: unknown): it is Infinity;
Checks if a given value is a non-finite number (Infinity
or -Infinity
).
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a non-finite number, false
otherwise.
Numbers
import { isInfinity } from "@nick/is/number/infinity";
console.log(isInfinity(Infinity)); // true
console.log(isInfinity(-Infinity)); // true
console.log(isInfinity(1)); // false
console.log(isInfinity(-1)); // false
console.log(isInfinity(NaN)); // false
function isInt16<N = number>(it: unknown): it is Int16<N>;
Checks if a value is a 16-bit integer (between -32768 and 32767).
To check for an unsigned 16-bit integer (0-65535), use isUint16.
Name | Info |
---|---|
it |
The value to check. |
true
if it
is a 16-bit integer, false
otherwise.
Numbers
int16
number
import { type Int16, isInt16, type MaybeInt16 } from "@nick/is/number";
let value = 1 as Int16;
const setValue = (newValue: MaybeInt16) => {
if (isInt16(newValue)) value = newValue;
};
setValue(0x7FFF); // <- No error!
// This will raise a TypeScript compiler error:
value = -32769; // <- TS2322 Type '-32769' is not assignable to type 'Int16'.
function isInt16(it: unknown): it is Int16;
Checks if a value is a 16-bit integer (between -32768 and 32767).
To check for an unsigned 16-bit integer (0-65535), use isUint16.
Name | Info |
---|---|
it |
The value to check. |
true
if it
is a 16-bit integer, false
otherwise.
Numbers
import { isInt16 } from "@nick/is/number";
isInt16(32768); // false
isInt16(-32769); // false
isInt16(1); // true
isInt16(32767); // true
isInt16(-32768); // true
function isInt32<N = number>(it: N): it is Int32<N>;
Checks if a given value is a signed 32-bit integer.
Name | Info |
---|---|
it |
The value to check. |
true
if it
is a signed 32-bit integer, false
otherwise.
Numbers
int32
number
import { type Int32, isInt32, type MaybeInt32 } from "jsr:@type/number/int32";
let value = 1 as Int32;
const setValue = (newValue: MaybeInt32) => {
if (isInt32(newValue)) value = newValue;
};
setValue(0x7FFFFFFF); // <- No error!
// This will raise a TypeScript compiler error:
value = -2147483649; // <- TS2322 Type '-2147483649' is not assignable to type 'Int32'.
function isInt32(it: unknown): it is Int32;
Checks if a given value is a signed 32-bit integer.
Name | Info |
---|---|
it |
The value to check. |
true
if it
is a signed 32-bit integer, false
otherwise.
Numbers
int32
number
import { isInt32 } from "jsr:@type/number/int32";
console.log(isInt32(0x7FFFFFFF)); // <- true
console.log(isInt32(-2147483649)); // <- false
function isInt8<N = number>(it: N): it is Int8<N>;
Checks if a given value is a signed 8-bit integer.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a signed 8-bit integer, false
otherwise.
Numbers
import { isInt8 } from "@nick/is/int8";
isInt8(1); // true
isInt8(1.0); // false
isInt8(1.1); // false
isInt8(1.00001e1); // false
function isInt8(it: unknown): it is Int8;
Checks if a given value is a signed 8-bit integer.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a signed 8-bit integer, false
otherwise.
Numbers
import { isInt8 } from "@nick/is/int8";
console.log(isInt8(1)); // true
console.log(isInt8(1.0)); // false
console.log(isInt8(1.1)); // false
console.log(isInt8(1.00001e1)); // false
function isInteger<N = number>(it: N): it is Integer<N>;
Checks if a given value is an integer.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is an integer, false
otherwise.
Numbers
import { isInteger } from "jsr:@nick/is/integer";
console.log(isInteger(0)); // true
console.log(isInteger(1)); // true
console.log(isInteger(-1)); // true
console.log(isInteger(1.5)); // false
console.log(isInteger(NaN)); // false
console.log(isInteger(Infinity)); // false
function isInteger(it: unknown): it is Integer;
Checks if a given value is an integer.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is an integer, false
otherwise.
Numbers
import { isInteger } from "jsr:@nick/is/integer";
console.log(isInteger(0)); // true
console.log(isInteger(1)); // true
console.log(isInteger(-1)); // true
console.log(isInteger(1.5)); // false
console.log(isInteger(NaN)); // false
console.log(isInteger(Infinity)); // false
function isNaN<N = number>(it: N): it is NaN<N>;
Checks if a given value is NaN
(not a number). This is a type-safe alias of
the global isNaN
function,
Name | Info |
---|---|
it |
The value to check. |
true
if the value is NaN
, false
otherwise.
Numbers
number
NaN
import { isNaN } from "jsr:@type/number";
console.log(isNaN(0)); // false
console.log(isNaN(1)); // false
console.log(isNaN(1.5)); // false
console.log(isNaN(NaN)); // true
console.log(isNaN(Infinity)); // false
function isNaN(it: unknown): it is NaN;
Checks if a given value is NaN
(not a number). This is a type-safe alias of
the global isNaN
function,
Name | Info |
---|---|
it |
The value to check. |
true
if the value is NaN
, false
otherwise.
Numbers
number
NaN
import { isNaN } from "jsr:@type/number";
console.log(isNaN(0)); // false
console.log(isNaN(1)); // false
console.log(isNaN(1.5)); // false
console.log(isNaN(NaN)); // true
console.log(isNaN(Infinity)); // false
function isNegative<N = number>(it: N): it is Negative<N>;
Checks if a given value is a negative number.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a negative number, false
otherwise.
Numbers
negative
import { isNegative } from "jsr:@nick/is/integer";
console.log(isNegative(0)); // false
console.log(isNegative(1)); // false
console.log(isNegative(1.5)); // false
console.log(isNegative(NaN)); // false
console.log(isNegative(Infinity)); // false
console.log(isNegative(-0)); // true
console.log(isNegative(-1)); // true
console.log(isNegative(-Infinity)); // true
function isNegative(it: unknown): it is Negative<number>;
Checks if a given value is a negative number.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a negative number, false
otherwise.
Numbers
negative
import { isNegative } from "jsr:@nick/is/integer";
console.log(isNegative(0)); // false
console.log(isNegative(1)); // false
console.log(isNegative(1.5)); // false
console.log(isNegative(NaN)); // false
console.log(isNegative(Infinity)); // false
console.log(isNegative(-0)); // true
console.log(isNegative(-1)); // true
console.log(isNegative(-Infinity)); // true
function isNegativeFiniteInteger<N = number>(
it: N,
): it is NegativeFiniteInteger<N>;
Checks if a given value is a negative finite integer.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a negative finite integer, false
otherwise.
Numbers
import { isNegativeFiniteInteger } from "jsr:@nick/is/integer";
console.log(isNegativeFiniteInteger(0)); // false
console.log(isNegativeFiniteInteger(1)); // false
console.log(isNegativeFiniteInteger(-1)); // true
console.log(isNegativeFiniteInteger(1.5)); // false
console.log(isNegativeFiniteInteger(NaN)); // false
console.log(isNegativeFiniteInteger(Infinity)); // false
function isNegativeFiniteInteger(it: unknown): it is NegativeFiniteInteger;
Checks if a given value is a negative finite integer.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a negative finite integer, false
otherwise.
Numbers
import { isNegativeFiniteInteger } from "jsr:@nick/is/integer";
console.log(isNegativeFiniteInteger(0)); // false
console.log(isNegativeFiniteInteger(1)); // false
console.log(isNegativeFiniteInteger(-1)); // true
console.log(isNegativeFiniteInteger(1.5)); // false
console.log(isNegativeFiniteInteger(NaN)); // false
console.log(isNegativeFiniteInteger(Infinity)); // false
function isNegativeFiniteNumber<N = number>(it: N): it is NegativeFinite<N>;
Checks if a given value is a negative finite number.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a negative finite number, false
otherwise.
Numbers
import { isNegativeFiniteNumber } from "jsr:@nick/is/integer";
console.log(isNegativeFiniteNumber(0)); // false
console.log(isNegativeFiniteNumber(1)); // false
console.log(isNegativeFiniteNumber(-1)); // true
console.log(isNegativeFiniteNumber(1.5)); // false
console.log(isNegativeFiniteNumber(NaN)); // false
console.log(isNegativeFiniteNumber(Infinity)); // false
function isNegativeFiniteNumber(it: unknown): it is NegativeFinite;
Checks if a given value is a negative finite number.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a negative finite number, false
otherwise.
Numbers
import { isNegativeFiniteNumber } from "jsr:@nick/is/integer";
console.log(isNegativeFiniteNumber(0)); // false
console.log(isNegativeFiniteNumber(1)); // false
console.log(isNegativeFiniteNumber(-1)); // true
console.log(isNegativeFiniteNumber(1.5)); // false
console.log(isNegativeFiniteNumber(NaN)); // false
console.log(isNegativeFiniteNumber(Infinity)); // false
function isNegativeInfinity(it: unknown): it is NegativeInfinity;
Name | Info |
---|---|
it |
The value to check. |
true
if the value is negative infinity, false
otherwise.
Numbers
number
negative
infinity
import { isNegativeInfinity } from "@nick/is/number/infinity";
console.log(isNegativeInfinity(Infinity)); // false
console.log(isNegativeInfinity(-Infinity)); // true
console.log(isNegativeInfinity(1)); // false
console.log(isNegativeInfinity(-1)); // false
console.log(isNegativeInfinity(NaN)); // false
function isNegativeInteger<N = number>(it: N): it is NegativeInteger<N>;
Checks if a given value is a negative integer.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a negative integer, false
otherwise.
Numbers
import { isNegativeInteger } from "jsr:@nick/is/integer";
console.log(isNegativeInteger(0)); // false
console.log(isNegativeInteger(1)); // false
console.log(isNegativeInteger(-1)); // true
console.log(isNegativeInteger(1.5)); // false
console.log(isNegativeInteger(NaN)); // false
console.log(isNegativeInteger(Infinity)); // false
function isNegativeInteger(it: unknown): it is NegativeInteger<number>;
Checks if a given value is a negative integer.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a negative integer, false
otherwise.
Numbers
import { isNegativeInteger } from "jsr:@nick/is/integer";
console.log(isNegativeInteger(0)); // false
console.log(isNegativeInteger(1)); // false
console.log(isNegativeInteger(-1)); // true
console.log(isNegativeInteger(1.5)); // false
console.log(isNegativeInteger(NaN)); // false
console.log(isNegativeInteger(Infinity)); // false
function isNegativeNonZeroFiniteInteger<N = number>(
it: N,
): it is NegativeNonZeroFiniteInteger<N>;
Checks if a given value is a negative nonzero finite integer.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a negative nonzero finite integer, false
otherwise.
Numbers
import { isNegativeNonZeroFiniteInteger } from "jsr:@nick/is/integer";
console.log(isNegativeNonZeroFiniteInteger(0)); // false
console.log(isNegativeNonZeroFiniteInteger(1)); // false
console.log(isNegativeNonZeroFiniteInteger(-1)); // true
console.log(isNegativeNonZeroFiniteInteger(1.5)); // false
console.log(isNegativeNonZeroFiniteInteger(NaN)); // false
console.log(isNegativeNonZeroFiniteInteger(Infinity)); // false
function isNegativeNonZeroFiniteInteger(
it: unknown,
): it is NegativeNonZeroFiniteInteger<number>;
Checks if a given value is a negative nonzero finite integer.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a negative nonzero finite integer, false
otherwise.
Numbers
import { isNegativeNonZeroFiniteInteger } from "jsr:@nick/is/integer";
console.log(isNegativeNonZeroFiniteInteger(0)); // false
console.log(isNegativeNonZeroFiniteInteger(1)); // false
console.log(isNegativeNonZeroFiniteInteger(-1)); // true
console.log(isNegativeNonZeroFiniteInteger(1.5)); // false
console.log(isNegativeNonZeroFiniteInteger(NaN)); // false
console.log(isNegativeNonZeroFiniteInteger(Infinity)); // false
function isNegativeNonZeroFiniteNumber<N = number>(
it: N,
): it is NegativeNonZeroFinite<N>;
Checks if a given value is a negative nonzero finite number.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a negative nonzero finite number, false
otherwise.
Numbers
import { isNegativeNonZeroFiniteNumber } from "jsr:@nick/is/integer";
console.log(isNegativeNonZeroFiniteNumber(0)); // false
console.log(isNegativeNonZeroFiniteNumber(1)); // false
console.log(isNegativeNonZeroFiniteNumber(-1)); // true
console.log(isNegativeNonZeroFiniteNumber(1.5)); // false
console.log(isNegativeNonZeroFiniteNumber(NaN)); // false
console.log(isNegativeNonZeroFiniteNumber(Infinity)); // false
function isNegativeNonZeroFiniteNumber(
it: unknown,
): it is NegativeNonZeroFinite;
Checks if a given value is a negative nonzero finite number.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a negative nonzero finite number, false
otherwise.
Numbers
import { isNegativeNonZeroFiniteNumber } from "jsr:@nick/is/integer";
console.log(isNegativeNonZeroFiniteNumber(0)); // false
console.log(isNegativeNonZeroFiniteNumber(1)); // false
console.log(isNegativeNonZeroFiniteNumber(-1)); // true
console.log(isNegativeNonZeroFiniteNumber(1.5)); // false
console.log(isNegativeNonZeroFiniteNumber(NaN)); // false
console.log(isNegativeNonZeroFiniteNumber(Infinity)); // false
function isNegativeNonZeroInteger<N = number>(
it: N,
): it is NegativeNonZeroInteger<N>;
Checks if a given value is a negative nonzero integer.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a negative nonzero integer, false
otherwise.
Numbers
import { isNegativeNonZeroInteger } from "jsr:@nick/is/integer";
console.log(isNegativeNonZeroInteger(0)); // false
console.log(isNegativeNonZeroInteger(1)); // false
console.log(isNegativeNonZeroInteger(-1)); // true
console.log(isNegativeNonZeroInteger(1.5)); // false
console.log(isNegativeNonZeroInteger(NaN)); // false
console.log(isNegativeNonZeroInteger(Infinity)); // true
function isNegativeNonZeroInteger(it: unknown): it is NegativeNonZeroInteger;
Checks if a given value is a negative nonzero integer.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a negative nonzero integer, false
otherwise.
Numbers
import { isNegativeNonZeroInteger } from "jsr:@nick/is/integer";
console.log(isNegativeNonZeroInteger(0)); // false
console.log(isNegativeNonZeroInteger(1)); // false
console.log(isNegativeNonZeroInteger(-1)); // true
console.log(isNegativeNonZeroInteger(1.5)); // false
console.log(isNegativeNonZeroInteger(NaN)); // false
console.log(isNegativeNonZeroInteger(Infinity)); // true
function isNegativeNonZeroNumber<N = number>(it: N): it is NegativeNonZero<N>;
Checks if a given value is a negative nonzero number.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a negative nonzero number, false
otherwise.
import { isNegativeNonZeroNumber } from "jsr:@nick/is/integer";
console.log(isNegativeNonZeroNumber(0)); // false
console.log(isNegativeNonZeroNumber(1)); // false
console.log(isNegativeNonZeroNumber(-1)); // true
console.log(isNegativeNonZeroNumber(1.5)); // false
console.log(isNegativeNonZeroNumber(NaN)); // false
console.log(isNegativeNonZeroNumber(Infinity)); // false
function isNegativeNonZeroNumber(it: unknown): it is NegativeNonZero;
Checks if a given value is a negative nonzero number.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a negative nonzero number, false
otherwise.
import { isNegativeNonZeroNumber } from "jsr:@nick/is/integer";
console.log(isNegativeNonZeroNumber(0)); // false
console.log(isNegativeNonZeroNumber(1)); // false
console.log(isNegativeNonZeroNumber(-1)); // true
console.log(isNegativeNonZeroNumber(1.5)); // false
console.log(isNegativeNonZeroNumber(NaN)); // false
console.log(isNegativeNonZeroNumber(Infinity)); // false
function isNegativeNumber<N = number>(it: N): it is Negative<N>;
Checks if a given value is a negative number.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a negative number, false
otherwise.
Numbers
negative
import { isNegative } from "jsr:@nick/is/integer";
console.log(isNegative(0)); // false
console.log(isNegative(1)); // false
console.log(isNegative(1.5)); // false
console.log(isNegative(NaN)); // false
console.log(isNegative(Infinity)); // false
console.log(isNegative(-0)); // true
console.log(isNegative(-1)); // true
console.log(isNegative(-Infinity)); // true
function isNegativeNumber(it: unknown): it is Negative<number>;
Checks if a given value is a negative number.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a negative number, false
otherwise.
Numbers
negative
import { isNegative } from "jsr:@nick/is/integer";
console.log(isNegative(0)); // false
console.log(isNegative(1)); // false
console.log(isNegative(1.5)); // false
console.log(isNegative(NaN)); // false
console.log(isNegative(Infinity)); // false
console.log(isNegative(-0)); // true
console.log(isNegative(-1)); // true
console.log(isNegative(-Infinity)); // true
function isNegativeZero<N = number>(it: N): it is NegativeZero<N>;
Checks if a given value is negative zero, which is a special numeric value in
JavaScript, distinctly different from it's positive counterpart. Checking for
negative zero involves more than simply x === -0
, as -0
is coerced into 0
in most contexts.
This function is designed to handle this edge case, and will return true
only
if the value is exactly -0
, and false
for anything else.
This is quite useful for mathematical operations and projects where data integrity and accuracy are paramount.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is negative zero, false
otherwise.
Numbers
import { isNegativeZero } from "jsr:@nick/is/number";
console.log(isNegativeZero(-0)); // true
console.log(isNegativeZero(0)); // false
console.log(isNegativeZero(-1)); // false
console.log(isNegativeZero(1)); // false
function isNegativeZero(it: unknown): it is NegativeZero;
Checks if a given value is negative zero, which is a special numeric value in
JavaScript, distinctly different from it's positive counterpart. Checking for
negative zero involves more than simply x === -0
, as -0
is coerced into 0
in most contexts.
This function is designed to handle this edge case, and will return true
only
if the value is exactly -0
, and false
for anything else.
This is quite useful for mathematical operations and projects where data integrity and accuracy are paramount.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is negative zero, false
otherwise.
Numbers
import { isNegativeZero } from "jsr:@nick/is/number";
console.log(isNegativeZero(-0)); // true
console.log(isNegativeZero(0)); // false
console.log(isNegativeZero(-1)); // false
console.log(isNegativeZero(1)); // false
function isNonZero<N = number>(it: N): it is NonZero<N>;
Checks if a given value is a nonzero number.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a nonzero number, false
otherwise.
Numbers
import { isNonZero } from "jsr:@nick/is/number/nonzero";
console.log(isNonZero(1)); // true
console.log(isNonZero(-1)); // true
console.log(isNonZero(1.5)); // true
console.log(isNonZero(0)); // false
console.log(isNonZero(-0)); // false
console.log(isNonZero(NaN)); // false
console.log(isNonZero(Infinity)); // true
function isNonZero(it: unknown): it is NonZero;
Checks if a given value is a nonzero number.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a nonzero number, false
otherwise.
Numbers
import { isNonZero } from "jsr:@nick/is/number/nonzero";
console.log(isNonZero(1)); // true
console.log(isNonZero(-1)); // true
console.log(isNonZero(1.5)); // true
console.log(isNonZero(0)); // false
console.log(isNonZero(-0)); // false
console.log(isNonZero(NaN)); // false
console.log(isNonZero(Infinity)); // true
function isNonZeroFiniteInteger<N = number>(
it: N,
): it is NonZeroFiniteInteger<N>;
Checks if a given value is a nonzero finite integer.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a nonzero finite integer, false
otherwise.
Numbers
import { isNonZeroFiniteInteger } from "jsr:@nick/is/integer";
console.log(isNonZeroFiniteInteger(0)); // false
console.log(isNonZeroFiniteInteger(1)); // true
console.log(isNonZeroFiniteInteger(-1)); // true
console.log(isNonZeroFiniteInteger(1.5)); // false
console.log(isNonZeroFiniteInteger(NaN)); // false
console.log(isNonZeroFiniteInteger(Infinity)); // true
function isNonZeroFiniteInteger(it: unknown): it is NonZeroFiniteInteger;
Checks if a given value is a nonzero finite integer.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a nonzero finite integer, false
otherwise.
Numbers
import { isNonZeroFiniteInteger } from "jsr:@nick/is/integer";
console.log(isNonZeroFiniteInteger(0)); // false
console.log(isNonZeroFiniteInteger(1)); // true
console.log(isNonZeroFiniteInteger(-1)); // true
console.log(isNonZeroFiniteInteger(1.5)); // false
console.log(isNonZeroFiniteInteger(NaN)); // false
console.log(isNonZeroFiniteInteger(Infinity)); // true
function isNonZeroFiniteNumber<N = number>(it: N): it is NonZeroFinite<N>;
Checks if a given value is a nonzero finite number.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a nonzero finite number, false
otherwise.
Numbers
import { isNonZeroFiniteNumber } from "jsr:@nick/is/integer";
console.log(isNonZeroFiniteNumber(0)); // false
console.log(isNonZeroFiniteNumber(1)); // true
console.log(isNonZeroFiniteNumber(-1)); // true
console.log(isNonZeroFiniteNumber(1.5)); // true
console.log(isNonZeroFiniteNumber(NaN)); // false
console.log(isNonZeroFiniteNumber(Infinity)); // true
function isNonZeroFiniteNumber(it: unknown): it is NonZeroFinite;
Checks if a given value is a nonzero finite number.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a nonzero finite number, false
otherwise.
Numbers
import { isNonZeroFiniteNumber } from "jsr:@nick/is/integer";
console.log(isNonZeroFiniteNumber(0)); // false
console.log(isNonZeroFiniteNumber(1)); // true
console.log(isNonZeroFiniteNumber(-1)); // true
console.log(isNonZeroFiniteNumber(1.5)); // true
console.log(isNonZeroFiniteNumber(NaN)); // false
console.log(isNonZeroFiniteNumber(Infinity)); // true
function isNonZeroInteger<N = number>(it: N): it is NonZeroInteger<N>;
Checks if a given value is a nonzero integer.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a nonzero integer, false
otherwise.
Numbers
import { isNonZeroInteger } from "jsr:@nick/is/integer";
console.log(isNonZeroInteger(0)); // false
console.log(isNonZeroInteger(1)); // true
console.log(isNonZeroInteger(-1)); // true
console.log(isNonZeroInteger(1.5)); // false
console.log(isNonZeroInteger(NaN)); // false
console.log(isNonZeroInteger(Infinity)); // true
function isNonZeroInteger(it: unknown): it is NonZeroInteger;
Checks if a given value is a nonzero integer.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a nonzero integer, false
otherwise.
Numbers
import { isNonZeroInteger } from "jsr:@nick/is/integer";
console.log(isNonZeroInteger(0)); // false
console.log(isNonZeroInteger(1)); // true
console.log(isNonZeroInteger(-1)); // true
console.log(isNonZeroInteger(1.5)); // false
console.log(isNonZeroInteger(NaN)); // false
console.log(isNonZeroInteger(Infinity)); // true
function isNonZeroNumber<N = number>(it: N): it is NonZero<N>;
Checks if a given value is a nonzero number.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a nonzero number, false
otherwise.
Numbers
import { isNonZero } from "jsr:@nick/is/number/nonzero";
console.log(isNonZero(1)); // true
console.log(isNonZero(-1)); // true
console.log(isNonZero(1.5)); // true
console.log(isNonZero(0)); // false
console.log(isNonZero(-0)); // false
console.log(isNonZero(NaN)); // false
console.log(isNonZero(Infinity)); // true
function isNonZeroNumber(it: unknown): it is NonZero;
Checks if a given value is a nonzero number.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a nonzero number, false
otherwise.
Numbers
import { isNonZero } from "jsr:@nick/is/number/nonzero";
console.log(isNonZero(1)); // true
console.log(isNonZero(-1)); // true
console.log(isNonZero(1.5)); // true
console.log(isNonZero(0)); // false
console.log(isNonZero(-0)); // false
console.log(isNonZero(NaN)); // false
console.log(isNonZero(Infinity)); // true
function isNumber(it: unknown): it is number;
Checks if the given value is a number. This includes all numbers, without
distinguishing between NaN
, Infinity
, and other special values.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a number, false
otherwise.
Primitives
import { isNumber } from "jsr:@nick/is/number";
isNumber("123"); // false
isNumber(123); // true
import { isNumber } from "jsr:@nick/is/number";
const x: unknown = 123;
if (isNumber(x)) {
console.log(x + 1);
// ^? const x: number
}
function isOdd<T = Numeric>(it: T): it is Odd<T>;
Checks if a given number / bigint is odd. Returns true
if the value is not
divisible by 2
, and false
otherwise. This usually corresponds to numbers
that end in 1
, 3
, 5
, 7
, or 9
.
Name | Info |
---|---|
it |
The number or bigint to check, either literal or in string format. |
true
if the value is odd, false
otherwise.
Numeric
import { isOdd } from "@nick/is/odd";
isOdd(1); // true
isOdd(2); // false
isOdd(3n); // true
isOdd(4n); // false
function isOdd(it: number | `${number}`): it is Odd<number>;
Checks if a given number / numeric string is odd. Returns true
if the value is
not divisible by 2
, and false
otherwise. This usually corresponds to numbers
that end in 1
, 3
, 5
, 7
, or 9
.
Name | Info |
---|---|
it |
The number or numeric string to check. |
true
if the value is odd, false
otherwise.
Numeric
import { isOdd } from "@nick/is/odd";
isOdd(1); // true
isOdd(2); // false
isOdd(3n); // true
isOdd(4n); // false
function isOdd(it: bigint | `${bigint}`): it is Odd<bigint>;
Checks if a given bigint or bigint string is an odd number. Returns true
if
the value is not divisible by 2
, and false
otherwise. This usually
corresponds to integers that end in 1
, 3
, 5
, 7
, or 9
.
Name | Info |
---|---|
it |
The bigint or bigint string to check. |
true
if the value is odd, false
otherwise.
Numeric
import { isOdd } from "@nick/is/odd";
isOdd(1); // true
isOdd(2); // false
isOdd(3n); // true
isOdd(4n); // false
function isOdd(it: unknown): it is Odd;
Checks if a given number / bigint is odd. Returns true
if the value is not
divisible by 2
, and false
otherwise. This usually corresponds to numbers
that end in 1
, 3
, 5
, 7
, or 9
.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is an odd finite integer, false
otherwise.
Numeric
import { isOdd } from "@nick/is/odd";
isOdd(1); // true
isOdd(2); // false
isOdd(3n); // true
isOdd(4n); // false
function isOddNumber<T = Numeric>(it: T): it is Odd<T>;
Checks if a given number / bigint is odd. Returns true
if the value is not
divisible by 2
, and false
otherwise. This usually corresponds to numbers
that end in 1
, 3
, 5
, 7
, or 9
.
Name | Info |
---|---|
it |
The number or bigint to check, either literal or in string format. |
true
if the value is odd, false
otherwise.
Numeric
import { isOdd } from "@nick/is/odd";
isOdd(1); // true
isOdd(2); // false
isOdd(3n); // true
isOdd(4n); // false
function isOddNumber(it: number | `${number}`): it is Odd<number>;
Checks if a given number / numeric string is odd. Returns true
if the value is
not divisible by 2
, and false
otherwise. This usually corresponds to numbers
that end in 1
, 3
, 5
, 7
, or 9
.
Name | Info |
---|---|
it |
The number or numeric string to check. |
true
if the value is odd, false
otherwise.
Numeric
import { isOdd } from "@nick/is/odd";
isOdd(1); // true
isOdd(2); // false
isOdd(3n); // true
isOdd(4n); // false
function isOddNumber(it: bigint | `${bigint}`): it is Odd<bigint>;
Checks if a given bigint or bigint string is an odd number. Returns true
if
the value is not divisible by 2
, and false
otherwise. This usually
corresponds to integers that end in 1
, 3
, 5
, 7
, or 9
.
Name | Info |
---|---|
it |
The bigint or bigint string to check. |
true
if the value is odd, false
otherwise.
Numeric
import { isOdd } from "@nick/is/odd";
isOdd(1); // true
isOdd(2); // false
isOdd(3n); // true
isOdd(4n); // false
function isOddNumber(it: unknown): it is Odd;
Checks if a given number / bigint is odd. Returns true
if the value is not
divisible by 2
, and false
otherwise. This usually corresponds to numbers
that end in 1
, 3
, 5
, 7
, or 9
.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is an odd finite integer, false
otherwise.
Numeric
import { isOdd } from "@nick/is/odd";
isOdd(1); // true
isOdd(2); // false
isOdd(3n); // true
isOdd(4n); // false
function isPositive<N = number>(it: N): it is Positive<N>;
Checks if a given value is a positive number.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a positive number, false
otherwise.
Numbers
positive
number
import { isPositive } from "jsr:@nick/is/integer";
console.log(isPositive(0)); // true
console.log(isPositive(1)); // true
console.log(isPositive(-1)); // false
console.log(isPositive(1.5)); // true
console.log(isPositive(NaN)); // false
console.log(isPositive(Infinity)); // true
function isPositive(it: unknown): it is Positive;
Checks if a given value is a positive number.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a positive number, false
otherwise.
Numbers
positive
number
import { isPositive } from "jsr:@nick/is/integer";
console.log(isPositive(0)); // true
console.log(isPositive(1)); // true
console.log(isPositive(-1)); // false
console.log(isPositive(1.5)); // true
console.log(isPositive(NaN)); // false
console.log(isPositive(Infinity)); // true
function isPositiveFiniteInteger<N = number>(
it: N,
): it is PositiveFiniteInteger<N>;
Checks if a given value is a positive finite integer.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a positive finite integer, false
otherwise.
Numbers
import { isPositiveFiniteInteger } from "jsr:@nick/is/integer";
console.log(isPositiveFiniteInteger(0)); // false
console.log(isPositiveFiniteInteger(1)); // true
console.log(isPositiveFiniteInteger(-1)); // false
console.log(isPositiveFiniteInteger(1.5)); // false
console.log(isPositiveFiniteInteger(NaN)); // false
console.log(isPositiveFiniteInteger(Infinity)); // false
function isPositiveFiniteInteger(it: unknown): it is PositiveFiniteInteger;
Checks if a given value is a positive finite integer.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a positive finite integer, false
otherwise.
Numbers
import { isPositiveFiniteInteger } from "jsr:@nick/is/integer";
console.log(isPositiveFiniteInteger(0)); // false
console.log(isPositiveFiniteInteger(1)); // true
console.log(isPositiveFiniteInteger(-1)); // false
console.log(isPositiveFiniteInteger(1.5)); // false
console.log(isPositiveFiniteInteger(NaN)); // false
console.log(isPositiveFiniteInteger(Infinity)); // false
function isPositiveFiniteNumber<N = number>(it: N): it is PositiveFinite<N>;
Checks if a given value is a positive finite number.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a positive finite number, false
otherwise.
Numbers
import { isPositiveFiniteNumber } from "jsr:@nick/is/integer";
console.log(isPositiveFiniteNumber(0)); // false
console.log(isPositiveFiniteNumber(1)); // true
console.log(isPositiveFiniteNumber(-1)); // false
console.log(isPositiveFiniteNumber(1.5)); // true
console.log(isPositiveFiniteNumber(NaN)); // false
console.log(isPositiveFiniteNumber(Infinity)); // false
function isPositiveFiniteNumber(it: unknown): it is PositiveFinite;
Checks if a given value is a positive finite number.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a positive finite number, false
otherwise.
Numbers
import { isPositiveFiniteNumber } from "jsr:@nick/is/integer";
console.log(isPositiveFiniteNumber(0)); // false
console.log(isPositiveFiniteNumber(1)); // true
console.log(isPositiveFiniteNumber(-1)); // false
console.log(isPositiveFiniteNumber(1.5)); // true
console.log(isPositiveFiniteNumber(NaN)); // false
console.log(isPositiveFiniteNumber(Infinity)); // false
function isPositiveInfinity(it: unknown): it is PositiveInfinity;
Name | Info |
---|---|
it |
The value to check. |
true
if the value is positive infinity, false
otherwise.
Numbers
number
positive
infinity
import { isPositiveInfinity } from "@nick/is/number/infinity";
console.log(isPositiveInfinity(Infinity)); // false
console.log(isPositiveInfinity(-Infinity)); // true
console.log(isPositiveInfinity(1)); // false
console.log(isPositiveInfinity(-1)); // false
console.log(isPositiveInfinity(NaN)); // false
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
function isPositiveNonZeroFiniteInteger<N = number>(
it: N,
): it is PositiveNonZeroFiniteInteger<N>;
Checks if a given value is a positive nonzero finite integer.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a positive nonzero finite integer, false
otherwise.
Numbers
import { isPositiveNonZeroFiniteInteger } from "jsr:@nick/is/integer";
console.log(isPositiveNonZeroFiniteInteger(0)); // false
console.log(isPositiveNonZeroFiniteInteger(1)); // true
console.log(isPositiveNonZeroFiniteInteger(-1)); // false
console.log(isPositiveNonZeroFiniteInteger(1.5)); // false
console.log(isPositiveNonZeroFiniteInteger(NaN)); // false
console.log(isPositiveNonZeroFiniteInteger(Infinity)); // true
function isPositiveNonZeroFiniteInteger(
it: unknown,
): it is PositiveNonZeroFiniteInteger;
Checks if a given value is a positive nonzero finite integer.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a positive nonzero finite integer, false
otherwise.
Numbers
import { isPositiveNonZeroFiniteInteger } from "jsr:@nick/is/integer";
console.log(isPositiveNonZeroFiniteInteger(0)); // false
console.log(isPositiveNonZeroFiniteInteger(1)); // true
console.log(isPositiveNonZeroFiniteInteger(-1)); // false
console.log(isPositiveNonZeroFiniteInteger(1.5)); // false
console.log(isPositiveNonZeroFiniteInteger(NaN)); // false
console.log(isPositiveNonZeroFiniteInteger(Infinity)); // true
function isPositiveNonZeroFiniteNumber<N = number>(
it: N,
): it is PositiveNonZeroFinite<N>;
Checks if a given value is a positive nonzero finite number.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a positive nonzero finite number, false
otherwise.
Numbers
import { isPositiveNonZeroFiniteNumber } from "jsr:@nick/is/integer";
console.log(isPositiveNonZeroFiniteNumber(0)); // false
console.log(isPositiveNonZeroFiniteNumber(1)); // true
console.log(isPositiveNonZeroFiniteNumber(-1)); // false
console.log(isPositiveNonZeroFiniteNumber(1.5)); // true
console.log(isPositiveNonZeroFiniteNumber(NaN)); // false
console.log(isPositiveNonZeroFiniteNumber(Infinity)); // true
function isPositiveNonZeroFiniteNumber(
it: unknown,
): it is PositiveNonZeroFinite;
Checks if a given value is a positive nonzero finite number.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a positive nonzero finite number, false
otherwise.
Numbers
import { isPositiveNonZeroFiniteNumber } from "jsr:@nick/is/integer";
console.log(isPositiveNonZeroFiniteNumber(0)); // false
console.log(isPositiveNonZeroFiniteNumber(1)); // true
console.log(isPositiveNonZeroFiniteNumber(-1)); // false
console.log(isPositiveNonZeroFiniteNumber(1.5)); // true
console.log(isPositiveNonZeroFiniteNumber(NaN)); // false
console.log(isPositiveNonZeroFiniteNumber(Infinity)); // true
function isPositiveNonZeroInteger<N = number>(
it: N,
): it is PositiveNonZeroInteger<N>;
Checks if a given value is a positive nonzero finite integer.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a positive nonzero finite integer, false
otherwise.
Numbers
import { isPositiveNonZeroInteger } from "jsr:@nick/is/integer";
console.log(isPositiveNonZeroInteger(0)); // false
console.log(isPositiveNonZeroInteger(1)); // true
console.log(isPositiveNonZeroInteger(-1)); // false
console.log(isPositiveNonZeroInteger(1.5)); // false
console.log(isPositiveNonZeroInteger(NaN)); // false
console.log(isPositiveNonZeroInteger(Infinity)); // true
function isPositiveNonZeroInteger(it: unknown): it is PositiveNonZeroInteger;
Checks if a given value is a positive nonzero finite integer.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a positive nonzero finite integer, false
otherwise.
Numbers
import { isPositiveNonZeroInteger } from "jsr:@nick/is/integer";
console.log(isPositiveNonZeroInteger(0)); // false
console.log(isPositiveNonZeroInteger(1)); // true
console.log(isPositiveNonZeroInteger(-1)); // false
console.log(isPositiveNonZeroInteger(1.5)); // false
console.log(isPositiveNonZeroInteger(NaN)); // false
console.log(isPositiveNonZeroInteger(Infinity)); // true
function isPositiveNonZeroNumber<N = number>(it: N): it is PositiveNonZero<N>;
Checks if a given value is a positive nonzero number.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a positive nonzero number, false
otherwise.
Numbers
import { isPositiveNonZeroNumber } from "jsr:@nick/is/integer";
console.log(isPositiveNonZeroNumber(0)); // false
console.log(isPositiveNonZeroNumber(1)); // true
console.log(isPositiveNonZeroNumber(-1)); // false
console.log(isPositiveNonZeroNumber(1.5)); // true
console.log(isPositiveNonZeroNumber(NaN)); // false
console.log(isPositiveNonZeroNumber(Infinity)); // true
function isPositiveNonZeroNumber(it: unknown): it is PositiveNonZero;
Checks if a given value is a positive nonzero number.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a positive nonzero number, false
otherwise.
Numbers
import { isPositiveNonZeroNumber } from "jsr:@nick/is/integer";
console.log(isPositiveNonZeroNumber(0)); // false
console.log(isPositiveNonZeroNumber(1)); // true
console.log(isPositiveNonZeroNumber(-1)); // false
console.log(isPositiveNonZeroNumber(1.5)); // true
console.log(isPositiveNonZeroNumber(NaN)); // false
console.log(isPositiveNonZeroNumber(Infinity)); // true
function isPositiveNonZeroNumber(it: unknown): it is PositiveNonZero;
function isPositiveNumber<N = number>(it: N): it is Positive<N>;
Checks if a given value is a positive number.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a positive number, false
otherwise.
Numbers
positive
number
import { isPositive } from "jsr:@nick/is/integer";
console.log(isPositive(0)); // true
console.log(isPositive(1)); // true
console.log(isPositive(-1)); // false
console.log(isPositive(1.5)); // true
console.log(isPositive(NaN)); // false
console.log(isPositive(Infinity)); // true
function isPositiveNumber(it: unknown): it is Positive;
Checks if a given value is a positive number.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a positive number, false
otherwise.
Numbers
positive
number
import { isPositive } from "jsr:@nick/is/integer";
console.log(isPositive(0)); // true
console.log(isPositive(1)); // true
console.log(isPositive(-1)); // false
console.log(isPositive(1.5)); // true
console.log(isPositive(NaN)); // false
console.log(isPositive(Infinity)); // true
function isPositiveZero<N = number>(it: N): it is PositiveZero<N>;
Checks if a given value is positive zero, which is a special numeric value in
JavaScript, distinctly different from it's negative counterpart. Checking for
positive zero involves more than simply x === +0
, as +0
is coerced into 0
in most contexts.
This function is designed to handle this edge case, and will return true
only
if the value is exactly +0
, and false
for anything else.
This is quite useful for mathematical operations and projects where data integrity and accuracy are paramount.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is positive zero, false
otherwise.
Numbers
import { isPositiveZero } from "jsr:@nick/is/number";
console.log(isPositiveZero(-0)); // false
console.log(isPositiveZero(0)); // true
console.log(isPositiveZero(-1)); // false
console.log(isPositiveZero(1)); // false
function isPositiveZero(it: unknown): it is PositiveZero;
Checks if a given value is positive zero, which is a special numeric value in
JavaScript, distinctly different from it's negative counterpart. Checking for
positive zero involves more than simply x === +0
, as +0
is coerced into 0
in most contexts.
This function is designed to handle this edge case, and will return true
only
if the value is exactly +0
, and false
for anything else.
This is quite useful for mathematical operations and projects where data integrity and accuracy are paramount.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is positive zero, false
otherwise.
Numbers
import { isPositiveZero } from "jsr:@nick/is/number";
console.log(isPositiveZero(-0)); // false
console.log(isPositiveZero(0)); // true
console.log(isPositiveZero(-1)); // false
console.log(isPositiveZero(1)); // false
function isUint16<N = number>(it: N): it is Uint16<N>;
Checks if a given value is an unsigned 16-bit integer.
Name | Info |
---|---|
it |
The value to check. |
true
if it
is an unsigned 16-bit integer, false
otherwise.
Numbers
number
unsigned
integer
import { isUint16, type MaybeUint16, type Uint16 } from "@nick/is/number";
let value = 1 as Uint16;
const setValue = (newValue: MaybeUint16) => {
if (isUint16(newValue)) value = newValue;
};
setValue(0xFFFF); // <- No error!
// This will raise a TypeScript compiler error:
value = -1; // <- TS2322 Type '-1' is not assignable to type 'Uint16'.
function isUint16(it: unknown): it is Uint16<number>;
Checks if a given value is an unsigned 16-bit integer.
Name | Info |
---|---|
it |
The value to check. |
true
if it
is an unsigned 16-bit integer, false
otherwise.
Numbers
number
unsigned
integer
import { isUint16, type MaybeUint16, type Uint16 } from "@nick/is/number";
let value = 1 as Uint16;
const setValue = (newValue: MaybeUint16) => {
if (isUint16(newValue)) value = newValue;
};
setValue(0xFFFF); // <- No error!
// This will raise a TypeScript compiler error:
value = -1; // <- TS2322 Type '-1' is not assignable to type 'Uint16'.
function isUint32<N = number>(it: N): it is Uint32<N>;
Checks if a given value is an unsigned 32-bit integer.
Name | Info |
---|---|
it |
The value to check. |
true
if it
is an unsigned 32-bit integer, false
otherwise.
Numbers
number
unsigned
integer
import { isUint32, type MaybeUint32, type Uint32 } from "@nick/is/number";
let value = 1 as Uint32;
const setValue = (newValue: MaybeUint32) => {
if (isUint32(newValue)) value = newValue;
};
setValue(0xFFFF); // <- No error!
// This will raise a TypeScript compiler error:
value = -1; // <- TS2322 Type '-1' is not assignable to type 'Uint32'.
function isUint32(it: unknown): it is Uint32<number>;
Checks if a given value is an unsigned 32-bit integer.
Name | Info |
---|---|
it |
The value to check. |
true
if it
is an unsigned 32-bit integer, false
otherwise.
Numbers
number
unsigned
integer
import { isUint32, type MaybeUint32, type Uint32 } from "@nick/is/number";
let value = 1 as Uint32;
const setValue = (newValue: MaybeUint32) => {
if (isUint32(newValue)) value = newValue;
};
setValue(0xFFFF); // <- No error!
// This will raise a TypeScript compiler error:
value = -1; // <- TS2322 Type '-1' is not assignable to type 'Uint32'.
function isUint8<N = number>(it: N): it is Uint8<N>;
Checks if a given value is an unsigned 8-bit integer.
Name | Info |
---|---|
it |
The value to check. |
true
if it
is an unsigned 8-bit integer, false
otherwise.
Numbers
number
unsigned
integer
import { isUint8 } from "jsr:@nick/is/uint8";
isUint8(1); // true
isUint8(128); // true
isUint8(0xFF); // true
isUint8(-1); // false
isUint8(420); // false
function isUint8(it: unknown): it is Uint8<number>;
Checks if a given value is an unsigned 8-bit integer.
Name | Info |
---|---|
it |
The value to check. |
true
if it
is an unsigned 8-bit integer, false
otherwise.
Numbers
number
unsigned
integer
import { isUint8 } from "jsr:@nick/is/uint8";
isUint8(1); // true
isUint8(128); // true
isUint8(0xFF); // true
isUint8(-1); // false
isUint8(420); // false
function isZero<N = number>(it: N): it is Zero<N>;
Checks if a given value is a zero number. This includes both positive and negative zero. It also supports numbers and numeric strings.
- To check exclusively for
-0
, use isNegativeZero instead. - To check exclusively for
+0
(meaning zero, but not negative zero), use isPositiveZero instead.
Numbers
function isZero(it: unknown): it is Zero;
Checks if a given value is a zero number. This includes both positive and negative zero. It also supports numbers and numeric strings.
- To check exclusively for
-0
, use isNegativeZero instead. - To check exclusively for
+0
(meaning zero, but not negative zero), use isPositiveZero instead.
Numbers
export type AnyRange<Min extends number = number, Max extends number = number> =
| RangeInclusiveMin<Min, Max>
| RangeInclusive<Min, Max>
| RangeInclusiveMax<Min, Max>
| RangeExclusive<Min, Max>;
-
Min
extendsnumber
(default:number
) -
Max
extendsnumber
(default:number
)
export type BigInteger<N = bigint> = CastInt<N, INTEGER>;
Casts a value into a big integer type (which is really just a bigint). If the
value is not a bigint or a string containing a valid integer, it will resolve to
never
.
-
N
(default:bigint
)
Numbers
export type Cast<N, T> = Extract<N, number> & T;
Casts a value into a specific numeric type. If the value is not a number, it
will resolve to never
, indicating its incompatibility with the type.
This is a low-level utility type that primarily serves as an internal helper for more user-friendly types like Integer and Positive. Unless you're building custom numeric types with your own branding, you most likely never directly handle this type in the wild.
N
T
Numbers
import type { Cast } from "jsr:@nick/is/number";
declare const MY_DOUBLE: unique symbol;
type DOUBLE<N extends number = number> = Cast<N, typeof MY_DOUBLE>;
let x = 4.3210123210 as DOUBLE;
let y = 3.1415926535 as DOUBLE;
console.log(x + y); // 7.4626049745
// This will raise a TypeScript compiler error:
x = 1; // <- TS2322 Type '1' is not assignable to type 'DOUBLE'.
export type CastInt<N, T> = Extract<N, bigint | `${bigint}`> & T;
Casts a value into a specific integer type. If the value is not a bigint, it
will resolve to never
, indicating its incompatibility with the type.
This is a low-level utility type that primarily serves as an internal helper for more user-friendly types like BigInteger or PositiveBigInteger. Unless you're building custom numeric types with your own branding, you most likely will never directly handle this type in the wild.
N
T
Numbers
import type { CastInt } from "jsr:@nick/is/number";
declare const INTEGER: unique symbol;
type INTEGER<N extends bigint = bigint> = CastInt<N, typeof INTEGER>;
let x = 3n as INTEGER;
let y = 5n as INTEGER;
console.log(x + y); // 8n
export type Derange =
| readonly [number, number, "[]"]
| readonly [number, "[]"]
| readonly [number, number, "[)"]
| readonly [number, "[)"]
| readonly [number, number, "(]"]
| readonly [number, "(]"]
| readonly [number, number, "()"]
| readonly [number, "()"]
| readonly [number, number, Exclusivity]
| readonly [number, Exclusivity];
export type Even<T extends Numeric = Numeric> = Cast<T, EVEN>;
Branded type representing an even number or bigint. Used by overloads of the
isEven
function to differentiate between
odd and even numbers.
-
T
extendsNumeric
(default:Numeric
)
Numeric
export type Exclusivity = AnyRange[2];
export type Finite<N = number> = Cast<N, FINITE>;
Casts a value into a finite type. If the value is not a number, it will resolve
to never
.
-
N
(default:number
)
Numbers
export type FiniteInteger<N = number> = Cast<N, FINITE & INTEGER>;
Casts a value into a finite integer type. If the value is not a number, it will
resolve to never
.
-
N
(default:number
)
Numbers
export type Float<N = number> = Cast<N, FLOAT>;
Casts a value into a floating-point type. If the value is not a number, it will
resolve to never
.
-
N
(default:number
)
Numbers
Types
float
number
import { type Float, isFloat } from "@nick/is/float";
let x = 1.5 as Float, y = 0;
if (isFloat(x)) {
console.log(x);
} else {
console.log(y);
}
// This will raise a TypeScript compiler error:
x = 1; // <- TS2322 Type '1' is not assignable to type 'Float'.
export type Float16<N = number> = Cast<N, FLOAT16>;
Casts a value into a 16-bit floating-point type (half-precision).
-
N
(default:number
)
Numbers
Types
float16
number
import { type Float16, isFloat16 } from "@nick/is/float16";
let i = 1.5 as Float16, y = 0;
if (isFloat16(i)) {
console.log(i);
} else {
console.log(y);
}
// This will raise a TypeScript compiler error:
i = 1; // <- TS2322 Type '1' is not assignable to type 'Float16'.
export type Float32<N = number> = Cast<N, FLOAT32>;
Casts a value into a floating-point type. If the value is not a number, it will
resolve to never
.
-
N
(default:number
)
Numbers
Types
float32
number
import { type Float32, isFloat32 } from "@nick/is/float32";
let x = 1.5 as Float32, y = 0;
if (isFloat32(x)) {
console.log(x);
} else {
console.log(y);
}
// This will raise a TypeScript compiler error:
x = 1; // <- TS2322 Type '1' is not assignable to type 'Float32'.
export type Float64<N = number> = Cast<N, FLOAT64>;
Casts a value into a float64-precision floating-point type. If the value is not
a number, it will resolve to never
.
-
N
(default:number
)
Numbers
Types
float64
number
import { type Float64, isFloat64 } from "jsr:@type/number/float64";
let x = 1.5 as Float64, y = 0;
if (isFloat64(x)) {
console.log(x);
} else {
console.log(y);
}
// This will raise a TypeScript compiler error:
x = 1; // <- TS2322 Type '1' is not assignable to type 'Float64'.
export type Infinity = PositiveInfinity | NegativeInfinity;
Special type representing either positive or negative infinity.
Numbers
types
number
infinity
export type InRange<
N extends number,
Min extends number = number,
Max extends number = number,
Tex extends Exclusivity = Exclusivity,
> =
& (number extends N ? IsInRange<Min, Max, Tex>
: `${Min}|${Max}` extends `-${number}|-${number}`
? `${N}` extends `-${number}` ? IsInRange<Min, Max, Tex> : never
: `${Min}|${Max}` extends `${number}|-${number}` ? never
: `${Min}|${Max}` extends `-${number}|${number}`
? `${N}` extends `-${number}` ? IsInRange<Min, Max, Tex> : never
: `${N}` extends `-${number}` ? never
: IsInRange<Min, Max, Tex>)
& N;
Type-level equivalent to the inRange
function, which (naively) checks if a number is within a given range. The range
can be specified in multiple ways, with one of four different exclusivity types.
-
N
extendsnumber
-
Min
extendsnumber
(default:number
) -
Max
extendsnumber
(default:number
) -
Tex
extendsExclusivity
(default:Exclusivity
)
-
inRange
for more information.
export type Int16<N = number> = Cast<N, INT16>;
Casts a value into a signed 16-bit integer type.
-
N
(default:number
)
Numbers
Types
int16
number
import { type Int16, isInt16, type MaybeInt16 } from "@nick/is/int16";
let value = 1 as Int16;
const setValue = (newValue: MaybeInt16) => {
if (isInt16(newValue)) value = newValue;
};
setValue(0x7FFF); // <- No error!
// This will raise a TypeScript compiler error:
value = -32769; // <- TS2322 Type '-32769' is not assignable to type 'Int16'.
export type Int32<N = number> = Cast<N, INT32>;
Casts a value into a signed 32-bit integer type.
-
N
(default:number
)
Numbers
Types
int32
number
import { type Int32, isInt32 } from "jsr:@type/number/int32";
let value = 1 as Int32;
const setValue = (newValue: Int32) => {
if (isInt32(newValue)) value = newValue;
};
setValue(0x7FFFFFFF); // <- No error!
// This will raise a TypeScript compiler error:
value = -2147483649; // <- TS2322 Type '-2147483649' is not assignable to type 'Int32'.
export type Int8<N = number> = Cast<N, INT8>;
Casts a value into a signed 8-bit integer type.
-
N
(default:number
)
Numbers
Types
int8
number
import { type Int8, isInt8 } from "@nick/is/int8";
let i = 1 as Int8, y = 0;
if (isInt8(i)) {
console.log(i);
} else {
console.log(y);
}
// This will raise a TypeScript compiler error:
i = 1.5; // <- TS2322 Type '1.5' is not assignable to type 'Int8'.
export type Integer<N = number> = N extends bigint
? `${N}` extends `${infer I extends number}` ? N & Integer<I> : never
: N extends number ? number extends N ? N & INTEGER
: `${N}` extends `${bigint}` ? N & INTEGER
: never
: never;
Casts a value into an integer type. If the value is not an number, or is a
non-integral number like 3.14, it will resolve to never
.
Note: once a value is cast to a type with this narrow of a constraint, TypeScript's compiler will refuse any assignment to it that is not exactly compatible with the type. If you find yourself encountering errors about incompatible types, try using the MaybeInteger type instead.
-
N
(default:number
)
Numbers
import { type Integer, isInteger } from "jsr:@type/number";
function add(a: Integer, b: Integer) {
return (a + b) as Integer;
}
let x = 1 as Integer, y = 2 as Integer, z = 3;
if (isInteger(z)) {
console.log(add(add(x, y), z));
} else {
console.log(add(x, y));
}
// These will raise TypeScript compiler errors:
add(x, z);
add(y, 3);
// This level of strictness can be a bit silly in the wrong application:
x = 1; // <- TS4321 (`MaybeInteger` would be a better choice here)
export type IsEven<T extends Numeric, True = T, False = never> = `${T}` extends
`${"" | bigint}${1 | 3 | 5 | 7 | 9}` ? True : False;
Type-level equivalent of isEven
, which
checks if a given numeric type (number or bigint) ends in an even number.
Returns True if so, and
False otherwise.
-
T
extendsNumeric
-
True
(default:T
) -
False
(default:never
)
Numeric
export type IsOdd<T extends Numeric, True = true, False = false> =
`${number}` extends `${T}` ? True
: `${bigint}` extends `${T}` ? True
: `${T}` extends `${infer _}${1 | 3 | 5 | 7 | 9}` ? True
: False;
Type-level equivalent of isOdd
, which
checks if a given numeric type (number or bigint) ends in an odd number. Returns
True if so, and
False otherwise.
-
T
extendsNumeric
-
True
(default:true
) -
False
(default:false
)
Numeric
export type MaybeFinite<N = number> = Cast<N, MAYBE_FINITE>;
Casts a value into a partial finite type. If the value is not a number, it will
resolve to never
.
-
N
(default:number
)
Numbers
export type MaybeFloat<N = number> = Cast<N, MAYBE_FLOAT>;
Casts a value into a partial floating-point type. If the value is not a number,
it will resolve to never
.
-
N
(default:number
)
Numbers
Types
maybe
float
number
import { isFloat, type MaybeFloat } from "@nick/is/float";
let x = 1.5 as MaybeFloat, y = 0;
if (isFloat(x)) {
console.log(x);
} else {
console.log(y);
}
y = 1; // <- No error! (this is the main difference from `Float`)
export type MaybeFloat16<N = number> = Cast<N, MAYBE_FLOAT16>;
Casts a value into a partial 16-bit floating-point type (half-precision).
-
N
(default:number
)
Numbers
Types
maybe
float16
number
export type MaybeFloat32<N = number> = Cast<N, MAYBE_FLOAT32>;
Casts a value into a partial floating-point type. If the value is not a number,
it will resolve to never
.
-
N
(default:number
)
Numbers
Types
maybe
float32
number
import { isFloat32, type MaybeFloat32 } from "@nick/is/float32";
let x = 1.5 as MaybeFloat32, y = 0;
if (isFloat32(x)) {
console.log(x);
} else {
console.log(y);
}
y = 1; // <- No error! (this is the main difference from `Float32`)
export type MaybeFloat64<N = number> = Cast<N, MAYBE_FLOAT64>;
Casts a value into a partial float64-precision floating-point type. If the value
is not a number, it will resolve to never
.
-
N
(default:number
)
Numbers
Types
maybe
float64
number
import { isFloat64, type MaybeFloat64 } from "jsr:@type/number/float64";
let x = 1.5 as MaybeFloat64, y = 0;
if (isFloat64(x)) {
console.log(x);
} else {
console.log(y);
}
y = 1; // <- No error! (this is the main difference from `Float64`)
export type MaybeInt16<N = number> = Cast<N, MAYBE_INT16>;
Casts a value into a partial signed 16-bit integer type.
-
N
(default:number
)
Numbers
Types
maybe
int16
number
import { type Int16, isInt16, type MaybeInt16 } from "@nick/is/int16";
let value = 1 as Int16;
const setValue = (newValue: MaybeInt16) => {
if (isInt16(newValue)) value = newValue;
};
setValue(0x7FFF); // <- No error!
value = -32769; // Error: Type '-32769' is not assignable to type 'Int16'.
export type MaybeInt32<N = number> = Cast<N, MAYBE_INT32>;
Casts a value into a partial signed 32-bit integer type.
-
N
(default:number
)
Numbers
Types
maybe
int32
number
import { isInt32, type MaybeInt32 } from "jsr:@type/number/int32";
let value = 1 as MaybeInt32;
const setValue = (newValue: MaybeInt32) => {
if (isInt32(newValue)) value = newValue;
};
setValue(0x7FFFFFFF); // <- No error!
value = -2147483649; // <- No error! (this is the main difference from `Int32`)
export type MaybeInt8<N = number> = Cast<N, MAYBE_INT8>;
Casts a value into a partial signed 8-bit integer type.
-
N
(default:number
)
Numbers
Types
maybe
int8
number
import { isInt8, type MaybeInt8 } from "@nick/is/int8";
let i = 1 as MaybeInt8, y = 0;
if (isInt8(i)) {
console.log(i);
} else {
console.log(y);
}
y = 1; // <- No error! (this is the main difference from `Int8`)
export type MaybeInteger<N = number> = N extends bigint
? `${N}` extends `${infer I extends number}` ? N & MaybeInteger<I> : never
: N extends number ? number extends N ? N & MAYBE_INTEGER
: `${N}` extends `${bigint}` ? N & MAYBE_INTEGER
: never
: never;
Casts a value into a partial integer type. If the value is not an number, or is
a non-integral number like 3.14, it will resolve to never
. This type is nearly
identical to Integer, except it allows
assignment of values that are not precisely compatible with the type, while
still providing an extra level of type safety over the base number
type.
Once a value is cast to a type of this constraint, TypeScript's compiler will refuse any incompatible assignment to it. To demonstrate, consider this example:
-
N
(default:number
)
Numbers
import {
isInteger,
type MaybeFloat,
type MaybeInteger,
} from "jsr:@type/number";
function add(a: MaybeInteger, b: MaybeInteger) {
return (a + b) as MaybeInteger;
}
let x = 1 as MaybeInteger, y = 2 as MaybeInteger, z = 3;
let xx = 1.1 as MaybeFloat, yy = 2.2 as MaybeFloat, zz = 3.3;
if (isInteger(z)) {
console.log(add(add(x, y), z));
} else {
console.log(add(x, y));
}
// These will raise TypeScript compiler errors:
add(x, yy); // <- TS2345 Type 'MaybeFloat' is not assignable to type 'MaybeInteger'.
y = yy; // <- TS2322 Type 'MaybeFloat' is not assignable to type 'MaybeInteger'.
y = 2; // <- No error! (this is the main difference from `Integer`)
export type MaybeNaN<N = number> = Cast<N, MAYBE_NAN>;
Casts a value into a partial NaN
type. This is a more forgiving form of the
NaN
type, which allows for the assignment of
other numeric values, but still retains the ability to distinguish itself from
generic numbers. This is often called a "Flavored" type, whereas the stricter
NaN
is known as a "Branded" type.
-
N
(default:number
)
Numbers
number
NaN
import { isNaN, type MaybeNaN } from "jsr:@type/number";
let x = NaN as MaybeNaN, y = 0;
if (isNaN(x)) {
console.log(x);
} else {
console.log(y);
}
y = NaN; // <- No error! (this is the main difference from `NaN`)
export type MaybeNegative<N = number> = Cast<N, MAYBE_NEGATIVE>;
Casts a value into a partial negative type. If the value is not a number, it
will resolve to never
.
-
N
(default:number
)
Types
Numbers
maybe
negative
number
import { isNegative, type MaybeNegative } from "jsr:@type/number";
let x = -1 as MaybeNegative, y = 0;
if (isNegative(x)) {
console.log(x);
} else {
console.log(y);
}
y = -1; // <- No error! (this is the main difference from `Negative`)
export type MaybeNegativeFinite<N = number> = Cast<N, MAYBE_NEGATIVE_FINITE>;
Casts a value into a partial negative finite type. If the value is not a number,
it will resolve to never
.
-
N
(default:number
)
Numbers
export type MaybeNegativeNonZero<N = number> = Cast<
N,
MAYBE_NEGATIVE & MAYBE_NON_ZERO
>;
Casts a value into a partial negative nonzero type. If the value is not a
number, it will resolve to never
.
-
N
(default:number
)
Numbers
export type MaybeNegativeNonZeroFinite<N = number> = Cast<
N,
MAYBE_NEGATIVE_NON_ZERO_FINITE
>;
Casts a value into a partial negative nonzero finite type. If the value is not a
number, it will resolve to never
.
-
N
(default:number
)
Numbers
export type MaybeNegativeZero<N = number> = Cast<N, MAYBE_NEGATIVE_ZERO>;
Casts a value into a partial negative zero type. If the value is not a number,
it will resolve to never
.
-
N
(default:number
)
Numbers
import { isNegativeZero, type MaybeNegativeZero } from "jsr:@type/number";
let x = -0 as MaybeNegativeZero, y = 0;
if (isNegativeZero(x)) {
console.log(x);
} else {
console.log(y);
}
y = -0; // <- No error! (this is the main difference from `NegativeZero`)
export type MaybeNonZero<N = number> = Cast<N, MAYBE_NON_ZERO>;
Casts a value into a partial nonzero type. If the value is not a number, it will
resolve to never
.
-
N
(default:number
)
Numbers
import { isNonZero, type MaybeNonZero } from "jsr:@type/number";
let x = 1 as MaybeNonZero, y = 0;
if (isNonZero(x)) {
console.log(x);
} else {
console.log(y);
}
y = 1; // <- No error! (this is the main difference from `NonZero`)
export type MaybeNonZeroFinite<N = number> = Cast<N, MAYBE_NON_ZERO_FINITE>;
Casts a value into a partial nonzero finite type. If the value is not a number,
it will resolve to never
.
-
N
(default:number
)
export type MaybePositive<N = number> = Cast<N, MAYBE_POSITIVE>;
Casts a value into a partial positive type. If the value is not a number, it
will resolve to never
.
-
N
(default:number
)
Numbers
Types
maybe
positive
number
import { isPositive, type MaybePositive } from "jsr:@type/number";
let x = 1 as MaybePositive, y = 0;
if (isPositive(x)) {
console.log(x);
} else {
console.log(y);
}
y = 1; // <- No error! (this is the main difference from `Positive`)
export type MaybePositiveFinite<N = number> = Cast<N, MAYBE_POSITIVE_FINITE>;
Casts a value into a partial positive finite type. If the value is not a number,
it will resolve to never
.
-
N
(default:number
)
Numbers
export type MaybePositiveNonZero<N = number> = Cast<
N,
MAYBE_POSITIVE & MAYBE_NON_ZERO
>;
Casts a value into a partial positive nonzero type. If the value is not a
number, it will resolve to never
.
-
N
(default:number
)
Numbers
export type MaybePositiveNonZeroFinite<N = number> = Cast<
N,
MAYBE_POSITIVE_NON_ZERO_FINITE
>;
Casts a value into a partial positive nonzero finite type. If the value is not a
number, it will resolve to never
.
-
N
(default:number
)
Numbers
export type MaybePositiveZero<N = number> = Cast<N, MAYBE_POSITIVE_ZERO>;
Casts a value into a partial positive zero type. If the value is not a number,
it will resolve to never
.
-
N
(default:number
)
Numbers
import { isPositiveZero, type MaybePositiveZero } from "jsr:@type/number";
let x = 0 as MaybePositiveZero, y = 1;
if (isPositiveZero(x)) {
console.log(x);
} else {
console.log(y);
}
y = 0; // <- No error! (this is the main difference from `PositiveZero`)
export type MaybeUint16<N = number> = Cast<N, MAYBE_UINT16>;
Casts a value into a partial unsigned 16-bit integer type.
-
N
(default:number
)
Numbers
Types
maybe
unsigned
integer
import { isUint16, type MaybeUint16, type Uint16 } from "@nick/is/number";
let value = 1 as Uint16;
const setValue = (newValue: MaybeUint16) => {
if (isUint16(newValue)) value = newValue;
};
setValue(0xFFFF); // <- No error!
// This will raise a TypeScript compiler error:
value = -1; // <- TS2322 Type '-1' is not assignable to type 'Uint16'.
export type MaybeUint32<N = number> = Cast<N, MAYBE_UINT32>;
Casts a value into a partial unsigned 32-bit integer type.
-
N
(default:number
)
Numbers
Types
maybe
unsigned
integer
import { isUint32, type MaybeUint32, type Uint32 } from "@nick/is/number";
let value = 1 as Uint32;
const setValue = (newValue: MaybeUint32) => {
if (isUint32(newValue)) value = newValue;
};
setValue(0xFFFF); // <- No error!
// This will raise a TypeScript compiler error:
value = -1; // <- TS2322 Type '-1' is not assignable to type 'Uint32'.
export type MaybeUint8<N = number> = Cast<N, MAYBE_UINT8>;
Casts a value into a partial unsigned 8-bit integer type.
-
N
(default:number
)
Numbers
Types
maybe
unsigned
integer
import { isUint8, type MaybeUint8 } from "@nick/is/uint8";
let i = 1 as MaybeUint8, y = 0;
if (isUint8(i)) {
console.log(i);
} else {
console.log(y);
}
y = 1; // <- No error! (this is the main difference from `Uint8`)
export type MaybeZero<N = number> = Cast<N, MAYBE_ZERO>;
Casts a value into a partial zero type. If the value is not a number, it will
resolve to never
.
-
N
(default:number
)
Numbers
import { isZero, type MaybeZero } from "jsr:@type/number";
let x = 0 as MaybeZero, y = 1;
if (isZero(x)) {
console.log(x);
} else {
console.log(y);
}
y = 0; // <- No error! (this is the main difference from `Zero`)
export type NaN<N = number> = Cast<N, NAN>;
Casts a value into a branded type that represents the special numeric value
NaN
(not a number). This is a very strict type, and it prevents any other type
from being assigned unless they pass the
isNaN
type guard. If the value is not a
subtype of number
, this will resolve to never
.
-
N
(default:number
)
Numbers
number
NaN
import { isNan, type NaN } from "jsr:@type/number";
let x = NaN as NaN, y = 0;
if (isNan(x)) {
console.log(x);
} else {
console.log(y);
}
// This will raise a TypeScript compiler error:
x = 0; // <- TS2322 Type '0' is not assignable to type 'NaN'.
export type Negative<N = number> = Cast<N, NEGATIVE>;
Casts a value into a negative type. If the value is not a number, it will
resolve to never
.
-
N
(default:number
)
Numbers
Types
negative
number
import { isNegative, type Negative } from "jsr:@type/number";
let x = -1 as Negative, y = 0;
if (isNegative(x)) {
console.log(x);
} else {
console.log(y);
}
// This will raise a TypeScript compiler error:
x = 0; // <- TS2322 Type '0' is not assignable to type 'Negative'.
export type NegativeBigInteger<N = bigint> = CastInt<N, NEGATIVE & INTEGER>;
Casts a value into a negative big integer type. If the value is not a bigint or
a string containing a valid integer, it will resolve to never
.
-
N
(default:bigint
)
Numbers
export type NegativeFinite<N = number> = Cast<N, NEGATIVE_FINITE>;
Casts a value into a negative finite type. If the value is not a number, it will
resolve to never
.
-
N
(default:number
)
Numbers
export type NegativeFiniteInteger<N = number> = Cast<
N,
NEGATIVE & FINITE & INTEGER
>;
Casts a value into a negative finite integer type. If the value is not a number,
it will resolve to never
.
-
N
(default:number
)
Numbers
export type NegativeInfinity = -Infinity;
Special type representing negative infinity (Number.NEGATIVE_INFINITY
).
Numbers
types
number
infinity
negative
export type NegativeInteger<N = number> = Cast<N, NEGATIVE & INTEGER>;
Casts a value into a negative integer type. If the value is not a number, it
will resolve to never
.
-
N
(default:number
)
Numbers
export type NegativeNonZero<N = number> = Cast<N, NEGATIVE & NON_ZERO>;
Casts a value into a negative nonzero type. If the value is not a number, it
will resolve to never
.
-
N
(default:number
)
Numbers
export type NegativeNonZeroFinite<N = number> = Cast<
N,
NEGATIVE_NON_ZERO_FINITE
>;
Casts a value into a negative nonzero finite type. If the value is not a number,
it will resolve to never
.
-
N
(default:number
)
Numbers
export type NegativeNonZeroFiniteInteger<N = number> = Cast<
N,
NEGATIVE & NON_ZERO & FINITE & INTEGER
>;
Casts a value into a negative nonzero finite integer type. If the value is not a
number, it will resolve to never
.
-
N
(default:number
)
Numbers
export type NegativeNonZeroInteger<N = number> = Cast<
N,
NEGATIVE & NON_ZERO & INTEGER
>;
Casts a value into a negative nonzero integer type. If the value is not a
number, it will resolve to never
.
-
N
(default:number
)
Numbers
export type NegativeZero<N = number> = Cast<N, NEGATIVE_ZERO>;
Casts a value into a negative zero type. If the value is not a number, it will
resolve to never
.
-
N
(default:number
)
Numbers
import { isNegativeZero, type NegativeZero } from "jsr:@type/number";
let x = -0 as NegativeZero, y = 0;
if (isNegativeZero(x)) {
console.log(x);
} else {
console.log(y);
}
// This will raise a TypeScript compiler error:
x = 0; // <- TS2322 Type '0' is not assignable to type 'NegativeZero'.
export type NonZero<N = number> = Cast<N, NON_ZERO>;
Casts a value into a nonzero type. If the value is not a number, it will resolve
to never
.
-
N
(default:number
)
Numbers
import { isNonZero, type NonZero } from "jsr:@type/number";
let x = 1 as NonZero, y = 0;
if (isNonZero(x)) {
console.log(x);
} else {
console.log(y);
}
// This will raise a TypeScript compiler error:
x = 0; // <- TS2322 Type '0' is not assignable to type 'NonZero'.
export type NonZeroFinite<N = number> = Cast<N, NON_ZERO_FINITE>;
Casts a value into a nonzero finite type. If the value is not a number, it will
resolve to never
.
-
N
(default:number
)
Numbers
export type NonZeroFiniteInteger<N = number> = Cast<
N,
NON_ZERO & FINITE & INTEGER
>;
Casts a value into a nonzero finite integer type. If the value is not a number,
it will resolve to never
.
-
N
(default:number
)
Numbers
export type NonZeroInteger<N = number> = Cast<N, NON_ZERO & INTEGER>;
Casts a value into a nonzero integer type. If the value is not a number, it will
resolve to never
.
-
N
(default:number
)
Numbers
export type Numeric = number | bigint | `${number | bigint}`;
export type Odd<T = number> = Cast<
IsOdd<Extract<T, Numeric>, Extract<T, Numeric>, never>,
ODD
>;
Branded type representing an odd number. Used by overloads of the
isOdd
function to differentiate between
odd and even numbers.
-
T
(default:number
)
Numeric
export type Positive<N = number> = Cast<N, POSITIVE>;
Casts a value into a positive type. If the value is not a number, it will
resolve to never
.
-
N
(default:number
)
Numbers
Types
positive
number
import { isPositive, type Positive } from "jsr:@type/number";
let x = 1 as Positive, y = 0;
if (isPositive(x)) {
console.log(x);
} else {
console.log(y);
}
// This will raise a TypeScript compiler error:
x = 0; // <- TS2322 Type '0' is not assignable to type 'Positive'.
export type PositiveBigInteger<N = bigint> = CastInt<N, POSITIVE & INTEGER>;
Casts a value into a positive big integer type. If the value is not a bigint or
a string containing a valid integer, it will resolve to never
.
-
N
(default:bigint
)
Numbers
export type PositiveFinite<N = number> = Cast<N, POSITIVE_FINITE>;
Casts a value into a positive finite type. If the value is not a number, it will
resolve to never
.
-
N
(default:number
)
Numbers
export type PositiveFiniteInteger<N = number> = Cast<
N,
POSITIVE & FINITE & INTEGER
>;
Casts a value into a positive finite integer type. If the value is not a number,
it will resolve to never
.
-
N
(default:number
)
Numbers
export type PositiveInfinity = Infinity;
Special type representing positive infinity (Number.POSITIVE_INFINITY
).
Numbers
types
number
infinity
positive
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
export type PositiveNonZero<N = number> = Cast<N, POSITIVE & NON_ZERO>;
Casts a value into a positive nonzero type. If the value is not a number, it
will resolve to never
.
-
N
(default:number
)
Numbers
export type PositiveNonZeroFinite<N = number> = Cast<
N,
POSITIVE_NON_ZERO_FINITE
>;
Casts a value into a positive nonzero finite type. If the value is not a number,
it will resolve to never
.
-
N
(default:number
)
Numbers
export type PositiveNonZeroFiniteInteger<N = number> = Cast<
N,
POSITIVE & NON_ZERO & FINITE & INTEGER
>;
Casts a value into a positive nonzero finite integer type. If the value is not a
number, it will resolve to never
.s
-
N
(default:number
)
Numbers
export type PositiveNonZeroInteger<N = number> = Cast<
N,
POSITIVE & NON_ZERO & INTEGER
>;
Casts a value into a positive nonzero integer type. If the value is not a
number, it will resolve to never
.
-
N
(default:number
)
Numbers
export type PositiveZero<N = number> = Cast<N, POSITIVE_ZERO>;
Casts a value into a positive zero type. If the value is not a number, it will
resolve to never
.
-
N
(default:number
)
Numbers
import { isPositiveZero, type PositiveZero } from "jsr:@type/number";
let x = 0 as PositiveZero, y = 1;
if (isPositiveZero(x)) {
console.log(x);
} else {
console.log(y);
}
// This will raise a TypeScript compiler error:
x = 1; // <- TS2322 Type '1' is not assignable to type 'PositiveZero'.
export type Range<
Min extends number = number,
Max extends number = number,
Tex extends Exclusivity = never,
> = [Tex] extends [never] ?
| RangeInclusiveMin<Min, Max>
| RangeInclusive<Min, Max>
| RangeInclusiveMax<Min, Max>
| RangeExclusive<Min, Max>
| RangeUnknown<Min, Max>
: Either<
Extract<Range<Min, Max, never>, Required<RangeUnknown<Min, Max, Tex>>>,
RangeUnknown<Min, Max, Exclusivity>
>;
-
Min
extendsnumber
(default:number
) -
Max
extendsnumber
(default:number
) -
Tex
extendsExclusivity
(default:never
)
export type RangeExclusive<
Min extends number = number,
Max extends number = number,
> = readonly [Min, Max, "()"] | readonly [Max, "()"];
-
Min
extendsnumber
(default:number
) -
Max
extendsnumber
(default:number
)
export type RangeInclusive<
Min extends number = number,
Max extends number = number,
> = readonly [Min, Max, "[]"] | readonly [Max, "[]"];
-
Min
extendsnumber
(default:number
) -
Max
extendsnumber
(default:number
)
export type RangeInclusiveMax<
Min extends number = number,
Max extends number = number,
> = readonly [Min, Max, "(]"] | readonly [Max, "(]"];
-
Min
extendsnumber
(default:number
) -
Max
extendsnumber
(default:number
)
export type RangeInclusiveMin<
Min extends number = number,
Max extends number = number,
> = readonly [Min, Max, "[)"] | readonly [Max, "[)"];
-
Min
extendsnumber
(default:number
) -
Max
extendsnumber
(default:number
)
export type RangeUnknown<
Min extends number = number,
Max extends number = number,
Tex extends Exclusivity = Exclusivity,
> = readonly [Min, Max, Tex] | readonly [Max, Tex];
-
Min
extendsnumber
(default:number
) -
Max
extendsnumber
(default:number
) -
Tex
extendsExclusivity
(default:Exclusivity
)
export type Uint16<N = number> = Cast<N, UINT16>;
Casts a value into an unsigned 16-bit integer type.
-
N
(default:number
)
Numbers
Types
unsigned
integer
import { isUint16, type MaybeUint16, type Uint16 } from "@nick/is/number";
let value = 1 as Uint16;
const setValue = (newValue: MaybeUint16) => {
if (isUint16(newValue)) value = newValue;
};
setValue(0xFFFF); // <- No error!
// This will raise a TypeScript compiler error:
value = -1; // <- TS2322 Type '-1' is not assignable to type 'Uint16'.
export type Uint32<N = number> = Cast<N, UINT32>;
Casts a value into an unsigned 32-bit integer type.
-
N
(default:number
)
Numbers
Types
unsigned
integer
import { isUint32, type MaybeUint32, type Uint32 } from "@nick/is/number";
let value = 1 as Uint32;
const setValue = (newValue: MaybeUint32) => {
if (isUint32(newValue)) value = newValue;
};
setValue(0xFFFF); // <- No error!
// This will raise a TypeScript compiler error:
value = -1; // <- TS2322 Type '-1' is not assignable to type 'Uint32'.
export type Uint8<N = number> = Cast<N, UINT8>;
Casts a value into an unsigned 8-bit integer type.
-
N
(default:number
)
Numbers
Types
unsigned
integer
import { isUint8, type Uint8 } from "@nick/is/uint8";
let i = 1 as Uint8, y = 0;
if (isUint8(i)) {
console.log(i);
} else {
console.log(y);
}
// This will raise a TypeScript compiler error:
i = -1; // <- TS2322 Type '-1' is not assignable to type 'Uint8'.
export type Unwrap<U> = U extends Cast<infer N, infer T> ? [N, T] : [U, never];
Unwraps a type that has been cast with Cast
into a tuple of the original value and the specific type it was cast to (or
"branded" with). If the given type was not cast with
Cast, it will resolve to a tuple containing
the original value and never
, respectively.
U
Numbers
import type { Cast, Unwrap } from "jsr:@nick/is/number";
type Int_3 = Cast<3, INTEGER>;
function unwrap<T>(value: T): Unwrap<T>[0] {
return value as Unwrap<T>[0];
}
export type Zero<N = number> = Cast<N, ZERO>;
Casts a value into a zero type. If the value is not a number, it will resolve to
never
.
-
N
(default:number
)
Numbers
import { isZero, type Zero } from "jsr:@type/number/zero";
let x = 0 as Zero, y = 1;
if (isZero(x)) {
console.log(x);
} else {
console.log(y);
}
// This will raise a TypeScript compiler error:
x = 1; // <- TS2322 Type '1' is not assignable to type 'Zero'.
readonly IS_EVEN: true;
readonly IS_INFINITE: false;
readonly IS_FINITE: true;
readonly IS_FLOAT: true;
readonly PRECISION: 0.5;
readonly PRECISION: 1;
readonly PRECISION: 2;
readonly IS_FINITE: false;
readonly IS_INFINITE: true;
readonly BIT_LENGTH: 16;
readonly BIT_LENGTH: 32;
readonly BIT_LENGTH: 64;
readonly BIT_LENGTH: 8;
readonly IS_INTEGER: true;
-
Min
extendsnumber
(default:number
) -
Max
extendsnumber
(default:number
) -
Tex
extendsExclusivity
(default:Exclusivity
)
readonly RANGE: readonly [Min,Max,Tex];
readonly IS_EVEN?: true;
readonly IS_INFINITE?: false;
readonly IS_FINITE?: true;
readonly IS_FLOAT?: true;
readonly PRECISION?: 0.5;
readonly PRECISION?: 1;
readonly PRECISION?: 2;
readonly IS_FINITE?: false;
readonly IS_INFINITE?: true;
readonly BIT_LENGTH?: 16;
readonly BIT_LENGTH?: 32;
readonly BIT_LENGTH?: 64;
readonly BIT_LENGTH?: 8;
readonly IS_INTEGER?: true;
readonly IS_NAN?: true;
readonly IS_POSITIVE?: false;
readonly IS_NEGATIVE?: true;
readonly IS_ZERO?: false;
readonly IS_NON_ZERO?: true;
readonly IS_ODD?: true;
readonly IS_NEGATIVE?: false;
readonly IS_POSITIVE?: true;
readonly IS_UNSIGNED?: true;
readonly IS_NON_ZERO?: false;
readonly IS_ZERO?: true;
readonly IS_NAN: true;
readonly IS_POSITIVE: false;
readonly IS_NEGATIVE: true;
readonly IS_ZERO: false;
readonly IS_NON_ZERO: true;
readonly IS_ODD: true;
readonly IS_NEGATIVE: false;
readonly IS_POSITIVE: true;
readonly IS_UNSIGNED: true;
readonly IS_NON_ZERO: false;
readonly IS_ZERO: true;