unique-random
Advanced tools
Comparing version 2.1.0 to 3.0.0
@@ -8,3 +8,3 @@ /** | ||
``` | ||
import uniqueRandom = require('unique-random'); | ||
import uniqueRandom from 'unique-random'; | ||
@@ -17,7 +17,2 @@ const random = uniqueRandom(1, 10); | ||
*/ | ||
declare function uniqueRandom( | ||
minimum: number, | ||
maximum: number | ||
): () => number; | ||
export = uniqueRandom; | ||
export default function uniqueRandom(minimum: number, maximum: number): () => number; |
@@ -1,5 +0,4 @@ | ||
'use strict'; | ||
export default function uniqueRandom(minimum, maximum) { | ||
let previousValue; | ||
module.exports = (minimum, maximum) => { | ||
let previousValue; | ||
return function random() { | ||
@@ -9,5 +8,7 @@ const number = Math.floor( | ||
); | ||
previousValue = number === previousValue && minimum !== maximum ? random() : number; | ||
return previousValue; | ||
}; | ||
}; | ||
} |
{ | ||
"name": "unique-random", | ||
"version": "2.1.0", | ||
"version": "3.0.0", | ||
"description": "Generate random numbers that are consecutively unique", | ||
"license": "MIT", | ||
"repository": "sindresorhus/unique-random", | ||
"funding": "https://github.com/sponsors/sindresorhus", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
"url": "https:/sindresorhus.com" | ||
}, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"engines": { | ||
"node": ">=6" | ||
"node": ">=12" | ||
}, | ||
@@ -32,6 +35,6 @@ "scripts": { | ||
"devDependencies": { | ||
"ava": "^1.4.1", | ||
"tsd": "^0.7.2", | ||
"xo": "^0.24.0" | ||
"ava": "^3.15.0", | ||
"tsd": "^0.14.0", | ||
"xo": "^0.38.2" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# unique-random [![Build Status](https://travis-ci.org/sindresorhus/unique-random.svg?branch=master)](https://travis-ci.org/sindresorhus/unique-random) | ||
# unique-random | ||
@@ -7,3 +7,2 @@ > Generate random numbers that are consecutively unique | ||
## Install | ||
@@ -15,7 +14,6 @@ | ||
## Usage | ||
```js | ||
const uniqueRandom = require('unique-random'); | ||
import uniqueRandom from 'unique-random'; | ||
@@ -28,3 +26,2 @@ const random = uniqueRandom(1, 10); | ||
## API | ||
@@ -36,3 +33,2 @@ | ||
## Related | ||
@@ -48,6 +44,1 @@ | ||
- [crypto-random-string](https://github.com/sindresorhus/crypto-random-string) - Generate a cryptographically strong random string | ||
## License | ||
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
Yes
3969
22
40