unique-random-array
Get consecutively unique elements from an array
Last updated 6 months ago by sindresorhus .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm 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, or undefined if the array is empty.

array

Type: unknown[]

Related

Current Tags

  • 4.0.0                                ...           latest (6 months ago)

5 Versions

  • 4.0.0                                ...           6 months ago
  • 3.0.0                                ...           4 years ago
  • 2.0.0                                ...           6 years ago
  • 1.0.1                                ...           7 years ago
  • 1.0.0                                ...           10 years ago
Maintainers (1)
Downloads
Total 0
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (3)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE