asynquence
Advanced tools
Comparing version 0.3.4-e to 0.3.4-f
/*! asynquence | ||
v0.3.4-e (c) Kyle Simpson | ||
v0.3.4-f (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(){clearTimeout(I),I=null,M.length=0,P.length=0,W.length=0,z.length=0}function e(){return w?l():(I||(I=t(l)),void 0)}function l(){var t,u;if(I=null,delete B.unpause,w)n();else if(Q)for(;P.length;){t=P.shift();try{t.apply(y,z)}catch(r){a(r)?z=z.concat(r):(z.push(r),r.stack&&z.push(r.stack)),0===P.length&&console.error.apply(console,z)}}else if(C&&M.length>0){C=!1,t=M.shift(),u=W.slice(),W.length=0,u.unshift(g());try{t.apply(y,u)}catch(r){a(r)?z=z.concat(r):z.push(r),Q=!0,e()}}}function g(){function n(){Q||w||C||(C=!0,W.push.apply(W,arguments),z.length=0,e())}return n.fail=function(){Q||w||C||(Q=!0,W.length=0,z.push.apply(z,arguments),e())},n.abort=function(){Q||w||(C=!1,w=!0,W.length=0,z.length=0,e())},n.errfcb=function(e){e?n.fail(e):n.apply(y,h.call(arguments,1))},n}function m(n,e,u){function r(){clearTimeout(m),m=_=q=g=null}function l(){return v?i():(m||(m=t(i)),void 0)}function i(){if(!(Q||w||b)){var e=[];m=null,d?(n.fail.apply(y,g),r()):v?(n.abort(),r()):c()&&(b=!0,_.forEach(function(n,t){e.push(q["s"+t])}),n.apply(y,e),r())}}function c(){if(!(Q||w||d||v||b||0===_.length)){var n=!0;return _.some(function(e){return null===e?(n=!1,!0):void 0}),n}}function o(){function n(){if(!(Q||w||d||v||b||_[e])){var n=f.messages.apply(y,arguments);q["s"+e]=n.length>1?n:n[0],_[e]=!0,l()}}var e=_.length;return n.fail=function(){Q||w||d||v||b||_[e]||(d=!0,g=h.call(arguments),l())},n.abort=function(){Q||w||d||v||b||(v=!0,i())},n.errfcb=function(e){e?n.fail(e):n.apply(y,h.call(arguments,1))},_[e]=null,n}var s,p,g,m,d=!1,v=!1,b=!1,_=[],q={};e.some(function(n){if(d||v)return!0;s=u.slice(),s.unshift(o());try{n.apply(y,s)}catch(e){return p=e,d=!0,!0}}),p&&(a(p)?n.fail.apply(y,p):n.fail(p))}function d(){return Q||w||0===arguments.length?B:(M.push.apply(M,o(arguments,c)),e(),B)}function v(){return w||0===arguments.length?B:(P.push.apply(P,arguments),e(),B)}function b(){if(Q||w||0===arguments.length)return B;var n=h.call(arguments);return d(function(e){var t=h.call(arguments,1);m(e,n,t)}),B}function _(){return w||0===arguments.length?B:(h.call(arguments).forEach(function(n){d(function(e){n.apply(y,h.call(arguments,1)),e()}).or(n.fail)}),B)}function q(){return Q||w||0===arguments.length?B:(h.call(arguments).forEach(function(n){var e;a(n)&&"next"in n&&(n.then(function(){e.apply(y,arguments)}).or(function(){e.fail.apply(y,arguments)}),n=u(function(n){e=n}),e=function(){n=u.apply(y,arguments)},e.fail=function(){var e=h.call(arguments);n=u(function(n){n.fail.apply(y,e)})}),d(function(e){a(n)||(n=n.apply(y,h.call(arguments,1))),n.pipe(e)})}),B)}function A(){return Q||w||0===arguments.length?B:(h.call(o(arguments,i)).forEach(function(n){d(function(e){var t=n.apply(y,h.call(arguments,1));a(t)||(t=f.messages(t)),e.apply(y,t)})}),B)}function k(){return Q||w||0===arguments.length?B:(h.call(arguments).forEach(function(n){d(function(e){"function"!=typeof n||"then"in n||(n=n.apply(y,h.call(arguments,1))),n.then(e,e.fail)})}),B)}function E(){var n;return A(function(){return n?n.apply(y,arguments):n=u.apply(y,arguments),f.messages.apply(y,arguments)}),v(function(){if(n)n.fail.apply(y,arguments);else{var e=h.call(arguments);n=u().then(function(n){n.fail.apply(y,e)})}}),u().then(function(e){n?n.pipe(e):n=e})}function x(){return Q?B:(w=!0,l(),B)}function j(){var n;return s={then_queue:M.slice(0),or_queue:P.slice(0)},n=u(),s=null,n}function O(){W.push.apply(W,arguments),e()}function S(n,e){var t=arguments.length>1;switch(n){case"seq_error":if(!t)return Q;Q=e;break;case"seq_aborted":if(!t)return w;w=e;break;case"then_ready":if(!t)return C;C=e;break;case"then_queue":return M;case"or_queue":return P;case"sequence_messages":return W;case"sequence_errors":return z}}function T(){Object.keys(p).forEach(function(n){B[n]=p[n](B,S)})}var I,Q=!1,w=!1,C=!0,M=[],P=[],W=[],z=[],B=r({then:d,or:v,gate:b,pipe:_,seq:q,val:A,promise:k,fork:E,abort:x,duplicate:j});return T(),s&&(M=s.then_queue.slice(0),P=s.or_queue.slice(0),B.unpause=O),B.then.apply(y,o(arguments,c)),B}function r(n){return Object.defineProperty(n,m,{enumerable:!1,value:!0}),n}function a(n){return null!=n&&"object"==typeof n&&n[m]}function l(n,e){return h.call(e).slice(1,n+1)}function i(n){return f.messages.apply(y,l(n,arguments))}function c(n){arguments[n+1].apply(y,l(n,arguments))}function o(n,e){var t,u;for(n=h.call(n),t=0;t<n.length;t++)if(Array.isArray(n[t])&&a(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 f,s,p={},g=(e||{})[n],h=Array.prototype.slice,m="__ASQ__",y=Object.create(null);return f=u,f.extend=function(n,e){return~["then","or","gate","pipe","seq","val","abort"].indexOf(n)||(p[n]=e),f},f.messages=function(){var n=h.call(arguments);return r(n),n},f.isSequence=function(n){return a(n)&&!Array.isArray(n)},f.isMessageWrapper=function(n){return a(n)&&Array.isArray(n)},f.unpause=function(n){return n.unpause&&n.unpause(),n},f.noConflict=function(){return e&&(e[n]=g),f},f}); | ||
!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(){clearTimeout(I),I=null,M.length=0,P.length=0,W.length=0,z.length=0}function e(){return w?l():(I||(I=t(l)),void 0)}function l(){var t,u;if(I=null,delete B.unpause,w)n();else if(Q)for(;P.length;){t=P.shift();try{t.apply(y,z)}catch(r){a(r)?z=z.concat(r):(z.push(r),r.stack&&z.push(r.stack)),0===P.length&&console.error.apply(console,z)}}else if(C&&M.length>0){C=!1,t=M.shift(),u=W.slice(),W.length=0,u.unshift(g());try{t.apply(y,u)}catch(r){a(r)?z=z.concat(r):z.push(r),Q=!0,e()}}}function g(){function n(){Q||w||C||(C=!0,W.push.apply(W,arguments),z.length=0,e())}return n.fail=function(){Q||w||C||(Q=!0,W.length=0,z.push.apply(z,arguments),e())},n.abort=function(){Q||w||(C=!1,w=!0,W.length=0,z.length=0,e())},n.errfcb=function(e){e?n.fail(e):n.apply(y,h.call(arguments,1))},n}function m(n,e,u){function r(){clearTimeout(m),m=_=q=g=null}function l(){return v?i():(m||(m=t(i)),void 0)}function i(){if(!(Q||w||b)){var e=[];m=null,d?(n.fail.apply(y,g),r()):v?(n.abort(),r()):c()&&(b=!0,_.forEach(function(n,t){e.push(q["s"+t])}),n.apply(y,e),r())}}function c(){if(!(Q||w||d||v||b||0===_.length)){var n=!0;return _.some(function(e){return null===e?(n=!1,!0):void 0}),n}}function o(){function n(){if(!(Q||w||d||v||b||_[e])){var n=f.messages.apply(y,arguments);q["s"+e]=n.length>1?n:n[0],_[e]=!0,l()}}var e=_.length;return n.fail=function(){Q||w||d||v||b||_[e]||(d=!0,g=h.call(arguments),l())},n.abort=function(){Q||w||d||v||b||(v=!0,i())},n.errfcb=function(e){e?n.fail(e):n.apply(y,h.call(arguments,1))},_[e]=null,n}var s,p,g,m,d=!1,v=!1,b=!1,_=[],q={};e.some(function(n){if(d||v)return!0;s=u.slice(),s.unshift(o());try{n.apply(y,s)}catch(e){return p=e,d=!0,!0}}),p&&(a(p)?n.fail.apply(y,p):n.fail(p))}function d(){return Q||w||0===arguments.length?B:(M.push.apply(M,o(arguments,c)),e(),B)}function v(){return w||0===arguments.length?B:(P.push.apply(P,arguments),e(),B)}function b(){if(Q||w||0===arguments.length)return B;var n=h.call(arguments);return d(function(e){var t=h.call(arguments,1);m(e,n,t)}),B}function _(){return w||0===arguments.length?B:(h.call(arguments).forEach(function(n){d(function(e){n.apply(y,h.call(arguments,1)),e()}).or(n.fail)}),B)}function q(){return Q||w||0===arguments.length?B:(h.call(arguments).forEach(function(n){var e;a(n)&&"next"in n&&(n.then(function(){e.apply(y,arguments)}).or(function(){e.fail.apply(y,arguments)}),n=u(function(n){e=n}),e=function(){n=u.apply(y,arguments)},e.fail=function(){var e=h.call(arguments);n=u(function(n){n.fail.apply(y,e)})}),d(function(e){a(n)||(n=n.apply(y,h.call(arguments,1))),n.pipe(e)})}),B)}function A(){return Q||w||0===arguments.length?B:(h.call(o(arguments,i)).forEach(function(n){d(function(e){var t=n.apply(y,h.call(arguments,1));a(t)||(t=f.messages(t)),e.apply(y,t)})}),B)}function k(){return Q||w||0===arguments.length?B:(h.call(arguments).forEach(function(n){d(function(e){"function"!=typeof n||"then"in n||(n=n.apply(y,h.call(arguments,1))),n.then(e,e.fail)})}),B)}function E(){var n;return A(function(){return n?n.apply(y,arguments):n=u.apply(y,arguments),f.messages.apply(y,arguments)}),v(function(){if(n)n.fail.apply(y,arguments);else{var e=h.call(arguments);n=u().then(function(n){n.fail.apply(y,e)})}}),u().then(function(e){n?n.pipe(e):n=e})}function x(){return Q?B:(w=!0,l(),B)}function j(){var n;return s={then_queue:M.slice(0),or_queue:P.slice(0)},n=u(),s=null,n}function O(){W.push.apply(W,arguments),I===!0&&(I=null),e()}function S(n,e){var t=arguments.length>1;switch(n){case"seq_error":if(!t)return Q;Q=e;break;case"seq_aborted":if(!t)return w;w=e;break;case"then_ready":if(!t)return C;C=e;break;case"then_queue":return M;case"or_queue":return P;case"sequence_messages":return W;case"sequence_errors":return z}}function T(){Object.keys(p).forEach(function(n){B[n]=p[n](B,S)})}var I,Q=!1,w=!1,C=!0,M=[],P=[],W=[],z=[],B=r({then:d,or:v,gate:b,pipe:_,seq:q,val:A,promise:k,fork:E,abort:x,duplicate:j});return T(),s&&(M=s.then_queue.slice(0),P=s.or_queue.slice(0),B.unpause=O,I=!0),B.then.apply(y,o(arguments,c)),B}function r(n){return Object.defineProperty(n,m,{enumerable:!1,value:!0}),n}function a(n){return null!=n&&"object"==typeof n&&n[m]}function l(n,e){return h.call(e).slice(1,n+1)}function i(n){return f.messages.apply(y,l(n,arguments))}function c(n){arguments[n+1].apply(y,l(n,arguments))}function o(n,e){var t,u;for(n=h.call(n),t=0;t<n.length;t++)if(Array.isArray(n[t])&&a(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 f,s,p={},g=(e||{})[n],h=Array.prototype.slice,m="__ASQ__",y=Object.create(null);return f=u,f.extend=function(n,e){return~["then","or","gate","pipe","seq","val","abort"].indexOf(n)||(p[n]=e),f},f.messages=function(){var n=h.call(arguments);return r(n),n},f.isSequence=function(n){return a(n)&&!Array.isArray(n)},f.isMessageWrapper=function(n){return a(n)&&Array.isArray(n)},f.unpause=function(n){return n.unpause&&n.unpause(),n},f.noConflict=function(){return e&&(e[n]=g),f},f}); |
/*! asynquence | ||
v0.3.4-e (c) Kyle Simpson | ||
v0.3.4-f (c) Kyle Simpson | ||
MIT License: http://getify.mit-license.org | ||
@@ -555,2 +555,3 @@ */ | ||
sequence_messages.push.apply(sequence_messages,arguments); | ||
if (seq_tick === true) seq_tick = null; | ||
scheduleSequenceTick(); | ||
@@ -631,2 +632,3 @@ } | ||
sequence_api.unpause = unpause; | ||
seq_tick = true; | ||
} | ||
@@ -633,0 +635,0 @@ |
{ | ||
"name": "asynquence", | ||
"version": "0.3.4-e", | ||
"version": "0.3.4-f", | ||
"description": "asynquence: async sequences & gates for flow-control", | ||
@@ -5,0 +5,0 @@ "main": "./asq.js", |
@@ -79,3 +79,3 @@ # asynquence | ||
The instance form of `unpause(..)` (not the `ASQ.unpause(..)`) will accept any arguments sent to it and pass them along as messages to the first step of the sequence. This allows you to set different templated (duplicated) sequences with distinct initial message states, if necessary. | ||
The instance form of `unpause(..)` (not `ASQ.unpause(..)`) will accept any arguments sent to it and pass them along as messages to the first step of the sequence, each time it's invoked. This allows you to setup different templated (duplicated) sequences with distinct initial message states, if necessary. | ||
@@ -82,0 +82,0 @@ `unpause()` is only present on a sequence API in this initial paused state after it was duplicated from another sequence. It is removed as soon as that next "tick" actually unpauses the sequence. It is safe to call multiple times until that next "tick", though that's not recommended. The `ASQ.unpause(..)` helper is always present, and it first checks for an `unpause()` on the specified sequence instance before calling it, so that's safer. |
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
77404
1971