random-int-memoized
v1.0.0
Published
A random integer generator that does not pick the same number twice until it runs out of unique numbers.
Downloads
1
Maintainers
Readme
random-int-memoized
Install
$ npm install random-int-memoized
Usage
Import/Require random-int-memoized
import { randomIntMemoized } from "random-int-memoized";
const { randomIntMemoized } = require("random-int-memoized");
Initialize random function and call it
const random = randomIntMemoized(1, 5);
console.log(random(), random(), random(), random(), random());
//=> 5 2 4 1 3
API
randomIntMemoized(lowerBound, upperBound)
Returns a function that when called will generate and return a random integer between and including the lowerBound and upperBound. The function will go through all numbers in the range before returning any given value twice.