variation
v1.0.0
Published
Utility functions to pick random values
Downloads
4
Readme
Variation 🎲
Utility functions to add variations to any kind of output.
Usage Example
const { random, chance, randomItem } = require('variation');
console.log(
random('hello', 'ciao', 'hola', 'salut'),
chance(0.5, 'beautiful'),
randomItem(['world', 'people'])
);
API
Table of Contents
random
Returns a random argument.
Parameters
args
...any
randomItem
Returns a random item from the given array.
Parameters
array
Array<any>
chance
Returns value
with the given probability, false
otherwise.
Parameters
probability
number (optional, default0.5
)value
any (optional, defaulttrue
)
License
MIT