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

fast-unique-numbers

Package Overview
Dependencies
Maintainers
1
Versions
148
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-unique-numbers - npm Package Compare versions

Comparing version 6.0.21 to 6.0.22

16

build/es5/bundle.js

@@ -40,5 +40,3 @@ (function (global, factory) {

*/
var nextNumber = lastNumber === undefined ? collection.size : lastNumber < TWO_TO_THE_POWER_OF_THIRTY ? lastNumber + 1 : 0;
if (!collection.has(nextNumber)) {

@@ -53,4 +51,2 @@ return cache(collection, nextNumber);

*/
if (collection.size < TWO_TO_THE_POWER_OF_TWENTY_NINE) {

@@ -60,16 +56,12 @@ while (collection.has(nextNumber)) {

}
return cache(collection, nextNumber);
} // Quickly check if there is a theoretical chance to generate a new number.
}
// Quickly check if there is a theoretical chance to generate a new number.
if (collection.size > MAX_SAFE_INTEGER) {
throw new Error('Congratulations, you created a collection of unique numbers which uses all available integers!');
} // Otherwise use the full scale of safely usable integers.
}
// Otherwise use the full scale of safely usable integers.
while (collection.has(nextNumber)) {
nextNumber = Math.floor(Math.random() * MAX_SAFE_INTEGER);
}
return cache(collection, nextNumber);

@@ -76,0 +68,0 @@ };

@@ -7,3 +7,2 @@ "use strict";

exports.createAddUniqueNumber = void 0;
const createAddUniqueNumber = generateUniqueNumber => {

@@ -16,3 +15,2 @@ return set => {

};
exports.createAddUniqueNumber = createAddUniqueNumber;

@@ -7,3 +7,2 @@ "use strict";

exports.createCache = void 0;
const createCache = lastNumberWeakMap => {

@@ -15,3 +14,2 @@ return (collection, nextNumber) => {

};
exports.createCache = createCache;

@@ -7,3 +7,2 @@ "use strict";

exports.createGenerateUniqueNumber = void 0;
/*

@@ -16,3 +15,2 @@ * The value of the constant Number.MAX_SAFE_INTEGER equals (2 ** 53 - 1) but it

const TWO_TO_THE_POWER_OF_THIRTY = TWO_TO_THE_POWER_OF_TWENTY_NINE * 2;
const createGenerateUniqueNumber = (cache, lastNumberWeakMap) => {

@@ -29,5 +27,3 @@ return collection => {

*/
let nextNumber = lastNumber === undefined ? collection.size : lastNumber < TWO_TO_THE_POWER_OF_THIRTY ? lastNumber + 1 : 0;
if (!collection.has(nextNumber)) {

@@ -42,4 +38,2 @@ return cache(collection, nextNumber);

*/
if (collection.size < TWO_TO_THE_POWER_OF_TWENTY_NINE) {

@@ -49,20 +43,15 @@ while (collection.has(nextNumber)) {

}
return cache(collection, nextNumber);
} // Quickly check if there is a theoretical chance to generate a new number.
}
// Quickly check if there is a theoretical chance to generate a new number.
if (collection.size > MAX_SAFE_INTEGER) {
throw new Error('Congratulations, you created a collection of unique numbers which uses all available integers!');
} // Otherwise use the full scale of safely usable integers.
}
// Otherwise use the full scale of safely usable integers.
while (collection.has(nextNumber)) {
nextNumber = Math.floor(Math.random() * MAX_SAFE_INTEGER);
}
return cache(collection, nextNumber);
};
};
exports.createGenerateUniqueNumber = createGenerateUniqueNumber;

@@ -11,11 +11,6 @@ "use strict";

exports.generateUniqueNumber = exports.addUniqueNumber = void 0;
var _addUniqueNumber = require("./factories/add-unique-number");
var _cache = require("./factories/cache");
var _generateUniqueNumber = require("./factories/generate-unique-number");
var _index = require("./types/index");
Object.keys(_index).forEach(function (key) {

@@ -32,3 +27,2 @@ if (key === "default" || key === "__esModule") return;

});
/*

@@ -38,2 +32,3 @@ * @todo Explicitly referencing the barrel file seems to be necessary when enabling the

*/
const LAST_NUMBER_WEAK_MAP = new WeakMap();

@@ -40,0 +35,0 @@ const cache = (0, _cache.createCache)(LAST_NUMBER_WEAK_MAP);

@@ -6,5 +6,3 @@ "use strict";

});
var _addUniqueNumberFactory = require("./add-unique-number-factory");
Object.keys(_addUniqueNumberFactory).forEach(function (key) {

@@ -20,5 +18,3 @@ if (key === "default" || key === "__esModule") return;

});
var _addUniqueNumberFunction = require("./add-unique-number-function");
Object.keys(_addUniqueNumberFunction).forEach(function (key) {

@@ -34,5 +30,3 @@ if (key === "default" || key === "__esModule") return;

});
var _cacheFactory = require("./cache-factory");
Object.keys(_cacheFactory).forEach(function (key) {

@@ -48,5 +42,3 @@ if (key === "default" || key === "__esModule") return;

});
var _cacheFunction = require("./cache-function");
Object.keys(_cacheFunction).forEach(function (key) {

@@ -62,5 +54,3 @@ if (key === "default" || key === "__esModule") return;

});
var _generateUniqueNumberFactory = require("./generate-unique-number-factory");
Object.keys(_generateUniqueNumberFactory).forEach(function (key) {

@@ -76,5 +66,3 @@ if (key === "default" || key === "__esModule") return;

});
var _generateUniqueNumberFunction = require("./generate-unique-number-function");
Object.keys(_generateUniqueNumberFunction).forEach(function (key) {

@@ -81,0 +69,0 @@ if (key === "default" || key === "__esModule") return;

@@ -13,3 +13,3 @@ {

"dependencies": {
"@babel/runtime": "^7.19.0",
"@babel/runtime": "^7.19.4",
"tslib": "^2.4.0"

@@ -19,7 +19,7 @@ },

"devDependencies": {
"@babel/cli": "^7.18.10",
"@babel/core": "^7.19.0",
"@babel/cli": "^7.19.3",
"@babel/core": "^7.19.6",
"@babel/plugin-external-helpers": "^7.18.6",
"@babel/plugin-transform-runtime": "^7.18.10",
"@babel/preset-env": "^7.19.0",
"@babel/plugin-transform-runtime": "^7.19.6",
"@babel/preset-env": "^7.19.4",
"@babel/register": "^7.18.9",

@@ -33,4 +33,4 @@ "@commitlint/cli": "^17.1.2",

"cz-conventional-changelog": "^3.3.0",
"eslint": "^8.23.0",
"eslint-config-holy-grail": "^52.0.32",
"eslint": "^8.26.0",
"eslint-config-holy-grail": "^52.0.33",
"grunt": "^1.5.3",

@@ -40,3 +40,3 @@ "grunt-cli": "^1.4.3",

"husky": "^8.0.1",
"karma": "^6.4.0",
"karma": "^6.4.1",
"karma-browserstack-launcher": "^1.6.0",

@@ -50,15 +50,15 @@ "karma-chrome-launcher": "^3.1.1",

"load-grunt-config": "^4.0.1",
"mocha": "^10.0.0",
"mocha": "^10.1.0",
"prettier": "^2.7.1",
"pretty-quick": "^3.1.3",
"rimraf": "^3.0.2",
"rollup": "^2.79.0",
"sinon": "^14.0.0",
"rollup": "^2.79.1",
"sinon": "^14.0.1",
"sinon-chai": "^3.7.0",
"tinybench": "^2.1.5",
"ts-loader": "^9.3.1",
"tinybench": "^2.3.1",
"ts-loader": "^9.4.1",
"tsconfig-holy-grail": "^11.1.36",
"tslint": "^6.1.3",
"tslint-config-holy-grail": "^53.2.33",
"typescript": "^4.8.2",
"typescript": "^4.8.4",
"webpack": "^5.74.0"

@@ -94,3 +94,3 @@ },

"types": "build/es2019/module.d.ts",
"version": "6.0.21"
"version": "6.0.22"
}
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