parkmiller-random
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

ParkMiller-Random

License npm

ParkMiller-Random is a lightweight JavaScript library for generating pseudorandom numbers using the Park-Miller algorithm.

Installation

You can install ParkMiller-Random via npm:

npm install parkmiller-random

Usage

const ParkMillerRandom = require('parkmiller-random');

// Create a new instance of ParkMillerRandom with a seed
const prng = new ParkMillerRandom(12345);

// Generate pseudorandom integer
const randomInt = prng.integer();

// Generate pseudorandom integer within range
const randomIntInRange = prng.integerInRange(10, 100);

// Generate pseudorandom floating-point number
const randomFloat = prng.float();

// Generate pseudorandom floating-point number within range
const randomFloatInRange = prng.floatInRange(0.5, 1.5);

// Generate pseudorandom boolean value
const randomBool = prng.boolean();

API

constructor(seed: number)

Constructs a new ParkMillerRandom instance with the specified seed.

integer(): number

Generates a pseudorandom integer.

integerInRange(min: number, max: number): number

Generates a pseudorandom integer within the specified range.

float(): number

Generates a pseudorandom floating-point number.

floatInRange(min: number, max: number): number

Generates a pseudorandom floating-point number within the specified range.

boolean(): boolean

Generates a pseudorandom boolean value.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Package Sidebar

Install

npm i parkmiller-random

Weekly Downloads

4

Version

1.0.0

License

MIT

Unpacked Size

7.27 kB

Total Files

5

Last publish

Collaborators

  • vincenzomaritato