asynquence
Advanced tools
Comparing version 0.3.4-g to 0.3.4-h
/*! asynquence | ||
v0.3.4-g (c) Kyle Simpson | ||
v0.3.4-h (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,w.length=0,C.length=0,P.length=0,z.length=0}function e(){return Q?l():(I||(I=t(l)),void 0)}function l(){var t,u;if(I=null,delete B.unpause,Q)n();else if(M)for(;C.length;){t=C.shift();try{t.apply(y,z)}catch(r){a(r)?z=z.concat(r):(z.push(r),r.stack&&z.push(r.stack)),0===C.length&&console.error.apply(console,z)}}else if(W&&w.length>0){W=!1,t=w.shift(),u=P.slice(),P.length=0,u.unshift(g());try{t.apply(y,u)}catch(r){a(r)?z=z.concat(r):z.push(r),M=!0,e()}}}function g(){function n(){M||Q||W||(W=!0,P.push.apply(P,arguments),z.length=0,e())}return n.fail=function(){M||Q||W||(M=!0,P.length=0,z.push.apply(z,arguments),e())},n.abort=function(){M||Q||(W=!1,Q=!0,P.length=0,z.length=0,e())},n.errfcb=function(e){e?n.fail(e):n.apply(y,m.call(arguments,1))},n}function h(n,e,u){function r(){clearTimeout(h),h=_=q=g=null}function l(){return v?i():(h||(h=t(i)),void 0)}function i(){if(!(M||Q||b)){var e=[];h=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(!(M||Q||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(!(M||Q||d||v||b||_[e])){var n=s.messages.apply(y,arguments);q["s"+e]=n.length>1?n:n[0],_[e]=!0,l()}}var e=_.length;return n.fail=function(){M||Q||d||v||b||_[e]||(d=!0,g=m.call(arguments),l())},n.abort=function(){M||Q||d||v||b||(v=!0,i())},n.errfcb=function(e){e?n.fail(e):n.apply(y,m.call(arguments,1))},_[e]=null,n}var f,p,g,h,d=!1,v=!1,b=!1,_=[],q={};e.some(function(n){if(d||v)return!0;f=u.slice(),f.unshift(o());try{n.apply(y,f)}catch(e){return p=e,d=!0,!0}}),p&&(a(p)?n.fail.apply(y,p):n.fail(p))}function d(){return M||Q||0===arguments.length?B:(w.push.apply(w,o(arguments,c)),e(),B)}function v(){return Q||0===arguments.length?B:(C.push.apply(C,arguments),e(),B)}function b(){if(M||Q||0===arguments.length)return B;var n=m.call(arguments);return d(function(e){var t=m.call(arguments,1);h(e,n,t)}),B}function _(){return Q||0===arguments.length?B:(m.call(arguments).forEach(function(n){d(function(e){n.apply(y,m.call(arguments,1)),e()}).or(n.fail)}),B)}function q(){return M||Q||0===arguments.length?B:(m.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=m.call(arguments);n=u(function(n){n.fail.apply(y,e)})}),d(function(e){a(n)||(n=n.apply(y,m.call(arguments,1))),n.pipe(e)})}),B)}function A(){return M||Q||0===arguments.length?B:(m.call(o(arguments,i)).forEach(function(n){d(function(e){var t=n.apply(y,m.call(arguments,1));a(t)||(t=s.messages(t)),e.apply(y,t)})}),B)}function k(){function n(n){return function(){n.apply(y,s.isMessageWrapper(arguments[0])?arguments[0]:arguments)}}return M||Q||0===arguments.length?B:(m.call(arguments).forEach(function(e){d(function(t){"function"!=typeof e||"then"in e||(e=e.apply(y,m.call(arguments,1))),e.then(n(t),n(t.fail))})}),B)}function E(){var n;return A(function(){return n?n.apply(y,arguments):n=u.apply(y,arguments),s.messages.apply(y,arguments)}),v(function(){if(n)n.fail.apply(y,arguments);else{var e=m.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 M?B:(Q=!0,l(),B)}function j(){var n;return f={then_queue:w.slice(0),or_queue:C.slice(0)},n=u(),f=null,n}function O(){P.push.apply(P,arguments),I===!0&&(I=null),e()}function S(n,e){var t=arguments.length>1;switch(n){case"seq_error":if(!t)return M;M=e;break;case"seq_aborted":if(!t)return Q;Q=e;break;case"then_ready":if(!t)return W;W=e;break;case"then_queue":return w;case"or_queue":return C;case"sequence_messages":return P;case"sequence_errors":return z}}function T(){Object.keys(p).forEach(function(n){B[n]=p[n](B,S)})}var I,M=!1,Q=!1,W=!0,w=[],C=[],P=[],z=[],B=r({then:d,or:v,gate:b,pipe:_,seq:q,val:A,promise:k,fork:E,abort:x,duplicate:j});return T(),f&&(w=f.then_queue.slice(0),C=f.or_queue.slice(0),B.unpause=O,I=!0),B.then.apply(y,o(arguments,c)),B}function r(n){return Object.defineProperty(n,h,{enumerable:!1,value:!0}),n}function a(n){return null!=n&&"object"==typeof n&&n[h]}function l(n,e){return m.call(e).slice(1,n+1)}function i(n){return s.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=m.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 s,f,p={},g=(e||{})[n],m=Array.prototype.slice,h="__ASQ__",y=Object.create(null);return s=u,s.extend=function(n,e){return~["then","or","gate","pipe","seq","val","abort"].indexOf(n)||(p[n]=e),s},s.messages=function(){var n=m.call(arguments);return r(n),n},s.isSequence=function(n){return a(n)&&!Array.isArray(n)},s.isMessageWrapper=function(n){return a(n)&&Array.isArray(n)},s.unpause=function(n){return n.unpause&&n.unpause(),n},s.noConflict=function(){return e&&(e[n]=g),s},s}); | ||
!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,w.length=0,C.length=0,P.length=0,z.length=0}function e(){return Q?l():(I||(I=t(l)),void 0)}function l(){var t,u;if(I=null,delete B.unpause,Q)n();else if(M)for(;C.length;){t=C.shift();try{t.apply(y,z)}catch(r){a(r)?z=z.concat(r):(z.push(r),r.stack&&z.push(r.stack)),0===C.length&&console.error.apply(console,z)}}else if(W&&w.length>0){W=!1,t=w.shift(),u=P.slice(),P.length=0,u.unshift(g());try{t.apply(y,u)}catch(r){a(r)?z=z.concat(r):z.push(r),M=!0,e()}}}function g(){function n(){M||Q||W||(W=!0,P.push.apply(P,arguments),z.length=0,e())}return n.fail=function(){M||Q||W||(M=!0,P.length=0,z.push.apply(z,arguments),e())},n.abort=function(){M||Q||(W=!1,Q=!0,P.length=0,z.length=0,e())},n.errfcb=function(e){e?n.fail(e):n.apply(y,m.call(arguments,1))},n}function h(n,e,u){function r(){clearTimeout(h),h=_=q=g=null}function l(){return v?i():(h||(h=t(i)),void 0)}function i(){if(!(M||Q||b)){var e=[];h=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(!(M||Q||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(!(M||Q||d||v||b||_[e])){var n=s.messages.apply(y,arguments);q["s"+e]=n.length>1?n:n[0],_[e]=!0,l()}}var e=_.length;return n.fail=function(){M||Q||d||v||b||_[e]||(d=!0,g=m.call(arguments),l())},n.abort=function(){M||Q||d||v||b||(v=!0,i())},n.errfcb=function(e){e?n.fail(e):n.apply(y,m.call(arguments,1))},_[e]=null,n}var f,p,g,h,d=!1,v=!1,b=!1,_=[],q={};e.some(function(n){if(d||v)return!0;f=u.slice(),f.unshift(o());try{n.apply(y,f)}catch(e){return p=e,d=!0,!0}}),p&&(a(p)?n.fail.apply(y,p):n.fail(p))}function d(){return M||Q||0===arguments.length?B:(w.push.apply(w,o(arguments,c)),e(),B)}function v(){return Q||0===arguments.length?B:(C.push.apply(C,arguments),e(),B)}function b(){if(M||Q||0===arguments.length)return B;var n=m.call(arguments);return d(function(e){var t=m.call(arguments,1);h(e,n,t)}),B}function _(){return Q||0===arguments.length?B:(m.call(arguments).forEach(function(n){d(function(e){n.apply(y,m.call(arguments,1)),e()}).or(n.fail)}),B)}function q(){return M||Q||0===arguments.length?B:(m.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=m.call(arguments);n=u(function(n){n.fail.apply(y,e)})}),d(function(e){a(n)||(n=n.apply(y,m.call(arguments,1))),n.pipe(e)})}),B)}function A(){return M||Q||0===arguments.length?B:(m.call(o(arguments,i)).forEach(function(n){d(function(e){var t=n.apply(y,m.call(arguments,1));a(t)||(t=s.messages(t)),e.apply(y,t)})}),B)}function k(){function n(n){return function(){n.apply(y,s.isMessageWrapper(arguments[0])?arguments[0]:arguments)}}return M||Q||0===arguments.length?B:(m.call(arguments).forEach(function(e){d(function(t){"function"!=typeof e||"then"in e||(e=e.apply(y,m.call(arguments,1))),e.then(n(t),n(t.fail))})}),B)}function E(){var n;return A(function(){return n?n.apply(y,arguments):n=u.apply(y,arguments),s.messages.apply(y,arguments)}),v(function(){if(n)n.fail.apply(y,arguments);else{var e=m.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 M?B:(Q=!0,l(),B)}function j(){var n;return f={then_queue:w.slice(0),or_queue:C.slice(0)},n=u(),f=null,n}function O(){P.push.apply(P,arguments),I===!0&&(I=null),e()}function S(n,e){var t=arguments.length>1;switch(n){case"seq_error":if(!t)return M;M=e;break;case"seq_aborted":if(!t)return Q;Q=e;break;case"then_ready":if(!t)return W;W=e;break;case"then_queue":return w;case"or_queue":return C;case"sequence_messages":return P;case"sequence_errors":return z}}function T(){Object.keys(p).forEach(function(n){B[n]=p[n](B,S)})}var I,M=!1,Q=!1,W=!0,w=[],C=[],P=[],z=[],B=r({then:d,or:v,gate:b,pipe:_,seq:q,val:A,promise:k,fork:E,abort:x,duplicate:j});return T(),f&&(w=f.then_queue.slice(0),C=f.or_queue.slice(0),B.unpause=O,I=!0),B.then.apply(y,o(arguments,c)),B}function r(n){return Object.defineProperty(n,h,{enumerable:!1,value:!0})}function a(n){return null!=n&&"object"==typeof n&&n[h]}function l(n,e){return m.call(e).slice(1,n+1)}function i(n){return s.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=m.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 s,f,p={},g=(e||{})[n],m=Array.prototype.slice,h="__ASQ__",y=Object.create(null);return s=u,s.extend=function(n,e){return~["then","or","gate","pipe","seq","val","abort"].indexOf(n)||(p[n]=e),s},s.messages=function(){var n=m.call(arguments);return r(n),n},s.isSequence=function(n){return a(n)&&!Array.isArray(n)},s.isMessageWrapper=function(n){return a(n)&&Array.isArray(n)},s.unpause=function(n){return n.unpause&&n.unpause(),n},s.noConflict=function(){return e&&(e[n]=g),s},s}); |
/*! asynquence | ||
v0.3.4-g (c) Kyle Simpson | ||
v0.3.4-h (c) Kyle Simpson | ||
MIT License: http://getify.mit-license.org | ||
@@ -657,8 +657,6 @@ */ | ||
function brandIt(obj) { | ||
Object.defineProperty(obj,brand,{ | ||
return Object.defineProperty(obj,brand,{ | ||
enumerable: false, | ||
value: true | ||
}); | ||
return obj; | ||
} | ||
@@ -665,0 +663,0 @@ |
{ | ||
"name": "asynquence", | ||
"version": "0.3.4-g", | ||
"version": "0.3.4-h", | ||
"description": "asynquence: async sequences & gates for flow-control", | ||
@@ -5,0 +5,0 @@ "main": "./asq.js", |
@@ -146,2 +146,4 @@ # asynquence | ||
**Note:** The return value will strictly either have a `value` property or a `done` property, but not both at the same time. | ||
`value` is any return message(s) from the `next(..)` invocation (`undefined` otherwise). `done` is `true` if the previously iterated step was (so far) the last registered step in the iterable sequence, or `false` if there's still more sequence steps queued up. | ||
@@ -166,3 +168,3 @@ | ||
for (var i=0, ret; | ||
!(ret && ret.done) && (ret = sq.next(i+1)); | ||
(ret = sq.next(i+1)) && !ret.done; | ||
i++ | ||
@@ -169,0 +171,0 @@ ) { |
56
tests.js
@@ -66,3 +66,3 @@ (function(name,context,dependency,definition){ | ||
FAIL(testDone,label + " (from timeout)"); | ||
},1000); | ||
},2000); | ||
}); | ||
@@ -98,3 +98,3 @@ tests.push(function(testDone){ | ||
FAIL(testDone,label + " (from timeout)"); | ||
},1000); | ||
},2000); | ||
}); | ||
@@ -135,3 +135,3 @@ tests.push(function(testDone){ | ||
FAIL(testDone,label + " (from timeout)"); | ||
},1000); | ||
},2000); | ||
}); | ||
@@ -167,3 +167,3 @@ tests.push(function(testDone){ | ||
FAIL(testDone,label + " (from timeout)"); | ||
},1000); | ||
},2000); | ||
}); | ||
@@ -197,3 +197,3 @@ tests.push(function(testDone){ | ||
FAIL(testDone,label + " (from timeout)"); | ||
},1000); | ||
},2000); | ||
}); | ||
@@ -281,3 +281,3 @@ tests.push(function(testDone){ | ||
FAIL(testDone,label + " (from timeout)"); | ||
},1000); | ||
},2000); | ||
}); | ||
@@ -331,3 +331,3 @@ tests.push(function(testDone){ | ||
FAIL(testDone,label + " (from timeout)"); | ||
},1000); | ||
},2000); | ||
}); | ||
@@ -372,3 +372,3 @@ tests.push(function(testDone){ | ||
FAIL(testDone,label + " (from timeout)"); | ||
},1000); | ||
},2000); | ||
}); | ||
@@ -411,3 +411,3 @@ tests.push(function(testDone){ | ||
FAIL(testDone,label + " (from timeout)"); | ||
},1000); | ||
},2000); | ||
}); | ||
@@ -450,3 +450,3 @@ tests.push(function(testDone){ | ||
FAIL(testDone,label + " (from timeout)"); | ||
},1000); | ||
},2000); | ||
}); | ||
@@ -481,3 +481,3 @@ tests.push(function(testDone){ | ||
FAIL(testDone,label + " (from timeout)"); | ||
},1000); | ||
},2000); | ||
}); | ||
@@ -512,3 +512,3 @@ tests.push(function(testDone){ | ||
FAIL(testDone,label + " (from timeout)"); | ||
},1000); | ||
},2000); | ||
}); | ||
@@ -544,3 +544,3 @@ tests.push(function(testDone){ | ||
FAIL(testDone,label + " (from timeout)"); | ||
},1000); | ||
},2000); | ||
}); | ||
@@ -576,3 +576,3 @@ tests.push(function(testDone){ | ||
FAIL(testDone,label + " (from timeout)"); | ||
},1000); | ||
},2000); | ||
}); | ||
@@ -646,3 +646,3 @@ tests.push(function(testDone){ | ||
FAIL(testDone,label + " (from timeout)"); | ||
},1000); | ||
},2000); | ||
}); | ||
@@ -714,3 +714,3 @@ tests.push(function(testDone){ | ||
FAIL(testDone,label + " (from timeout)"); | ||
},1000); | ||
},2000); | ||
}); | ||
@@ -751,3 +751,3 @@ tests.push(function(testDone){ | ||
FAIL(testDone,label + " (from timeout)"); | ||
},1000); | ||
},2000); | ||
}); | ||
@@ -784,3 +784,3 @@ tests.push(function(testDone){ | ||
FAIL(testDone,label + " (from timeout)"); | ||
},1000); | ||
},2000); | ||
}); | ||
@@ -878,3 +878,3 @@ tests.push(function(testDone){ | ||
FAIL(testDone,label + " (from timeout)"); | ||
},1000); | ||
},2000); | ||
}); | ||
@@ -889,3 +889,3 @@ tests.push(function(testDone){ | ||
def.resolve(args.length > 1 ? args : args[0]); | ||
},50); | ||
},10); | ||
return def.promise; | ||
@@ -899,3 +899,3 @@ } | ||
def.reject(args.length > 1 ? args : args[0]); | ||
},50); | ||
},10); | ||
return def.promise; | ||
@@ -956,3 +956,3 @@ } | ||
FAIL(testDone,label + " (from timeout)"); | ||
},1000); | ||
},2000); | ||
}); | ||
@@ -1066,3 +1066,3 @@ tests.push(function(testDone){ | ||
FAIL(testDone,label + " (from timeout)"); | ||
},1000); | ||
},2000); | ||
}); | ||
@@ -1075,3 +1075,3 @@ tests.push(function(testDone){ | ||
done("Hello"); | ||
},100); | ||
},10); | ||
}); | ||
@@ -1119,3 +1119,3 @@ | ||
done.fail("World"); | ||
},100); | ||
},10); | ||
}); | ||
@@ -1187,3 +1187,3 @@ | ||
FAIL(testDone,label + " (from timeout)"); | ||
},1000); | ||
},2000); | ||
}); | ||
@@ -1279,3 +1279,3 @@ tests.push(function(testDone){ | ||
FAIL(testDone,label + " (from timeout)"); | ||
},1000); | ||
},2000); | ||
}); | ||
@@ -1335,3 +1335,3 @@ tests.push(function(testDone){ | ||
FAIL(testDone,label + " (from timeout)"); | ||
},1000); | ||
},2000); | ||
}); | ||
@@ -1338,0 +1338,0 @@ |
Sorry, the diff of this file is not supported yet
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
81015
10
2098
419