Get consecutively unique elements from an array
Switch branches/tags
Nothing to show
Clone or download
Latest commit 8cee9d2 Mar 23, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.editorconfig Require Node.js 6 Mar 23, 2018
.gitattributes Require Node.js 6 Mar 23, 2018
.gitignore Require Node.js 6 Mar 23, 2018
.npmrc Require Node.js 6 Mar 23, 2018
.travis.yml Require Node.js 6 Mar 23, 2018
index.js Require Node.js 6 Mar 23, 2018
license Require Node.js 6 Mar 23, 2018
package.json Require Node.js 6 Mar 23, 2018
readme.md Require Node.js 6 Mar 23, 2018
test.js Require Node.js 6 Mar 23, 2018

readme.md

unique-random-array Build Status

Get consecutively unique elements from an array

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

Install

$ npm install unique-random-array

Usage

const uniqueRandomArray = require('unique-random-array');
const random = uniqueRandomArray([1, 2, 3, 4]);

console.log(random(), random(), random(), random());
//=> 4 2 1 4

API

uniqueRandomArray(input)

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

input

Type: Array

Related

License

MIT © Sindre Sorhus