Set of simple math utilities.
$ npm install --save math-functions
// import a specific function
import { random } from 'math-functions';
// or everything at once
import * as mathUtils from 'math-functions';
const value = random(0, 50, true);
const mapped = mathUtils.map(24, 0, 100, 0, 1);
(alias of getRandomValueInRange
)
Get a random value in the given [min
, max
] range.
round
is false
by default.
(alias of mapValueToRange
)
Map val
from range [inMin
, inMax
] to [outMin
, outMax
] range.
(alias of isPowerOfTwo
)
Returns true
if val
is a power of two, false
otherwise.
MIT, see LICENSE.md for more details.