New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dahelpers

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dahelpers - npm Package Compare versions

Comparing version 0.3.5 to 0.3.6

33

dahelpers.js

@@ -596,23 +596,35 @@ // Generated by CoffeeScript 1.6.3

},
throttled: function(fn, period) {
throttled: function(fn, period, bindTo) {
var lastCall;
if (bindTo == null) {
bindTo = null;
}
lastCall = null;
return function() {
var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
if (!lastCall || Date.now() - lastCall >= period) {
lastCall = Date.now();
return fn.apply(null, arguments);
return fn.apply(bindTo, args);
}
};
},
debounced: function(fn, period) {
debounced: function(fn, period, bindTo) {
var timeout;
if (bindTo == null) {
bindTo = null;
}
timeout = null;
return function() {
var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
if (timeout != null) {
clearTimeout(timeout);
}
return timeout = setTimeout(fn, period);
return timeout = setTimeout(function() {
return fn.apply(bindTo, args);
}, period);
};
},
queued: function(fn, period) {
queued: function(fn, period, bindTo) {
var execQueue, queueArgs, queued, timeout;

@@ -622,4 +634,13 @@ if (period == null) {

}
if (bindTo == null) {
bindTo = null;
}
queueArgs = [];
timeout = null;
if (arguments.length === 2) {
if (!h.type(period, 'number')) {
bindTo = period;
period = null;
}
}
execQueue = function() {

@@ -630,3 +651,3 @@ var a, _i, _len, _results;

a = queueArgs[_i];
_results.push(fn.apply(null, a));
_results.push(fn.apply(bindTo, a));
}

@@ -633,0 +654,0 @@ return _results;

2

package.json

@@ -43,3 +43,3 @@ {

},
"version" : "0.3.5"
"version" : "0.3.6"
}

@@ -2251,3 +2251,3 @@ // Generated by CoffeeScript 1.6.3

describe('#throttled', function() {
return it('throttles the function', function() {
it('throttles the function', function() {
var cycles, maxCalls, throttled;

@@ -2265,6 +2265,21 @@ maxCalls = 5;

});
return it('can be bound to custom object', function() {
var maxCalls, o, res;
res = [];
maxCalls = 5;
o = {
a: function() {
maxCalls -= 1;
equal(this, o);
}
};
o.a = h.throttled(o.a, 50, o);
while (maxCalls) {
o.a();
}
});
});
describe('#debounced', function() {
return it('debounces the function', function() {
it('debounces the function', function() {
var actualCalls, debounced, interval, maxCalls;

@@ -2287,2 +2302,24 @@ maxCalls = 5;

});
return it('can be bound to objects', function() {
var counter, interval, maxCalls, o;
maxCalls = 5;
counter = 0;
o = {
a: function() {
counter += 1;
equal(this, o);
}
};
o.a = h.debounced(o.a, 50, o);
interval = setInterval(function() {
o.a();
maxCalls -= 1;
if (!maxCalls) {
return clearInterval(interval);
}
}, 45);
return setTimeout(function() {
return equal(counter, 1);
}, 5 * 45 + 50 + 30);
});
});

@@ -2310,3 +2347,3 @@

});
return it('can be forced to run the queue immediately', function() {
it('can be forced to run the queue immediately', function() {
var counter, i, maxCalls, queued, _i;

@@ -2324,2 +2361,24 @@ maxCalls = 5;

});
return it('can be bound to objects', function() {
var counter, interval, maxCalls, o;
maxCalls = 5;
counter = 0;
o = {
a: function() {
counter += 1;
equal(this, o);
}
};
o.a = h.queued(o.a, 50, o);
interval = setInterval(function() {
o.a();
maxCalls -= 1;
if (!maxCalls) {
return clearInterval(interval);
}
}, 45);
return setTimeout(function() {
return equal(counter, 5);
}, 5 * 45 + 50 + 30);
});
});

@@ -2326,0 +2385,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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