21 lines
424 B
JavaScript
Executable File
21 lines
424 B
JavaScript
Executable File
'use strict';
|
|
|
|
import bankersRounding from "bankers-rounding";
|
|
|
|
const isNumeric = (num) => {
|
|
if (num === null && typeof num === "object") return false;
|
|
return !isNaN(num);
|
|
};
|
|
|
|
const roundTo = (num, places, type = 'bankers') => {
|
|
if (type == 'bankers') {
|
|
return bankersRounding(num, places);
|
|
}
|
|
return +(Math.round(num + "e+" + places) + "e-" + places);
|
|
};
|
|
|
|
export default {
|
|
isNumeric,
|
|
roundTo,
|
|
}
|