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

disyuntor

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

disyuntor - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

8

index.js

@@ -32,3 +32,3 @@ const ms = require('ms');

var failures, lastFailure, currentCooldown;
var failures, lastFailure, currentCooldown, monitorCalled;

@@ -51,2 +51,3 @@ function getState() {

currentCooldown = config.cooldown;
monitorCalled = false;
}

@@ -66,2 +67,6 @@

const err = new DisyuntorError(`${config.name}: the circuit-breaker is open`);
if (!monitorCalled) {
monitorCalled = true;
config.monitor({err});
}
return setImmediate(originalCallback, err);

@@ -76,3 +81,2 @@ }

}
config.monitor({err, args});
originalCallback(err);

@@ -79,0 +83,0 @@ }

{
"name": "disyuntor",
"description": "A circuit-breaker implementation with exponential backoff.",
"version": "1.2.0",
"version": "1.2.1",
"author": "José F. Romaniello <jfromaniello@gmail.com> (http://joseoncode.com)",

@@ -6,0 +6,0 @@ "repository": {

@@ -44,4 +44,3 @@ const disyuntor = require('./..');

assert.closeTo(Date.now() - startTime, 10, 10);
assert.equal(monitorCalls[0].err, err);
assert.equal(monitorCalls[0].args.length, 0);
assert.equal(monitorCalls.length, 0);
done();

@@ -52,11 +51,10 @@ });

it('should fail immediately after "maxFailures"', function (done) {
sut().catch((err1) => {
sut().catch(() => {
var startTime = Date.now();
sut().catch(err2 => {
assert.instanceOf(err2, Error);
assert.instanceOf(err2, DisyuntorError);
assert.match(err2.message, /test\.func: the circuit-breaker is open/);
sut().catch(err => {
assert.instanceOf(err, Error);
assert.instanceOf(err, DisyuntorError);
assert.match(err.message, /test\.func: the circuit-breaker is open/);
assert.closeTo(Date.now() - startTime, 1, 2);
assert.equal(monitorCalls[0].err, err1);
assert.equal(monitorCalls[0].args.length, 0);
assert.equal(monitorCalls[0].err, err);
done();

@@ -72,4 +70,3 @@ });

assert.match(err.message, /test\.func: specified timeout of 10ms was reached/);
assert.equal(monitorCalls[1].err, err);
assert.equal(monitorCalls[1].args.length, 0);
assert.equal(monitorCalls.length, 0);
done();

@@ -155,7 +152,6 @@ });

assert.equal(err1.message, 'failure');
assert.equal(monitorCalls[0].err, err1);
assert.equal(monitorCalls[0].args.length, 1);
assert.equal(monitorCalls[0].args[0], 2);
assert.equal(monitorCalls.length, 0);
return sut(2).catch(err2 => {
assert.match(err2.message, /test\.func: the circuit-breaker is open/);
assert.equal(monitorCalls[0].err, err2);
});

@@ -162,0 +158,0 @@ });

@@ -35,4 +35,3 @@ const disyuntor = require('./..');

assert.closeTo(Date.now() - startTime, 10, 10);
assert.equal(monitorCalls[0].err, err);
assert.equal(monitorCalls[0].args.length, 0);
assert.equal(monitorCalls.length, 0);
done();

@@ -43,9 +42,8 @@ });

it('should fail immediately after "maxFailures"', function (done) {
sut((err1) => {
sut(() => {
var startTime = Date.now();
sut(err2 => {
assert.match(err2.message, /test\.func: the circuit-breaker is open/);
sut(err => {
assert.match(err.message, /test\.func: the circuit-breaker is open/);
assert.closeTo(Date.now() - startTime, 1, 2);
assert.equal(monitorCalls[0].err, err1);
assert.equal(monitorCalls[0].args.length, 0);
assert.equal(monitorCalls[0].err, err);
done();

@@ -61,4 +59,3 @@ });

assert.match(err.message, /test\.func: specified timeout of 10ms was reached/);
assert.equal(monitorCalls[1].err, err);
assert.equal(monitorCalls[1].args.length, 0);
assert.equal(monitorCalls.length, 0);
done();

@@ -79,2 +76,3 @@ });

assert.match(err.message, /test\.func: specified timeout of 10ms was reached/);
assert.equal(monitorCalls.length, 0);
cb();

@@ -89,2 +87,3 @@ });

assert.match(err.message, /test\.func: the circuit-breaker is open/);
assert.equal(monitorCalls.length, 1);
cb();

@@ -98,2 +97,3 @@ });

assert.match(err.message, /test\.func: specified timeout of 10ms was reached/);
assert.equal(monitorCalls.length, 1);
cb();

@@ -108,2 +108,3 @@ });

assert.match(err.message, /test\.func: specified timeout of 10ms was reached/);
assert.equal(monitorCalls.length, 1);
cb();

@@ -144,7 +145,6 @@ });

assert.equal(err1.message, 'failure');
assert.equal(monitorCalls[0].err, err1);
assert.equal(monitorCalls[0].args.length, 1);
assert.equal(monitorCalls[0].args[0], 2);
assert.equal(monitorCalls.length, 0);
sut(2, err2 => {
assert.match(err2.message, /test\.func: the circuit-breaker is open/);
assert.equal(monitorCalls[0].err, err2);
done();

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