
This is a collection of functions for working with numbers.
The getAbsoluteNumber function returns the absolute value of a number.
import { getAbsoluteNumber } from '@aracna/core';
// will log 1
console.log(getAbsoluteNumber(-1));The getFixedNumber function returns a number with a fixed number of decimals.
import { getFixedNumber } from '@aracna/core';
// will log 2.5
console.log(getFixedNumber(2.51, 1));The getNumbersDistance function returns the distance between two numbers.
import { getNumbersDistance } from '@aracna/core';
// will log 2
console.log(getNumbersDistance(3, 5));The getLimitedNumber function returns a number between a minimum and a maximum.
import { getLimitedNumber } from '@aracna/core';
// will log 3
console.log(getLimitedNumber(5, { max: 3 }));The getNumberPercentage function returns the percentage of a number. Optionally the percentage can be rounded.
import { getNumberPercentage } from '@aracna/core';
// will log 75%
console.log(getNumberPercentage(75));The getHighestNumber function returns the highest number in an array of numbers.
import { getHighestNumber } from '@aracna/core';
// will log 2
console.log(getHighestNumber(0, 1, 2));The getLowestNumber function returns the lowest number in an array of numbers.
import { getLowestNumber } from '@aracna/core';
// will log 0
console.log(getLowestNumber(0, 1, 2));The parseBigInt function returns a bigint from an unknown value.
import { parseBigInt } from '@aracna/core';
// will log 1n
console.log(parseBigInt('1'));The parseNumber function returns a number from an unknown value.
import { parseNumber } from '@aracna/core';
// will log 5
console.log(parseNumber('5'));
// will log 2.5
console.log(parseNumber('2.5'));The isNumberEven function checks if a number is even.
import { isNumberEven } from '@aracna/core';
// will log true
console.log(isNumberEven(0));The isNumberOdd function checks if a number is odd.
import { isNumberOdd } from '@aracna/core';
// will log true
console.log(isNumberOdd(1));The isNumberMultipleOf function checks if a number is multiple of another number.
import { isNumberMultipleOf } from '@aracna/core';
// will log true
console.log(isNumberMultipleOf(4, 2));