Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

This package has been deprecated

Author message:

Please, use @js-random/all instead!

@js-random/global

0.1.2 • Public • Published

@js-random/global

A collection of simple and lightweight randomizers for JavaScript integrated into the native API (TypeScript friendly)

Installation

npm i -S @js-random/global

Usage

Upon importing, the main JS constructors (Number, String, Date, Boolean) will recieve a random function, which is equivalent to a corresponding @js-random package:

commonjs:

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

TS/ES6+

import '@js-random/global';

result:

Number.random();  // 42
String.random();  // "@!f33D s)97"
Date.random();    // 23 May 7562 01:41:12:632
Boolean.random(); // false

It is also possible to globalize each package individually, by adding a / with the original @js-random/* package name to the @js-random/global:

import '@js-random/global/number';
 
Number.random();  // 42
String.random();  // TypeError: 'random' is not a function
Date.random();    // TypeError: 'random' is not a function
Boolean.random(); // TypeError: 'random' is not a function

One could also want to use this via a <script> tag. This is possible using unpkg:

<!-- For all packages -->
<script src="https://unpkg.com/@js-random/global"></script>
 
<!-- For a specific package -->
<script src="https://unpkg.com/@js-random/global/unpkg/number"></script>
<script src="https://unpkg.com/@js-random/global/unpkg/string"></script>
<script src="https://unpkg.com/@js-random/global/unpkg/boolean"></script>
<script src="https://unpkg.com/@js-random/global/unpkg/date"></script>

Install

npm i @js-random/global

DownloadsWeekly Downloads

1

Version

0.1.2

License

MIT

Unpacked Size

8.95 kB

Total Files

36

Last publish

Collaborators

  • avatar