Comparing version 1.0.3 to 1.1.0
@@ -38,15 +38,20 @@ 'use strict'; | ||
Breaker.prototype.run = function run(context, callback) { | ||
var self, fallback, fn; | ||
Breaker.prototype.run = function run(/*args...n, callback*/) { | ||
var args, self, fallback, orig; | ||
args = Array.prototype.slice.call(arguments); | ||
self = this; | ||
fallback = this.fallback; | ||
fn = callback; | ||
if (fallback instanceof Breaker) { | ||
fn = function wrapper(err/*, ...data*/) { | ||
orig = args.slice(); | ||
args[args.length - 1] = function wrapper(err/*, ...data*/) { | ||
var callback; | ||
if (err && self.isOpen()) { | ||
fallback.run(context, callback); | ||
fallback.run.apply(fallback, orig); | ||
return; | ||
} | ||
callback = orig.pop(); | ||
callback.apply(null, arguments); | ||
@@ -56,11 +61,14 @@ }; | ||
this._run(context, fn); | ||
this._run.apply(this, args); | ||
}; | ||
Breaker.prototype._run = function _run(context, callback) { | ||
var self, start, timer, execute; | ||
Breaker.prototype._run = function _run(/*args...n, callback*/) { | ||
var args, callback, self, start, timer, execute; | ||
this.emit('execute'); | ||
args = Array.prototype.slice.call(arguments); | ||
callback = args.pop(); | ||
if (this.isOpen() || this._pendingClose) { | ||
@@ -97,4 +105,3 @@ this.emit('reject'); | ||
execute = Zalgo.contain(this._impl.execute, this._impl); | ||
execute(context, function onreponse(err/*, ...data*/) { | ||
args[args.length] = function onreponse(err/*, ...data*/) { | ||
if (!timer) { return; } | ||
@@ -117,3 +124,7 @@ | ||
callback.apply(null, arguments); | ||
}); | ||
}; | ||
execute = Zalgo.contain(this._impl.execute, this._impl); | ||
execute.apply(null, args); | ||
}; | ||
@@ -120,0 +131,0 @@ |
{ | ||
"name": "levee", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"description": "A circuitbreaker implementation for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14664
252