New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

unique-random-array

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unique-random-array - npm Package Compare versions

Comparing version 3.0.0 to 4.0.0

7

index.d.ts

@@ -0,1 +1,4 @@

type EmptyArray = readonly never[] & {length: 0};
type NonEmptyArray<T> = readonly [T, ...T[]] | readonly [...T[], T] | readonly [T, ...T[], T];
/**

@@ -16,2 +19,4 @@ Get consecutively unique elements from an array.

*/
export default function uniqueRandomArray<T>(array: readonly T[]): () => T;
export default function uniqueRandomArray<T>(array: EmptyArray): () => undefined;
export default function uniqueRandomArray<T>(array: NonEmptyArray<T>): () => T;
export default function uniqueRandomArray<T>(array: readonly T[]): () => T | undefined;

4

index.js

@@ -1,6 +0,6 @@

import uniqueRandom from 'unique-random';
import {consecutiveUniqueRandom} from 'unique-random';
export default function uniqueRandomArray(array) {
const random = uniqueRandom(0, array.length - 1);
const random = consecutiveUniqueRandom(0, array.length - 1);
return () => array[random()];
}
{
"name": "unique-random-array",
"version": "3.0.0",
"version": "4.0.0",
"description": "Get consecutively unique elements from an array",

@@ -14,5 +14,9 @@ "license": "MIT",

"type": "module",
"exports": "./index.js",
"exports": {
"types": "./index.d.ts",
"default": "./index.js"
},
"sideEffects": false,
"engines": {
"node": ">=12"
"node": ">=18"
},

@@ -38,9 +42,9 @@ "scripts": {

"dependencies": {
"unique-random": "^3.0.0"
"unique-random": "^4.0.0"
},
"devDependencies": {
"ava": "^3.15.0",
"tsd": "^0.14.0",
"xo": "^0.38.2"
"ava": "^6.1.3",
"tsd": "^0.31.0",
"xo": "^0.58.0"
}
}

@@ -9,5 +9,5 @@ # unique-random-array

```sh
npm install unique-random-array
```
$ npm install unique-random-array
```

@@ -29,3 +29,3 @@ ## Usage

Returns a function, that when called, will return a random element that's never the same as the previous.
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.

@@ -32,0 +32,0 @@ #### array

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc