mirror of
https://github.com/umami-software/umami.git
synced 2026-02-12 00:27:11 +01:00
Updated components build.
This commit is contained in:
parent
5f27ba149b
commit
56af91950a
53 changed files with 942 additions and 333 deletions
20
src/lib/generate.ts
Normal file
20
src/lib/generate.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import prand from 'pure-rand';
|
||||
|
||||
const seed = Date.now() ^ (Math.random() * 0x100000000);
|
||||
const rng = prand.xoroshiro128plus(seed);
|
||||
|
||||
export function random(min: number, max: number) {
|
||||
return prand.unsafeUniformIntDistribution(min, max, rng);
|
||||
}
|
||||
|
||||
export function getRandomChars(
|
||||
n: number,
|
||||
chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
||||
) {
|
||||
const arr = chars.split('');
|
||||
let s = '';
|
||||
for (let i = 0; i < n; i++) {
|
||||
s += arr[random(0, arr.length - 1)];
|
||||
}
|
||||
return s;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue