1. unique-random-array
Get consecutively unique elements from an array
unique-random-array
Package: unique-random-array
Created by: sindresorhus
Last modified: Tue, 28 Jun 2022 04:41:59 GMT
Version: 3.0.0
License: MIT
Downloads: 302,815
Repository: https://github.com/sindresorhus/unique-random-array

Install

npm install unique-random-array
yarn add unique-random-array

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 POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code