unique-random-array
Get consecutively unique elements from an array
Last updated 8 years ago by sindresorhus .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install unique-random-array 
SYNC missed versions from official npm registry.

unique-random-array

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

import uniqueRandomArray from 'unique-random-array';

const random = uniqueRandomArray([1, 2, 3, 4]);

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

API

uniqueRandomArray(array)

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

array

Type: unknown[]

Related

Current Tags

  • 3.0.0                                ...           latest (5 years ago)

4 Versions

  • 3.0.0                                ...           5 years ago
  • 2.0.0                                ...           7 years ago
  • 1.0.1                                ...           8 years ago
  • 1.0.0                                ...           11 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (1)
Dev Dependencies (1)
Dependents (2)

Copyright 2013 - present © cnpmjs.org | Home |