unique-random

Generate random numbers that are consecutively unique

npm install unique-random
2 downloads in the last day
3 downloads in the last week
17 downloads in the last month

unique-random Build Status

Generate random numbers that are consecutively unique.

Useful for eg. slideshows where you don't want to have the same slide twice in a row.

Install

Download manually or with a package-manager.

npm

npm install --save unique-random

Bower

bower install --save unique-random

Component

component install sindresorhus/unique-random

Example

Using Node.js. Will generate a random number between 1 and 10.

var uniqueRandom = require('unique-random')(1, 10);
console.log(uniqueRandom(), uniqueRandom(), uniqueRandom());
// 5 2 6

API

uniqueRandom(min, max)

Returns a function which when called will return a random number that's never the same as the previous number.

License

MIT © Sindre Sorhus

npm loves you