Interface Numbers

Generator to generate numbers.

interface Numbers {
    boolean(): boolean;
    float32(): number;
    float32Range(min: number, max: number): number;
    float64(): number;
    float64Range(min: number, max: number): number;
    hexUint128(): string;
    hexUint16(): string;
    hexUint256(): string;
    hexUint32(): string;
    hexUint64(): string;
    hexUint8(): string;
    int16(): number;
    int32(): number;
    int64(): number;
    int8(): number;
    intRange(min: number, max: number): number;
    number(min: number, max: number): number;
    randomInt(ints: number[]): number;
    randomUint(uints: number[]): number;
    shuffleInts(ints: number[]): number[];
    uint16(): number;
    uint32(): number;
    uint64(): number;
    uint8(): number;
    uintRange(min: number, max: number): number;
}

Methods

  • Data type that represents one of two possible values, typically true or false.

    Returns boolean

    a random boolean

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

    let faker = new Faker(11)

    export default function () {
    console.log(faker.numbers.boolean())
    }

    Output (formatted as JSON value)

    true
    
  • Data type representing floating-point numbers with 32 bits of precision in computing.

    Returns number

    a random float32

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

    let faker = new Faker(11)

    export default function () {
    console.log(faker.numbers.float32())
    }

    Output (formatted as JSON value)

    1.9168120387159532e+38
    
  • Float32 value between given range.

    Parameters

    • min: number

      Min

    • max: number

      Max

    Returns number

    a random float32 range

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

    let faker = new Faker(11)

    export default function () {
    console.log(faker.numbers.float32Range(3,5))
    }

    Output (formatted as JSON value)

    4.126601219177246
    
  • Data type representing floating-point numbers with 64 bits of precision in computing.

    Returns number

    a random float64

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

    let faker = new Faker(11)

    export default function () {
    console.log(faker.numbers.float64())
    }

    Output (formatted as JSON value)

    1.012641406418422e+308
    
  • Float64 value between given range.

    Parameters

    • min: number

      Min

    • max: number

      Max

    Returns number

    a random float64 range

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

    let faker = new Faker(11)

    export default function () {
    console.log(faker.numbers.float64Range(3,5))
    }

    Output (formatted as JSON value)

    4.126600960731799
    
  • Hexadecimal representation of an 128-bit unsigned integer.

    Returns string

    a random hexuint128

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

    let faker = new Faker(11)

    export default function () {
    console.log(faker.numbers.hexUint128())
    }

    Output (formatted as JSON value)

    "0xaa1b0c903d687691402ee58a2330f9c5"
    
  • Hexadecimal representation of an 16-bit unsigned integer.

    Returns string

    a random hexuint16

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

    let faker = new Faker(11)

    export default function () {
    console.log(faker.numbers.hexUint16())
    }

    Output (formatted as JSON value)

    "0xaa1b"
    
  • Hexadecimal representation of an 256-bit unsigned integer.

    Returns string

    a random hexuint256

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

    let faker = new Faker(11)

    export default function () {
    console.log(faker.numbers.hexUint256())
    }

    Output (formatted as JSON value)

    "0xaa1b0c903d687691402ee58a2330f9c54b727953d2379f94d23ea4cdad195b6a"
    
  • Hexadecimal representation of an 32-bit unsigned integer.

    Returns string

    a random hexuint32

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

    let faker = new Faker(11)

    export default function () {
    console.log(faker.numbers.hexUint32())
    }

    Output (formatted as JSON value)

    "0xaa1b0c90"
    
  • Hexadecimal representation of an 64-bit unsigned integer.

    Returns string

    a random hexuint64

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

    let faker = new Faker(11)

    export default function () {
    console.log(faker.numbers.hexUint64())
    }

    Output (formatted as JSON value)

    "0xaa1b0c903d687691"
    
  • Hexadecimal representation of an 8-bit unsigned integer.

    Returns string

    a random hexuint8

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

    let faker = new Faker(11)

    export default function () {
    console.log(faker.numbers.hexUint8())
    }

    Output (formatted as JSON value)

    "0xaa"
    
  • Signed 16-bit integer, capable of representing values from 32,768 to 32,767.

    Returns number

    a random int16

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

    let faker = new Faker(11)

    export default function () {
    console.log(faker.numbers.int16())
    }

    Output (formatted as JSON value)

    -4595
    
  • Signed 32-bit integer, capable of representing values from -2,147,483,648 to 2,147,483,647.

    Returns number

    a random int32

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

    let faker = new Faker(11)

    export default function () {
    console.log(faker.numbers.int32())
    }

    Output (formatted as JSON value)

    -15831539
    
  • Signed 64-bit integer, capable of representing values from -9,223,372,036,854,775,808 to -9,223,372,036,854,775,807.

    Returns number

    a random int64

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

    let faker = new Faker(11)

    export default function () {
    console.log(faker.numbers.int64())
    }

    Output (formatted as JSON value)

    5195529898953699000
    
  • Signed 8-bit integer, capable of representing values from -128 to 127.

    Returns number

    a random int8

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

    let faker = new Faker(11)

    export default function () {
    console.log(faker.numbers.int8())
    }

    Output (formatted as JSON value)

    -115
    
  • Integer value between given range.

    Parameters

    • min: number

      Min

    • max: number

      Max

    Returns number

    a random intrange

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

    let faker = new Faker(11)

    export default function () {
    console.log(faker.numbers.intRange(3,5))
    }

    Output (formatted as JSON value)

    3
    
  • Mathematical concept used for counting, measuring, and expressing quantities or values.

    Parameters

    • min: number

      Min

    • max: number

      Max

    Returns number

    a random number

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

    let faker = new Faker(11)

    export default function () {
    console.log(faker.numbers.number(-2147483648,2147483647))
    }

    Output (formatted as JSON value)

    -15831539
    
  • Randomly selected value from a slice of int.

    Parameters

    • ints: number[]

      Integers

    Returns number

    a random random int

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

    let faker = new Faker(11)

    export default function () {
    console.log(faker.numbers.randomInt([14,8,13]))
    }

    Output (formatted as JSON value)

    14
    
  • Randomly selected value from a slice of uint.

    Parameters

    • uints: number[]

      Unsigned Integers

    Returns number

    a random random uint

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

    let faker = new Faker(11)

    export default function () {
    console.log(faker.numbers.randomUint([14,8,13]))
    }

    Output (formatted as JSON value)

    14
    
  • Shuffles an array of ints.

    Parameters

    • ints: number[]

      Integers

    Returns number[]

    a random shuffle ints

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

    let faker = new Faker(11)

    export default function () {
    console.log(faker.numbers.shuffleInts([14,8,13]))
    }

    Output (formatted as JSON value)

    [8,13,14]
    
  • Unsigned 16-bit integer, capable of representing values from 0 to 65,535.

    Returns number

    a random uint16

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

    let faker = new Faker(11)

    export default function () {
    console.log(faker.numbers.uint16())
    }

    Output (formatted as JSON value)

    15082
    
  • Unsigned 32-bit integer, capable of representing values from 0 to 4,294,967,295.

    Returns number

    a random uint32

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

    let faker = new Faker(11)

    export default function () {
    console.log(faker.numbers.uint32())
    }

    Output (formatted as JSON value)

    2131652109
    
  • Unsigned 64-bit integer, capable of representing values from 0 to 18,446,744,073,709,551,615.

    Returns number

    a random uint64

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

    let faker = new Faker(11)

    export default function () {
    console.log(faker.numbers.uint64())
    }

    Output (formatted as JSON value)

    5195529898953699000
    
  • Unsigned 8-bit integer, capable of representing values from 0 to 255.

    Returns number

    a random uint8

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

    let faker = new Faker(11)

    export default function () {
    console.log(faker.numbers.uint8())
    }

    Output (formatted as JSON value)

    234
    
  • Non-negative integer value between given range.

    Parameters

    • min: number

      Min

    • max: number

      Max

    Returns number

    a random uintrange

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

    let faker = new Faker(11)

    export default function () {
    console.log(faker.numbers.uintRange(0,4294967295))
    }

    Output (formatted as JSON value)

    2131652109