Socket
Socket
Sign inDemoInstall

enhanced-resolve

Package Overview
Dependencies
0
Maintainers
1
Versions
129
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.7 to 0.2.8

30

lib/createThrottledFunction.js

@@ -7,14 +7,31 @@ /*

MAX_DURATION = MAX_DURATION || 2000;
var RESOLUTION = Math.floor(Math.min(MAX_DURATION / 20, 300));
cache = cache || {};
var lastTime = new Date();
var currentTime = lastTime;
var trottled = false;
function tick() {
currentTime = new Date();
trottled = true;
setTimeout(unthrottle, RESOLUTION);
}
function unthrottle() {
trottled = false;
}
return function throttledFunction(identifier) {
var args = Array.prototype.slice.call(arguments, 0);
var callback = args.pop();
var currentTime = new Date();
// clear all if old
if(currentTime - lastTime > MAX_DURATION) {
for(var name in cache)
delete cache[name];
if(!trottled) {
tick();
// clear all if old
if(currentTime - lastTime > MAX_DURATION) {
for(var name in cache)
delete cache[name];
}
}

@@ -41,4 +58,5 @@

lastTime = currentTime;
var requestTime = currentTime;
args.push(function onThrottledFunctionCallback(err, result) {
cacheEntry.time = currentTime;
cacheEntry.time = requestTime;
cacheEntry.err = err;

@@ -45,0 +63,0 @@ cacheEntry.result = result;

2

package.json
{
"name": "enhanced-resolve",
"version": "0.2.7",
"version": "0.2.8",
"author": "Tobias Koppers @sokra",

@@ -5,0 +5,0 @@ "description": "Offers a async require.resolve function. It's highly configurable.",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc