random-function
Create a function that when executed, calls a function randomly based on a given weighted array of functions.
Installation
npm install -S random-function
Usage
; // --- DEMO 1: create a "balancedGreet()" functionconst balancedGreet = ;// each of the 4 greeting functions has an equal chance of being called each time // balancedGreet() is called ; // --- DEMO 2: create a "weightedGreet()" function const weightedGreet = ;// "Hello" has 50% chance of being called, while the other 2 functions has 25% each ;
Test Coverage
Test coverage report.
History
v0.0.1 (29 Dec 2016) - First version.