Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

seedable-random

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

seedable-random

Seedable Math.random compatible pseudorandom number generator

  • 0.0.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
17K
increased by13.25%
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 13 Oct 2013

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc