1.0.0 • Published 6 years ago

small-prng v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

small-prng

A fast, seedable replacement for Math.random().

npm Node.js Build Status Code Coverage Maintainability Dependencies Status MIT licensed

Installation

npm i small-prng

Usage

Exported global function

The seed for the exported function random() is based on process.hrtime() when the module is first required.

const { random } = require('small-prng');

random();

Creating a seeded PRNG

To create a seeded PRNG, use the exported function prng(). Calling prng() without any arguments will use process.hrtime() as the seed.

const { prng } = require('small-prng');

const mySeed = 1;
const random = prng(mySeed);

random();

License

The majority of the code in this repository is released under the MIT license. However, the JavaScript port of Bob Jenkins's small noncryptographic PRNG in src/prng.js is public domain.