Licence
MIT
Version
1.0.0
Deps
0
Size
10 kB
Vulns
0
Weekly
0
RandoML
About
RandoML is a library of random numbers with the option of excluding or increasing the priority of a number.
How to Install
First, install the library in your project by npm:
$ npm install randoml
Or Yarn:
$ yarn add randoml
You can also connect script via one of CDNs:
bundle.run: https://bundle.run/randoml
jsDelivr: https://cdn.jsdelivr.net/npm/randoml/
unpkg: https://unpkg.com/randoml/
Getting Started
Connect libary to project using script tag in HTML:
<script src="/path/to/randoml.js"></script>
ES6 import:
import RandoML from 'randoml';
Or CommonJS:
const RandoML = require('randoml');
Next use library:
const random = new RandoML({
settings: {
// options...
},
callbacks: {
// callbacks...
}
});
Methods
• Choose:
random.choose();
Options
Settings
| Name | Type | Default | Description | Available options |
|---|---|---|---|---|
| min | number | 1 |
minimum random value | number (smaller than max) |
| max | number | 15 |
maxmum random value | number (bigger than min) |
| exclude | number[] | null |
numbers excluded from choice | array of numbers (in range between min and max) |
| hold | number[] | null |
numbers with higher priority (bigger possibility) | array of numbers (in range between min and max) |
Callbacks
| Name | Description | Available options |
|---|---|---|
| onInit | callback on library init | () => { /* code */ } |
| onChoice | callback on number choice | () => { /* code */ } |
| onResult | callback on choice result | () => { /* code */ } |
| onRangeEnd | callback when range length is 0 | () => { /* code */ } |
License
This project is licensed under the MIT License 2019-present Jakub Biesiada