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

cog

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cog - npm Package Compare versions

Comparing version 0.5.0 to 0.5.1

2

package.json

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

"author": "Damon Oehlman <damon.oehlman@gmail.com>",
"version": "0.5.0",
"version": "0.5.1",
"dependencies": {},

@@ -8,0 +8,0 @@ "devDependencies": {

@@ -235,2 +235,8 @@ # cog

## cog/throttle
```js
var throttle = require('cog/throttle');
```
### throttle(fn, delay)

@@ -237,0 +243,0 @@

@@ -5,4 +5,10 @@ /* jshint node: true */

/**
### throttle(fn, delay)
## cog/throttle
```js
var throttle = require('cog/throttle');
```
### throttle(fn, delay, opts)
A cherry-pickable throttle function. Used to throttle `fn` to ensure

@@ -14,7 +20,11 @@ that it can be called at most once every `delay` milliseconds. Will

**/
module.exports = function(fn, delay) {
var lastExec = 0;
module.exports = function(fn, delay, opts) {
var lastExec = (opts || {}).leading !== false ? 0 : Date.now();
var trailing = (opts || {}).trailing;
var timer;
var queuedArgs;
var queuedScope;
// trailing defaults to true
trailing = trailing || trailing === undefined;

@@ -37,3 +47,3 @@ function invokeDefered() {

return timer = setTimeout(invokeDefered, delay - elapsed);
return trailing && (timer = setTimeout(invokeDefered, delay - elapsed));
}

@@ -40,0 +50,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