UNPKG

@jsonjoy.com/json-random

Version:

Random JSON generation, structured JSON by schema generation, no dependencies.

26 lines (25 loc) 752 B
export declare const rnd: (seed?: number) => () => number; /** * Executes code in a callback *deterministically*: the `Math.random()` function * is mocked for the duration of the callback. * * Example: * * ```js * deterministic(123, () => { * return Math.random() + 1; * }); * ``` * * @param rndSeed A seed number or a random number generator function. * @param code Code to execute deterministically. * @returns Return value of the code block. */ export declare const deterministic: <T>(rndSeed: number | (() => number), code: () => T) => T; /** * Creates a deep clone of any JSON-like object. * * @param obj Any plain POJO object. * @returns A deep copy of the object. */ export declare const clone: <T = unknown>(obj: T) => T;