mirror of
https://github.com/excalidraw/excalidraw.git
synced 2024-11-10 11:35:52 +01:00
11396a21de
* refactor: use isTestEnv() utils where applicable * check if process is defined
16 lines
416 B
TypeScript
16 lines
416 B
TypeScript
import { Random } from "roughjs/bin/math";
|
|
import { nanoid } from "nanoid";
|
|
import { isTestEnv } from "./utils";
|
|
|
|
let random = new Random(Date.now());
|
|
let testIdBase = 0;
|
|
|
|
export const randomInteger = () => Math.floor(random.next() * 2 ** 31);
|
|
|
|
export const reseed = (seed: number) => {
|
|
random = new Random(seed);
|
|
testIdBase = 0;
|
|
};
|
|
|
|
export const randomId = () => (isTestEnv() ? `id${testIdBase++}` : nanoid());
|