randomlyjs
v1.0.2
Published
randomly choose one of several alternatives
Downloads
7
Readme
randomly
Make random decisions
Install
$ npm install randomlyjs
Usage
const randomly = require('randomlyjs')
randomly('foo', 'bar')
//50% of the time, returns 'foo'; 50% of the time, returns 'bar'
randomly(1, 3, 5, 7, 8)
//equal probability of returning 1, 3, 5, 7, or 8
//works with callbacks
const buggify = function(fn) {
return function() {
return randomly(fn(...arguments), (() => new Error('Unexpected Token:😏'))())
}
}