A set of utility functions related to math or numbers.
Add @aceworks-studio/math
in your dependencies:
yarn add @aceworks-studio/math
Or if you are using npm
:
npm install @aceworks-studio/math
function isFinite(value: number): boolean
Returns true
if the number not equal to infinity (or negative infinity) or NaN
.
function isInteger(value: number): boolean
Returns true
if the number is finite and a whole number (no decimal part).
function isSafeInteger(value: number): boolean
Returns true
if the number is finite, a whole number (no decimal part) and no other number rounds to it.
function isNaN(value: number): boolean
Returns true
if the number is NaN
.
function lerp(initialValue: number, finalValue: number, alpha: number): number
Returns a number interpolated between an initial value and a final value using a number alpha
between 0 and 1.
function round(value: number, decimals: number?): number
Returns a number rounded with the given decimals, or rounded to the nearest integer.
This project is available under the MIT license. See LICENSE.txt for details.
If you would like to use this library on a Lua environment where it is currently incompatible, open an issue (or comment on an existing one) to request the appropriate modifications.
The library uses darklua to process its code.