UNPKG

1.71 kBTypeScriptView Raw
1/**
2 * Random generator for string values.
3 *
4 * ### Example ###
5 *
6 * let value1 = RandomString.pickChar("ABC"); // Possible result: "C"
7 * let value2 = RandomString.pick(["A","B","C"]); // Possible result: "gBW"
8 */
9export declare class RandomString {
10 private static readonly _digits;
11 private static readonly _symbols;
12 private static readonly _alphaLower;
13 private static readonly _alphaUpper;
14 private static readonly _alpha;
15 private static readonly _chars;
16 /**
17 * Picks a random character from a string.
18 *
19 * @param values a string to pick a char from
20 * @returns a randomly picked char.
21 */
22 static pickChar(values: string): string;
23 /**
24 * Picks a random string from an array of string.
25 *
26 * @param values strings to pick from.
27 * @returns a randomly picked string.
28 */
29 static pick(values: string[]): string;
30 /**
31 * Distorts a string by randomly replacing characters in it.
32 *
33 * @param value a string to distort.
34 * @returns a distored string.
35 */
36 static distort(value: string): string;
37 /**
38 * Generates random alpha characted [A-Za-z]
39 *
40 * @returns a random characted.
41 */
42 static nextAlphaChar(): string;
43 /**
44 * Generates a random string, consisting of upper and lower case letters (of the English alphabet),
45 * digits (0-9), and symbols ("_,.:-/.[].{},#-!,$=%.+^.&*-() ").
46 *
47 * @param minLength (optional) minimum string length.
48 * @param maxLength maximum string length.
49 * @returns a random string.
50 */
51 static nextString(minLength: number, maxLength: number): string;
52}