UNPKG

@itwin/itwinui-react

Version:

A react component library for iTwinUI

14 lines (13 loc) 457 B
export const getBoundedValue = (val, min, max) => Math.min(max, Math.max(min, val)); export const getRandomValue = (length = 21) => { let alphabet = '_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; let id = ''; for (let i = 0; i < length; i++) id += alphabet[(64 * Math.random()) | 0]; return id; }; export const roundByDPR = (value) => { let dpr = window.devicePixelRatio || 1; return Math.round(value * dpr) / dpr; };