Skip to content

aweary/unique-random-at-depth

Repository files navigation

unique-random-at-depth Build Status

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

Install

$ npm install --save unique-random-at-depth

Usage

var uniqueRandom = require('unique-random-at-depth');
var rand = uniqueRandom(1, 10, 3);

console.log(rand(), rand(), rand());
//=> 5 2 6

API

uniqueRandomAtDepth(min, max, [depth])

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.

Related

License

MIT © Sindre Sorhus MIT © Brandon Dail

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published