1.0.3 • Published 6 years ago

wariai v1.0.3

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

Wariai

Shuffles randomly a list or pick an option among several weighted ones

Install

With npm : npm install wariai

First, create a JSON string containing your options & weights following this pattern :

let obj = '[{ "option": "test1", "weight": 1},{ "option": "test2", "weight": 2},{ "option": "test3", "weight": 3},{ "option": "test4", "weight": 4}]';

Then, create the picker object :

let picker = new Picker(obj);

You can now pick an element or shuffle the list with the following code :

picker.pickOneWithWeight(); // Returns a random object from the list, taking weights into account
picker.getRandomizedList(); // Returns a randomly shuffled list of elements
1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago