@prng/core
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

PRNG (Pseudo Random Number Generator)

A Collection of PRNG's in JavaScript and TypeScript

This library is a wrapper around all implementations of the PRNG's made by @bryc found in https://github.com/bryc/code/blob/master/jshash/PRNGs.md

Install

With NPM: npm install prng@npm:@prng/core

With Yarn: yarn add prng@npm:@prng/core

With PNPM: pnpm install prng@npm:@prng/core

Create a Generator (In JavaScript)

  const { PRNG } = require('prng'); // or import { PRNG } from 'prng' with es6 modules

  // First argument is the algorithm, i.e. - mulberry32, sfc32, jsf32, gjrand32, etc.
  const prng = PRNG.createGenerator('mulberry32', 1999);
  console.log(prng.next().value);
  console.log(prng.next().value);

Create a Callback (In JavaScript)

  const { PRNG } = require('prng'); // or import { PRNG } from 'prng' with es6 modules

  // First argument is the algorithm, i.e. - mulberry32, sfc32, jsf32, gjrand32, etc.
  const prng = PRNG.createCallback('mulberry32', 1999);
  console.log(prng());
  console.log(prng());

Readme

Keywords

none

Package Sidebar

Install

npm i @prng/core

Weekly Downloads

1

Version

1.0.2

License

none

Unpacked Size

9.73 kB

Total Files

4

Last publish

Collaborators

  • swimauger