@js-random/number
v0.3.5
Published
A simple and lightweight number randomizer for JavaScript (TypeScript friendly)
Downloads
128
Maintainers
Readme
@js-random/number
A simple and lightweight number randomizer for JavaScript (TypeScript friendly)
Installation
npm i -S @js-random/number
Usage
commonjs:
var randomNumber = require('@js-random/number').default;
TS/ES6+:
import randomNumber from '@js-random/number';
<script> tag
:
<script src="https://unpkg.com/@js-random/number"></script>
var number = randomNumber(); // from 0 to 100 (inclusive)
var fromTwoToTen = randomNumber(2, 10); // random number from `2` to `10` (inclusive)
Global version
This package also has a global version, which introduces side-effects by exposing the api as Number.random()
function.
Import
commonjs:
require('@js-random/number/lib/global');
ES6+:
import '@js-random/number/module/global';
TS:
import '@js-random/number/module/global';
<script> tag
<script src="https://unpkg.com/@js-random/number/unpkg/global"></script>
Usage
var number = Number.random(); // from 0 to 100 (inclusive)
var fromTwoToTen = Number.random(2, 10); // random number from `2` to `10` (inclusive)
Other packages
Please, have a look at other packages from @js-random
series:
@js-random/all
- all the randomizers in one package - GitHub repo, NPM@js-random/string
GitHub repo, NPM@js-random/boolean
GitHub repo, NPM@js-random/date
GitHub repo, NPM@js-random/function
GitHub repo, NPM