3.0.0 - 2021-02-04
Num.isNumber(input)
method determining whether the giveninput
is a numberNum.isNotInteger(input)
method determining whether the giveninput
is not an integerNum(123).isInRange(min, max)
method determining whether the given number is in the range betweenmin
andmax
- bump dependencies
- change
main
entrypoint inpackage.json
todist
folder - move test runner from
@hapi/lab
tojest
- move assertions from
@hapi/code
tojest
- this package does not export the
Number
readonly properties (e.g.MAX_VALUE
, etc.) anymore. Please use the globalNumber
object instead- that means, you must use the global
Number
object for number parsing, likeNumber.parseInt('1')
instead ofNum.parseInt('1')
- that means, you must use the global
- remove
index.js
file which acted as a middleman to export fromdist
folder - remove
index.js
file which acted as a middleman to export fromdist
folder
Starting in version 3.0
, this package does not export a class extending Number
. Instead, this package exports a function,
like the global Number
object does. You’ll find helpful methods on the default export, like Num.isInteger(123)
helping
you seamlessly interact with numbers. Wrapping a number like Num(123)
returns an extended Number
instance. This Number
instance extends the Number
class with helpful methods, like isInRange(min, max)
.
Usage
const Num = require('@supercharge/numbers')
/**
* before (v2)
*/
// retrieving the actual number value
new Num(123) // returns 123
// accessing readonly properties
Num.MAX_VALUE
/**
* now (v3)
*/
// retrieving the actual number value
Num(123).get() // returns 123
// access readonly properties using the global `Number` object
Num.MAX_VALUE // undefined
Number.MAX_VALUE // the “MAX_VALUE”
2.0.0 - 2020-07-27
isDecimal(number)
method to determine whether the givennumber
is a number with decimal places- options as the third parameters to all methods generating random integers
- the options object currently allow the
except
property to exclude an array of numbers when generating a random number. Example:Num.randomIntWithin(10, 20, { except: [14, 15] })
- the options object currently allow the
- move code to TypeScript to automatically generate Typings
Well, the previous version had two similar methods (randomInt
and randomIntInRange
). While randomIntInRange
accepted an options object, randomInt
did not. The randomInt
method was removed in favor of randomIntWithin
.
- Renamed methods:
allIntInRange
is nowallIntWithin
randomIntInRange
is nowrandomIntWithin
- removed
randomInt
method in favor ofrandomIntWithin
because it has a more explicite naming
1.1.0 - 2020-02-11
- extend native
Number
class to make all existing Number methods available .allIntInRange(min, max)
method to generate a list of integers between min and max.randomIntInRange(min, max, { except = [] })
method to retrieve a random integer in range
1.0.0
release 🚀 🎉