1.0.0 • Published 3 years ago

randoml v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

RandoML

NPM version NPM downloads

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

NameTypeDefaultDescriptionAvailable options
minnumber1minimum random valuenumber (smaller than max)
maxnumber15maxmum random valuenumber (bigger than min)
excludenumber[]nullnumbers excluded from choicearray of numbers (in range between min and max)
holdnumber[]nullnumbers with higher priority (bigger possibility)array of numbers (in range between min and max)

Callbacks

NameDescriptionAvailable options
onInitcallback on library init() => { /* code */ }
onChoicecallback on number choice() => { /* code */ }
onResultcallback on choice result() => { /* code */ }
onRangeEndcallback when range length is 0() => { /* code */ }

License

This project is licensed under the MIT License © 2019-present Jakub Biesiada