Huge News!Announcing our $40M Series B led by Abstract Ventures.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 1.0.1 to 2.0.0

index.d.ts

11

index.js
'use strict';
var uniqueRandom = require('unique-random');
const uniqueRandom = require('unique-random');
module.exports = function (arr) {
var rand = uniqueRandom(0, arr.length - 1);
return function () {
return arr[rand()];
};
module.exports = array => {
const random = uniqueRandom(0, array.length - 1);
return () => array[random()];
};
{
"name": "unique-random-array",
"version": "1.0.1",
"description": "Get consecutively unique elements from an array",
"keywords": [
"unique",
"uniq",
"random",
"rand",
"number",
"single",
"generate",
"non-repeating",
"array",
"arr",
"item",
"element"
],
"license": "MIT",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"files": [
"index.js"
],
"repository": "sindresorhus/unique-random-array",
"scripts": {
"test": "ava"
},
"dependencies": {
"unique-random": "^1.0.0"
},
"devDependencies": {
"ava": "*"
},
"engines": {
"node": ">=0.10.0"
}
"name": "unique-random-array",
"version": "2.0.0",
"description": "Get consecutively unique elements from an array",
"license": "MIT",
"repository": "sindresorhus/unique-random-array",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=8"
},
"scripts": {
"test": "xo && ava && tsd"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"unique",
"random",
"number",
"single",
"generate",
"non-repeating",
"array",
"item",
"element"
],
"dependencies": {
"unique-random": "^2.1.0"
},
"devDependencies": {
"ava": "^1.4.1",
"tsd": "^0.7.2",
"xo": "^0.24.0"
}
}

@@ -10,5 +10,5 @@ # unique-random-array [![Build Status](https://travis-ci.org/sindresorhus/unique-random-array.svg?branch=master)](https://travis-ci.org/sindresorhus/unique-random-array)

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

@@ -19,6 +19,7 @@

```js
var uniqueRandomArray = require('unique-random-array');
var rand = uniqueRandomArray([1, 2, 3, 4]);
const uniqueRandomArray = require('unique-random-array');
console.log(rand(), rand(), rand(), rand());
const random = uniqueRandomArray([1, 2, 3, 4]);
console.log(random(), random(), random(), random());
//=> 4 2 1 4

@@ -30,10 +31,9 @@ ```

### uniqueRandomArray(input)
### uniqueRandomArray(array)
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.
#### input
#### array
*Required*
Type: `array`
Type: `unknown[]`

@@ -54,2 +54,2 @@

MIT © [Sindre Sorhus](http://sindresorhus.com)
MIT © [Sindre Sorhus](https://sindresorhus.com)

Sorry, the diff of this file is not supported yet

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