sindresorhus / unique-random

Generate random numbers that are consecutively unique
MIT License
116 stars 15 forks source link

Support optional depth argument #1

Closed aweary closed 8 years ago

aweary commented 8 years ago

Currently unique-random only guarantees a unique random value at a depth of 1 in the call history. We can potentially add a third optional argument depth where users can specifiy how many calls deep the returned value should be compared against. So something like

var rand = uniqueRandom(1, 10, 3);

would mean that the returned value would be unique relative to the last 3 calls.

I'm just wondering if this is something you'd be interested in supporting. If so I can PR. I can fork it otherwise.

sindresorhus commented 8 years ago

Why? What do you need it for?

aweary commented 8 years ago

Using the same slideshow example, you could specify how many pictures in a row are unique. Avoiding possible scenarios like picture1 => picture3 => picture1

sindresorhus commented 8 years ago

I think this would make more sense as a separate module.

aweary commented 8 years ago

For reference: Aweary/unique-random-at-depth