0.3.5 • Published 5 years ago

@js-random/all v0.3.5

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

@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.
0.3.5

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago