1.0.3 • Published 7 years ago
numery v1.0.3
Numery
Numery is a collection of useful helper functions for numbers manipulation in Javascript
Installation
yarn add numeryUsage
const { isValidNumber } = require('numery')Contents
For Numbers in General
isValidNumber
- Signature:
isValidNumber(x: Any) => boolean - Verify that the given argument data type is in fact a valid number.
- A valid number is any number between
[-Infinity, Infinity], including the infinities, but notNaN. - To exclude infinities, use
isFiniteNumber(x)instead - Return
trueif a valid number.falseotherwise.
isEvenNumber
- Signature:
isEvenNumber(x: Any) => boolean - Verify if the argument is an even number.
- Return
trueif even.falseotherwise.
isOddNumber
- Signature:
isOddNumber(x: Any) => boolean - Verify if the argument is an odd number.
- Return
trueif odd.falseotherwise.
isFiniteNumber
- Signature:
isFiniteNumber(x: Any) => boolean - Verify that the argument is in fact a finite number.
- A finite number is a valid number that is not an infinity (+ or -).
- Return
trueif a finite number.falseotherwise.
isFinitePositiveNumber
- Signature:
isFinitePositiveNumber(x: Any) => boolean - Verify that the argument is in fact a finite and positive number, including
0 - A finite number is a valid number that is not an infinity (+ or -).
- Return
trueif a finite positive number.falseotherwise.
isStrictFinitePositiveNumber
- Signature:
isStrictFinitePositiveNumber(x: Any) => boolean - Verify that the argument is in fact a finite and strictly positive number, not including
0 - A finite number is a valid number that is not an infinity (+ or -).
- Return
trueif a strict finite positive number.falseotherwise.
isFiniteNegativeNumber
- Signature:
isFiniteNegativeNumber(x: Any) => boolean - Verify that the argument is in fact a finite and negative number
- A finite number is a valid number that is not an infinity (+ or -).
- Return
trueif a finite negative number.falseotherwise.
isNumberMultipleOf
- Signature:
isNumberMultipleOf(x: Any, y: Any) => boolean - Verify if the first argument is a multiple of the second argument.
- NOTE: Second argument must be a strict positive number. return false otherwise.
- Return
trueif multiple.falseotherwise.
For Integers
isInteger
- Signature:
isInteger(x: Any) => boolean - Verify if a given number is a valid integer.
- Infinities are not integers.
- Return
trueif an integer.falseotherwise.
isPositiveInteger
- Signature:
isPositiveInteger(x: Any) => boolean - Verify if a given number is a valid positive integer, including 0.
- Return
trueif a positive integer.falseotherwise.
isStrictPositiveInteger
- Signature:
isStrictPositiveInteger(x: Any) => boolean - Verify if a given number is a valid positive integer, strictly not equal to
0. - Return
trueif a strict positive integer.falseotherwise.
isNegativeInteger
- Signature:
isNegativeInteger(x: Any) => boolean - Verify if a given number is a valid negative integer.
- Return
trueif a negative integer.falseotherwise.