UNPKG

@intuit/judo

Version:

Test command line interfaces.

19 lines (14 loc) 673 B
"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.truncateAfterDecimal = exports.truncate = void 0;const truncate = (number, length) => { const str = number.toString(); let truncateLength = length; if (str.indexOf('.') !== -1) { truncateLength += 1; } const truncated = str.slice(0, truncateLength); return parseFloat(truncated); };exports.truncate = truncate; const truncateAfterDecimal = (number, digits) => { const re = new RegExp('(\\d+\\.\\d{' + digits + '})(\\d)'); const m = number.toString().match(re); return m ? parseFloat(m[1]) : number.valueOf(); };exports.truncateAfterDecimal = truncateAfterDecimal;