Socket
Socket
Sign inDemoInstall

seedable-random

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    seedable-random

Seedable Math.random compatible pseudorandom number generator


Version published
Weekly downloads
10K
increased by30%
Maintainers
1
Install size
2.93 kB
Created
Weekly downloads
 

Readme

Source

Seedable pseudorandom number generator

Usage

var random = require('seedable-random');

random.seed(123);
console.log(random());

As a Math.random replacement

Math.random = require('seedable-random');
Math.random.seed(12345);
  • Works as a drop-in for Math.random

  • Relatively fast (about 2.5 times slower than Math.random on my machine)

  • Seeds itself from the clock by default

  • Tries to be pretty random

  • Well tested (TODO come up with some PRNG torture tests)

TODO

Possibility to switch the generator (linear-feedback shift register, Mersenne twister, digits of Math.sin(), etc. based on your needs)

A word of warning

Current implementation just calls Math.sin() with the seed. It's likely that it's not quite that random (for example, the distribution could be biased towards numbers near 1.0). Some more tests are needed.

Keywords

FAQs

Last updated on 13 Oct 2013

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc