Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: typo

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
languagejavascript
themeConfluence
languagejavascript
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
languagejavascript
themeConfluence
languagejavascript
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
languagejavascript
themeConfluence
languagejavascript
strn = random:photo({"q" : "kitten"})

uuid

Generates a UUID

Code Block
themeConfluence
languagejavascript
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
languagejavascript
themeConfluence
n = random:number(lower = 0, upper = 1)