Skip to content

Number ​

The Number module provides a set of utility functions for working with numbers in JavaScript/TypeScript. These functions allow you to perform common operations such as checking number types, testing mathematical properties, and executing numerical calculations.

All functions are designed to be simple, efficient, and easy to use, following best development practices.

Overview ​

divisors ​

typescript
divisors(value: number): number[]

Returns all positive integer divisors of a number.

inRange ​

typescript
inRange(value: number, min: number, max: number): boolean

Checks if a number is within an inclusive range.

isEven ​

typescript
isEven(value: number): boolean

Checks if a number is even.

isFinite ​

typescript
isFinite(value: number): boolean

Checks if a value is a finite number.

isFloat ​

typescript
isFloat(value: number): boolean

Checks if a value is a finite floating-point number.

isInfinity ​

typescript
isInfinity(value: number): boolean

Checks if a value is positive or negative infinity.

isInteger ​

typescript
isInteger(value: number): boolean

Checks if a value is a finite integer.

isNaN ​

typescript
isNaN(value: any): boolean

Checks if a value is NaN (Not-a-Number).

isNegative ​

typescript
isNegative(value: number): boolean

Checks if a number is negative.

isOdd ​

typescript
isOdd(value: number): boolean

Checks if a number is odd.

isPositive ​

typescript
isPositive(value: number): boolean

Checks if a number is positive.

isPrime ​

typescript
isPrime(value: number): boolean

Checks if an integer is prime.

range

typescript
range(start: number, end: number, step?: number): number[]

Creates an array of numbers within a specified range, with a defined step.

sumOfDigits ​

typescript
sumOfDigits(value: number): number

Returns the sum of the digits of a number.

Released under the MIT License.