Options
All
  • Public
  • Public/Protected
  • All
Menu

Class RandomString

Random generator for string values.

Example

let value1 = RandomString.pickChar("ABC");     // Possible result: "C"
let value2 = RandomString.pick(["A","B","C"]); // Possible result: "gBW"

Hierarchy

  • RandomString

Index

Methods

Static distort

  • distort(value: string): string
  • Distorts a string by randomly replacing characters in it.

    Parameters

    • value: string

      a string to distort.

    Returns string

    a distored string.

Static nextAlphaChar

  • nextAlphaChar(): string
  • Generates random alpha characted [A-Za-z]

    Returns string

    a random characted.

Static nextString

  • nextString(minLength: number, maxLength: number): string
  • Generates a random string, consisting of upper and lower case letters (of the English alphabet), digits (0-9), and symbols ("_,.:-/.[].{},#-!,$=%.+^.&*-() ").

    Parameters

    • minLength: number

      (optional) minimum string length.

    • maxLength: number

      maximum string length.

    Returns string

    a random string.

Static pick

  • pick(values: string[]): string
  • Picks a random string from an array of string.

    Parameters

    • values: string[]

      strings to pick from.

    Returns string

    a randomly picked string.

Static pickChar

  • pickChar(values: string): string
  • Picks a random character from a string.

    Parameters

    • values: string

      a string to pick a char from

    Returns string

    a randomly picked char.

Generated using TypeDoc