the-math
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -12,3 +12,3 @@ export interface IRoundOptions { | ||
type?: 'floor' | 'ceil' | 'round'; | ||
decimal?: number; | ||
precision?: number; | ||
} | ||
@@ -15,0 +15,0 @@ export interface IChainOptions { |
@@ -51,3 +51,3 @@ "use strict"; | ||
roundType: ((_a = options === null || options === void 0 ? void 0 : options.round) === null || _a === void 0 ? void 0 : _a.type) || ((_b = globalOptions.round) === null || _b === void 0 ? void 0 : _b.type), | ||
decimal: ((_c = options === null || options === void 0 ? void 0 : options.round) === null || _c === void 0 ? void 0 : _c.decimal) || ((_d = globalOptions.round) === null || _d === void 0 ? void 0 : _d.decimal) | ||
precision: ((_c = options === null || options === void 0 ? void 0 : options.round) === null || _c === void 0 ? void 0 : _c.precision) || ((_d = globalOptions.round) === null || _d === void 0 ? void 0 : _d.precision) | ||
}; | ||
@@ -54,0 +54,0 @@ } |
export default function round(operation: { | ||
number: number; | ||
}, { decimal, roundType }: { | ||
decimal?: number; | ||
}, { precision, roundType }: { | ||
precision?: number; | ||
roundType?: 'floor' | 'ceil' | 'round'; | ||
}): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function round(operation, _a) { | ||
var _b = _a.decimal, decimal = _b === void 0 ? 0 : _b, _c = _a.roundType, roundType = _c === void 0 ? 'round' : _c; | ||
var _b = _a.precision, precision = _b === void 0 ? 0 : _b, _c = _a.roundType, roundType = _c === void 0 ? 'round' : _c; | ||
if (roundType === 'floor') { | ||
operation.number = | ||
Math.floor(operation.number * Math.pow(10, decimal)) / Math.pow(10, decimal); | ||
Math.floor(operation.number * Math.pow(10, precision)) / Math.pow(10, precision); | ||
} | ||
if (roundType === 'ceil') { | ||
operation.number = | ||
Math.ceil(operation.number * Math.pow(10, decimal)) / Math.pow(10, decimal); | ||
Math.ceil(operation.number * Math.pow(10, precision)) / Math.pow(10, precision); | ||
} | ||
if (roundType === 'round') { | ||
operation.number = | ||
Math.round(operation.number * Math.pow(10, decimal)) / Math.pow(10, decimal); | ||
Math.round(operation.number * Math.pow(10, precision)) / Math.pow(10, precision); | ||
} | ||
} | ||
exports.default = round; |
{ | ||
"name": "the-math", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "Core of TheMath Calculator", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
34638