unique-random-array
Advanced tools
Comparing version 1.0.1 to 2.0.0
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
4015
5
21
0
3
+ Addedunique-random@2.1.0(transitive)
- Removedunique-random@1.0.0(transitive)
Updatedunique-random@^2.1.0