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

throttleit

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

throttleit - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

4

component.json

@@ -5,3 +5,3 @@ {

"description": "Throttle a function",
"version": "0.0.1",
"version": "0.0.2",
"keywords": [],

@@ -14,2 +14,2 @@ "dependencies": {},

]
}
}
module.exports = function(fn, ms){
var ok = true;
return function(){
if (!ok) return;
/**
* Module exports.
*/
// invoke
fn.apply(this, arguments);
module.exports = throttle;
// timeout
ok = false;
setTimeout(function(){
ok = true;
}, ms);
}
};
/**
* Returns a new function that, when invoked, invokes `func` at most one time per
* `wait` milliseconds.
*
* @param {Function} func The `Function` instance to wrap.
* @param {Number} wait The minimum number of milliseconds that must elapse in between `func` invokations.
* @return {Function} A new function that wraps the `func` function passed in.
* @api public
*/
function throttle (func, wait) {
var rtn; // return value
var last = 0; // last invokation timestamp
return function throttled () {
var now = new Date().getTime();
var delta = now - last;
if (delta >= wait) {
rtn = func.apply(this, arguments);
last = now;
}
return rtn;
};
}
{
"name": "throttleit",
"description": "Throttle a function",
"version": "0.0.1",
"version": "0.0.2",
"keywords": [],
"repository": {
"type": "git",
"url": "git://github.com/component/throttle.git"
},
"dependencies": {},

@@ -7,0 +11,0 @@ "development": {},

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