Module: lib/baseContext

Members

(static) empty

The empty object

Source:

Methods

(static) random(minopt, maxopt) → {number}

Generate a random number random() is the same as Math.random(): 0 <= x < 1 random(N) returns a number 0 <= x < N random(M, N) returns M <= x < N

Parameters:
Name Type Attributes Default Description
min number <optional>
0
max number <optional>
1
Source:
Returns:
Type
number

(static) randomBool() → {boolean}

Source:
Returns:
Type
boolean

(static) randomCode(lenopt) → {string}

Generate a random string with digits (0-9)

Parameters:
Name Type Attributes Default Description
len number <optional>
8
Source:
Returns:
Type
string

(static) randomDate(intervalopt, baseDateopt) → {Date}

Generate a random Date previous from a given Date

Parameters:
Name Type Attributes Default Description
interval number <optional>
86.4e6
baseDate Date <optional>
new Date
Source:
Returns:
Type
Date

(static) randomEmail(domainopt) → {string}

Generate a random valid email address

Parameters:
Name Type Attributes Default Description
domain string <optional>
'example.com'
Source:
Returns:
Type
string

(static) randomHex(lenopt) → {string}

Generate a random string with hex chars (0-9a-f)

Parameters:
Name Type Attributes Default Description
len number <optional>
8
Source:
Returns:
Type
string

(static) randomInt(minopt, maxopt) → {number}

Generate a random int min <= x < max randomInt() is equal to randomInt(0, 100) randomInt(N) is equal to randomInt(0, N)

Parameters:
Name Type Attributes Default Description
min number <optional>
0
max number <optional>
100
Source:
Returns:
Type
number

(static) randomOf(…value) → {*}

Return one of its arguments

Parameters:
Name Type Attributes Description
value * <repeatable>
Source:
Returns:
Type
*

(static) randomStr(lenopt, alphabetopt) → {string}

Generate a random string with base64 chars (A-Za-z0-9+/)

Parameters:
Name Type Attributes Default Description
len number <optional>
8
alphabet string <optional>
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
Source:
Returns:
Type
string

(static) randomUrl(baseopt) → {string}

Generate a random valid url

Parameters:
Name Type Attributes Default Description
base string <optional>
'http://example.com'
Source:
Returns:
Type
string