1.2.0 • Published 3 years ago

node-prng v1.2.0

Weekly downloads
4
License
MIT
Repository
github
Last release
3 years ago

node-prng - Node bindings of pseudorandom number generators

Background

This project is an assorted Node.js C bindings of some very fast pseudorandom number generators. Most of them is based on here

Install

yarn add node-prng

or

npm install --save node-prng

Usage

const prng = require('node-prng')

console.log(prng.xorshift32().toString('hex')) // 32bit random number
console.log(prng.xorshift64().toString('hex')) // 64bit random number

console.log(prng.xoroshiro128_p().toString('hex')) // 64bit random number, super fast, less "reliable"
console.log(prng.xoroshiro128_pp().toString('hex')) // 64bit random number, fast
console.log(prng.xoroshiro128_ss().toString('hex')) // 64bit random number, very fast

console.log(prng.xoshiro256_p().toString('hex')) // 64bit random number, super fast
console.log(prng.xoshiro256_pp().toString('hex')) // 64bit random number, very fast
console.log(prng.xoshiro256_ss().toString('hex')) // 64bit random number, very fast

Tests

yarn test

or

npm test

Plan

There is a list of TODO, including more PRNGs, enhancement of the C library and code optimizations. But you might consider in future, we will have:

  1. Support for the xoshiro512 family (xoshiro512+, xoshiro512++, xoshiro512**)
  2. Support for the xoroshiro1024 family (xoroshiro1024+, xoroshiro1024++, xoroshiro1024**)
  3. Larger random bytes array generators using the above.

Credit

Great thanks to the opened C sources and inspirations by Sebastiano Vigna of the Università degli Studi di Milano.

1.2.0

3 years ago

1.1.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago