Interface Strings

Generator to generate strings.

interface Strings {
    digit(): string;
    digitN(count: number): string;
    letter(): string;
    letterN(count: number): string;
    lexify(str: string): string;
    numerify(str: string): string;
    randomString(strs: string[]): string[];
    shuffleStrings(strs: string[]): string[];
    uuid(): string;
}

Methods

  • Numerical symbol used to represent numbers.

    Returns string

    a random digit

    import { Faker } from "k6/x/faker"

    let faker = new Faker(11)

    export default function () {
    console.log(faker.strings.digit())
    }

    Output (formatted as JSON value)

    "0"
    
  • string of length N consisting of ASCII digits.

    Parameters

    • count: number

      Count

    Returns string

    a random digitn

    import { Faker } from "k6/x/faker"

    let faker = new Faker(11)

    export default function () {
    console.log(faker.strings.digitN(3))
    }

    Output (formatted as JSON value)

    "005"
    
  • Character or symbol from the American Standard Code for Information Interchange (ASCII) character set.

    Returns string

    a random letter

    import { Faker } from "k6/x/faker"

    let faker = new Faker(11)

    export default function () {
    console.log(faker.strings.letter())
    }

    Output (formatted as JSON value)

    "W"
    
  • ASCII string with length N.

    Parameters

    • count: number

      Count

    Returns string

    a random lettern

    import { Faker } from "k6/x/faker"

    let faker = new Faker(11)

    export default function () {
    console.log(faker.strings.letterN(3))
    }

    Output (formatted as JSON value)

    "WCp"
    
  • Replace ? with random generated letters.

    Parameters

    • str: string

      String

    Returns string

    a random lexify

    import { Faker } from "k6/x/faker"

    let faker = new Faker(11)

    export default function () {
    console.log(faker.strings.lexify("none"))
    }

    Output (formatted as JSON value)

    "none"
    
  • Replace # with random numerical values.

    Parameters

    • str: string

      String

    Returns string

    a random numerify

    import { Faker } from "k6/x/faker"

    let faker = new Faker(11)

    export default function () {
    console.log(faker.strings.numerify("none"))
    }

    Output (formatted as JSON value)

    "none"
    
  • Return a random string from a string array.

    Parameters

    • strs: string[]

      Strings

    Returns string[]

    a random random string

    import { Faker } from "k6/x/faker"

    let faker = new Faker(11)

    export default function () {
    console.log(faker.strings.randomString(["none","how","these","keep","trip","congolese","choir","computer","still","far"]))
    }

    Output (formatted as JSON value)

    "none"
    
  • Shuffle an array of strings.

    Parameters

    • strs: string[]

      Strings

    Returns string[]

    a random shuffle strings

    import { Faker } from "k6/x/faker"

    let faker = new Faker(11)

    export default function () {
    console.log(faker.strings.shuffleStrings(["none","how","these","keep","trip","congolese","choir","computer","still","far"]))
    }

    Output (formatted as JSON value)

    ["these","congolese","far","choir","still","trip","computer","how","keep","none"]
    
  • 128-bit identifier used to uniquely identify objects or entities in computer systems.

    Returns string

    a random uuid

    import { Faker } from "k6/x/faker"

    let faker = new Faker(11)

    export default function () {
    console.log(faker.strings.uuid())
    }

    Output (formatted as JSON value)

    "ea6ab1ab-f06c-4990-835d-e628b7e659e1"