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

event-horizon

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

event-horizon - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

6

event-horizon.js

@@ -16,3 +16,3 @@ /*global module*/

for (index = 0; index < max; index += 1) {
if (time - timeArray[index] < conf.max) {
if ((time - timeArray[index]) < conf.window) {
break; // we reached the window again

@@ -26,3 +26,3 @@ }

return {
run: function (func, eatenCB) {
run: function (func, eat) {
var time = new Date().getTime();

@@ -39,3 +39,3 @@

if (timeArray.length >= conf.max) {
eatenCB();
eat();
return;

@@ -42,0 +42,0 @@ }

{
"name": "event-horizon",
"version": "0.1.5",
"version": "0.1.6",
"description": "Stay below a certain number of things per second",

@@ -11,3 +11,3 @@ "main": "event-horizon.js",

"scripts": {
"test": "gulp test"
"test": "mocha test"
},

@@ -14,0 +14,0 @@ "keywords": [

@@ -32,3 +32,3 @@ /*global require, describe, it, console, setTimeout*/

it('should use a sliding window', function (done) {
var t = horizon.instance({ window: 20, max: 10 }),
var t = horizon.instance({ window: 100, max: 10 }),
run = 0,

@@ -42,14 +42,14 @@ eaten = 0,

loop(100, t, i, function () {eaten += 1; }, function () { run += 1; });
}, 18);
}, 70);
setTimeout(function () {
loop(100, t, i, function () {eaten += 1; }, function () { run += 1; });
assert.equal(10, run);
assert.equal(10, run);
assert.equal(190, eaten);
done();
}, 21);
}, 105);
});
it('should reset when I go over window', function (done) {
var t = horizon.instance({ window: 10, max: 10 }),
var t = horizon.instance({ window: 100, max: 10 }),
run = 0,

@@ -69,5 +69,5 @@ eaten = 0,

done();
}, 11);
}, 11);
}, 102);
}, 102);
});
});
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