UNPKG

@itwin/itwinui-react

Version:

A react component library for iTwinUI

35 lines (34 loc) 877 B
'use strict'; Object.defineProperty(exports, '__esModule', { value: true, }); function _export(target, all) { for (var name in all) Object.defineProperty(target, name, { enumerable: true, get: all[name], }); } _export(exports, { getBoundedValue: function () { return getBoundedValue; }, getRandomValue: function () { return getRandomValue; }, roundByDPR: function () { return roundByDPR; }, }); const getBoundedValue = (val, min, max) => Math.min(max, Math.max(min, val)); const getRandomValue = (length = 21) => { let alphabet = '_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; let id = ''; for (let i = 0; i < length; i++) id += alphabet[(64 * Math.random()) | 0]; return id; }; const roundByDPR = (value) => { let dpr = window.devicePixelRatio || 1; return Math.round(value * dpr) / dpr; };