JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q45143F
  • License ISC

A simple, no-frills, seedable random number generator from sha256 hashes

Package Exports

  • seedable
  • seedable/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (seedable) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

A simple, no-frills, seedable random number generator from sha256 hashes.

Written in plain JavaScript. Depends on Node.js Crypto.

Installation

npm install seedable

Usage

const createRng = require("seedable");

const rng = createRng(); // same as createRng(0)

rng.value; // -> 0.7383370615243194

rng.float(); // -> 0.9614931357219447 (same as rng.value)

rng.int(); // -> 100808138967781

rng.int(0, 10); // -> 4

rng.int() / rng.maxInt; // -> 0.103077615824823 (same as rng.value)

Array.from({ length: 5 }, rng.float);
/* [
  0.09483751870746815,
  0.7032565997288494,
  0.7963769571204509,
  0.22362232298566553,
  0.15776174101813822
] */