UNPKG

585 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.prettyNumber = exports.clamp = void 0;
4/**
5 * Clamp number within the inclusive range within the lower and upper bounds.
6 */
7function clamp(v, lower, upper) {
8 return Math.max(lower, Math.min(v, upper));
9}
10exports.clamp = clamp;
11/**
12 * Precision conversion
13 */
14function prettyNumber(n, precision = 10) {
15 if (typeof n !== 'number')
16 return n;
17 return Math.abs(n) < 1e-15 ? n : parseFloat(n.toFixed(precision));
18}
19exports.prettyNumber = prettyNumber;
20//# sourceMappingURL=number.js.map
\No newline at end of file