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:
ES6 import:
;
Or CommonJS:
const RandoML = ;
Next use library:
const random = settings: // options... callbacks: // callbacks... ;
Methods
• Choose:
random;
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