/** * List of alphabet on all cases + number from 0-9. * This can use as whitelist array on random option. * * @public */ export declare const alphanumeric: Array; /** * Random interface, All random class must implement this interface. * * @public */ export declare interface IRandom { /* Excluded from this release type: pseudo */ /** * copy random to new instance. * * @param seed - new seed * * @public */ copy(seed: ISeed): IRandom; } /** * Seed interface, All seed class must implement this interface. * * @public */ export declare interface ISeed { /** * copy seed to new instance. * * @param input - input for new seed * @param builder - seed builder * @returns new seed * * @public */ copy(input: string, builder?: SeedBuilder): ISeed; /** * get seed value. * * @param patch - patch function */ value(patch?: SeedPatch): number; } /** * List of alphabet on lower case. * This can use as whitelist array on random option. * * @public */ export declare const lowerAlphabet: Array; /** * List of alphabet on lower case + number from 0-9. * This can use as whitelist array on random option. * * @public */ export declare const lowerAlphanumeric: Array; /** * List of number from 0-9. * This can use as whitelist array on random option. * * @public */ export declare const numeric: Array; /** * Base random implementation, * this include all utilities around random * using {@link IRandom.pseudo} function to generate * random value. * * @beta */ export declare abstract class Random implements IRandom { protected seed: ISeed; /** * Create new random instance. * * @param seed - random seed * * @beta */ constructor(seed: ISeed); /** * random boolean, the result can be either true or false. * * @returns randomed boolean * * @beta */ boolean(): boolean; /** * random integer number based from input option. * * @param option - random option * @returns integer number * * @beta */ int(option?: Partial): number; /** * random float number based from input option. * * @param option - random option * @returns float number * * @beta */ float(option?: Partial): number; /** * random either integer or float number based from input option. * default mode is float. * * @param option - random option * @returns number * * @beta */ number(option?: Partial): number; /** * random fixed size string from input option. * * @param option - random option * @returns string * * @beta */ fixedString(option?: Partial): string; /** * random dynamic size string from input option. * * @param option - random option * @returns string * * @beta */ dynamicString(option?: Partial): string; /** * randomly select value from input whitelist. * * @param option - random option * @returns value from input array * * @beta */ select(option: RandomSelectOption): T; /** * randomly shuffle input whitelist * * @param option - random option * @returns shuffled array * * @beta */ shuffle(option: RandomMultipleValueOption): Array; /** * randomly select value based on weighted number. * * @param options - weighted value * @returns value from input * * @beta */ weighted(...options: Array>): T; /* Excluded from this release type: getSeed */ abstract pseudo(): number; abstract copy(seed: ISeed): IRandom; } /** * Random Alea is based on MWC (Multiply-with-Carry). It includes its own string hash function: Mash. * * @see https://github.com/bryc/code/blob/master/jshash/PRNGs.md#alea * * @public */ export declare class RandomAlea extends Random { private _n; private _a; private _b; private _c; private _x; private _y; constructor(seed: ISeed); pseudo(): number; copy(s?: ISeed): Random; /** * create mash from seed. * * @param seed - seed string * @returns mash from seed */ private _mash; } /** * option for random dynamic length string. * * @public */ export declare type RandomDynamicStringOption = RandomMultipleValueOption & RandomIntOption; /** * option for random fixed length string. * * @public */ export declare type RandomFixedStringOption = RandomMultipleValueOption & { length: number; }; /** * option for random float. * * @public */ export declare type RandomFloatOption = Omit; /** * option for random integer. * * @public */ export declare type RandomIntOption = Omit; /** * This is based option for multiple value randomizer. * * @public */ export declare type RandomMultipleValueOption = { /** * list of whitelist values */ whitelist: Array; }; /** * option for random number. * * @public */ export declare type RandomNumberOption = { /** * minimum value of output */ min: number; /** * maximum value of output. */ max: number; /** * inclusive maximum value when generate output. */ maxInclusive: boolean; /** * round output to integer */ integerMode: boolean; }; /** * option for randomly select element from values. * Whitelist is a list of possible outcome. * * @public */ export declare type RandomSelectOption = RandomMultipleValueOption; /** * simple random algorithm. * * @remarks * * You should use this random for testing only, * Since it will always return fixed range of value, * no matter how many times we called. * * @public */ export declare class RandomSimple extends Random { private _whitelist; private _pointer; constructor(); pseudo(): number; copy(): Random; /** * Move pointer to next number. */ private _nextPointer; } /** * Option for weighted list. * * @public */ export declare type RandomWeightedOption = { weight: number; value: T; }; /** * Random Xoshiro128++ included in Xoshiro family. * * @see https://github.com/bryc/code/blob/master/jshash/PRNGs.md#xoshiro * * @public */ export declare class RandomXoshiro128PP extends Random { private _a; private _b; private _c; private _d; constructor(seed: ISeed); pseudo(): number; copy(s?: ISeed): Random; } /** * Random Xoshiro128** included in Xoshiro family. * * @see https://github.com/bryc/code/blob/master/jshash/PRNGs.md#xoshiro * * @public */ export declare class RandomXoshiro128SS extends Random { private _a; private _b; private _c; private _d; constructor(seed: ISeed); pseudo(): number; copy(s?: ISeed): Random; } /** * Base seed class. This can be extends for simplify seed class. * * @public */ export declare class Seed implements ISeed { private readonly _fn; private readonly _builder; /** * create new seed instance. * * @param input - seed input value * @param builder - seed builder * */ constructor(input: string, builder: SeedBuilder); /** * {@inheritDoc ISeed.copy} */ copy(input: string, builder?: SeedBuilder | undefined): ISeed; /** * {@inheritDoc ISeed.value} */ value(patch?: SeedPatch): number; } /** * A seed builder to build function based on input value. * * @public */ export declare type SeedBuilder = (input: string) => SeedFn; /** * Fixed implementation for random seed. * This always return single value from input. * * @remarks * * You should use this seed for testing only, * Since it will always return fixed value, * no matter how many times we called. * * @public */ export declare class SeedFixed extends Seed { /** * SeedBuilder for Fixed algorithm * * @param input - any string * @returns function for generate seed value * * @public */ static readonly Builder: SeedBuilder; /** * Create new Fixed seed algorithm * * @param input - any integer/double * * @public */ constructor(input: number); } /** * A function for generate seed, * this should return different value every time it called. * * @public */ export declare type SeedFn = () => number; /** * A patch function to modify seed value after it generated. * * @public */ export declare type SeedPatch = (n: number) => number; /** * Timestamp implementation for random seed. * This always return current timestamp * * @public */ export declare class SeedTimestamp extends Seed { /** * SeedBuilder for Timestamp algorithm * * @returns function for generate seed value * * @public */ static readonly Builder: SeedBuilder; /** * Create new Timestamp seed algorithm * * @public */ constructor(); } /** * Xfnv1a implementation for random seed. * * @see https://github.com/bryc/code/blob/master/jshash/PRNGs.md#addendum-a-seed-generating-functions * * @public */ export declare class SeedXfnv1a extends Seed { /** * SeedBuilder for Xfnv1a algorithm * * @param input - any string * @returns function for generate seed value * * @public */ static readonly Builder: SeedBuilder; /** * Create new Xfnv1a seed algorithm * * @param input - any string * * @public */ constructor(input: string); } /** * Xmur3 implementation for random seed. * * @see https://github.com/bryc/code/blob/master/jshash/PRNGs.md#addendum-a-seed-generating-functions * * @public */ export declare class SeedXmur3 extends Seed { /** * SeedBuilder for Xmur3 algorithm * * @param input - any string * @returns function for generate seed value * * @public */ static readonly Builder: SeedBuilder; /** * Create new Xmur3 seed algorithm * * @param input - any string * * @public */ constructor(input: string); } /** * List of alphabet on upper case. * This can use as whitelist array on random option. * * @public */ export declare const upperAlphabet: Array; /** * List of alphabet on upper case + number from 0-9. * This can use as whitelist array on random option. * * @public */ export declare const upperAlphanumeric: Array; export { }