queue.io
Version:
An events based queue iteration JavaScript module
73 lines • 9.57 kB
JavaScript
var require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
function noop(){}var process=module.exports={}
process.nextTick=function(){var e="undefined"!=typeof window&&window.setImmediate,t="undefined"!=typeof window&&window.MutationObserver,n="undefined"!=typeof window&&window.postMessage&&window.addEventListener
if(e)return function(e){return window.setImmediate(e)}
var r=[]
if(t){var s=document.createElement("div"),i=new MutationObserver(function(){var e=r.slice()
r.length=0,e.forEach(function(e){e()})})
return i.observe(s,{attributes:!0}),function(e){r.length||s.setAttribute("yes","no"),r.push(e)}}return n?(window.addEventListener("message",function(e){var t=e.source
if((t===window||null===t)&&"process-tick"===e.data&&(e.stopPropagation(),r.length>0)){var n=r.shift()
n()}},!0),function(e){r.push(e),window.postMessage("process-tick","*")}):function(e){setTimeout(e,0)}}(),process.title="browser",process.browser=!0,process.env={},process.argv=[],process.on=noop,process.addListener=noop,process.once=noop,process.off=noop,process.removeListener=noop,process.removeAllListeners=noop,process.emit=noop,process.binding=function(){throw Error("process.binding is not supported")},process.cwd=function(){return"/"},process.chdir=function(){throw Error("process.chdir is not supported")}
},{}],"events":[function(require,module,exports){
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
function EventEmitter(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function isFunction(e){return"function"==typeof e}function isNumber(e){return"number"==typeof e}function isObject(e){return"object"==typeof e&&null!==e}function isUndefined(e){return void 0===e}module.exports=EventEmitter,EventEmitter.EventEmitter=EventEmitter,EventEmitter.prototype._events=void 0,EventEmitter.prototype._maxListeners=void 0,EventEmitter.defaultMaxListeners=10,EventEmitter.prototype.setMaxListeners=function(e){if(!isNumber(e)||0>e||isNaN(e))throw TypeError("n must be a positive number")
return this._maxListeners=e,this},EventEmitter.prototype.emit=function(e){var t,n,s,r,i,o
if(this._events||(this._events={}),"error"===e&&(!this._events.error||isObject(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t
throw TypeError('Uncaught, unspecified "error" event.')}if(n=this._events[e],isUndefined(n))return!1
if(isFunction(n))switch(arguments.length){case 1:n.call(this)
break
case 2:n.call(this,arguments[1])
break
case 3:n.call(this,arguments[1],arguments[2])
break
default:for(s=arguments.length,r=Array(s-1),i=1;s>i;i++)r[i-1]=arguments[i]
n.apply(this,r)}else if(isObject(n)){for(s=arguments.length,r=Array(s-1),i=1;s>i;i++)r[i-1]=arguments[i]
for(o=n.slice(),s=o.length,i=0;s>i;i++)o[i].apply(this,r)}return!0},EventEmitter.prototype.addListener=function(e,t){var n
if(!isFunction(t))throw TypeError("listener must be a function")
if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,isFunction(t.listener)?t.listener:t),this._events[e]?isObject(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,isObject(this._events[e])&&!this._events[e].warned){var n
n=isUndefined(this._maxListeners)?EventEmitter.defaultMaxListeners:this._maxListeners,n&&n>0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())}return this},EventEmitter.prototype.on=EventEmitter.prototype.addListener,EventEmitter.prototype.once=function(e,t){function n(){this.removeListener(e,n),s||(s=!0,t.apply(this,arguments))}if(!isFunction(t))throw TypeError("listener must be a function")
var s=!1
return n.listener=t,this.on(e,n),this},EventEmitter.prototype.removeListener=function(e,t){var n,s,r,i
if(!isFunction(t))throw TypeError("listener must be a function")
if(!this._events||!this._events[e])return this
if(n=this._events[e],r=n.length,s=-1,n===t||isFunction(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t)
else if(isObject(n)){for(i=r;i-->0;)if(n[i]===t||n[i].listener&&n[i].listener===t){s=i
break}if(0>s)return this
1===n.length?(n.length=0,delete this._events[e]):n.splice(s,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},EventEmitter.prototype.removeAllListeners=function(e){var t,n
if(!this._events)return this
if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this
if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t)
return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],isFunction(n))this.removeListener(e,n)
else for(;n.length;)this.removeListener(e,n[n.length-1])
return delete this._events[e],this},EventEmitter.prototype.listeners=function(e){var t
return t=this._events&&this._events[e]?isFunction(this._events[e])?[this._events[e]]:this._events[e].slice():[]},EventEmitter.listenerCount=function(e,t){var n
return n=e._events&&e._events[t]?isFunction(e._events[t])?1:e._events[t].length:0}
},{}],"queue.io":[function(require,module,exports){
(function (process){
/*
Copyright 2014 Lcf.vs
Released under the MIT license
https://github.com/Lcfvs/queue.io
*/
/* Copyright 2014 Lcf.vs - Released under the MIT license - https://github.com/Lcfvs/queue.io */var Queue=function(e){'use strict';var t,z='exports',y='object',x='string',w='function',v='EventEmitter';if(t=function(e,t,n){var r,i,s,o,u,a,f,l,c,h,p,d,g='done',A='events',B='error',b='prototype',C='emit',D='length',j=Object,q=j.freeze,m=j.defineProperty;return r=e(A)[v],i={},s={},q(i),q(s),o=y==typeof t&&t,u=w==typeof setImmediate&&setImmediate||y==typeof process&&process.nextTick||function(e){setTimeout(e,0)},a=function v(e,t){var n,i,s;return n=this instanceof v?this:j.create(v[b]),i=[],s={p:0,m:(new r).once(g,n[C].bind(n,g)),v:c(t,e),q:n,s:i,l:[]},n.iterate=function(e){var t;return t=s.l,e=d(t,s.v,n,e),s.i&&!s.p?u(t.next):s.m.once(g,t.next),e},n.append=function(e,t,n){return(!s.i||s.p)&&(t=h(s,e,t,n),i.push(t),1===i[D]&&t.r()),e},n.listen=function(e,t,n){return(!s.i||s.p)&&(t=h(s,e,t,n),t.r()),e},n.intercept=function(e,t,n){return!s.i||s.p?(s.p+=1,function(i,o){return i?s.q[C](B,i):(o instanceof v?e.call(s.q,o,t,n):o instanceof r?e.call(s.q,v(o,t),t,n):e.call(s.q,v.from(o),f(t,n)),void --s.p)}):void 0},l(e)&&n.listen(e,t),u(function(){s.i=!0,s.p||s.m[C](g)}),n},a[b]=j.create(r[b],{constructor:{value:a,writable:!0,configurable:!0}}),a.from=function(e,t){var n,i,s,o,u;for(n=0,i=e[D],s=new r,o=c(t),u=a(s,o);i>n;n+=1)s[C](o,e[n]);return s[C](g),u},f=function(e,t){return e===i||e===s?e:t===i||t===s?t:i},l=function(e){return e instanceof r?e:void 0},c=function(e,t){return x==typeof e?e:x==typeof t?t:'value'},h=function(e,t,n,r){return e.p+=1,{d:f(r,n),m:l(t),v:c(n),h:e,r:p}},p=function(){var e,t,n,r,i,s,o;e=this,t=e.m,n=e.v,r=e.h,i=r.q,s=r.l,t instanceof a&&(t=t.iterate(e.d)),o=function(e,t){s.push(e),t&&t()},t.on(n,o),t.once(g,function(){var i;t.removeListener(n,o),--r.p,i=r.s,i[0]===e&&(i.shift(),(i=r.s[0])&&i.r()),u(function(){!r.i||r.p||r.s[D]||r.m[C](g)})}),t.once(B,i[C].bind(i,B))},d=function(e,t,n,i){var o,a,f;return o=0,a=new r,e.next=function l(){var r;return function(){var c;f||(f=e.slice(0),i===s&&f.reverse()),r||(c=Array[b].slice.call(arguments,0),u(function(){var e;o>=f[D]?a[C](g,n):(e=f[o],c.unshift(t,e,l(),n),a[C].apply(a,c)),o+=1}),r=!0)}}(),a},m(a,'NEXT',{value:i,enumerable:!0}),m(a,'PREV',{value:s,enumerable:!0}),a.noConflict=function(){return n[z]=o,a},a},w==typeof define&&define.amd)define(t);else if(y==typeof module&&module[z])return module[z]=t(require);return t(function(){var t;if(t=e[A]?e[A][v]:e[v],!t)throw Error('Unable to find '+v);return{EventEmitter:t}})}(this)
}).call(this,require('_process'))
},{"_process":1,"events":"events"}]},{},[]);