npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

seeded-random-engine

v1.0.5

Published

> An array of seeded random number generators that can enable multiple devices to be primitively synchronized.

Downloads

8

Readme

Seeded Random Engine

An array of seeded random number generators that can enable multiple devices to be primitively synchronized.

Example usage

import SeededRandomEngine from "seeded-random-engine";

const engine = new SeededRandomEngine({
  // The seed is unique to the instance.
  seed: "A unique case sensitive string",
  // Maximum amount of random numbers needed per generation.
  cores: 4,
  // Generations of history to save in memory.
  // Useful if you need to recall past generations.
  memory: 10,
});

// Generate a first generation of four random numbers (four "cores" provided above).
engine.generate();
// engine.values() will return an array of four random numbers.
console.log(engine.values());
// eg. [0.3230205841828137, 0.2185600262600928, 0.1377083600964397, 0.9505280032753944]

// Change the engine generation to 57
engine.to(57);
// Any engine sharing this seed and set to generation 57 will always yield the same values.
console.log(engine.values());
// Call engine.generate() to increase the generation and generate numbers.
engine.generate();
// Current generation is now 58 and values() returns four new numbers.
console.log(engine.values());

What is this useful for?

Say we want a number of devices to see the same new random number every time a button is pressed.

One way we could do this would be to randomly generate a number and update the devices over the network solution using something like web sockets. That solution, while valid, is somewhat overkill if all I need is a synchronized random number generator.

Enter the seeded random engine. The concept is that if devices share a seed, multiple random number generators (RNGs) can be synchronised between the devices.

The core use case for this engine is one where human beings can do that sync easily together. I can tell my friend "enter seed 'willie' and we are at generation 100." With two small inputs, my friend can sync their device with everyone else and be looking at the exact same randomized data.