12345678910111213141516171819202122 |
- /*!
- * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
- * v1.0.0-beta.97
- */
- 'use strict';
- 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;
|