Generate random numbers that are consecutively unique
JavaScript
Permalink
Failed to load latest commit information.
.editorconfig tweaks Aug 13, 2014
.gitattributes init Nov 13, 2013
.gitignore init Nov 13, 2013
.jshintrc tweaks Aug 13, 2014
.travis.yml Update .travis.yml Feb 8, 2015
index.js tweaks Aug 13, 2014
license tweaks Aug 13, 2014
package.json minor tweaks Jan 19, 2015
readme.md Close #2 PR: Add unique-random-at-depth to the related repo list. Mar 8, 2016
test.js tweaks Aug 13, 2014

readme.md

unique-random Build Status

Generate random numbers that are consecutively unique

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

Install

$ npm install --save unique-random

Usage

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

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

API

uniqueRandom(min, max)

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

Related

License

MIT © Sindre Sorhus