asynquence
Advanced tools
Comparing version 0.4.0-a to 0.4.0-b
/*! asynquence | ||
v0.4.0-a (c) Kyle Simpson | ||
v0.4.0-b (c) Kyle Simpson | ||
MIT License: http://getify.mit-license.org | ||
*/ | ||
!function(n,e,t){"undefined"!=typeof module&&module.exports?module.exports=t():"function"==typeof define&&define.amd?define(t):e[n]=t(n,e)}("ASQ",this,function(n,e){"use strict";function t(n){return"undefined"!=typeof setImmediate?setImmediate(n):setTimeout(n,0)}function u(){function n(){P?a():Q||(Q=t(a))}function e(){throw 1===F.length?F[0]:F}function a(){var t,u;if(Q=null,delete G.unpause,P)clearTimeout(Q),Q=null,z.length=B.length=D.length=F.length=0;else if(C)for(0!==B.length||M||(M=!0,e());B.length;){M=!0,t=B.shift();try{t.apply(b,F)}catch(r){h(r)?F=F.concat(r):(F.push(r),r.stack&&F.push(r.stack)),0===B.length&&e()}}else if(W&&z.length>0){W=!1,t=z.shift(),u=D.slice(),D.length=0,u.unshift(l());try{t.apply(b,u)}catch(r){h(r)?F=F.concat(r):F.push(r),C=!0,n()}}}function l(){function e(){C||P||W||(W=!0,D.push.apply(D,arguments),F.length=0,n())}return e.fail=function(){C||P||W||(C=!0,D.length=0,F.push.apply(F,arguments),n())},e.abort=function(){C||P||(W=!1,P=!0,D.length=F.length=0,n())},e.errfcb=function(n){n?e.fail(n):e.apply(b,d.call(arguments,1))},e}function o(n,e,u){function r(){clearTimeout(g),g=_=q=s=null}function a(){return y?l():(g||(g=t(l)),void 0)}function l(){if(!(C||P||v)){var e=[];g=null,m?(n.fail.apply(b,s),r()):y?(n.abort(),r()):i()&&(v=!0,_.forEach(function(n,t){e.push(q["s"+t])}),n.apply(b,e),r())}}function i(){if(0!==_.length){var n=!0;return _.some(function(e){return null===e?(n=!1,!0):void 0}),n}}function c(){function n(){if(!(C||P||m||y||v||_[e])){var n=p.apply(b,arguments);q["s"+e]=n.length>1?n:n[0],_[e]=!0,a()}}var e=_.length;return n.fail=function(){C||P||m||y||v||_[e]||(m=!0,s=d.call(arguments),a())},n.abort=function(){C||P||m||y||v||(y=!0,l())},n.errfcb=function(e){e?n.fail(e):n.apply(b,d.call(arguments,1))},_[e]=null,n}var f,o,s,g,m=!1,y=!1,v=!1,_=[],q={};e.some(function(n){if(m||y)return!0;f=u.slice(),f.unshift(c());try{n.apply(b,f)}catch(e){return o=e,m=!0,!0}}),o&&(h(o)?n.fail.apply(b,o):n.fail(o))}function y(){return C||P||0===arguments.length?G:(z.push.apply(z,f(arguments,c)),n(),G)}function v(){return P||0===arguments.length?G:(B.push.apply(B,arguments),n(),G)}function _(){if(C||P||0===arguments.length)return G;var n=d.call(arguments);return y(function(e){var t=d.call(arguments,1);o(e,n,t)}),G}function q(){return P||0===arguments.length?G:(d.call(arguments).forEach(function(n){y(function(e){n.apply(b,d.call(arguments,1)),e()}).or(n.fail)}),G)}function k(){return C||P||0===arguments.length?G:(d.call(arguments).forEach(function(n){var e;g(n)&&(n.defer(),"next"in n&&(n.then(function(){e.apply(b,arguments)}).or(function(){e.fail.apply(b,arguments)}),n=u(function(n){e=n}).defer(),e=function(){n=u.apply(b,arguments).defer()},e.fail=function(){var e=d.call(arguments);n=u(function(n){n.fail.apply(b,e)}).defer()})),y(function(e){g(n)||(n=n.apply(b,d.call(arguments,1))),n.pipe(e)})}),G)}function A(){return C||P||0===arguments.length?G:(d.call(f(arguments,i)).forEach(function(n){y(function(e){var t=n.apply(b,d.call(arguments,1));h(t)||(t=p(t)),e.apply(b,t)})}),G)}function E(){function n(n){return function(){n.apply(b,h(arguments[0])?arguments[0]:arguments)}}return C||P||0===arguments.length?G:(d.call(arguments).forEach(function(e){y(function(t){"function"!=typeof e||"then"in e||(e=e.apply(b,d.call(arguments,1))),e.then(n(t),n(t.fail))})}),G)}function x(){var n;return A(function(){return n?n.apply(b,arguments):n=u.apply(b,arguments).defer(),p.apply(b,arguments)}),v(function(){if(n)n.fail.apply(b,arguments);else{var e=d.call(arguments);n=u().then(function(n){n.fail.apply(b,e)}).defer()}}),u().then(function(e){n?n.pipe(e):n=e}).defer()}function j(){return C?G:(P=!0,a(),G)}function O(){var n;return s={then_queue:z.slice(),or_queue:B.slice()},n=u(),s=null,n}function S(){D.push.apply(D,arguments),Q===!0&&(Q=null),n()}function T(){return B.push(function(){}),G}function w(n,e){var t=arguments.length>1;switch(n){case"seq_error":if(!t)return C;C=e;break;case"seq_aborted":if(!t)return P;P=e;break;case"then_ready":if(!t)return W;W=e;break;case"then_queue":return z;case"or_queue":return B;case"sequence_messages":return D;case"sequence_errors":return F}}function I(){Object.keys(m).forEach(function(n){G[n]=m[n](G,w)})}var Q,C=!1,M=!1,P=!1,W=!0,z=[],B=[],D=[],F=[],G=r({then:y,or:v,gate:_,pipe:q,seq:k,val:A,promise:E,fork:x,abort:j,duplicate:O,defer:T});return I(),s&&(z=s.then_queue.slice(0),B=s.or_queue.slice(0),G.unpause=S,Q=!0),G.then.apply(b,f(arguments,c)),G}function r(n){return Object.defineProperty(n,v,{enumerable:!1,value:!0})}function a(n){return null!=n&&"object"==typeof n&&n[v]}function l(n,e){return d.call(e).slice(1,n+1)}function i(n){return p.apply(b,l(n,arguments))}function c(n){arguments[n+1].apply(b,l(n,arguments))}function f(n,e){var t,u;for(n=d.call(n),t=0;t<n.length;t++)if(h(n[t]))n[t]=e.bind.apply(e,[null,n[t].length].concat(n[t]));else if("function"!=typeof n[t]){for(u=t+1;u<n.length&&("function"!=typeof n[u]&&!a(n[u]));u++);n.splice(t,u-t,e.bind.apply(e,[null,u-t].concat(n.slice(t,u))))}return n}var o,s,p,g,h,m={},y=(e||{})[n],d=[].slice,v="__ASQ__",b=Object.create(null);return o=u,o.extend=function(n,e){return~["then","or","gate","pipe","seq","val","promise","fork","abort","duplicate","defer"].indexOf(n)||(m[n]=e),o},o.messages=p=function(){var n=d.call(arguments);return r(n)},o.isSequence=g=function(n){return a(n)&&!Array.isArray(n)},o.isMessageWrapper=h=function(n){return a(n)&&Array.isArray(n)},o.unpause=function(n){return n.unpause&&n.unpause(),n},o.noConflict=function(){return e&&(e[n]=y),o},o}); |
/*! asynquence | ||
v0.4.0-a (c) Kyle Simpson | ||
v0.4.0-b (c) Kyle Simpson | ||
MIT License: http://getify.mit-license.org | ||
@@ -578,3 +578,3 @@ */ | ||
function defer() { | ||
or_queue.push(function(){}); | ||
or_queue.push(function ignored(){}); | ||
return sequence_api; | ||
@@ -581,0 +581,0 @@ } |
{ | ||
"name": "asynquence", | ||
"version": "0.4.0-a", | ||
"version": "0.4.0-b", | ||
"description": "asynquence: async sequences & gates for flow-control", | ||
@@ -5,0 +5,0 @@ "main": "./asq.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
85062