Comparing version 0.1.0 to 0.1.1
@@ -22,3 +22,2 @@ /* | ||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
(function(a){a=a||{};var b={},c,d,e=function(){};c=function(a,d,e){var f=a.halt=!1;a.error=function(){a.halt=!0},a.next=function(c){c&&(f=!1);if(!a.halt&&d&&d.length){var e=d.shift(),g=e.shift();f=!0;try{b[g].apply(a,[e,e.length,g])}catch(h){a.error(h)}}return a};for(var g in b){if(typeof a[g]==="function")continue;(function(b){a[b]=function(){var e,g=Array.prototype.slice.call(arguments);g.unshift(b);if(!d)return c({},[g],b);a.then=a[b],d.push(g);return f?a:a.next()}})(g)}e&&(a.then=a[e]),a.callMethod=function(b,c){c.unshift(b),d.unshift(c),a.next(!0)};return a.next()},d=a.addMethod=function(d){var e=Array.prototype.slice.call(arguments),f=e.pop();for(var g=0,h=e.length;g<h;g++)typeof e[g]==="string"&&(b[e[g]]=f);--h||(b["then"+ethod[0].toUpperCase()+d.substr(1)]=f),c(a)},d("chain",function(a){var b=this,c=function(){if(!b.halt){if(!a.length)return b.next(!0);try{null!=a.shift().call(this,c,b.error)&&c()}catch(d){b.error(d)}}};c()}),d("run",function(a,b){var c=this,d=function(){c.halt||(--b||c.next(!0))};for(var e=0,f=b;!this.halt&&e<f;e++)null!=a[e].call(this,d,this.error)&&d()}),d("first",function(a,b){var c=this,d=function(){c.next(!0)};for(var e=0;!this.halt&&e<b;e++)null!=a.shift().call(this,d,this.error)&&this.next(!0)}),d("all",function(a,b){for(var c=0;!this.halt&&c<b;c++)a.shift().call(this,e,this.error);this.next(!0)}),d("onError",!1,function(a,b){var c=this.error;this.error=function(d){c();for(var e=0;e<b;e++)a[e].call(this,d)}})})(this) | ||
*/(function(a){a=a||{};var b={},c,d,e=function(){};c=function(a,d,e){var f=a.halt=!1;a.error=function(){a.halt=!0},a.next=function(c){c&&(f=!1);if(!a.halt&&d&&d.length){var e=d.shift(),g=e.shift();f=!0;try{b[g].apply(a,[e,e.length,g])}catch(h){a.error(h)}}return a};for(var g in b){if(typeof a[g]==="function")continue;(function(b){a[b]=function(){var e=Array.prototype.slice.call(arguments);e.unshift(b);if(!d)return c({},[e],b);a.then=a[b],d.push(e);return f?a:a.next()}})(g)}e&&(a.then=a[e]),a.callMethod=function(b,c){c.unshift(b),d.unshift(c),a.next(!0)};return a.next()},d=a.addMethod=function(d){var e=Array.prototype.slice.call(arguments),f=e.pop();for(var g=0,h=e.length;g<h;g++)typeof e[g]==="string"&&(b[e[g]]=f);--h||(b["then"+d[0].toUpperCase()+d.substr(1)]=f),c(a)},d("chain",function(a){var b=this,c=function(){if(!b.halt){if(!a.length)return b.next(!0);try{null!=a.shift().call(this,c,b.error)&&c()}catch(d){b.error(d)}}};c()}),d("run",function(a,b){var c=this,d=function(){c.halt||(--b||c.next(!0))};for(var e=0,f=b;!this.halt&&e<f;e++)null!=a[e].call(this,d,this.error)&&d()}),d("onError",!1,function(a,b){var c=this.error;this.error=function(d){c();for(var e=0;e<b;e++)a[e].call(this,d)}})})(this) |
24
chain.js
@@ -59,3 +59,3 @@ /* | ||
context[alias] = function () { | ||
var uc, args = Array.prototype.slice.call(arguments); | ||
var args = Array.prototype.slice.call(arguments); | ||
args.unshift(alias); | ||
@@ -96,3 +96,3 @@ if (!stack) { | ||
//e.g. adding 'run' also adds 'thenRun' as a method | ||
handlers['then' + ethod[0].toUpperCase() + method.substr(1)] = handler; | ||
handlers['then' + method[0].toUpperCase() + method.substr(1)] = handler; | ||
} | ||
@@ -137,22 +137,2 @@ createChain(exports); | ||
//Run each function in parallel and progress once any function is complete | ||
add('first', function (args, arg_len) { | ||
var self = this, next = function () { | ||
self.next(true); | ||
} | ||
for (var i = 0; !this.halt && i < arg_len; i++) { | ||
if (null != args.shift().call(this, next, this.error)) { | ||
this.next(true); | ||
} | ||
} | ||
}); | ||
//Run each function in parallel and progress immediately | ||
add('all', function (args, arg_len) { | ||
for (var i = 0; !this.halt && i < arg_len; i++) { | ||
args.shift().call(this, nop, this.error); | ||
} | ||
this.next(true); | ||
}); | ||
//Attach error handler(s) | ||
@@ -159,0 +139,0 @@ add('onError', false, function (args, arg_len) { |
{ "name" : "chain", | ||
"description" : "A microframework for handlign (a)sync events", | ||
"version" : "0.1.0", | ||
"description" : "A microframework for handling (a)sync events", | ||
"version" : "0.1.1", | ||
"homepage" : "http://github.com/chriso/chain.js", | ||
@@ -5,0 +5,0 @@ "keywords" : ["async","asynchronous","events","parallel"], |
10158
6
196