@esri/calcite-components
Version:
Web Components for Esri's Calcite Design System.
22 lines (19 loc) • 646 B
JavaScript
/*!
* All material copyright ESRI, All Rights Reserved, unless otherwise specified.
* See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
*/
;
const clamp = (value, min, max) => Math.max(min, Math.min(value, max));
const decimalPlaces = (value) => {
const match = ("" + value).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);
if (!match) {
return 0;
}
return Math.max(0,
// Number of digits right of decimal point.
(match[1] ? match[1].length : 0) -
// Adjust for scientific notation.
(match[2] ? +match[2] : 0));
};
exports.clamp = clamp;
exports.decimalPlaces = decimalPlaces;