UNPKG

@stokr/components-library

Version:

STOKR - Components Library

13 lines (12 loc) 510 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.fixDecimals = exports.default = void 0; // Convert to float; fix decimals; convert to string; return const fixDecimals = function (value, decimals) { let roundingFn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Math.round; return (roundingFn(Number(value) * 10 ** decimals) / 10 ** decimals).toFixed(decimals); }; exports.fixDecimals = fixDecimals; var _default = exports.default = fixDecimals;