1.0.2 • Published 7 years ago

@axetroy/roll v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
7 years ago

Roll

Roll item from a given list with simple api.

Installation

npm install @axetroy/roll

or if you are using yarn(recommend)

yarn add @axetroy/roll

Usage

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);

API

.add(item:any, rank: number): void

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.

.roll(): any

start roll and return item.

Test

git clone https://github.com/axetroy/roll.git
cd ./gpm.js
yarn
yarn run test

Contributing

git clone https://github.com/axetroy/roll.git
cd ./gpm.js
yarn
yarn run test

You can flow Contribute Guide

Contributors

Axetroy💻 🔌 ⚠️ 🐛 🎨

License

The MIT License

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago