@keita-sama69/random
v1.0.7
Published
A randomization module for JavaScript
Downloads
3
Readme
A simple randomization module
Package intended for people who don't want to type Math.floor(Math.random() * value)
or something similar.
Usage
Run npm i @keita-sama69/random
to install the package then to use it:
const { pickRandom, getNum } = require('@keita-sama69/random');
require('@keita-sama69/random') // For appending .random() to arrays
const num = 10;
const arr = ['kinda', 'lame', 'but', 'exists'];
const str = 'hello world';
console.log(pickRandom(num));
//Expected Output: Number between 0 - 10.
console.log(pickRandom(arr));
//Expected Output: A string from the array.
console.log(pickRandom(str));
//Expected Output: A letter from the string.
console.log(arr.random())
//Expected Output: A string from the array.
// The getNum function gets a number between two numbers, simple.
console.log(getNum(69, 420))
//Expected Output: A number between 69 and 420.
Added:
- ESM support
Planned:
- Nothing