Roll item from a given list with simple api.
npm install @axetroy/roll
or if you are using yarn(recommend)
yarn add @axetroy/roll
const Roll = require('@axetroy/roll');
const roller = new Roll();
roller.add('Apple', 1); // 10% get Apple
roller.add('Sydney', 2); // 20% get Sydney
roller.add('Banana', 7); // 70% get Banana
const result = roller.roll();
console.log(result);
add an item to roller.
- item: any thing except undefined and null
- rank: rank of the item. you can set any number >0, no need the make them in 10 total.
start roll and return item.
git clone https://github.com/axetroy/roll.git
cd ./gpm.js
yarn
yarn run test
git clone https://github.com/axetroy/roll.git
cd ./gpm.js
yarn
yarn run test
You can flow Contribute Guide
Axetroy 💻 🔌 |
---|
The MIT License