@keita-sama69/random

1.0.7 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i @keita-sama69/random

Weekly Downloads

1

Version

1.0.7

License

ISC

Unpacked Size

1.67 kB

Total Files

3

Last publish

Collaborators

  • keita-sama69