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

seedrandom

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

seedrandom

Seeded random number generator for Javascript.

  • 3.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.3M
decreased by-11.4%
Maintainers
1
Weekly downloads
 
Created

What is seedrandom?

The seedrandom npm package is a library that allows developers to create seeded random number generators. This means that the random numbers generated can be repeatable and predictable if the same seed is used. It is useful for scenarios where reproducibility is important, such as in testing or simulations.

What are seedrandom's main functionalities?

Basic Seeded Random Number Generation

This feature allows you to create a new random number generator that is seeded with a specific string. The same seed will produce the same sequence of numbers each time.

var seedrandom = require('seedrandom');
var rng = seedrandom('hello.');
console.log(rng());

Using Different Algorithms

Seedrandom supports different algorithms for random number generation, such as 'xor128', 'tychei', among others. This allows for flexibility in the properties of the random number sequence.

var seedrandom = require('seedrandom');
var rng = seedrandom('hello.', { algorithm: 'xor128' });
console.log(rng());

State Saving and Restoring

This feature allows you to save the state of the random number generator and create a new generator with that state, effectively cloning the generator at a specific point in its sequence.

var seedrandom = require('seedrandom');
var rng = seedrandom('hello.');
var state = rng.state();
var rng2 = seedrandom(state);
console.log(rng2());

Autoseeding

If no seed is provided, seedrandom can automatically generate a seed based on entropy from the current time and the execution environment, producing a unique random number sequence.

var seedrandom = require('seedrandom');
var rng = seedrandom();
console.log(rng());

Other packages similar to seedrandom

Keywords

FAQs

Package last updated on 09 Aug 2019

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