🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

seed-random

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

seed-random

Generate random numbers with a seed, useful for reproducible tests

2.2.0
latest
Source
npm
Version published
Weekly downloads
1.4M
-11.44%
Maintainers
1
Weekly downloads
 
Created

What is seed-random?

The 'seed-random' npm package is used to generate random numbers with a deterministic sequence based on a seed value. This is useful for scenarios where reproducibility is important, such as in simulations, games, or procedural content generation.

What are seed-random's main functionalities?

Basic Usage

This feature allows you to create a random number generator that produces the same sequence of numbers for a given seed. This is useful for creating reproducible results.

const seedrandom = require('seed-random');
const random = seedrandom('my-seed');
console.log(random()); // Generates a random number based on the seed

Multiple Generators

You can create multiple random number generators with different seeds, each producing its own sequence of random numbers. This is useful for managing different random processes independently.

const seedrandom = require('seed-random');
const random1 = seedrandom('seed1');
const random2 = seedrandom('seed2');
console.log(random1()); // Generates a random number based on 'seed1'
console.log(random2()); // Generates a random number based on 'seed2'

State Saving and Restoring

This feature allows you to save the state of a random number generator and restore it later. This is useful for pausing and resuming random processes without losing the sequence.

const seedrandom = require('seed-random');
const random = seedrandom('my-seed', { state: true });
const state = random.state();
console.log(random()); // Generates a random number
const newRandom = seedrandom('', { state: state });
console.log(newRandom()); // Continues the sequence from the saved state

Other packages similar to seed-random

FAQs

Package last updated on 11 Nov 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