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 🙏

© 2026 – Pkg Stats / Ryan Hefner

toosoon-prng-controllers

v5.0.0

Published

This project provides PRNG functions with a set of controllers for generating pseudo-random values using a seed-based approach

Readme

TOOSOON Pseudo-Random Number Generator (PRNG) — Controllers

This project provides PRNG functions with a set of controllers for generating pseudo-random values using a seed-based approach.

It adds additionnal features to the main library: toosoon-prng.

NPM

Installation

Yarn:

$ yarn add toosoon-prng-controllers

NPM:

$ npm install toosoon-prng-controllers

Usage

import { IntController, IntGroupController } from 'toosoon-prng-controllers';

const config = {
  count: new IntController('count', 0, 10),
  counts: new IntGroupController('counts', 5, 10)
};

config.count.getValue(); // Pseudo-random integer in the interval [0, 10)

for (let i = 0; i < 5; i++) {
  config.counts.getValueAt(i); // Pseudo-random integers in the interval [5, 10)
}

Controllers

PRNGController

Utility abstract class for generating pseudo-random values.

Properties

.seed

Seed string used for pseudo-random generations.

PRNGController.seed: string;
.value

Pseudo-random value generated by the controller.

PRNGController<T>.value: T;

Methods

.getValue()

Generate the controller pseudo-random value.

PRNGController<T>.getValue(): T;
.dispose()

Dispose the controller.

PRNGController.dispose(): void;

BooleanController

Utility class extending PRNGController for generating pseudo-random boolean values.

Constructor

| Parameter | Type | Default | Description | | ------------- | ---------| ------- | ----------------------------------------------- | | seed | Seed | | Seed string used for pseudo-random generations. | | [probability] | number | 0.5 | Probability to get true. |

Properties

.value

Pseudo-random boolean value generated by the controller.

BooleanController.value: boolean;
.probability

Probability to get true.

BooleanController.probability: number;

SignController

Utility class extending PRNGController for generating pseudo-random sign values (-1 or 1).

Constructor

| Parameter | Type | Default | Description | | ------------- | ---------| ------- | ----------------------------------------------- | | seed | Seed | | Seed string used for pseudo-random generations. | | [probability] | number | 0.5 | Probability to get 1. |

Properties

.value

Pseudo-random sign value generated by the controller.

SignController.value: number;
.probability

Probability to get 1.

SignController.probability: number;

FloatController

Utility class extending PRNGController for generating pseudo-random floating-point numbers within a specified range.

Constructor

| Parameter | Type | Default | Description | | --------- | ------------------ | ------- | ----------------------------------------------- | | seed | Seed | | Seed string used for pseudo-random generations. | | [min] | number | 0 | Minimum boundary. | | [max] | number | 1 | Maximum boundary. |

Properties

.value

Pseudo-random floating-point number generated by the controller.

FloatController.value: number;
.min

Minimum boundary.

FloatController.min: number;
.max

Maximum boundary.

FloatController.max: number;

IntController

Utility class extending PRNGController for generating pseudo-random integer numbers within a specified range.

Constructor

| Parameter | Type | Default | Description | | --------- | ------------------ | ------- | ----------------------------------------------- | | seed | Seed | | Seed string used for pseudo-random generations. | | min | number | | Minimum boundary. | | max | number | | Maximum boundary. |

Properties

.value

Pseudo-random integer number generated by the controller.

IntController.value: number;
.min

Minimum boundary.

IntController.min: number;
.max

Maximum boundary.

IntController.max: number;

HexColorController

Utility class extending PRNGController for generating pseudo-random hexadecimal color strings.

Constructor

| Parameter | Type | Default | Description | | --------- | -------- | ------- | ----------------------------------------------- | | seed | Seed | | Seed string used for pseudo-random generations. |

Properties

.value

Pseudo-random hexadecimal color string generated by the controller.

HexColorController.value: string;

ItemController

Utility class extending PRNGController for pseudo-randomly picking an item from an array.

Constructor

| Parameter | Type | Default | Description | | --------- | ------ | ------- | ----------------------------------------------- | | seed | Seed | | Seed string used for pseudo-random generations. | | items | T[] | | Array of items to pseudo-randomly pick from. |

Properties

.value

Item pseudo-randomly picked from the items array.

ItemController<T>.value: T;
.items

Array of items to pseudo-randomly pick from.

ItemController<T>.items: T[];

ObjectPropertyController

Utility class extending PRNGController for pseudo-randomly picking a property value from an object.

Constructor

| Parameter | Type | Default | Description | | --------- | ------------------- | ------- | ------------------------------------------------------- | | seed | Seed | | Seed string used for pseudo-random generations. | | object | Record<string, T> | | Object to pseudo-randomly pick the property value from. |

Properties

.value

Property value pseudo-randomly picked from the object.

ObjectPropertyController<T>.value: T | undefined;
.object

Object to pseudo-randomly pick the property value from.

ObjectPropertyController<T>.object: Record<string, T>;

WeightsController

Utility class extending PRNGController for pseudo-randomly picking an item from an array of weighted items.

Types

type WeightedItem<T = unknown> = { weight: number; value: T };

type WeightedItems<T = unknown> = Array<WeightedItem<T>>;

Constructor

| Parameter | Type | Default | Description | | --------- | ------------------ | ------- | --------------------------------------------------------- | | seed | Seed | | Seed string or number used for pseudo-random generations. | | items | WeightedItems<T> | | Array of weighted items to pseudo-randomly pick from. |

Properties

.value

Item pseudo-randomly picked from the weighted items array.

WeightsController<T>.value: T;
.items

Array of weighted items to pseudo-randomly pick from.

WeightsController<T>.items: WeightedItems<T>;
.weights

Array of weights.

WeightsController.weights: readonly number[];

GaussianController

Utility class extending PRNGController for generating pseudo-random numbers fitting a Gaussian (normal) distribution.

Constructor

| Parameter | Type | Default | Description | |-----------|-----------|---------|---------------------------------------------------------- | | seed | Seed | | Seed string or number used for pseudo-random generations. | | [mean] | number | 0 | Mean (central) value of the distribution. | | [spread] | number | 1 | Spread (standard deviation) of the distribution. |

Properties

.value

Pseudo-random number value generated by the controller.

GaussianController.value: number;
.mean

Mean (central) value for the distribution.

GaussianController.mean: number;
.spread

Spread (standard deviation) for the distribution.

GaussianController.spread: number;

Group Controllers

PRNGGroupController

Utility abstract class for managing multiple instances of controllers.

Properties

.seed

Seed string used for pseudo-random generations.

PRNGGroupController.seed: string;
.controllers

Controllers managed by the group.

PRNGGroupController<T, C>.controllers: C[];

Methods

.createController(index)

Create a new controller.

  • index: Index of the controller to create.
PRNGGroupController<T, C>.createController(index: number): C;
.getValueAt(index)

Generate a pseudo-random value.

  • index: Index of the controller to use.
PRNGGroupController<T>.getValueAt(index: number): T;
.dispose()

Dispose the group controllers.

PRNGGroupController.dispose(): void;

BooleanGroupController

Utility class extending PRNGGroupController for managing multiple BooleanController.

Constructor

| Parameter | Type | Default | Description | | ------------- | ---------| ------- | ----------------------------------------------- | | seed | Seed | | Seed string used for pseudo-random generations. | | [probability] | number | 0.5 | Probability to get true. |

Properties

.probability

Probability to get true.

BooleanGroupController.probability: number;

SignGroupController

Utility class extending PRNGGroupController for managing multiple SignController.

Constructor

| Parameter | Type | Default | Description | | ------------- | ---------| ------- | ----------------------------------------------- | | seed | Seed | | Seed string used for pseudo-random generations. | | [probability] | number | 0.5 | Probability to get 1. |

Properties

.probability

Probability to get 1.

SignGroupController.probability: number;

FloatGroupController

Utility class extending PRNGGroupController for managing multiple FloatController.

Constructor

| Parameter | Type | Default | Description | | --------- | ------------------ | ------- | ----------------------------------------------- | | seed | Seed | | Seed string used for pseudo-random generations. | | [min] | number | 0 | Minimum boundary. | | [max] | number | 1 | Maximum boundary. |

Properties

.min

Minimum boundary.

FloatGroupController.min: number;
.max

Maximum boundary.

FloatGroupController.max: number;

IntGroupController

Utility class extending PRNGGroupController for managing multiple IntController.

Constructor

| Parameter | Type | Default | Description | | --------- | ------------------ | ------- | ----------------------------------------------- | | seed | Seed | | Seed string used for pseudo-random generations. | | min | number | | Minimum boundary. | | max | number | | Maximum boundary. |

Properties

.min

Minimum boundary.

IntGroupController.min: number;
.max

Maximum boundary.

IntGroupController.max: number;

HexColorGroupController

Utility class extending PRNGGroupController for managing multiple HexColorController.

Constructor

| Parameter | Type | Default | Description | | --------- | -------- | ------- | ----------------------------------------------- | | seed | Seed | | Seed string used for pseudo-random generations. |

ItemGroupController

Utility class extending PRNGGroupController for managing multiple ItemController.

Constructor

| Parameter | Type | Default | Description | | --------- | ------ | ------- | ----------------------------------------------- | | seed | Seed | | Seed string used for pseudo-random generations. | | items | T[] | | Array of items to pseudo-randomly pick from. |

Properties

.items

Array of items to pseudo-randomly pick from.

ItemGroupController<T>.items: T[];

ObjectPropertyGroupController

Utility class extending PRNGGroupController for managing multiple ObjectPropertyController.

Constructor

| Parameter | Type | Default | Description | | --------- | ------------------- | ------- | ------------------------------------------------------- | | seed | Seed | | Seed string used for pseudo-random generations. | | object | Record<string, T> | | Object to pseudo-randomly pick the property value from. |

Properties

.object

Object to pseudo-randomly pick the property value from.

ObjectPropertyGroupController<T>.object: Record<string, T>;

WeightsGroupController

Utility class extending PRNGGroupController for managing multiple WeightsController.

Constructor

| Parameter | Type | Default | Description | | --------- | ------------------ | ------- | --------------------------------------------------------- | | seed | Seed | | Seed string or number used for pseudo-random generations. | | items | WeightedItems<T> | | Array of weighted items to pseudo-randomly pick from. |

Properties

.items

Array of weighted items to pseudo-randomly pick from.

WeightsGroupController<T>.items: WeightedItems<T>;
.weights

Array of weights.

WeightsGroupController.weights: readonly number[];

GaussianGroupController

Utility class extending PRNGGroupController for managing multiple GaussianController.

Constructor

| Parameter | Type | Default | Description | |-----------|-----------|---------|---------------------------------------------------------- | | seed | Seed | | Seed string or number used for pseudo-random generations. | | [mean] | number | 0 | Mean (central) value of the distribution. | | [spread] | number | 1 | Spread (standard deviation) of the distribution. |

Properties

.mean

Mean (central) value for the distribution.

GaussianGroupController.mean: number;
.spread

Spread (standard deviation) for the distribution.

GaussianGroupController.spread: number;

License

MIT License, see LICENSE for details.