Info | ||
---|---|---|
| ||
This library has not yet been ported to the New Pico Engine |
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() |
uuid
Generates a UUID using node cuid package.
Code Block | ||||
---|---|---|---|---|
| ||||
str = random:uuid() |
...
integer
Returns a random integer between lower
and upper
(inclusive) using Lodash's random. The range bounds can be equal or in any order.
Code Block | ||||
---|---|---|---|---|
| ||||
n = random: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) |