1.0.3 • Published 5 years ago

wariai v1.0.3

Weekly downloads
1
License
MIT
Repository
github
Last release
5 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

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago