improbable
Version:
give a function and a probability, recieve either that function or a noop
27 lines (16 loc) • 417 B
Markdown
probably run a function
npm install `improbable`
```js
var probably = require('improbable').probably
var maybeHello = probably(0.5, function() { console.log('hello') })
// 0.5 probability of being this function, 0.5 of being noop
maybeHello()
maybeHello()
maybeHello()
// calling over will always yield same result, either logging "hello" or doing nothing
```
MIT