@js-random/all
TypeScript icon, indicating that this package has built-in type declarations

0.3.5 • Public • Published

@js-random/all

A collection of simple and lightweight randomizers for JavaScript (TypeScript friendly)

Packages

Here's a list of packages that are included in this build:

Installation

For each individual package - see links above.

If you want everything at once, just do:

npm i -S @js-random/all

Usage

There are two ways to use @js-random/all: imported and global.

Imported

This way you need to import the object containing all the randomizers yourself:

commonjs:

// Every @js-random package is contained in this object by their respective name
const random = require('@js-random/all');

TS/ES6+

import * as random from '@js-random/all';

<script> tag

<script src="https://unpkg.com/@js-random/all"></script>
// For example - `@js-random/number` and `@js-random/boolean`:
const randomNumber = random.number(0, 10); // random number from 0 to 10 (inclusive)
const randomBoolean = random.boolean();    // half the chance of getting `true` or `false`
const probablyTrue = random.boolean(0.99); // 99% of getting `true`

Global

This setup introduces side-effects: each package's function is inserted into global constructors as random() method:

commonjs

require('@js-random/all/lib/global');

ES6+

import '@js-random/all/module/global';

TS

import '@js-random/all/global';

and then:

const randomNumber = Number.random(0, 10);
const probablyTrue = Boolean.random(0.99); // 99% of getting `true`
// Same is true for String, Date and etc.

Package Sidebar

Install

npm i @js-random/all

Weekly Downloads

2

Version

0.3.5

License

MIT

Unpacked Size

16.7 kB

Total Files

21

Last publish

Collaborators

  • raiondesu