Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

unique-random

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unique-random - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

index.d.ts

15

index.js
'use strict';
module.exports = (min, max) => {
let prev;
return function rand() {
const num = Math.floor((Math.random() * (max - min + 1)) + min);
prev = (num === prev && min !== max) ? rand() : num;
return prev;
module.exports = (minimum, maximum) => {
let previousValue;
return function random() {
const number = Math.floor(
(Math.random() * (maximum - minimum + 1)) + minimum
);
previousValue = number === previousValue && minimum !== maximum ? random() : number;
return previousValue;
};
};

14

package.json
{
"name": "unique-random",
"version": "2.0.0",
"version": "2.1.0",
"description": "Generate random numbers that are consecutively unique",

@@ -16,12 +16,11 @@ "license": "MIT",

"scripts": {
"test": "xo && ava"
"test": "xo && ava && tsd"
},
"files": [
"index.js"
"index.js",
"index.d.ts"
],
"keywords": [
"unique",
"uniq",
"random",
"rand",
"number",

@@ -34,5 +33,6 @@ "single",

"devDependencies": {
"ava": "*",
"xo": "*"
"ava": "^1.4.1",
"tsd": "^0.7.2",
"xo": "^0.24.0"
}
}

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

const uniqueRandom = require('unique-random');
const rand = uniqueRandom(1, 10);
console.log(rand(), rand(), rand());
const random = uniqueRandom(1, 10);
console.log(random(), random(), random());
//=> 5 2 6

@@ -29,5 +30,5 @@ ```

### uniqueRandom(min, max)
### uniqueRandom(minimum, maximum)
Returns a function that when called will return a random number that is never the same as the previous.
Returns a function, that when called, will return a random number that is never the same as the previous.

@@ -34,0 +35,0 @@

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