UNPKG

ng-zorro-antd-yj

Version:

An enterprise-class UI components based on Ant Design and Angular

42 lines 2.68 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @param {?} min * @param {?} max * @param {?} value * @return {?} */ export function getPercent(min, max, value) { return ((value - min) / (max - min)) * 100; } /** * @param {?} num * @return {?} */ export function getPrecision(num) { /** @type {?} */ var numStr = num.toString(); /** @type {?} */ var dotIndex = numStr.indexOf('.'); return dotIndex >= 0 ? numStr.length - dotIndex - 1 : 0; } /** * @param {?} num * @param {?} min * @param {?} max * @return {?} */ export function ensureNumberInRange(num, min, max) { if (isNaN(num) || num < min) { return min; } else if (num > max) { return max; } else { return num; } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnVtYmVyLmpzIiwic291cmNlUm9vdCI6Im5nOi8vbmctem9ycm8tYW50ZC15ai8iLCJzb3VyY2VzIjpbImNvcmUvdXRpbC9udW1iZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7OztBQUFBLE1BQU0sVUFBVSxVQUFVLENBQUMsR0FBVyxFQUFFLEdBQVcsRUFBRSxLQUFhO0lBQ2hFLE9BQU8sQ0FBQyxDQUFDLEtBQUssR0FBRyxHQUFHLENBQUMsR0FBRyxDQUFDLEdBQUcsR0FBRyxHQUFHLENBQUMsQ0FBQyxHQUFHLEdBQUcsQ0FBQztBQUM3QyxDQUFDOzs7OztBQUVELE1BQU0sVUFBVSxZQUFZLENBQUMsR0FBVzs7UUFDaEMsTUFBTSxHQUFHLEdBQUcsQ0FBQyxRQUFRLEVBQUU7O1FBQ3ZCLFFBQVEsR0FBRyxNQUFNLENBQUMsT0FBTyxDQUFDLEdBQUcsQ0FBQztJQUNwQyxPQUFPLFFBQVEsSUFBSSxDQUFDLENBQUMsQ0FBQyxDQUFDLE1BQU0sQ0FBQyxNQUFNLEdBQUcsUU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