f1fc308a5d
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Panayiotis Lipiridis <lipiridis@gmail.com>
16 lines
399 B
TypeScript
16 lines
399 B
TypeScript
import { Random } from "roughjs/bin/math";
|
|
import { nanoid } from "nanoid";
|
|
|
|
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 = () =>
|
|
process.env.NODE_ENV === "test" ? `id${testIdBase++}` : nanoid();
|