unique-random-array
- Version 4.0.0
- Published
- 4.31 kB
- 1 dependency
- MIT license
Install
npm i unique-random-array
yarn add unique-random-array
pnpm add unique-random-array
Overview
Get consecutively unique elements from an array
Index
Functions
Type Aliases
Functions
function uniqueRandomArray
uniqueRandomArray: { <T>(array: EmptyArray): () => undefined; <T>(array: NonEmptyArray<T>): () => T; <T>(array: readonly T[]): () => T;};
Get consecutively unique elements from an array.
Returns
A function, that when called, will return a random element that is never the same as the previous.
Example 1
import uniqueRandomArray from 'unique-random-array';const random = uniqueRandomArray([1, 2, 3, 4]);console.log(random(), random(), random(), random());//=> 4 2 1 4
Type Aliases
type EmptyArray
type EmptyArray = readonly never[] & { length: 0 };
type NonEmptyArray
type NonEmptyArray<T> = | readonly [T, ...T[]] | readonly [...T[], T] | readonly [T, ...T[], T];
Package Files (1)
Dependencies (1)
Dev Dependencies (3)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/unique-random-array
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/unique-random-array)
- HTML<a href="https://www.jsdocs.io/package/unique-random-array"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 2769 ms. - Missing or incorrect documentation? Open an issue for this package.