lcg-bytes

1.0.2 • Public • Published

Fast pseudo-random bytes generation without dependencies

Example

Math.random will be used as a seed

let {randomBytes} = require("lcg-bytes")
randomBytes(5);
// > randomBytes(5)
// Uint8Array(5) [ 226, 134, 254, 127, 62 ]

With custom seed

// rnd_uint32 is a Math.random()-based seed
let {lcg_parkmiller, rnd_uint32} = require("lcg-bytes")
let rnd = lcg_parkmiller(rnd_uint32());
> rnd.randomBytes(5)
Uint8Array(5) [ 200, 24, 194, 39, 184 ]

Benchmark

const benchmark = require("lcg-bytes/benchmark");
benchmark();

Readme

Keywords

Package Sidebar

Install

npm i lcg-bytes

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

2.77 kB

Total Files

5

Last publish

Collaborators

  • kisel