mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-09-12 03:50:06 +02:00
Much more thorough tests! (#1053)
This commit is contained in:
18
src/random.ts
Normal file
18
src/random.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Random } from "roughjs/bin/math";
|
||||
import nanoid from "nanoid";
|
||||
|
||||
let random = new Random(Date.now());
|
||||
let testIdBase = 0;
|
||||
|
||||
export function randomInteger() {
|
||||
return Math.floor(random.next() * 2 ** 31);
|
||||
}
|
||||
|
||||
export function reseed(seed: number) {
|
||||
random = new Random(seed);
|
||||
testIdBase = 0;
|
||||
}
|
||||
|
||||
export function randomId() {
|
||||
return process.env.NODE_ENV === "test" ? `id${testIdBase++}` : nanoid();
|
||||
}
|
Reference in New Issue
Block a user