Generate random numbers that are consecutively unique at a provided depth
MIT License
Generate random numbers that are consecutively unique relative to a provided call depth.
Useful for things like slideshows where you don't want to have the same slide n
times in a row. Based on unique-random
$ npm install --save unique-random-at-depth
var uniqueRandom = require('unique-random-at-depth');
var rand = uniqueRandom(1, 10, 3);
console.log(rand(), rand(), rand());
//=> 5 2 6
Returns a function that when called will return a random number that's never the same as the previous. If depth
is provided it will ensure that the random is unique relative to the last n results. So if you pass in 5
it will ensure that
the return value is unique relative to the last 5 results.
MIT © Sindre Sorhus MIT © Brandon Dail