The random library provides a few convenience utilities functions to generate random content
...
word
Returns a random word from the Unix standard dictionaryusing node random-words package. Note that random-words parameters are not supported in KRL.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
str = random:word() |
quote (fortune)
Returns a random quote from www.iheartquotes.com. See the api for possible parameters
...
uuid
Generates a UUID using node cuid package.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
qstrstr = random:quote({"source":"math"}uuid() |
...
integer
Returns a random photo from google picasa's public api. See the api for possible parameters
...
integer between lower
and upper
(inclusive) using Lodash's random. The range bounds can be equal or in any order.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
strn = random:photo({"q" : "kitten"}) |
uuid
Generates a UUID
Code Block | ||||
---|---|---|---|---|
| ||||
str = random:uuid() |
...
integer(upper = 2, lower = 0)
a = random:integer(5) //returns random integer where 0 <= a <= 5 |
Because upper
is the first argument, you can call this function with a single argument to get a random integer between 0
and that number.
number
Returns a random number (float) between lower
and upper
(inclusive) using Lodash's random. The range bounds can be equal or in any order.
Code Block | ||||
---|---|---|---|---|
| ||||
n = random:number(lower = 0, upper = 1) |