@newdash/newdash
Version:
javascript/typescript utility library
40 lines (39 loc) • 894 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.round = void 0;
const createRound_1 = __importDefault(require("./.internal/createRound"));
/**
* @internal
* @private
* @ignore
*/
const internal = (0, createRound_1.default)("round");
/**
* Computes `number` rounded to `precision`.
*
* @since 4.7.0
* @category Math
* @param num The number to round down.
* @param precision The precision to round down to.
* @returns Returns the rounded down number.
* @example
*
* ```js
* round(4.006)
* // => 4
*
* round(4.006, 2)
* // => 4.01
*
* round(4060, -2)
* // => 4100
* ```
*/
function round(num, precision = 0) {
return internal(num, precision);
}
exports.round = round;
exports.default = round;