Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

spica

Package Overview
Dependencies
Maintainers
1
Versions
804
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spica - npm Package Compare versions

Comparing version 0.0.33 to 0.0.34

6

dist/spica.min.js

@@ -1,3 +0,3 @@

/*! spica v0.0.33 https://github.com/falsandtru/spica | (c) 2016, falsandtru | MIT License */
define="function"==typeof define&&define.amd?define:function(){"use strict";var e="spica",t={};return function n(r,i,u){return u?void u.apply(this,i.map(function(e){switch(e){case"require":return"function"==typeof require?require:void 0;case"exports":return r.indexOf("/")===-1?t[r]="undefined"==typeof exports?self[r]=self[r]||{}:exports:t[r]=t.hasOwnProperty(r)?t[r]:{};default:return".d"===e.slice(-2)&&{}||t.hasOwnProperty(e)&&t[e]||"function"==typeof require&&require(e)||self[e]}})):void n(e,r,i)}}();var __extends=this&&this.__extends||function(e,t){function n(){this.constructor=e}for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)};define("src/lib/concat",["require","exports"],function(e,t){"use strict";function n(e,t){for(var n=0,r=t.length,i=e.length;n<r;++n)e[n+i]=t[n];return e}t.concat=n}),define("src/lib/observable",["require","exports","src/lib/concat"],function(e,t,n){"use strict";var r=function(){function e(){this.node_={parent:void 0,childrenMap:Object.create(null),childrenList:[],registers:[]}}return e.prototype.monitor=function(e,t,n){var r=this;return void 0===n&&(n=t),void this.throwTypeErrorIfInvalidSubscriber_(t,e),void this.seekNode_(e).registers.push([e,n,!0,t]),function(){return r.off(e,n)}},e.prototype.on=function(e,t,n){var r=this;return void 0===n&&(n=t),void this.throwTypeErrorIfInvalidSubscriber_(t,e),void this.seekNode_(e).registers.push([e,n,!1,function(e){return t(e)}]),function(){return r.off(e,n)}},e.prototype.off=function(e,t){switch(typeof t){case"function":return void this.seekNode_(e).registers.some(function(e,n,r){var i=e[1];if(t!==i)return!1;switch(n){case 0:return!void r.shift();case r.length-1:return!void r.pop();default:return!void r.splice(n,1)}});case"undefined":var n=this.seekNode_(e);return n.childrenMap=Object.create(null),n.childrenList=[],void(n.registers=[]);default:throw this.throwTypeErrorIfInvalidSubscriber_(t,e)}},e.prototype.once=function(e,t){var n=this;return void this.throwTypeErrorIfInvalidSubscriber_(t,e),this.on(e,function(r){return void n.off(e,t),t(r)},t)},e.prototype.emit=function(e,t,n){void this.drain_(e,t,n)},e.prototype.reflect=function(e,t){var n=[];return void this.emit(e,t,function(e,t){return n=t}),n},e.prototype.drain_=function(e,t,n){var r=[];if(void this.refsBelow_(this.seekNode_(e)).reduce(function(e,i){var u=i[2],o=i[3];if(!u)try{var c=o(t);n&&(r[r.length]=c)}catch(e){void 0!==e&&null!==e&&void console.error(e+"")}},void 0),void this.refsAbove_(this.seekNode_(e)).reduce(function(e,n){var r=n[2],i=n[3];if(r)try{void i(t)}catch(e){void 0!==e&&null!==e&&void console.error(e)}},void 0),n)try{void n(t,r)}catch(e){void console.error(e)}},e.prototype.refs=function(e){return this.refsBelow_(this.seekNode_(e))},e.prototype.refsAbove_=function(e){var t=e.parent,r=e.registers;for(r=n.concat([],r);t;)r=n.concat(r,t.registers),t=t.parent;return r},e.prototype.refsBelow_=function(e){var t=e.childrenList,r=e.childrenMap,i=e.registers;i=n.concat([],i);for(var u=0;u<t.length;++u){var o=t[u],c=this.refsBelow_(r[o]);i=n.concat(i,c),0===c.length&&(void delete r[o],void t.splice(t.indexOf(o),1),void--u)}return i},e.prototype.seekNode_=function(e){for(var t=this.node_,n=0,r=e;n<r.length;n++){var i=r[n],u=t.childrenMap;u[i+""]||(void t.childrenList.push(i+""),u[i+""]={parent:t,childrenMap:Object.create(null),childrenList:[],registers:[]}),t=u[i+""]}return t},e.prototype.throwTypeErrorIfInvalidSubscriber_=function(e,t){switch(typeof e){case"function":return;default:throw new TypeError("Spica: Observable: Invalid subscriber.\n\t"+t+" "+e)}},e}();t.Observable=r}),define("src/lib/tick",["require","exports"],function(e,t){"use strict";function n(e){void u.push(e),void i()}function r(){for(var e=u.length;;){try{for(;e>0;)void--e,void u.shift()()}catch(e){console.error(e);continue}break}o=!1}function i(){o||0!==u.length&&(void Promise.resolve().then(r),o=!0)}var u=[],o=!1,c=Function("return typeof process === 'object' && typeof window !== 'object'")();t.Tick=c?Function("return fn => process.nextTick(fn)")():n}),define("src/lib/thenable",["require","exports"],function(e,t){"use strict";function n(e){return!!e&&"object"==typeof e&&"function"==typeof e.then}t.isThenable=n}),define("src/lib/sqid",["require","exports"],function(e,t){"use strict";function n(e){if(arguments.length>0){if("number"!=typeof e)throw new TypeError("Spica: sqid: A parameter value must be a number: "+e);if(e>=0==!1)throw new TypeError("Spica: sqid: A parameter value must be a positive number: "+e);if(e%1!==0)throw new TypeError("Spica: sqid: A parameter value must be an integer: "+e)}return void 0===e?(1e15+ ++r+"").slice(1):(1e15+e+"").slice(1)}var r=0;t.sqid=n}),define("src/lib/noop",["require","exports"],function(e,t){"use strict";function n(){}t.noop=n}),define("src/lib/supervisor",["require","exports","src/lib/observable","src/lib/tick","src/lib/thenable","src/lib/sqid","src/lib/noop"],function(e,t,n,r,i,u,o){"use strict";var c=function(){function e(t){var r=void 0===t?{}:t,i=r.name,c=void 0===i?"":i,s=r.timeout,a=void 0===s?0:s,f=r.destructor,d=void 0===f?o.noop:f;if(this.id=u.sqid(),this.events={init:new n.Observable,loss:new n.Observable,exit:new n.Observable},this.procs=new n.Observable,this.alive=!0,this.registerable=!0,this.scheduled=!1,this.workerSharedResource={procs:this.procs},this.queue=[],this.constructor===e)throw new Error("Spica: Supervisor: <"+this.id+"/"+this.name+">: Cannot instantiate abstract classes.");this.name=c,this.timeout=a,this.destructor_=d,void++this.constructor.count}return e.prototype.destructor=function(e){void this.checkState(),this.alive=!1,void this.drain();try{void this.destructor_(e)}catch(e){void console.error(e)}void--this.constructor.count,void Object.freeze(this)},e.prototype.schedule=function(){var e=this;this.alive&&(this.scheduled||(void r.Tick(function(t){e.alive&&(e.scheduled=!1,void e.drain())}),this.scheduled=!0))},e.prototype.register=function(e,t,n){if(void this.checkState(),!this.registerable)throw new Error("Spica: Supervisor: <"+this.id+"/"+this.name+"/"+e+">: Cannot register a process after a supervisor is terminated.");if(this.procs.refs([e]).length>0)throw new Error("Spica: Supervisor: <"+this.id+"/"+this.name+"/"+e+">: Cannot register a process multiply using the same name.");return void this.schedule(),t="function"==typeof t?{init:function(e){return e},call:t,exit:function(e){}}:t,new a(this,this.workerSharedResource,e,t,n).terminate},e.prototype.call=function(e,t,n,r){var i=this;void 0===r&&(r=this.timeout),void this.checkState(),void this.queue.push([e,t,n,r,Date.now()]),void this.schedule(),r<1/0!=!1&&r>0!=!1&&void setTimeout(function(){return void i.drain(e)},r+9)},e.prototype.cast=function(e,t,n){void 0===n&&(n=this.timeout),void this.checkState();var r=this.procs.reflect([e],new s.Call(t,n));return 0===r.length&&void this.events.loss.emit([e],[e,t]),r.length>0},e.prototype.refs=function(e){return void this.checkState(),this.procs.refs(void 0===e?[]:[e]).map(function(e){var t=e[1],n=t(new s.Self);return[n.name,n.process,n.state,n.terminate]})},e.prototype.terminate=function(e,t){if(this.registerable){void 0===e&&(this.registerable=!1);var n=void 0===e?[]:[e];void this.procs.emit(n,new s.Exit(t)),void this.procs.off(n),void 0===e&&void this.destructor(t)}},e.prototype.checkState=function(){if(!this.alive)throw new Error("Spica: Supervisor: <"+this.id+"/"+this.name+">: A supervisor is already terminated.")},e.prototype.drain=function(e){for(var t,n=this,r=Date.now(),u=function(u){var c=o.queue[u],a=c[0],f=c[1],d=c[2],l=c[3],p=c[4],h=void 0===e||e===a?o.procs.reflect([a],new s.Call(f,p+l-r)):[];if(o.alive&&0===h.length&&r<p+l)return t=u,"continue";if(0===u?void o.queue.shift():void o.queue.splice(u,1),void--u,0===h.length&&void o.events.loss.emit([a],[a,f]),o.alive&&h.length>0){var v=h[0];if(i.isThenable(v))void Promise.resolve(v).then(function(e){return n.alive?void d(e):void d(void 0,new Error("Spica: Supervisor: <"+n.id+"/"+n.name+"/"+a+">: A request is expired."))},function(e){return void d(void 0,e)});else try{void d(v)}catch(e){void console.error(e)}}else void d(void 0,new Error("Spica: Supervisor: <"+o.id+"/"+o.name+"/"+a+">: A request is expired."));t=u},o=this,c=0;c<this.queue.length;++c)u(c),c=t},e}();t.Supervisor=c,c.count=0,c.procs=0,function(e){}(c=t.Supervisor||(t.Supervisor={}));var s;!function(e){var t=function(){function e(){void this.COMMAND}return e}();e.Self=t;var n=function(){function e(e,t){this.param=e,this.timeout=t,void this.COMMAND}return e}();e.Call=n;var r=function(){function e(e){this.reason=e,void this.COMMAND}return e}();e.Exit=r}(s||(s={}));var a=function(){function e(t,n,r,i,u){var o=this;this.sv=t,this.sharedResource=n,this.name=r,this.process=i,this.state=u,this.alive=!0,this.called=!1,this.concurrency=1,this.receive=function(t){return e.prototype.receive.call(o,t)},this.terminate=function(t){return e.prototype.terminate.call(o,t)},void++this.sv.constructor.procs,void this.sharedResource.procs.on([r],this.receive)}return e.prototype.destructor=function(e){if(this.alive){void this.sharedResource.procs.off([this.name],this.receive),this.alive=!1,void--this.sv.constructor.procs,void Object.freeze(this);try{void this.process.exit(this.state,e),void this.sv.events.exit.emit([this.name],[this.name,this.process,this.state,e])}catch(e){void this.sv.events.exit.emit([this.name],[this.name,this.process,this.state,e]),void this.sv.terminate(void 0,e)}}},e.prototype.receive=function(e){var t=this;if(void this.checkState(),e instanceof s.Call){if(0===this.concurrency)throw void 0;try{void--this.concurrency,this.called||(this.called=!0,void this.sv.events.init.emit([this.name],[this.name,this.process,this.state]),this.state=this.process.init(this.state));var n=this.process.call(e.param,this.state);if(i.isThenable(n))return new Promise(function(r,i){void n.then(r,i),e.timeout<1/0!=!1&&void setTimeout(function(){return void i(new Error("Spica: Supervisor: <"+t.sv.id+"/"+t.sv.name+"/"+t.name+">: Timeout while processing."))},e.timeout)}).then(function(e){var n=e[0],r=e[1];if(void++t.concurrency,void t.sv.schedule(),!t.alive)throw void 0;return t.state=r,n},function(e){if(void++t.concurrency,void t.sv.schedule(),!t.alive)throw e;throw void t.terminate(e),e});void++this.concurrency;var r=n[0],u=n[1];return this.state=u,r}catch(e){throw void void this.terminate(e)}}if(e instanceof s.Exit)throw void void this.terminate(e.reason);if(e instanceof s.Self)return this;throw new TypeError("Spica: Supervisor: <"+this.sv.id+"/"+this.sv.name+"/"+this.name+">: Invalid command: "+e)},e.prototype.terminate=function(e){void this.destructor(e)},e.prototype.checkState=function(){if(!this.alive)throw new Error("Spica: Supervisor: <"+this.sv.id+"/"+this.sv.name+"/"+this.name+">: A process is already terminated:\n"+this.process)},e}()}),define("src/lib/monad/lazy",["require","exports"],function(e,t){"use strict";var n=function(){function e(e){this.thunk=e}return e.prototype.evaluate=function(){return this.memory_=this.memory_||this.thunk()},e}();t.Lazy=n}),define("src/lib/monad/functor",["require","exports","src/lib/monad/lazy"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t}(n.Lazy);t.Functor=r,function(e){function t(e,t){return t?e.fmap(t):function(t){return e.fmap(t)}}e.fmap=t}(r=t.Functor||(t.Functor={}))}),define("src/lib/curry",["require","exports"],function(e,t){"use strict";function n(e,t,r){return e.length===t.length?e.apply(r,t):function(){for(var i=[],u=0;u<arguments.length;u++)i[u-0]=arguments[u];return n(e,t.concat(i),r)}}t.curry=function(e,t){return 0===e.length?function(){return e.call(t)}:n(e,[],t)}}),define("src/lib/monad/applicative",["require","exports","src/lib/monad/functor","src/lib/curry"],function(e,t,n,r){"use strict";var i=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t}(n.Functor);t.Applicative=i,function(e){function t(e,n){return n?e.bind(function(e){return n.fmap(function(t){return 0===e.length?e(t):r.curry(e)(t)})}):function(n){return t(e,n)}}e.ap=t}(i=t.Applicative||(t.Applicative={}))}),define("src/lib/monad/monad",["require","exports","src/lib/monad/applicative"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t}(n.Applicative);t.Monad=r,function(e){function t(e,n){return n?e.bind(n):function(n){return t(e,n)}}e.bind=t}(r=t.Monad||(t.Monad={}))}),define("src/lib/monad/monadplus",["require","exports","src/lib/monad/monad"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t}(n.Monad);t.MonadPlus=r,function(e){}(r=t.MonadPlus||(t.MonadPlus={}))}),define("src/lib/monad/maybe.impl",["require","exports","src/lib/monad/monadplus"],function(e,t,n){"use strict";function r(){throw new Error("Spica: Maybe: Invalid thunk call.")}var i=function(e){function t(t){var n=e.call(this,t)||this;return void n.MAYBE,n}return __extends(t,e),t.prototype.fmap=function(e){return this.bind(function(t){return new u(e(t))})},t.prototype.ap=function(e){return t.ap(this,e)},t.prototype.bind=function(e){var n=this;return new t(function(){var r=n.evaluate();if(r instanceof u)return e(r.extract());if(r instanceof o)return r;if(r instanceof t)return r.bind(e);throw new TypeError("Spica: Maybe: Invalid monad value.\n\t"+r)})},t.prototype.extract=function(e,t){return t?this.fmap(t).extract(e):this.evaluate().extract(e)},t}(n.MonadPlus);t.Maybe=i,function(e){function t(e){return new u(e)}e.pure=t,e.Return=t}(i=t.Maybe||(t.Maybe={}));var u=function(e){function t(t){var n=e.call(this,r)||this;return n.a=t,void n.JUST,n}return __extends(t,e),t.prototype.bind=function(e){var t=this;return new i(function(){return e(t.extract())})},t.prototype.extract=function(e,t){return t?t(this.a):this.a},t}(i);t.Just=u;var o=function(e){function t(){var t=e.call(this,r)||this;return void t.NOTHING,t}return __extends(t,e),t.prototype.bind=function(e){return this},t.prototype.extract=function(e){if(!e)throw void 0;return e()},t}(i);t.Nothing=o,function(e){function t(t,n){return new e(function(){return t.fmap(function(){return t}).extract(function(){return n})})}e.mzero=new o,e.mplus=t}(i=t.Maybe||(t.Maybe={}))}),define("src/lib/monad/maybe",["require","exports","src/lib/monad/maybe.impl"],function(e,t,n){"use strict";function r(e){return new n.Just(e)}var i;!function(e){e.fmap=n.Maybe.fmap,e.pure=n.Maybe.pure,e.ap=n.Maybe.ap,e.Return=n.Maybe.Return,e.bind=n.Maybe.bind,e.mzero=n.Maybe.mzero,e.mplus=n.Maybe.mplus}(i=t.Maybe||(t.Maybe={})),t.Just=r,t.Nothing=n.Maybe.mzero}),define("src/lib/monad/either.impl",["require","exports","src/lib/monad/monad"],function(e,t,n){"use strict";function r(){throw new Error("Spica: Either: Invalid thunk call.")}var i=function(e){function t(t){var n=e.call(this,t)||this;return void n.EITHER,n}return __extends(t,e),t.prototype.fmap=function(e){return this.bind(function(t){return new o(e(t))})},t.prototype.ap=function(e){return t.ap(this,e)},t.prototype.bind=function(e){var n=this;return new t(function(){var r=n.evaluate();if(r instanceof u)return r;if(r instanceof o)return e(r.extract());if(r instanceof t)return r.bind(e);throw new TypeError("Spica: Either: Invalid monad value.\n\t"+r)})},t.prototype.extract=function(e,t){return t?this.fmap(t).extract(e):this.evaluate().extract(e)},t}(n.Monad);t.Either=i,function(e){function t(e){return new o(e)}e.pure=t,e.Return=t}(i=t.Either||(t.Either={}));var u=function(e){function t(t){var n=e.call(this,r)||this;return n.a=t,void n.LEFT,n}return __extends(t,e),t.prototype.bind=function(e){return this},t.prototype.extract=function(e){if(!e)throw this.a;return e(this.a)},t}(i);t.Left=u;var o=function(e){function t(t){var n=e.call(this,r)||this;return n.b=t,void n.RIGHT,n}return __extends(t,e),t.prototype.bind=function(e){var t=this;return new i(function(){return e(t.extract())})},t.prototype.extract=function(e,t){return t?t(this.b):this.b},t}(i);t.Right=o}),define("src/lib/monad/either",["require","exports","src/lib/monad/either.impl"],function(e,t,n){"use strict";function r(e){return new n.Left(e)}function i(e){return new n.Right(e)}var u;!function(e){e.fmap=n.Either.fmap,e.pure=n.Either.pure,e.ap=n.Either.ap,e.Return=n.Either.Return,e.bind=n.Either.bind}(u=t.Either||(t.Either={})),t.Left=r,t.Right=i}),define("src/lib/cancelable",["require","exports","src/lib/noop","src/lib/monad/maybe","src/lib/monad/either"],function(e,t,n,r,i){"use strict";var u=function(){function e(){var e=this;this.canceled=!1,this.listeners=new Set,this.promise=function(t){return e.canceled?e.promise_=e.promise_||new Promise(function(t,n){return void n(e.reason)}):Promise.resolve(t)},this.maybe=function(t){return e.canceled?r.Nothing:r.Just(t)},this.either=function(t){return e.canceled?i.Left(e.reason):i.Right(t)},this.cancel=function(t){return e.cancel=n.noop,e.canceled=!0,e.reason=t,e.listeners.forEach(function(e){return void e(t)}),e.listeners.clear(),void(e.listeners.add=function(t){return void t(e.reason),e.listeners})}}return e}();t.Cancelable=u}),define("src/lib/monad/sequence/core",["require","exports","src/lib/monad/monadplus"],function(e,t,n){"use strict";function r(){throw new Error("Spica: Sequence: Invalid thunk call.")}var i=function(e){function t(t){var n=e.call(this,r)||this;return n.cons=t,n}return __extends(t,e),t.prototype[Symbol.iterator]=function(){var e=this,n=function(){return e.iterate()};return{next:function(){var e=n();return n=t.Thunk.iterator(e),{done:!t.isIterable(e),value:t.Thunk.value(e)}}}},t}(n.MonadPlus);t.Sequence=i,function(e){}(i=t.Sequence||(t.Sequence={})),function(e){function t(e){return r.iterator(e)!==i.done}var n;!function(t){function n(t,n){switch(arguments.length){case 0:return[];case 1:return[t];case 2:return[t,n];default:throw e.Exception.invalidConsError(arguments)}}t.cons=n}(n=e.Data||(e.Data={}));var r;!function(e){function t(e){return e[0]}function n(e){return e[1]}function r(e){return e[2]}e.value=t,e.iterator=n,e.index=r}(r=e.Thunk||(e.Thunk={}));var i;!function(t){function n(t,i,u){return e.isIterable(t)?u(t,function(){return n(r.iterator(t)(),i,u)}):i(t)}t.done=function(){return[void 0,t.done,-1]},t.when=n}(i=e.Iterator||(e.Iterator={})),e.isIterable=t;var u;!function(e){function t(e){return console.error(e,e.length,e[0],e[1]),new TypeError("Spica: Sequence: Invalid parameters of cons.")}function n(e){return console.error(e),new TypeError("Spica: Sequence: Invalid data.")}function r(e){return console.error(e),new TypeError("Spica: Sequence: Invalid thunk.")}e.invalidConsError=t,e.invalidDataError=n,e.invalidThunkError=r}(u=e.Exception||(e.Exception={}))}(i=t.Sequence||(t.Sequence={}))}),define("src/lib/monad/sequence/member/static/resume",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.resume=function(e){return new n.Sequence(function(t,r){return void 0===t&&(t=e),n.Sequence.Iterator.when(t(),function(){return r()},function(e){return r(n.Sequence.Thunk.value(e),n.Sequence.Thunk.iterator(e))})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/static/from",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.from=function(e){return new n.Sequence(function(t,n){var r=void 0===t?[e[Symbol.iterator](),0]:t,i=r[0],u=r[1],o=i.next();return o.done?n():n(o.value,[i,u+1])}).reduce()},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/static/cycle",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.cycle=function(e){return new n.Sequence(function t(n,r){var i=void 0===n?[e[Symbol.iterator](),0]:n,u=i[0],o=i[1],c=u.next();return c.done?t([e[Symbol.iterator](),o+1],r):r(c.value,[u,o+1])}).reduce()},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/static/random",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.random=function(e){return void 0===e&&(e=function(){return Math.random()}),"function"==typeof e?n.Sequence.from(new n.Sequence(function(t,n){return n(e(),t)})):this.random().map(function(t){return e[t*e.length|0]})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/static/concat",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.concat=function(e){return new n.Sequence(function(t,r){var i=void 0===t?[function(){return e.iterate()},n.Sequence.Iterator.done]:t,u=i[0],o=i[1];return n.Sequence.Iterator.when(u(),function(){return r()},function(e,t){return o=o===n.Sequence.Iterator.done?function(){return n.Sequence.Thunk.value(e).iterate()}:o,n.Sequence.Iterator.when(o(),function(){return o=n.Sequence.Iterator.done,t()},function(t){return r(n.Sequence.Thunk.value(t),[function(){return e},n.Sequence.Thunk.iterator(t)])})})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/static/zip",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.zip=function(e,t){return new n.Sequence(function(r,i){var u=void 0===r?[function(){return e.iterate()},function(){return t.iterate()}]:r,o=u[0],c=u[1];return n.Sequence.Iterator.when(o(),function(){return i()},function(e){return n.Sequence.Iterator.when(c(),function(){return i()},function(t){return i([n.Sequence.Thunk.value(e),n.Sequence.Thunk.value(t)],[n.Sequence.Thunk.iterator(e),n.Sequence.Thunk.iterator(t)])})})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/static/difference",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.difference=function(e,t,r){return new n.Sequence(function(i,u){var o=void 0===i?[function(){return e.iterate()},function(){return t.iterate()}]:i,c=o[0],s=o[1];return n.Sequence.Iterator.when(c(),function(){return n.Sequence.Iterator.when(s(),function(){return u()},function(e){return u(n.Sequence.Thunk.value(e),[n.Sequence.Iterator.done,n.Sequence.Thunk.iterator(e)])})},function(e,t){return n.Sequence.Iterator.when(s(),function(){return u(n.Sequence.Thunk.value(e),[n.Sequence.Thunk.iterator(e),n.Sequence.Iterator.done])},function(i){var o=r(n.Sequence.Thunk.value(e),n.Sequence.Thunk.value(i));return o<0?u(n.Sequence.Thunk.value(e),[n.Sequence.Thunk.iterator(e),function(){return i}]):o>0?u(n.Sequence.Thunk.value(i),[function(){return e},n.Sequence.Thunk.iterator(i)]):(s=function(){return n.Sequence.Thunk.iterator(i)()},t())})})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/static/union",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.union=function(e,t,r){return new n.Sequence(function(i,u){var o=void 0===i?[function(){return e.iterate()},function(){return t.iterate()}]:i,c=o[0],s=o[1];return n.Sequence.Iterator.when(c(),function(){return n.Sequence.Iterator.when(s(),function(){return u()},function(e){return u(n.Sequence.Thunk.value(e),[n.Sequence.Iterator.done,n.Sequence.Thunk.iterator(e)])})},function(e){return n.Sequence.Iterator.when(s(),function(){return u(n.Sequence.Thunk.value(e),[n.Sequence.Thunk.iterator(e),n.Sequence.Iterator.done])},function(t){var i=r(n.Sequence.Thunk.value(e),n.Sequence.Thunk.value(t));return i<0?u(n.Sequence.Thunk.value(e),[n.Sequence.Thunk.iterator(e),function(){return t}]):i>0?u(n.Sequence.Thunk.value(t),[function(){return e},n.Sequence.Thunk.iterator(t)]):u(n.Sequence.Thunk.value(e),[n.Sequence.Thunk.iterator(e),n.Sequence.Thunk.iterator(t)])})})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/static/intersect",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.intersect=function(e,t,r){return new n.Sequence(function(i,u){var o=void 0===i?[function(){return e.iterate()},function(){return t.iterate()}]:i,c=o[0],s=o[1];return n.Sequence.Iterator.when(c(),function(){return u()},function(e,t){return n.Sequence.Iterator.when(s(),function(){return u()},function(i,o){var c=r(n.Sequence.Thunk.value(e),n.Sequence.Thunk.value(i));return c<0?(s=function(){return i},t()):c>0?o():u(n.Sequence.Thunk.value(e),[n.Sequence.Thunk.iterator(e),n.Sequence.Thunk.iterator(i)])})})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/static/pure",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.pure=function(e){return new n.Sequence(function(t,n){return n(e)})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/static/return",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.Return=function(e){return new n.Sequence(function(t,n){return n(e)})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/static/mempty",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r,r.mempty=new n.Sequence(function(e,t){return t()})}),define("src/lib/monad/sequence/member/static/mconcat",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";function r(e,t){return new n.Sequence(function(r,i){var u=void 0===r?[function(){return e.iterate()},function(){return t.iterate()}]:r,o=u[0],c=u[1];return n.Sequence.Iterator.when(o(),function(){return n.Sequence.Iterator.when(c(),function(){return i()},function(e){return i(n.Sequence.Thunk.value(e),[n.Sequence.Iterator.done,n.Sequence.Thunk.iterator(e)])})},function(e){return i(n.Sequence.Thunk.value(e),[n.Sequence.Thunk.iterator(e),c])})})}var i=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.mconcat=function(e){return Array.from(e).reduce(function(e,t){return r(e,t)},n.Sequence.mempty)},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=i}),define("src/lib/monad/sequence/member/static/mappend",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.mappend=function(e,t){return n.Sequence.mconcat([e,t])},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/static/mzero",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r,r.mzero=n.Sequence.mempty}),define("src/lib/monad/sequence/member/static/mplus",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r,r.mplus=n.Sequence.mappend}),define("src/lib/monad/sequence/member/instance/extract",["require","exports","src/lib/monad/sequence/core","src/lib/concat"],function(e,t,n,r){"use strict";var i=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.extract=function(){for(var e=this,t=[],i=function(){return e.iterate()};;){var u=i();if(!n.Sequence.isIterable(u))return t;void r.concat(t,[n.Sequence.Thunk.value(u)]),i=n.Sequence.Thunk.iterator(u)}},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=i}),define("src/lib/monad/sequence/member/instance/iterate",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.iterate=function(){return this.iterate_()},t.prototype.iterate_=function(e,t){var r=this;void 0===t&&(t=0);var i=this.cons(e,n.Sequence.Data.cons);switch(i.length){case 0:return[void 0,n.Sequence.Iterator.done,-1];case 1:return[i[0],function(){return n.Sequence.Iterator.done()},t];case 2:return[i[0],function(){return r.iterate_(i[1],t+1)},t];default:throw n.Sequence.Exception.invalidDataError(i)}},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/instance/memoize",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=new WeakMap,i=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.memoize=function(){var e=this;return new n.Sequence(function(t,i){var u=void 0===t?[0,r.get(e)||r.set(e,new Map).get(e)]:t,o=u[0],c=u[1];return n.Sequence.Iterator.when(c.get(o)||c.set(o,o>0&&c.has(o-1)?n.Sequence.Thunk.iterator(c.get(o-1))():e.iterate()).get(o),function(){return i()},function(e){return i(n.Sequence.Thunk.value(e),[o+1,c])})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=i}),define("src/lib/monad/sequence/member/instance/reduce",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.reduce=function(){var e=this;return new n.Sequence(function(t,r){var i=void 0===t?[0,new Map]:t,u=i[0],o=i[1];return n.Sequence.Iterator.when(o.get(u)||o.set(u,u>0&&o.has(u-1)?n.Sequence.Thunk.iterator(o.get(u-1))():e.iterate()).get(u),function(){return r()},function(e){return r(n.Sequence.Thunk.value(e),[u+1,o])})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/instance/take",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.take=function(e){var t=this;return new n.Sequence(function(r,i){return void 0===r&&(r=function(){return t.iterate()}),n.Sequence.Iterator.when(e>0?r():n.Sequence.Iterator.done(),function(){return i()},function(t){return n.Sequence.Thunk.index(t)+1<e?i(n.Sequence.Thunk.value(t),n.Sequence.Thunk.iterator(t)):i(n.Sequence.Thunk.value(t))})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/instance/drop",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.drop=function(e){var t=this;return new n.Sequence(function(r,i){return void 0===r&&(r=function(){
return t.iterate()}),n.Sequence.Iterator.when(r(),function(){return i()},function(t,r){return n.Sequence.Thunk.index(t)<e?r():i(n.Sequence.Thunk.value(t),n.Sequence.Thunk.iterator(t))})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/instance/takeWhile",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.takeWhile=function(e){var t=this;return new n.Sequence(function(r,i){return void 0===r&&(r=function(){return t.iterate()}),n.Sequence.Iterator.when(r(),function(){return i()},function(t){return e(n.Sequence.Thunk.value(t))?i(n.Sequence.Thunk.value(t),n.Sequence.Thunk.iterator(t)):i()})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/instance/dropWhile",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.dropWhile=function(e){var t=this;return new n.Sequence(function(r,i){return void 0===r&&(r=function(){return t.iterate()}),n.Sequence.Iterator.when(r(),function(){return i()},function(t,r){return e(n.Sequence.Thunk.value(t))?r():i(n.Sequence.Thunk.value(t),n.Sequence.Thunk.iterator(t))})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/instance/takeUntil",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.takeUntil=function(e){var t=this;return new n.Sequence(function(r,i){return void 0===r&&(r=function(){return t.iterate()}),n.Sequence.Iterator.when(r(),function(){return i()},function(t){return e(n.Sequence.Thunk.value(t))?i(n.Sequence.Thunk.value(t)):i(n.Sequence.Thunk.value(t),n.Sequence.Thunk.iterator(t))})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/instance/dropUntil",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.dropUntil=function(e){var t=this;return new n.Sequence(function(r,i){return void 0===r&&(r=function(){return t.iterate()}),n.Sequence.Iterator.when(r(),function(){return i()},function(t,r){return e(n.Sequence.Thunk.value(t))?r():i(n.Sequence.Thunk.value(t),n.Sequence.Thunk.iterator(t))})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/instance/fmap",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.fmap=function(e){var t=this;return new n.Sequence(function(r){return void 0===r&&(r=function(){return t.iterate()}),n.Sequence.Iterator.when(r(),function(){return n.Sequence.Data.cons()},function(t){return n.Sequence.Data.cons(e(n.Sequence.Thunk.value(t)),n.Sequence.Thunk.iterator(t))})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/instance/ap",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.ap=function(e){return n.Sequence.ap(this,e)},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/instance/bind",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.bind=function(e){return n.Sequence.concat(this.fmap(e))},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/instance/mapM",["require","exports","src/lib/monad/sequence/core","src/lib/concat"],function(e,t,n,r){"use strict";var i=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.mapM=function(e){var t=this;return n.Sequence.from([0]).bind(function(){var i=t.extract();switch(i.length){case 0:return n.Sequence.mempty;default:var u=i.shift();return e(u).bind(function(t){return 0===i.length?n.Sequence.from([[t]]):n.Sequence.from(i).mapM(e).fmap(function(e){return r.concat([t],e)})})}})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=i}),define("src/lib/monad/sequence/member/instance/filterM",["require","exports","src/lib/monad/sequence/core","src/lib/concat"],function(e,t,n,r){"use strict";var i=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.filterM=function(e){var t=this;return n.Sequence.from([0]).bind(function(){var i=t.extract();switch(i.length){case 0:return n.Sequence.from([[]]);default:var u=i.shift();return e(u).bind(function(t){return t?0===i.length?n.Sequence.from([[u]]):n.Sequence.from(i).filterM(e).fmap(function(e){return r.concat([u],e)}):0===i.length?n.Sequence.from([[]]):n.Sequence.from(i).filterM(e)})}})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=i}),define("src/lib/monad/sequence/member/instance/map",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.map=function(e){var t=this;return new n.Sequence(function(r){return void 0===r&&(r=function(){return t.iterate()}),n.Sequence.Iterator.when(r(),function(){return n.Sequence.Data.cons()},function(t){return n.Sequence.Data.cons(e(n.Sequence.Thunk.value(t),n.Sequence.Thunk.index(t)),n.Sequence.Thunk.iterator(t))})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/instance/filter",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.filter=function(e){var t=this;return new n.Sequence(function(r,i){return void 0===r&&(r=function(){return t.iterate()}),n.Sequence.Iterator.when(r(),function(){return i()},function(t,r){return e(n.Sequence.Thunk.value(t),n.Sequence.Thunk.index(t))?i(n.Sequence.Thunk.value(t),n.Sequence.Thunk.iterator(t)):r()})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/instance/scan",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.scan=function(e,t){var r=this;return new n.Sequence(function(i){var u=void 0===i?[t,function(){return r.iterate()},0]:i,o=u[0],c=u[1],s=u[2];return n.Sequence.Iterator.when(c(),function(){return 0===s?n.Sequence.Data.cons(t):n.Sequence.Data.cons()},function(t){return n.Sequence.Data.cons(o=e(o,n.Sequence.Thunk.value(t)),[o,n.Sequence.Thunk.iterator(t),n.Sequence.Thunk.index(t)+1])})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/instance/fold",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.fold=function(e,t){var r=this;return new n.Sequence(function(i){return void 0===i&&(i=function(){return r.reduce().iterate()}),n.Sequence.Iterator.when(i(),function(){return n.Sequence.Data.cons(t)},function(r){return n.Sequence.Data.cons(e(n.Sequence.Thunk.value(r),n.Sequence.resume(n.Sequence.Thunk.iterator(r)).fold(e,t)))})}).bind(function(e){return e})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/instance/group",["require","exports","src/lib/monad/sequence/core","src/lib/concat"],function(e,t,n,r){"use strict";var i=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.group=function(e){var t=this;return new n.Sequence(function(i,u){var o=void 0===i?[function(){return t.iterate()},[]]:i,c=o[0],s=o[1];return n.Sequence.Iterator.when(c(),function(){return 0===s.length?u():u(s)},function(t,i){return 0===s.length||e(s[0],n.Sequence.Thunk.value(t))?(r.concat(s,[n.Sequence.Thunk.value(t)]),i()):u(s,[n.Sequence.Thunk.iterator(t),r.concat([],[n.Sequence.Thunk.value(t)])])})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=i}),define("src/lib/monad/sequence/member/instance/subsequences",["require","exports","src/lib/monad/sequence/core","src/lib/concat"],function(e,t,n,r){"use strict";function i(e){return n.Sequence.Iterator.when(e.iterate(),function(){return n.Sequence.mempty},function(e){return n.Sequence.mappend(n.Sequence.from([[n.Sequence.Thunk.value(e)]]),new n.Sequence(function(t,u){return n.Sequence.Iterator.when(e,function(){return u()},function(e){return u(i(n.Sequence.resume(n.Sequence.Thunk.iterator(e))).fold(function(t,i){return n.Sequence.mappend(n.Sequence.mappend(n.Sequence.from([t]),n.Sequence.from([r.concat([n.Sequence.Thunk.value(e)],t)])),i)},n.Sequence.mempty))})}).bind(function(e){return e}))})}var u=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.subsequences=function(){var e=this;return n.Sequence.mappend(n.Sequence.from([[]]),n.Sequence.from([0]).bind(function(){return i(e)}))},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=u}),define("src/lib/monad/sequence/member/instance/permutations",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";function r(e,t){return n.Sequence.Iterator.when(e.iterate(),function(){return n.Sequence.mempty},function(e){return new n.Sequence(function(i,u){return n.Sequence.Iterator.when(e,function(){return u()},function(e){function i(e,t){return o(function(e){return e},e,t)[1]}function o(e,t,r){return n.Sequence.Iterator.when(t.iterate(),function(){return[s,r]},function(t){var i=n.Sequence.Thunk.value(t),u=o(function(t){return e(n.Sequence.mappend(n.Sequence.from([i]),t))},n.Sequence.resume(n.Sequence.Thunk.iterator(t)),r),s=u[0],a=u[1];return[n.Sequence.mappend(n.Sequence.from([i]),s),n.Sequence.mappend(n.Sequence.from([e(n.Sequence.mappend(n.Sequence.from([c]),n.Sequence.mappend(n.Sequence.from([i]),s))).extract()]),a)]})}var c=n.Sequence.Thunk.value(e),s=n.Sequence.resume(n.Sequence.Thunk.iterator(e)).memoize();return u(t.permutations().fold(function(e,t){return i(n.Sequence.from(e),t)},r(s,n.Sequence.mappend(n.Sequence.from([c]),t))))})}).bind(function(e){return e})})}var i=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.permutations=function(){var e=this;return n.Sequence.from([0]).bind(function(){var t=e.extract();return 0===t.length?n.Sequence.mempty:n.Sequence.from([t])}).bind(function(e){return n.Sequence.mappend(n.Sequence.from([e]),r(n.Sequence.from(e),n.Sequence.mempty))})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=i}),define("src/lib/type",["require","exports"],function(e,t){"use strict";function n(e){return Object.prototype.toString.call(e).split(" ").pop().slice(0,-1)}t.type=n}),define("src/lib/assign",["require","exports","src/lib/type"],function(e,t,n){"use strict";function r(e){return function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];if(void 0===t||null===t)throw new TypeError("Spica: assign: Cannot walk on "+t+".");for(var i=0,u=n;i<u.length;i++){var o=u[i];if(void 0!==o&&null!==o)for(var c=0,s=Object.keys(Object(o));c<s.length;c++){var a=s[c],f=Object.getOwnPropertyDescriptor(Object(o),a);void 0!==f&&f.enumerable&&void e(a,Object(t),Object(o))}}return Object(t)}}t.assign=r(function(e,t,n){return t[e]=n[e]}),t.clone=r(function(e,r,i){switch(n.type(i[e])){case"Array":return r[e]=t.clone([],i[e]);case"Object":return r[e]=t.clone({},i[e]);default:return r[e]=i[e]}}),t.extend=r(function(e,r,i){switch(n.type(i[e])){case"Array":return r[e]=t.extend([],i[e]);case"Object":switch(n.type(r[e])){case"Function":case"Object":return r[e]=t.extend(r[e],i[e]);default:return r[e]=t.extend({},i[e])}default:return r[e]=i[e]}})}),define("src/lib/compose",["require","exports","src/lib/assign"],function(e,t,n){"use strict";function r(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return t.reduce(function(e,t){void n.assign(e.prototype,t.prototype);for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e},e)}t.compose=r}),define("src/lib/monad/sequence",["require","exports","src/lib/monad/sequence/core","src/lib/monad/sequence/member/static/resume","src/lib/monad/sequence/member/static/from","src/lib/monad/sequence/member/static/cycle","src/lib/monad/sequence/member/static/random","src/lib/monad/sequence/member/static/concat","src/lib/monad/sequence/member/static/zip","src/lib/monad/sequence/member/static/difference","src/lib/monad/sequence/member/static/union","src/lib/monad/sequence/member/static/intersect","src/lib/monad/sequence/member/static/pure","src/lib/monad/sequence/member/static/return","src/lib/monad/sequence/member/static/mempty","src/lib/monad/sequence/member/static/mconcat","src/lib/monad/sequence/member/static/mappend","src/lib/monad/sequence/member/static/mzero","src/lib/monad/sequence/member/static/mplus","src/lib/monad/sequence/member/instance/extract","src/lib/monad/sequence/member/instance/iterate","src/lib/monad/sequence/member/instance/memoize","src/lib/monad/sequence/member/instance/reduce","src/lib/monad/sequence/member/instance/take","src/lib/monad/sequence/member/instance/drop","src/lib/monad/sequence/member/instance/takeWhile","src/lib/monad/sequence/member/instance/dropWhile","src/lib/monad/sequence/member/instance/takeUntil","src/lib/monad/sequence/member/instance/dropUntil","src/lib/monad/sequence/member/instance/fmap","src/lib/monad/sequence/member/instance/ap","src/lib/monad/sequence/member/instance/bind","src/lib/monad/sequence/member/instance/mapM","src/lib/monad/sequence/member/instance/filterM","src/lib/monad/sequence/member/instance/map","src/lib/monad/sequence/member/instance/filter","src/lib/monad/sequence/member/instance/scan","src/lib/monad/sequence/member/instance/fold","src/lib/monad/sequence/member/instance/group","src/lib/monad/sequence/member/instance/subsequences","src/lib/monad/sequence/member/instance/permutations","src/lib/compose"],function(e,t,n,r,i,u,o,c,s,a,f,d,l,p,h,v,m,q,b,y,S,x,_,w,k,g,T,M,I,O,j,E,P,N,A,R,D,z,C,L,F,W){"use strict";t.Sequence=n.Sequence,void W.compose(n.Sequence,r.default,i.default,u.default,o.default,c.default,s.default,a.default,f.default,d.default,l.default,p.default,h.default,v.default,m.default,q.default,b.default,y.default,S.default,x.default,_.default,w.default,k.default,g.default,T.default,M.default,I.default,O.default,j.default,E.default,P.default,N.default,A.default,R.default,D.default,z.default,C.default,L.default,F.default)}),define("src/lib/flip",["require","exports","src/lib/curry"],function(e,t,n){"use strict";function r(e){return n.curry(function(t,n){return e.length>1?e(n,t):e(n)(t)})}t.flip=r}),define("src/lib/list",["require","exports","src/lib/concat"],function(e,t,n){"use strict";var r=function(){function e(){void this.NIL}return e.prototype.push=function(e){return new i(e,this)},e.prototype.array=function(){return[]},e}();t.Nil=r;var i=function(){function e(e,t){this.head_=e,this.tail_=t,void this.CONS}return e.prototype.push=function(t){return new e(t,this)},e.prototype.head=function(){return this.head_},e.prototype.tail=function(){return this.tail_},e.prototype.walk=function(e){return void e(this.head()),this.tail()},e.prototype.modify=function(e){return this.tail().push(e(this.head()))},e.prototype.extend=function(e){return this.push(e(this.head()))},e.prototype.compact=function(e){var t=this;return this.tail().modify(function(n){return e(t.head(),n)})},e.prototype.reverse=function(){return this.array().reduce(function(e,t){return e.push(t)},new r)},e.prototype.tuple=function(){return this.array()},e.prototype.array=function(){return n.concat([this.head()],this.tail().array())},e}()}),define("src/lib/hlist",["require","exports","src/lib/concat"],function(e,t,n){"use strict";var r=function(){function e(){void this.NIL}return e.prototype.push=function(e){return new i(e,this)},e.prototype.array=function(){return[]},e}();t.HNil=r;var i=function(){function e(e,t){this.head_=e,this.tail_=t,void this.CONS}return e.prototype.push=function(t){return new e(t,this)},e.prototype.head=function(){return this.head_},e.prototype.tail=function(){return this.tail_},e.prototype.walk=function(e){return void e(this.head()),this.tail()},e.prototype.modify=function(e){return this.tail().push(e(this.head()))},e.prototype.extend=function(e){return this.push(e(this.head()))},e.prototype.compact=function(e){var t=this;return this.tail().modify(function(n){return e(t.head(),n)})},e.prototype.reverse=function(){return this.array().reduce(function(e,t){return e.push(t)},new r)},e.prototype.tuple=function(){return this.array()},e.prototype.array=function(){return n.concat([this.head()],this.tail().array())},e}()}),define("src/lib/collection/datamap",["require","exports","src/lib/sqid","src/lib/type"],function(e,t,n,r){"use strict";function i(e){return e instanceof Object==!1}var u=function(){function e(e){void 0===e&&(e=[]);var t=this;this.store=new Map,this.weakstore=new WeakMap,void Array.from(e).forEach(function(e){var n=e[0],r=e[1];return void t.set(n,r)})}return e.prototype.stringify=function(e){switch(typeof e){case"undefined":return"0:"+e;case"boolean":return"1:"+e;case"number":return"2:"+(1e3+(""+e).length)+":"+e;case"string":return"3:"+(1e14+e.length)+":"+e;default:return i(e)?"8:"+e:Array.isArray(e)?"9:[ "+this.stringifyArray(e)+" ]":"9:{ "+(this.stringifyObject(e)||this.weakstore.get(e)||this.weakstore.set(e,n.sqid()).get(e))+" }"}},e.prototype.stringifyArray=function(e){for(var t="",n=0,r=e;n<r.length;n++){var i=r[n];t+=""+this.stringify(i)}return t},e.prototype.stringifyObject=function(e){if("Object"!==r.type(e))return"";for(var t=Object.keys(e),n="",i=0,u=t;i<u.length;i++){var o=u[i];n+=this.stringify(o)+": "+this.stringify(e[o])}return n||" "},e.prototype.get=function(e){return(this.store.get(this.stringify(e))||[])[1]},e.prototype.set=function(e,t){return void this.store.set(this.stringify(e),[e,t]),this},e.prototype.has=function(e){return this.store.has(this.stringify(e))},e.prototype.delete=function(e){return this.store.delete(this.stringify(e))},e.prototype.clear=function(){return this.store.clear()},Object.defineProperty(e.prototype,"size",{get:function(){return this.store.size},enumerable:!0,configurable:!0}),e}();t.DataMap=u}),define("src/lib/collection/cachemap",["require","exports"],function(e,t){"use strict";var n=Date.now();void setInterval(function(){return n=Date.now()},100);var r=function(){function e(e){void 0===e&&(e=[]);var t=this;this.store=new Map,void Array.from(e).forEach(function(e){var n=e[0],r=e[1];return void t.set(n,r)})}return e.prototype.clean=function(e){this.store.has(e)&&this.store.get(e)[0]<n&&void this.store.delete(e)},e.prototype.get=function(e){return void this.clean(e),(this.store.get(e)||[0,void 0])[1]},e.prototype.set=function(e,t,r){return void 0===r&&(r=1/0),void this.clean(e),void this.store.set(e,[n+r,t]),this},e.prototype.has=function(e){return void this.clean(e),this.store.has(e)},e.prototype.delete=function(e){return void this.clean(e),this.store.delete(e)},e.prototype.clear=function(){return this.store.clear()},Object.defineProperty(e.prototype,"size",{get:function(){return this.store.size},enumerable:!0,configurable:!0}),e}();t.CacheMap=r}),define("src/lib/collection/attrmap",["require","exports"],function(e,t){"use strict";var n=function(){function e(e,t,n){void 0===e&&(e=[]),void 0===t&&(t=WeakMap),void 0===n&&(n=Map);var r=this;this.KeyMap=t,this.ValueMap=n,this.store=new this.KeyMap,void Array.from(e).forEach(function(e){var t=e[0],n=e[1],i=e[2];return void r.set(t,n,i)})}return e.prototype.get=function(e,t){return this.store.get(e)&&this.store.get(e).get(t)},e.prototype.set=function(e,t,n){var r=this.store.has(e)?this.store.get(e):this.store.set(e,new this.ValueMap).get(e);return void r.set(t,n),this},e.prototype.has=function(e,t){return 1===arguments.length?this.store.has(e):this.store.has(e)&&this.store.get(e).has(t)},e.prototype.delete=function(e,t){return 1===arguments.length?this.store.delete(e):!!this.store.has(e)&&this.store.get(e).delete(t)},e}();t.AttrMap=n}),define("src/lib/mixin",["require","exports","src/lib/assign"],function(e,t,n){"use strict";function r(){for(var e=[],t=0;t<arguments.length;t++)e[t-0]=arguments[t];return e.reduceRight(function(e,t){return i(t,e)},function(){function e(){}return e}())}function i(e,t){var r=function(){function n(){return e.call(t.call(this)||this)}return n}();void n.assign(r.prototype,e.prototype,t.prototype);for(var i in t)t.hasOwnProperty(i)&&(r[i]=t[i]);for(var i in e)e.hasOwnProperty(i)&&(r[i]=e[i]);return r}t.Mixin=r}),define("src/lib/fingerprint",["require","exports"],function(e,t){"use strict";function n(){return i(u([o(window.navigator),o(window.screen),o((new Date).getTimezoneOffset())].join()))}function r(){return i(u([o(process)].join()))}function i(e){return e.split("").reduce(function(e,t,n){return(+t*n+e)%1e9||e-+t},0)}function u(e){return e.split("").map(function(e){return e.charCodeAt(0)}).join("")}function o(e,t){if(void 0===t&&(t=5),t>0&&e&&"object"==typeof e){var n="{";for(var r in e)n+='"'+r+'": '+o(e[r],t-1)+",";return n+="}"}return!e||e.toString?'"'+e+'"':'"'+Object.prototype.toString.call(e)+'"'}t.FINGERPRINT="object"==typeof window?n():r(),t.browser=n,t.server=r,t.hash=i,t.str2digit=u,t.stringify=o}),define("src/lib/uuid",["require","exports","src/lib/fingerprint"],function(e,t,n){"use strict";function r(){var e=o=o*Date.now()%1e15;if(e<16||1e15<e)throw new Error("Spica: uuid: Invalid uuid dynamic seed.");for(var t="",n=0,r=u;n<r.length;n++){var i=r[n];if("x"===i||"y"===i){var c=Math.random()*e%16|0,s="x"==i?c:3&c|8;t+=s.toString(16)}else t+=i}return t.toLowerCase()}var i=n.FINGERPRINT*Date.now()%1e15;if(!i||"number"!=typeof i||i<100||1e15<i)throw new Error("Spica: uuid: Invalid uuid static seed.\n\t"+n.FINGERPRINT);var u=Object.freeze("xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".split("")),o=i;t.v4=r}),define("src/lib/sort",["require","exports"],function(e,t){"use strict";function n(e,t,n,r){if(void 0===r&&(r=!1),!r&&n*n>1.25*e.length)return e.sort(t);n=n<e.length-1?n:e.length-1;for(var i=0;i<n;++i)for(var u=i+1;u<e.length;++u)if(t(e[i],e[u])>0!=!1){var o=e[i];e[i]=e[u],e[u]=o}return e}t.sort=n}),define("src/export",["require","exports","src/lib/supervisor","src/lib/observable","src/lib/cancelable","src/lib/monad/sequence","src/lib/monad/maybe","src/lib/monad/either","src/lib/curry","src/lib/flip","src/lib/list","src/lib/hlist","src/lib/collection/datamap","src/lib/collection/cachemap","src/lib/collection/attrmap","src/lib/mixin","src/lib/tick","src/lib/fingerprint","src/lib/uuid","src/lib/sqid","src/lib/assign","src/lib/concat","src/lib/sort"],function(e,t,n,r,i,u,o,c,s,a,f,d,l,p,h,v,m,q,b,y,S,x,_){"use strict";t.Supervisor=n.Supervisor,t.Observable=r.Observable,t.Cancelable=i.Cancelable,t.Sequence=u.Sequence,t.Maybe=o.Maybe,t.Just=o.Just,t.Nothing=o.Nothing,t.Either=c.Either,t.Left=c.Left,t.Right=c.Right,t.curry=s.curry,t.flip=a.flip,t.Nil=f.Nil,t.HNil=d.HNil,t.DataMap=l.DataMap,t.CacheMap=p.CacheMap,t.AttrMap=h.AttrMap,t.Mixin=v.Mixin,t.Tick=m.Tick,t.FINGERPRINT=q.FINGERPRINT,t.uuid=b.v4,t.sqid=y.sqid,t.assign=S.assign,t.clone=S.clone,t.extend=S.extend,t.concat=x.concat,t.sort=_.sort}),define("spica",["require","exports","src/export","./src/import"],function(e,t,n){"use strict";function r(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}r(n)});
/*! spica v0.0.34 https://github.com/falsandtru/spica | (c) 2016, falsandtru | MIT License */
define="function"==typeof define&&define.amd?define:function(){"use strict";var e="spica",t={};return function n(r,i,u){return u?void u.apply(this,i.map(function(e){switch(e){case"require":return"function"==typeof require?require:void 0;case"exports":return r.indexOf("/")===-1?t[r]="undefined"==typeof exports?self[r]=self[r]||{}:exports:t[r]=t.hasOwnProperty(r)?t[r]:{};default:return".d"===e.slice(-2)&&{}||t.hasOwnProperty(e)&&t[e]||"function"==typeof require&&require(e)||self[e]}})):void n(e,r,i)}}();var __extends=this&&this.__extends||function(e,t){function n(){this.constructor=e}for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)};define("src/lib/concat",["require","exports"],function(e,t){"use strict";function n(e,t){for(var n=0,r=t.length,i=e.length;n<r;++n)e[n+i]=t[n];return e}t.concat=n}),define("src/lib/observable",["require","exports","src/lib/concat"],function(e,t,n){"use strict";var r=function(){function e(){this.node_={parent:void 0,childrenMap:Object.create(null),childrenList:[],registers:[]}}return e.prototype.monitor=function(e,t,n){var r=this;return void 0===n&&(n=t),void this.throwTypeErrorIfInvalidSubscriber_(t,e),void this.seekNode_(e).registers.push([e,n,!0,t]),function(){return r.off(e,n)}},e.prototype.on=function(e,t,n){var r=this;return void 0===n&&(n=t),void this.throwTypeErrorIfInvalidSubscriber_(t,e),void this.seekNode_(e).registers.push([e,n,!1,function(e){return t(e)}]),function(){return r.off(e,n)}},e.prototype.off=function(e,t){switch(typeof t){case"function":return void this.seekNode_(e).registers.some(function(e,n,r){var i=e[1];if(t!==i)return!1;switch(n){case 0:return!void r.shift();case r.length-1:return!void r.pop();default:return!void r.splice(n,1)}});case"undefined":var n=this.seekNode_(e);return n.childrenMap=Object.create(null),n.childrenList=[],void(n.registers=[]);default:throw this.throwTypeErrorIfInvalidSubscriber_(t,e)}},e.prototype.once=function(e,t){var n=this;return void this.throwTypeErrorIfInvalidSubscriber_(t,e),this.on(e,function(r){return void n.off(e,t),t(r)},t)},e.prototype.emit=function(e,t,n){void this.drain_(e,t,n)},e.prototype.reflect=function(e,t){var n=[];return void this.emit(e,t,function(e,t){return n=t}),n},e.prototype.drain_=function(e,t,n){var r=[];if(void this.refsBelow_(this.seekNode_(e)).reduce(function(e,i){var u=i[2],o=i[3];if(!u)try{var c=o(t);n&&(r[r.length]=c)}catch(e){void 0!==e&&null!==e&&void console.error(e+"")}},void 0),void this.refsAbove_(this.seekNode_(e)).reduce(function(e,n){var r=n[2],i=n[3];if(r)try{void i(t)}catch(e){void 0!==e&&null!==e&&void console.error(e)}},void 0),n)try{void n(t,r)}catch(e){void console.error(e)}},e.prototype.refs=function(e){return this.refsBelow_(this.seekNode_(e))},e.prototype.refsAbove_=function(e){var t=e.parent,r=e.registers;for(r=n.concat([],r);t;)r=n.concat(r,t.registers),t=t.parent;return r},e.prototype.refsBelow_=function(e){var t=e.childrenList,r=e.childrenMap,i=e.registers;i=n.concat([],i);for(var u=0;u<t.length;++u){var o=t[u],c=this.refsBelow_(r[o]);i=n.concat(i,c),0===c.length&&(void delete r[o],void t.splice(t.indexOf(o),1),void--u)}return i},e.prototype.seekNode_=function(e){for(var t=this.node_,n=0,r=e;n<r.length;n++){var i=r[n],u=t.childrenMap;u[i+""]||(void t.childrenList.push(i+""),u[i+""]={parent:t,childrenMap:Object.create(null),childrenList:[],registers:[]}),t=u[i+""]}return t},e.prototype.throwTypeErrorIfInvalidSubscriber_=function(e,t){switch(typeof e){case"function":return;default:throw new TypeError("Spica: Observable: Invalid subscriber.\n\t"+t+" "+e)}},e}();t.Observable=r}),define("src/lib/tick",["require","exports"],function(e,t){"use strict";function n(e){void u.push(e),void i()}function r(){o=!1;for(var e=u.length;;){try{for(;e>0;)void--e,void u.shift()()}catch(e){console.error(e);continue}break}}function i(){o||0!==u.length&&(void Promise.resolve().then(r),o=!0)}var u=[],o=!1,c=Function("return typeof process === 'object' && typeof window !== 'object'")();t.Tick=c?Function("return fn => process.nextTick(fn)")():n}),define("src/lib/thenable",["require","exports"],function(e,t){"use strict";function n(e){return!!e&&"object"==typeof e&&"function"==typeof e.then}t.isThenable=n}),define("src/lib/sqid",["require","exports"],function(e,t){"use strict";function n(e){if(arguments.length>0){if("number"!=typeof e)throw new TypeError("Spica: sqid: A parameter value must be a number: "+e);if(e>=0==!1)throw new TypeError("Spica: sqid: A parameter value must be a positive number: "+e);if(e%1!==0)throw new TypeError("Spica: sqid: A parameter value must be an integer: "+e)}return void 0===e?(1e15+ ++r+"").slice(1):(1e15+e+"").slice(1)}var r=0;t.sqid=n}),define("src/lib/noop",["require","exports"],function(e,t){"use strict";function n(){}t.noop=n}),define("src/lib/supervisor",["require","exports","src/lib/observable","src/lib/tick","src/lib/thenable","src/lib/sqid","src/lib/noop"],function(e,t,n,r,i,u,o){"use strict";var c=function(){function e(t){var r=void 0===t?{}:t,i=r.name,c=void 0===i?"":i,s=r.timeout,a=void 0===s?0:s,f=r.destructor,d=void 0===f?o.noop:f;if(this.id=u.sqid(),this.events={init:new n.Observable,loss:new n.Observable,exit:new n.Observable},this.procs=new n.Observable,this.alive=!0,this.registerable=!0,this.scheduled=!1,this.workerSharedResource={procs:this.procs},this.queue=[],this.constructor===e)throw new Error("Spica: Supervisor: <"+this.id+"/"+this.name+">: Cannot instantiate abstract classes.");this.name=c,this.timeout=a,this.destructor_=d,void++this.constructor.count}return e.prototype.destructor=function(e){void this.checkState(),this.alive=!1,void this.drain();try{void this.destructor_(e)}catch(e){void console.error(e)}void--this.constructor.count,void Object.freeze(this)},e.prototype.schedule=function(){var e=this;this.alive&&(this.scheduled||(void r.Tick(function(t){e.alive&&(e.scheduled=!1,void e.drain())}),this.scheduled=!0))},e.prototype.register=function(e,t,n){if(void this.checkState(),!this.registerable)throw new Error("Spica: Supervisor: <"+this.id+"/"+this.name+"/"+e+">: Cannot register a process after a supervisor is terminated.");if(this.procs.refs([e]).length>0)throw new Error("Spica: Supervisor: <"+this.id+"/"+this.name+"/"+e+">: Cannot register a process multiply using the same name.");return void this.schedule(),t="function"==typeof t?{init:function(e){return e},call:t,exit:function(e){}}:t,new a(this,this.workerSharedResource,e,t,n).terminate},e.prototype.call=function(e,t,n,r){var i=this;void 0===r&&(r=this.timeout),void this.checkState(),void this.queue.push([e,t,n,r,Date.now()]),void this.schedule(),r<1/0!=!1&&r>0!=!1&&void setTimeout(function(){return void i.drain(e)},r+9)},e.prototype.cast=function(e,t,n){void 0===n&&(n=this.timeout),void this.checkState();var r=this.procs.reflect([e],new s.Call(t,n));return 0===r.length&&void this.events.loss.emit([e],[e,t]),r.length>0},e.prototype.refs=function(e){return void this.checkState(),this.procs.refs(void 0===e?[]:[e]).map(function(e){var t=e[1],n=t(new s.Self);return[n.name,n.process,n.state,n.terminate]})},e.prototype.terminate=function(e,t){if(this.registerable){void 0===e&&(this.registerable=!1);var n=void 0===e?[]:[e];void this.procs.emit(n,new s.Exit(t)),void this.procs.off(n),void 0===e&&void this.destructor(t)}},e.prototype.checkState=function(){if(!this.alive)throw new Error("Spica: Supervisor: <"+this.id+"/"+this.name+">: A supervisor is already terminated.")},e.prototype.drain=function(e){for(var t,n=this,r=Date.now(),u=function(u){var c=o.queue[u],a=c[0],f=c[1],d=c[2],l=c[3],p=c[4],h=void 0===e||e===a?o.procs.reflect([a],new s.Call(f,p+l-r)):[];if(o.alive&&0===h.length&&r<p+l)return t=u,"continue";if(0===u?void o.queue.shift():void o.queue.splice(u,1),void--u,0===h.length){void o.events.loss.emit([a],[a,f]);try{void d(void 0,new Error("Spica: Supervisor: Task: Failed."))}catch(e){void console.error(e)}}else{var v=h[0];if(i.isThenable(v))void Promise.resolve(v).then(function(e){return n.alive?void d(e):void d(void 0,new Error("Spica: Supervisor: Task: Failed."))},function(){return void d(void 0,new Error("Spica: Supervisor: Task: Failed."))}).catch(function(e){return void console.error(e)});else try{void d(v)}catch(e){void console.error(e)}}t=u},o=this,c=0;c<this.queue.length;++c)u(c),c=t},e}();t.Supervisor=c,c.count=0,c.procs=0,function(e){}(c=t.Supervisor||(t.Supervisor={}));var s;!function(e){var t=function(){function e(){void this.COMMAND}return e}();e.Self=t;var n=function(){function e(e,t){this.param=e,this.timeout=t,void this.COMMAND}return e}();e.Call=n;var r=function(){function e(e){this.reason=e,void this.COMMAND}return e}();e.Exit=r}(s||(s={}));var a=function(){function e(t,n,r,i,u){var o=this;this.sv=t,this.sharedResource=n,this.name=r,this.process=i,this.state=u,this.alive=!0,this.called=!1,this.concurrency=1,this.receive=function(t){return e.prototype.receive.call(o,t)},this.terminate=function(t){return e.prototype.terminate.call(o,t)},void++this.sv.constructor.procs,void this.sharedResource.procs.on([r],this.receive)}return e.prototype.destructor=function(e){if(this.alive){void this.sharedResource.procs.off([this.name],this.receive),this.alive=!1,void--this.sv.constructor.procs,void Object.freeze(this);try{void this.process.exit(this.state,e),void this.sv.events.exit.emit([this.name],[this.name,this.process,this.state,e])}catch(e){void this.sv.events.exit.emit([this.name],[this.name,this.process,this.state,e]),void this.sv.terminate(void 0,e)}}},e.prototype.receive=function(e){var t=this;if(void this.checkState(),e instanceof s.Call){if(0===this.concurrency)throw void 0;try{void--this.concurrency,this.called||(this.called=!0,void this.sv.events.init.emit([this.name],[this.name,this.process,this.state]),this.state=this.process.init(this.state));var n=this.process.call(e.param,this.state);if(i.isThenable(n))return new Promise(function(t,r){void n.then(t,r),e.timeout<1/0!=!1&&void setTimeout(function(){return void r(new Error("Spica: Supervisor: Task: Timeout while processing."))},e.timeout)}).then(function(e){var n=e[0],r=e[1];if(void++t.concurrency,void t.sv.schedule(),!t.alive)throw void 0;return t.state=r,n},function(e){if(void++t.concurrency,void t.sv.schedule(),!t.alive)throw e;throw void t.terminate(e),e});void++this.concurrency;var r=n[0],u=n[1];return this.state=u,r}catch(e){throw void void this.terminate(e)}}if(e instanceof s.Exit)throw void void this.terminate(e.reason);if(e instanceof s.Self)return this;throw new TypeError("Spica: Supervisor: <"+this.sv.id+"/"+this.sv.name+"/"+this.name+">: Invalid command: "+e)},e.prototype.terminate=function(e){void this.destructor(e)},e.prototype.checkState=function(){if(!this.alive)throw new Error("Spica: Supervisor: <"+this.sv.id+"/"+this.sv.name+"/"+this.name+">: A process is already terminated:\n"+this.process)},e}()}),define("src/lib/monad/lazy",["require","exports"],function(e,t){"use strict";var n=function(){function e(e){this.thunk=e}return e.prototype.evaluate=function(){return this.memory_=this.memory_||this.thunk()},e}();t.Lazy=n}),define("src/lib/monad/functor",["require","exports","src/lib/monad/lazy"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t}(n.Lazy);t.Functor=r,function(e){function t(e,t){return t?e.fmap(t):function(t){return e.fmap(t)}}e.fmap=t}(r=t.Functor||(t.Functor={}))}),define("src/lib/curry",["require","exports"],function(e,t){"use strict";function n(e,t,r){return e.length===t.length?e.apply(r,t):function(){for(var i=[],u=0;u<arguments.length;u++)i[u-0]=arguments[u];return n(e,t.concat(i),r)}}t.curry=function(e,t){return 0===e.length?function(){return e.call(t)}:n(e,[],t)}}),define("src/lib/monad/applicative",["require","exports","src/lib/monad/functor","src/lib/curry"],function(e,t,n,r){"use strict";var i=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t}(n.Functor);t.Applicative=i,function(e){function t(e,n){return n?e.bind(function(e){return n.fmap(function(t){return 0===e.length?e(t):r.curry(e)(t)})}):function(n){return t(e,n)}}e.ap=t}(i=t.Applicative||(t.Applicative={}))}),define("src/lib/monad/monad",["require","exports","src/lib/monad/applicative"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t}(n.Applicative);t.Monad=r,function(e){function t(e,n){return n?e.bind(n):function(n){return t(e,n)}}e.bind=t}(r=t.Monad||(t.Monad={}))}),define("src/lib/monad/monadplus",["require","exports","src/lib/monad/monad"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t}(n.Monad);t.MonadPlus=r,function(e){}(r=t.MonadPlus||(t.MonadPlus={}))}),define("src/lib/monad/maybe.impl",["require","exports","src/lib/monad/monadplus"],function(e,t,n){"use strict";function r(){throw new Error("Spica: Maybe: Invalid thunk call.")}var i=function(e){function t(t){var n=e.call(this,t)||this;return void n.MAYBE,n}return __extends(t,e),t.prototype.fmap=function(e){return this.bind(function(t){return new u(e(t))})},t.prototype.ap=function(e){return t.ap(this,e)},t.prototype.bind=function(e){var n=this;return new t(function(){var r=n.evaluate();if(r instanceof u)return e(r.extract());if(r instanceof o)return r;if(r instanceof t)return r.bind(e);throw new TypeError("Spica: Maybe: Invalid monad value.\n\t"+r)})},t.prototype.extract=function(e,t){return t?this.fmap(t).extract(e):this.evaluate().extract(e)},t}(n.MonadPlus);t.Maybe=i,function(e){function t(e){return new u(e)}e.pure=t,e.Return=t}(i=t.Maybe||(t.Maybe={}));var u=function(e){function t(t){var n=e.call(this,r)||this;return n.a=t,void n.JUST,n}return __extends(t,e),t.prototype.bind=function(e){var t=this;return new i(function(){return e(t.extract())})},t.prototype.extract=function(e,t){return t?t(this.a):this.a},t}(i);t.Just=u;var o=function(e){function t(){var t=e.call(this,r)||this;return void t.NOTHING,t}return __extends(t,e),t.prototype.bind=function(e){return this},t.prototype.extract=function(e){if(!e)throw void 0;return e()},t}(i);t.Nothing=o,function(e){function t(t,n){return new e(function(){return t.fmap(function(){return t}).extract(function(){return n})})}e.mzero=new o,e.mplus=t}(i=t.Maybe||(t.Maybe={}))}),define("src/lib/monad/maybe",["require","exports","src/lib/monad/maybe.impl"],function(e,t,n){"use strict";function r(e){return new n.Just(e)}var i;!function(e){e.fmap=n.Maybe.fmap,e.pure=n.Maybe.pure,e.ap=n.Maybe.ap,e.Return=n.Maybe.Return,e.bind=n.Maybe.bind,e.mzero=n.Maybe.mzero,e.mplus=n.Maybe.mplus}(i=t.Maybe||(t.Maybe={})),t.Just=r,t.Nothing=n.Maybe.mzero}),define("src/lib/monad/either.impl",["require","exports","src/lib/monad/monad"],function(e,t,n){"use strict";function r(){throw new Error("Spica: Either: Invalid thunk call.")}var i=function(e){function t(t){var n=e.call(this,t)||this;return void n.EITHER,n}return __extends(t,e),t.prototype.fmap=function(e){return this.bind(function(t){return new o(e(t))})},t.prototype.ap=function(e){return t.ap(this,e)},t.prototype.bind=function(e){var n=this;return new t(function(){var r=n.evaluate();if(r instanceof u)return r;if(r instanceof o)return e(r.extract());if(r instanceof t)return r.bind(e);throw new TypeError("Spica: Either: Invalid monad value.\n\t"+r)})},t.prototype.extract=function(e,t){return t?this.fmap(t).extract(e):this.evaluate().extract(e)},t}(n.Monad);t.Either=i,function(e){function t(e){return new o(e)}e.pure=t,e.Return=t}(i=t.Either||(t.Either={}));var u=function(e){function t(t){var n=e.call(this,r)||this;return n.a=t,void n.LEFT,n}return __extends(t,e),t.prototype.bind=function(e){return this},t.prototype.extract=function(e){if(!e)throw this.a;return e(this.a)},t}(i);t.Left=u;var o=function(e){function t(t){var n=e.call(this,r)||this;return n.b=t,void n.RIGHT,n}return __extends(t,e),t.prototype.bind=function(e){var t=this;return new i(function(){return e(t.extract())})},t.prototype.extract=function(e,t){return t?t(this.b):this.b},t}(i);t.Right=o}),define("src/lib/monad/either",["require","exports","src/lib/monad/either.impl"],function(e,t,n){"use strict";function r(e){return new n.Left(e)}function i(e){return new n.Right(e)}var u;!function(e){e.fmap=n.Either.fmap,e.pure=n.Either.pure,e.ap=n.Either.ap,e.Return=n.Either.Return,e.bind=n.Either.bind}(u=t.Either||(t.Either={})),t.Left=r,t.Right=i}),define("src/lib/cancelable",["require","exports","src/lib/noop","src/lib/monad/maybe","src/lib/monad/either"],function(e,t,n,r,i){"use strict";var u=function(){function e(){var e=this;this.canceled=!1,this.listeners=new Set,this.promise=function(t){return e.canceled?e.promise_=e.promise_||new Promise(function(t,n){return void n(e.reason)}):Promise.resolve(t)},this.maybe=function(t){return e.canceled?r.Nothing:r.Just(t)},this.either=function(t){return e.canceled?i.Left(e.reason):i.Right(t)},this.cancel=function(t){return e.cancel=n.noop,e.canceled=!0,e.reason=t,e.listeners.forEach(function(e){return void e(t)}),e.listeners.clear(),void(e.listeners.add=function(t){return void t(e.reason),e.listeners})}}return e}();t.Cancelable=u}),define("src/lib/monad/sequence/core",["require","exports","src/lib/monad/monadplus"],function(e,t,n){"use strict";function r(){throw new Error("Spica: Sequence: Invalid thunk call.")}var i=function(e){function t(t){var n=e.call(this,r)||this;return n.cons=t,n}return __extends(t,e),t.prototype[Symbol.iterator]=function(){var e=this,n=function(){return e.iterate()};return{next:function(){var e=n();return n=t.Thunk.iterator(e),{done:!t.isIterable(e),value:t.Thunk.value(e)}}}},t}(n.MonadPlus);t.Sequence=i,function(e){}(i=t.Sequence||(t.Sequence={})),function(e){function t(e){return r.iterator(e)!==i.done}var n;!function(t){function n(t,n){switch(arguments.length){case 0:return[];case 1:return[t];case 2:return[t,n];default:throw e.Exception.invalidConsError(arguments)}}t.cons=n}(n=e.Data||(e.Data={}));var r;!function(e){function t(e){return e[0]}function n(e){return e[1]}function r(e){return e[2]}e.value=t,e.iterator=n,e.index=r}(r=e.Thunk||(e.Thunk={}));var i;!function(t){function n(t,i,u){return e.isIterable(t)?u(t,function(){return n(r.iterator(t)(),i,u)}):i(t)}t.done=function(){return[void 0,t.done,-1]},t.when=n}(i=e.Iterator||(e.Iterator={})),e.isIterable=t;var u;!function(e){function t(e){return console.error(e,e.length,e[0],e[1]),new TypeError("Spica: Sequence: Invalid parameters of cons.")}function n(e){return console.error(e),new TypeError("Spica: Sequence: Invalid data.")}function r(e){return console.error(e),new TypeError("Spica: Sequence: Invalid thunk.")}e.invalidConsError=t,e.invalidDataError=n,e.invalidThunkError=r}(u=e.Exception||(e.Exception={}))}(i=t.Sequence||(t.Sequence={}))}),define("src/lib/monad/sequence/member/static/resume",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.resume=function(e){return new n.Sequence(function(t,r){return void 0===t&&(t=e),n.Sequence.Iterator.when(t(),function(){return r()},function(e){return r(n.Sequence.Thunk.value(e),n.Sequence.Thunk.iterator(e))})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/static/from",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.from=function(e){return new n.Sequence(function(t,n){var r=void 0===t?[e[Symbol.iterator](),0]:t,i=r[0],u=r[1],o=i.next();return o.done?n():n(o.value,[i,u+1])}).reduce()},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/static/cycle",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.cycle=function(e){return new n.Sequence(function t(n,r){var i=void 0===n?[e[Symbol.iterator](),0]:n,u=i[0],o=i[1],c=u.next();return c.done?t([e[Symbol.iterator](),o+1],r):r(c.value,[u,o+1])}).reduce()},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/static/random",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.random=function(e){return void 0===e&&(e=function(){return Math.random()}),"function"==typeof e?n.Sequence.from(new n.Sequence(function(t,n){return n(e(),t)})):this.random().map(function(t){return e[t*e.length|0]})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/static/concat",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.concat=function(e){return new n.Sequence(function(t,r){var i=void 0===t?[function(){return e.iterate()},n.Sequence.Iterator.done]:t,u=i[0],o=i[1];return n.Sequence.Iterator.when(u(),function(){return r()},function(e,t){return o=o===n.Sequence.Iterator.done?function(){return n.Sequence.Thunk.value(e).iterate()}:o,n.Sequence.Iterator.when(o(),function(){return o=n.Sequence.Iterator.done,t()},function(t){return r(n.Sequence.Thunk.value(t),[function(){return e},n.Sequence.Thunk.iterator(t)])})})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/static/zip",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.zip=function(e,t){return new n.Sequence(function(r,i){var u=void 0===r?[function(){return e.iterate()},function(){return t.iterate()}]:r,o=u[0],c=u[1];return n.Sequence.Iterator.when(o(),function(){return i()},function(e){return n.Sequence.Iterator.when(c(),function(){return i()},function(t){return i([n.Sequence.Thunk.value(e),n.Sequence.Thunk.value(t)],[n.Sequence.Thunk.iterator(e),n.Sequence.Thunk.iterator(t)])})})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/static/difference",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.difference=function(e,t,r){return new n.Sequence(function(i,u){var o=void 0===i?[function(){return e.iterate()},function(){return t.iterate()}]:i,c=o[0],s=o[1];return n.Sequence.Iterator.when(c(),function(){return n.Sequence.Iterator.when(s(),function(){return u()},function(e){return u(n.Sequence.Thunk.value(e),[n.Sequence.Iterator.done,n.Sequence.Thunk.iterator(e)])})},function(e,t){return n.Sequence.Iterator.when(s(),function(){return u(n.Sequence.Thunk.value(e),[n.Sequence.Thunk.iterator(e),n.Sequence.Iterator.done])},function(i){var o=r(n.Sequence.Thunk.value(e),n.Sequence.Thunk.value(i));return o<0?u(n.Sequence.Thunk.value(e),[n.Sequence.Thunk.iterator(e),function(){return i}]):o>0?u(n.Sequence.Thunk.value(i),[function(){return e},n.Sequence.Thunk.iterator(i)]):(s=function(){return n.Sequence.Thunk.iterator(i)()},t())})})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/static/union",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.union=function(e,t,r){return new n.Sequence(function(i,u){var o=void 0===i?[function(){return e.iterate()},function(){return t.iterate()}]:i,c=o[0],s=o[1];return n.Sequence.Iterator.when(c(),function(){return n.Sequence.Iterator.when(s(),function(){return u()},function(e){return u(n.Sequence.Thunk.value(e),[n.Sequence.Iterator.done,n.Sequence.Thunk.iterator(e)])})},function(e){return n.Sequence.Iterator.when(s(),function(){return u(n.Sequence.Thunk.value(e),[n.Sequence.Thunk.iterator(e),n.Sequence.Iterator.done])},function(t){var i=r(n.Sequence.Thunk.value(e),n.Sequence.Thunk.value(t));return i<0?u(n.Sequence.Thunk.value(e),[n.Sequence.Thunk.iterator(e),function(){return t}]):i>0?u(n.Sequence.Thunk.value(t),[function(){return e},n.Sequence.Thunk.iterator(t)]):u(n.Sequence.Thunk.value(e),[n.Sequence.Thunk.iterator(e),n.Sequence.Thunk.iterator(t)])})})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/static/intersect",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.intersect=function(e,t,r){return new n.Sequence(function(i,u){var o=void 0===i?[function(){return e.iterate()},function(){return t.iterate()}]:i,c=o[0],s=o[1];return n.Sequence.Iterator.when(c(),function(){return u()},function(e,t){return n.Sequence.Iterator.when(s(),function(){return u()},function(i,o){var c=r(n.Sequence.Thunk.value(e),n.Sequence.Thunk.value(i));return c<0?(s=function(){return i},t()):c>0?o():u(n.Sequence.Thunk.value(e),[n.Sequence.Thunk.iterator(e),n.Sequence.Thunk.iterator(i)])})})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/static/pure",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.pure=function(e){return new n.Sequence(function(t,n){return n(e)})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/static/return",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.Return=function(e){return new n.Sequence(function(t,n){return n(e)})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/static/mempty",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r,r.mempty=new n.Sequence(function(e,t){return t()})}),define("src/lib/monad/sequence/member/static/mconcat",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";function r(e,t){return new n.Sequence(function(r,i){var u=void 0===r?[function(){return e.iterate()},function(){return t.iterate()}]:r,o=u[0],c=u[1];return n.Sequence.Iterator.when(o(),function(){return n.Sequence.Iterator.when(c(),function(){return i()},function(e){return i(n.Sequence.Thunk.value(e),[n.Sequence.Iterator.done,n.Sequence.Thunk.iterator(e)])})},function(e){return i(n.Sequence.Thunk.value(e),[n.Sequence.Thunk.iterator(e),c])})})}var i=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.mconcat=function(e){return Array.from(e).reduce(function(e,t){return r(e,t)},n.Sequence.mempty)},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=i}),define("src/lib/monad/sequence/member/static/mappend",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.mappend=function(e,t){return n.Sequence.mconcat([e,t])},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/static/mzero",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r,r.mzero=n.Sequence.mempty}),define("src/lib/monad/sequence/member/static/mplus",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r,r.mplus=n.Sequence.mappend}),define("src/lib/monad/sequence/member/instance/extract",["require","exports","src/lib/monad/sequence/core","src/lib/concat"],function(e,t,n,r){"use strict";var i=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.extract=function(){for(var e=this,t=[],i=function(){return e.iterate()};;){var u=i();if(!n.Sequence.isIterable(u))return t;void r.concat(t,[n.Sequence.Thunk.value(u)]),i=n.Sequence.Thunk.iterator(u)}},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=i}),define("src/lib/monad/sequence/member/instance/iterate",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.iterate=function(){return this.iterate_()},t.prototype.iterate_=function(e,t){var r=this;void 0===t&&(t=0);var i=this.cons(e,n.Sequence.Data.cons);switch(i.length){case 0:return[void 0,n.Sequence.Iterator.done,-1];case 1:return[i[0],function(){return n.Sequence.Iterator.done()},t];case 2:return[i[0],function(){return r.iterate_(i[1],t+1)},t];default:throw n.Sequence.Exception.invalidDataError(i)}},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/instance/memoize",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=new WeakMap,i=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.memoize=function(){var e=this;return new n.Sequence(function(t,i){var u=void 0===t?[0,r.get(e)||r.set(e,new Map).get(e)]:t,o=u[0],c=u[1];return n.Sequence.Iterator.when(c.get(o)||c.set(o,o>0&&c.has(o-1)?n.Sequence.Thunk.iterator(c.get(o-1))():e.iterate()).get(o),function(){return i()},function(e){return i(n.Sequence.Thunk.value(e),[o+1,c])})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=i}),define("src/lib/monad/sequence/member/instance/reduce",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.reduce=function(){var e=this;return new n.Sequence(function(t,r){var i=void 0===t?[0,new Map]:t,u=i[0],o=i[1];return n.Sequence.Iterator.when(o.get(u)||o.set(u,u>0&&o.has(u-1)?n.Sequence.Thunk.iterator(o.get(u-1))():e.iterate()).get(u),function(){return r()},function(e){return r(n.Sequence.Thunk.value(e),[u+1,o])})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/instance/take",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.take=function(e){var t=this;return new n.Sequence(function(r,i){return void 0===r&&(r=function(){return t.iterate()}),n.Sequence.Iterator.when(e>0?r():n.Sequence.Iterator.done(),function(){return i()},function(t){return n.Sequence.Thunk.index(t)+1<e?i(n.Sequence.Thunk.value(t),n.Sequence.Thunk.iterator(t)):i(n.Sequence.Thunk.value(t))})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/instance/drop",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.drop=function(e){var t=this;return new n.Sequence(function(r,i){return void 0===r&&(r=function(){
return t.iterate()}),n.Sequence.Iterator.when(r(),function(){return i()},function(t,r){return n.Sequence.Thunk.index(t)<e?r():i(n.Sequence.Thunk.value(t),n.Sequence.Thunk.iterator(t))})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/instance/takeWhile",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.takeWhile=function(e){var t=this;return new n.Sequence(function(r,i){return void 0===r&&(r=function(){return t.iterate()}),n.Sequence.Iterator.when(r(),function(){return i()},function(t){return e(n.Sequence.Thunk.value(t))?i(n.Sequence.Thunk.value(t),n.Sequence.Thunk.iterator(t)):i()})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/instance/dropWhile",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.dropWhile=function(e){var t=this;return new n.Sequence(function(r,i){return void 0===r&&(r=function(){return t.iterate()}),n.Sequence.Iterator.when(r(),function(){return i()},function(t,r){return e(n.Sequence.Thunk.value(t))?r():i(n.Sequence.Thunk.value(t),n.Sequence.Thunk.iterator(t))})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/instance/takeUntil",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.takeUntil=function(e){var t=this;return new n.Sequence(function(r,i){return void 0===r&&(r=function(){return t.iterate()}),n.Sequence.Iterator.when(r(),function(){return i()},function(t){return e(n.Sequence.Thunk.value(t))?i(n.Sequence.Thunk.value(t)):i(n.Sequence.Thunk.value(t),n.Sequence.Thunk.iterator(t))})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/instance/dropUntil",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.dropUntil=function(e){var t=this;return new n.Sequence(function(r,i){return void 0===r&&(r=function(){return t.iterate()}),n.Sequence.Iterator.when(r(),function(){return i()},function(t,r){return e(n.Sequence.Thunk.value(t))?r():i(n.Sequence.Thunk.value(t),n.Sequence.Thunk.iterator(t))})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/instance/fmap",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.fmap=function(e){var t=this;return new n.Sequence(function(r){return void 0===r&&(r=function(){return t.iterate()}),n.Sequence.Iterator.when(r(),function(){return n.Sequence.Data.cons()},function(t){return n.Sequence.Data.cons(e(n.Sequence.Thunk.value(t)),n.Sequence.Thunk.iterator(t))})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/instance/ap",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.ap=function(e){return n.Sequence.ap(this,e)},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/instance/bind",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.bind=function(e){return n.Sequence.concat(this.fmap(e))},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/instance/mapM",["require","exports","src/lib/monad/sequence/core","src/lib/concat"],function(e,t,n,r){"use strict";var i=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.mapM=function(e){var t=this;return n.Sequence.from([0]).bind(function(){var i=t.extract();switch(i.length){case 0:return n.Sequence.mempty;default:var u=i.shift();return e(u).bind(function(t){return 0===i.length?n.Sequence.from([[t]]):n.Sequence.from(i).mapM(e).fmap(function(e){return r.concat([t],e)})})}})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=i}),define("src/lib/monad/sequence/member/instance/filterM",["require","exports","src/lib/monad/sequence/core","src/lib/concat"],function(e,t,n,r){"use strict";var i=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.filterM=function(e){var t=this;return n.Sequence.from([0]).bind(function(){var i=t.extract();switch(i.length){case 0:return n.Sequence.from([[]]);default:var u=i.shift();return e(u).bind(function(t){return t?0===i.length?n.Sequence.from([[u]]):n.Sequence.from(i).filterM(e).fmap(function(e){return r.concat([u],e)}):0===i.length?n.Sequence.from([[]]):n.Sequence.from(i).filterM(e)})}})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=i}),define("src/lib/monad/sequence/member/instance/map",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.map=function(e){var t=this;return new n.Sequence(function(r){return void 0===r&&(r=function(){return t.iterate()}),n.Sequence.Iterator.when(r(),function(){return n.Sequence.Data.cons()},function(t){return n.Sequence.Data.cons(e(n.Sequence.Thunk.value(t),n.Sequence.Thunk.index(t)),n.Sequence.Thunk.iterator(t))})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/instance/filter",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.filter=function(e){var t=this;return new n.Sequence(function(r,i){return void 0===r&&(r=function(){return t.iterate()}),n.Sequence.Iterator.when(r(),function(){return i()},function(t,r){return e(n.Sequence.Thunk.value(t),n.Sequence.Thunk.index(t))?i(n.Sequence.Thunk.value(t),n.Sequence.Thunk.iterator(t)):r()})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/instance/scan",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.scan=function(e,t){var r=this;return new n.Sequence(function(i){var u=void 0===i?[t,function(){return r.iterate()},0]:i,o=u[0],c=u[1],s=u[2];return n.Sequence.Iterator.when(c(),function(){return 0===s?n.Sequence.Data.cons(t):n.Sequence.Data.cons()},function(t){return n.Sequence.Data.cons(o=e(o,n.Sequence.Thunk.value(t)),[o,n.Sequence.Thunk.iterator(t),n.Sequence.Thunk.index(t)+1])})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/instance/fold",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.fold=function(e,t){var r=this;return new n.Sequence(function(i){return void 0===i&&(i=function(){return r.reduce().iterate()}),n.Sequence.Iterator.when(i(),function(){return n.Sequence.Data.cons(t)},function(r){return n.Sequence.Data.cons(e(n.Sequence.Thunk.value(r),n.Sequence.resume(n.Sequence.Thunk.iterator(r)).fold(e,t)))})}).bind(function(e){return e})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}),define("src/lib/monad/sequence/member/instance/group",["require","exports","src/lib/monad/sequence/core","src/lib/concat"],function(e,t,n,r){"use strict";var i=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.group=function(e){var t=this;return new n.Sequence(function(i,u){var o=void 0===i?[function(){return t.iterate()},[]]:i,c=o[0],s=o[1];return n.Sequence.Iterator.when(c(),function(){return 0===s.length?u():u(s)},function(t,i){return 0===s.length||e(s[0],n.Sequence.Thunk.value(t))?(r.concat(s,[n.Sequence.Thunk.value(t)]),i()):u(s,[n.Sequence.Thunk.iterator(t),r.concat([],[n.Sequence.Thunk.value(t)])])})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=i}),define("src/lib/monad/sequence/member/instance/subsequences",["require","exports","src/lib/monad/sequence/core","src/lib/concat"],function(e,t,n,r){"use strict";function i(e){return n.Sequence.Iterator.when(e.iterate(),function(){return n.Sequence.mempty},function(e){return n.Sequence.mappend(n.Sequence.from([[n.Sequence.Thunk.value(e)]]),new n.Sequence(function(t,u){return n.Sequence.Iterator.when(e,function(){return u()},function(e){return u(i(n.Sequence.resume(n.Sequence.Thunk.iterator(e))).fold(function(t,i){return n.Sequence.mappend(n.Sequence.mappend(n.Sequence.from([t]),n.Sequence.from([r.concat([n.Sequence.Thunk.value(e)],t)])),i)},n.Sequence.mempty))})}).bind(function(e){return e}))})}var u=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.subsequences=function(){var e=this;return n.Sequence.mappend(n.Sequence.from([[]]),n.Sequence.from([0]).bind(function(){return i(e)}))},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=u}),define("src/lib/monad/sequence/member/instance/permutations",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";function r(e,t){return n.Sequence.Iterator.when(e.iterate(),function(){return n.Sequence.mempty},function(e){return new n.Sequence(function(i,u){return n.Sequence.Iterator.when(e,function(){return u()},function(e){function i(e,t){return o(function(e){return e},e,t)[1]}function o(e,t,r){return n.Sequence.Iterator.when(t.iterate(),function(){return[s,r]},function(t){var i=n.Sequence.Thunk.value(t),u=o(function(t){return e(n.Sequence.mappend(n.Sequence.from([i]),t))},n.Sequence.resume(n.Sequence.Thunk.iterator(t)),r),s=u[0],a=u[1];return[n.Sequence.mappend(n.Sequence.from([i]),s),n.Sequence.mappend(n.Sequence.from([e(n.Sequence.mappend(n.Sequence.from([c]),n.Sequence.mappend(n.Sequence.from([i]),s))).extract()]),a)]})}var c=n.Sequence.Thunk.value(e),s=n.Sequence.resume(n.Sequence.Thunk.iterator(e)).memoize();return u(t.permutations().fold(function(e,t){return i(n.Sequence.from(e),t)},r(s,n.Sequence.mappend(n.Sequence.from([c]),t))))})}).bind(function(e){return e})})}var i=function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.permutations=function(){var e=this;return n.Sequence.from([0]).bind(function(){var t=e.extract();return 0===t.length?n.Sequence.mempty:n.Sequence.from([t])}).bind(function(e){return n.Sequence.mappend(n.Sequence.from([e]),r(n.Sequence.from(e),n.Sequence.mempty))})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t.default=i}),define("src/lib/type",["require","exports"],function(e,t){"use strict";function n(e){return Object.prototype.toString.call(e).split(" ").pop().slice(0,-1)}t.type=n}),define("src/lib/assign",["require","exports","src/lib/type"],function(e,t,n){"use strict";function r(e){return function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];if(void 0===t||null===t)throw new TypeError("Spica: assign: Cannot walk on "+t+".");for(var i=0,u=n;i<u.length;i++){var o=u[i];if(void 0!==o&&null!==o)for(var c=0,s=Object.keys(Object(o));c<s.length;c++){var a=s[c],f=Object.getOwnPropertyDescriptor(Object(o),a);void 0!==f&&f.enumerable&&void e(a,Object(t),Object(o))}}return Object(t)}}t.assign=r(function(e,t,n){return t[e]=n[e]}),t.clone=r(function(e,r,i){switch(n.type(i[e])){case"Array":return r[e]=t.clone([],i[e]);case"Object":return r[e]=t.clone({},i[e]);default:return r[e]=i[e]}}),t.extend=r(function(e,r,i){switch(n.type(i[e])){case"Array":return r[e]=t.extend([],i[e]);case"Object":switch(n.type(r[e])){case"Function":case"Object":return r[e]=t.extend(r[e],i[e]);default:return r[e]=t.extend({},i[e])}default:return r[e]=i[e]}})}),define("src/lib/compose",["require","exports","src/lib/assign"],function(e,t,n){"use strict";function r(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return t.reduce(function(e,t){void n.assign(e.prototype,t.prototype);for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e},e)}t.compose=r}),define("src/lib/monad/sequence",["require","exports","src/lib/monad/sequence/core","src/lib/monad/sequence/member/static/resume","src/lib/monad/sequence/member/static/from","src/lib/monad/sequence/member/static/cycle","src/lib/monad/sequence/member/static/random","src/lib/monad/sequence/member/static/concat","src/lib/monad/sequence/member/static/zip","src/lib/monad/sequence/member/static/difference","src/lib/monad/sequence/member/static/union","src/lib/monad/sequence/member/static/intersect","src/lib/monad/sequence/member/static/pure","src/lib/monad/sequence/member/static/return","src/lib/monad/sequence/member/static/mempty","src/lib/monad/sequence/member/static/mconcat","src/lib/monad/sequence/member/static/mappend","src/lib/monad/sequence/member/static/mzero","src/lib/monad/sequence/member/static/mplus","src/lib/monad/sequence/member/instance/extract","src/lib/monad/sequence/member/instance/iterate","src/lib/monad/sequence/member/instance/memoize","src/lib/monad/sequence/member/instance/reduce","src/lib/monad/sequence/member/instance/take","src/lib/monad/sequence/member/instance/drop","src/lib/monad/sequence/member/instance/takeWhile","src/lib/monad/sequence/member/instance/dropWhile","src/lib/monad/sequence/member/instance/takeUntil","src/lib/monad/sequence/member/instance/dropUntil","src/lib/monad/sequence/member/instance/fmap","src/lib/monad/sequence/member/instance/ap","src/lib/monad/sequence/member/instance/bind","src/lib/monad/sequence/member/instance/mapM","src/lib/monad/sequence/member/instance/filterM","src/lib/monad/sequence/member/instance/map","src/lib/monad/sequence/member/instance/filter","src/lib/monad/sequence/member/instance/scan","src/lib/monad/sequence/member/instance/fold","src/lib/monad/sequence/member/instance/group","src/lib/monad/sequence/member/instance/subsequences","src/lib/monad/sequence/member/instance/permutations","src/lib/compose"],function(e,t,n,r,i,u,o,c,s,a,f,d,l,p,h,v,m,q,b,y,S,x,_,w,k,g,T,M,O,I,j,E,P,N,R,A,D,z,C,L,F,W){"use strict";t.Sequence=n.Sequence,void W.compose(n.Sequence,r.default,i.default,u.default,o.default,c.default,s.default,a.default,f.default,d.default,l.default,p.default,h.default,v.default,m.default,q.default,b.default,y.default,S.default,x.default,_.default,w.default,k.default,g.default,T.default,M.default,O.default,I.default,j.default,E.default,P.default,N.default,R.default,A.default,D.default,z.default,C.default,L.default,F.default)}),define("src/lib/flip",["require","exports","src/lib/curry"],function(e,t,n){"use strict";function r(e){return n.curry(function(t,n){return e.length>1?e(n,t):e(n)(t)})}t.flip=r}),define("src/lib/list",["require","exports","src/lib/concat"],function(e,t,n){"use strict";var r=function(){function e(){void this.NIL}return e.prototype.push=function(e){return new i(e,this)},e.prototype.array=function(){return[]},e}();t.Nil=r;var i=function(){function e(e,t){this.head_=e,this.tail_=t,void this.CONS}return e.prototype.push=function(t){return new e(t,this)},e.prototype.head=function(){return this.head_},e.prototype.tail=function(){return this.tail_},e.prototype.walk=function(e){return void e(this.head()),this.tail()},e.prototype.modify=function(e){return this.tail().push(e(this.head()))},e.prototype.extend=function(e){return this.push(e(this.head()))},e.prototype.compact=function(e){var t=this;return this.tail().modify(function(n){return e(t.head(),n)})},e.prototype.reverse=function(){return this.array().reduce(function(e,t){return e.push(t)},new r)},e.prototype.tuple=function(){return this.array()},e.prototype.array=function(){return n.concat([this.head()],this.tail().array())},e}()}),define("src/lib/hlist",["require","exports","src/lib/concat"],function(e,t,n){"use strict";var r=function(){function e(){void this.NIL}return e.prototype.push=function(e){return new i(e,this)},e.prototype.array=function(){return[]},e}();t.HNil=r;var i=function(){function e(e,t){this.head_=e,this.tail_=t,void this.CONS}return e.prototype.push=function(t){return new e(t,this)},e.prototype.head=function(){return this.head_},e.prototype.tail=function(){return this.tail_},e.prototype.walk=function(e){return void e(this.head()),this.tail()},e.prototype.modify=function(e){return this.tail().push(e(this.head()))},e.prototype.extend=function(e){return this.push(e(this.head()))},e.prototype.compact=function(e){var t=this;return this.tail().modify(function(n){return e(t.head(),n)})},e.prototype.reverse=function(){return this.array().reduce(function(e,t){return e.push(t)},new r)},e.prototype.tuple=function(){return this.array()},e.prototype.array=function(){return n.concat([this.head()],this.tail().array())},e}()}),define("src/lib/collection/datamap",["require","exports","src/lib/sqid","src/lib/type"],function(e,t,n,r){"use strict";function i(e){return e instanceof Object==!1}var u=function(){function e(e){void 0===e&&(e=[]);var t=this;this.store=new Map,this.weakstore=new WeakMap,void Array.from(e).forEach(function(e){var n=e[0],r=e[1];return void t.set(n,r)})}return e.prototype.stringify=function(e){switch(typeof e){case"undefined":return"0:"+e;case"boolean":return"1:"+e;case"number":return"2:"+(1e3+(""+e).length)+":"+e;case"string":return"3:"+(1e14+e.length)+":"+e;default:return i(e)?"8:"+e:Array.isArray(e)?"9:[ "+this.stringifyArray(e)+" ]":"9:{ "+(this.stringifyObject(e)||this.weakstore.get(e)||this.weakstore.set(e,n.sqid()).get(e))+" }"}},e.prototype.stringifyArray=function(e){for(var t="",n=0,r=e;n<r.length;n++){var i=r[n];t+=""+this.stringify(i)}return t},e.prototype.stringifyObject=function(e){if("Object"!==r.type(e))return"";for(var t=Object.keys(e),n="",i=0,u=t;i<u.length;i++){var o=u[i];n+=this.stringify(o)+": "+this.stringify(e[o])}return n||" "},e.prototype.get=function(e){return(this.store.get(this.stringify(e))||[])[1]},e.prototype.set=function(e,t){return void this.store.set(this.stringify(e),[e,t]),this},e.prototype.has=function(e){return this.store.has(this.stringify(e))},e.prototype.delete=function(e){return this.store.delete(this.stringify(e))},e.prototype.clear=function(){return this.store.clear()},Object.defineProperty(e.prototype,"size",{get:function(){return this.store.size},enumerable:!0,configurable:!0}),e}();t.DataMap=u}),define("src/lib/collection/cachemap",["require","exports"],function(e,t){"use strict";var n=Date.now();void function e(){n=Date.now(),void setTimeout(e,100)}();var r=function(){function e(e){void 0===e&&(e=[]);var t=this;this.store=new Map,void Array.from(e).forEach(function(e){var n=e[0],r=e[1];return void t.set(n,r)})}return e.prototype.clean=function(e){this.store.has(e)&&this.store.get(e)[0]<n&&void this.store.delete(e)},e.prototype.get=function(e){return void this.clean(e),(this.store.get(e)||[0,void 0])[1]},e.prototype.set=function(e,t,r){return void 0===r&&(r=1/0),void this.clean(e),void this.store.set(e,[n+r,t]),this},e.prototype.has=function(e){return void this.clean(e),this.store.has(e)},e.prototype.delete=function(e){return void this.clean(e),this.store.delete(e)},e.prototype.clear=function(){return this.store.clear()},Object.defineProperty(e.prototype,"size",{get:function(){return this.store.size},enumerable:!0,configurable:!0}),e}();t.CacheMap=r}),define("src/lib/collection/attrmap",["require","exports"],function(e,t){"use strict";var n=function(){function e(e,t,n){void 0===e&&(e=[]),void 0===t&&(t=WeakMap),void 0===n&&(n=Map);var r=this;this.KeyMap=t,this.ValueMap=n,this.store=new this.KeyMap,void Array.from(e).forEach(function(e){var t=e[0],n=e[1],i=e[2];return void r.set(t,n,i)})}return e.prototype.get=function(e,t){return this.store.get(e)&&this.store.get(e).get(t)},e.prototype.set=function(e,t,n){var r=this.store.has(e)?this.store.get(e):this.store.set(e,new this.ValueMap).get(e);return void r.set(t,n),this},e.prototype.has=function(e,t){return 1===arguments.length?this.store.has(e):this.store.has(e)&&this.store.get(e).has(t)},e.prototype.delete=function(e,t){return 1===arguments.length?this.store.delete(e):!!this.store.has(e)&&this.store.get(e).delete(t)},e}();t.AttrMap=n}),define("src/lib/mixin",["require","exports","src/lib/assign"],function(e,t,n){"use strict";function r(){for(var e=[],t=0;t<arguments.length;t++)e[t-0]=arguments[t];return e.reduceRight(function(e,t){return i(t,e)},function(){function e(){}return e}())}function i(e,t){var r=function(){function n(){return e.call(t.call(this)||this)}return n}();void n.assign(r.prototype,e.prototype,t.prototype);for(var i in t)t.hasOwnProperty(i)&&(r[i]=t[i]);for(var i in e)e.hasOwnProperty(i)&&(r[i]=e[i]);return r}t.Mixin=r}),define("src/lib/fingerprint",["require","exports"],function(e,t){"use strict";function n(){return i(u([o(window.navigator),o(window.screen),o((new Date).getTimezoneOffset())].join()))}function r(){return i(u([o(process)].join()))}function i(e){return e.split("").reduce(function(e,t,n){return(+t*n+e)%1e9||e-+t},0)}function u(e){return e.split("").map(function(e){return e.charCodeAt(0)}).join("")}function o(e,t){if(void 0===t&&(t=5),t>0&&e&&"object"==typeof e){var n="{";for(var r in e)n+='"'+r+'": '+o(e[r],t-1)+",";return n+="}"}return!e||e.toString?'"'+e+'"':'"'+Object.prototype.toString.call(e)+'"'}t.FINGERPRINT="object"==typeof window?n():r(),t.browser=n,t.server=r,t.hash=i,t.str2digit=u,t.stringify=o}),define("src/lib/uuid",["require","exports","src/lib/fingerprint"],function(e,t,n){"use strict";function r(){var e=o=o*Date.now()%1e15;if(e<16||1e15<e)throw new Error("Spica: uuid: Invalid uuid dynamic seed.");for(var t="",n=0,r=u;n<r.length;n++){var i=r[n];if("x"===i||"y"===i){var c=Math.random()*e%16|0,s="x"==i?c:3&c|8;t+=s.toString(16)}else t+=i}return t.toLowerCase()}var i=n.FINGERPRINT*Date.now()%1e15;if(!i||"number"!=typeof i||i<100||1e15<i)throw new Error("Spica: uuid: Invalid uuid static seed.\n\t"+n.FINGERPRINT);var u=Object.freeze("xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".split("")),o=i;t.v4=r}),define("src/lib/sort",["require","exports"],function(e,t){"use strict";function n(e,t,n,r){if(void 0===r&&(r=!1),!r&&n*n>1.25*e.length)return e.sort(t);n=n<e.length-1?n:e.length-1;for(var i=0;i<n;++i)for(var u=i+1;u<e.length;++u)if(t(e[i],e[u])>0!=!1){var o=e[i];e[i]=e[u],e[u]=o}return e}t.sort=n}),define("src/export",["require","exports","src/lib/supervisor","src/lib/observable","src/lib/cancelable","src/lib/monad/sequence","src/lib/monad/maybe","src/lib/monad/either","src/lib/curry","src/lib/flip","src/lib/list","src/lib/hlist","src/lib/collection/datamap","src/lib/collection/cachemap","src/lib/collection/attrmap","src/lib/mixin","src/lib/tick","src/lib/fingerprint","src/lib/uuid","src/lib/sqid","src/lib/assign","src/lib/concat","src/lib/sort"],function(e,t,n,r,i,u,o,c,s,a,f,d,l,p,h,v,m,q,b,y,S,x,_){"use strict";t.Supervisor=n.Supervisor,t.Observable=r.Observable,t.Cancelable=i.Cancelable,t.Sequence=u.Sequence,t.Maybe=o.Maybe,t.Just=o.Just,t.Nothing=o.Nothing,t.Either=c.Either,t.Left=c.Left,t.Right=c.Right,t.curry=s.curry,t.flip=a.flip,t.Nil=f.Nil,t.HNil=d.HNil,t.DataMap=l.DataMap,t.CacheMap=p.CacheMap,t.AttrMap=h.AttrMap,t.Mixin=v.Mixin,t.Tick=m.Tick,t.FINGERPRINT=q.FINGERPRINT,t.uuid=b.v4,t.sqid=y.sqid,t.assign=S.assign,t.clone=S.clone,t.extend=S.extend,t.concat=x.concat,t.sort=_.sort}),define("spica",["require","exports","src/export","./src/import"],function(e,t,n){"use strict";function r(e){for(var n in e)t.hasOwnProperty(n)||(t[n]=e[n])}r(n)});
{
"name": "spica",
"version": "0.0.33",
"version": "0.0.34",
"description": "Supervisor, Observable, Sequence, Maybe, Either and some utils.",

@@ -58,8 +58,8 @@ "private": false,

"karma-mocha": "^1.2.0",
"lodash": "^4.16.2",
"lodash": "^4.16.3",
"mocha": "^3.1.0",
"npm-check-updates": "^2.8.1",
"npm-check-updates": "^2.8.2",
"power-assert": "^1.4.1",
"run-sequence": "^1.2.2",
"typescript": "2.1.0-dev.20161003"
"typescript": "2.1.0-dev.20161004"
},

@@ -66,0 +66,0 @@ "scripts": {

@@ -21,3 +21,3 @@ /**

register(name: N, process: Supervisor.Process<P, R, S> | Supervisor.Process.Call<P, R, S>, state: S): (reason?: any) => void;
call(name: N, param: P, callback: (reply: R, error?: Error) => void, timeout?: number): void;
call(name: N, param: P, callback: Supervisor.Callback<R>, timeout?: number): void;
cast(name: N, param: P, timeout?: number): boolean;

@@ -33,7 +33,7 @@ refs(name?: N): [N, Supervisor.Process<P, R, S>, S, (reason: any) => void][];

}
export interface Process<P, R, S> {
export type Process<P, R, S> = {
readonly init: Process.Init<S>;
readonly call: Process.Call<P, R, S>;
readonly exit: Process.Exit<S>;
}
};
export namespace Process {

@@ -44,2 +44,5 @@ export type Init<S> = (state: S) => S;

}
export type Callback<R> = {
(reply: R, error?: Error): void;
};
export namespace Event {

@@ -46,0 +49,0 @@ export namespace Data {

import {WeakMapLike} from 'spica';
let time = Date.now();
void setInterval(() => time = Date.now(), 100);
void (function loop() {
time = Date.now();
void setTimeout(loop, 100);
})();

@@ -6,0 +9,0 @@ export class CacheMap<K, V> implements WeakMapLike<K, V> {

@@ -106,7 +106,7 @@ import {Supervisor} from './supervisor';

assert(reason === void 0);
assert(cnt === 12 && ++cnt);
assert(cnt === 14 && ++cnt);
assert(TestSupervisor.count === 1);
assert(TestSupervisor.procs === 0);
Tick(() => {
assert(cnt === 13 && ++cnt);
assert(cnt === 15 && ++cnt);
assert(TestSupervisor.count === 0);

@@ -141,5 +141,4 @@ assert(TestSupervisor.procs === 0);

case 4: {
assert(cnt === 11 && ++cnt);
assert(cnt === 12 && ++cnt);
assert(param === 4);
sv.terminate();
return;

@@ -186,4 +185,4 @@ }

assert(sv.cast('', 2) === true);
sv.call('', 3, done);
sv.call('', 4, done);
sv.call('', 3, (r, e) => assert(r === void 0) || assert(e instanceof Error) || assert(cnt === 11 && ++cnt));
sv.call('', 4, (r, e) => assert(r === void 0) || assert(e instanceof Error) || assert(cnt === 13 && ++cnt) || sv.terminate());
assert(cnt === 5 && ++cnt);

@@ -249,5 +248,5 @@ });

sv.events.loss.on([''], ([, param]) => assert(cnt === 1 && param === 2 && ++cnt));
sv.call('', 1, r => assert(r === 1) || assert(cnt === 2 && ++cnt));
sv.call('', 2, done);
sv.call('', 3, r => assert(r === 3) || assert(cnt === 3 && ++cnt) || sv.terminate() || done(), Infinity);
sv.call('', 1, r => assert(r === 1) || assert(cnt === 3 && ++cnt));
sv.call('', 2, (r, e) => assert(r === void 0) || assert(e instanceof Error) || assert(cnt === 2 && ++cnt));
sv.call('', 3, r => assert(r === 3) || assert(cnt === 4 && ++cnt) || sv.terminate() || done(), Infinity);
});

@@ -254,0 +253,0 @@

@@ -78,3 +78,3 @@ import {Supervisor as ISupervisor} from 'spica';

}
public call(name: N, param: P, callback: (reply: R, error?: Error) => void, timeout = this.timeout): void {
public call(name: N, param: P, callback: Supervisor.Callback<R>, timeout = this.timeout): void {
void this.checkState();

@@ -133,3 +133,3 @@ void this.queue.push([

}
private readonly queue: [N, P, (reply: R, error?: Error) => void, number, number][] = [];
private readonly queue: [N, P, Supervisor.Callback<R>, number, number][] = [];
private drain(target?: N): void {

@@ -151,4 +151,10 @@ const now = Date.now();

void this.events.loss.emit([name], [name, param]);
try {
void callback(<any>void 0, new Error(`Spica: Supervisor: Task: Failed.`));
}
catch (reason) {
void console.error(reason);
}
}
if (this.alive && replies.length > 0) {
else {
const [reply] = replies;

@@ -161,5 +167,8 @@ if (isThenable(reply)) {

? void callback(reply)
: void callback(<any>void 0, new Error(`Spica: Supervisor: <${this.id}/${this.name}/${name}>: A request is expired.`)),
: void callback(<any>void 0, new Error(`Spica: Supervisor: Task: Failed.`)),
() =>
void callback(<any>void 0, new Error(`Spica: Supervisor: Task: Failed.`)))
.catch(
reason =>
void callback(<any>void 0, reason));
void console.error(reason));
}

@@ -175,5 +184,2 @@ else {

}
else {
void callback(<any>void 0, new Error(`Spica: Supervisor: <${this.id}/${this.name}/${name}>: A request is expired.`));
}
}

@@ -190,2 +196,3 @@ }

}
export type Callback<R> = ISupervisor.Callback<R>;
export import Event = ISupervisor.Event;

@@ -281,3 +288,3 @@ }

if (cmd.timeout < Infinity === false) return;
void setTimeout(() => void reject(new Error(`Spica: Supervisor: <${this.sv.id}/${this.sv.name}/${this.name}>: Timeout while processing.`)), cmd.timeout);
void setTimeout(() => void reject(new Error(`Spica: Supervisor: Task: Timeout while processing.`)), cmd.timeout);
})

@@ -284,0 +291,0 @@ .then(

@@ -30,2 +30,6 @@ import {Tick} from './tick';

it('recursion', function (done) {
Tick(() => Tick(done));
});
/*

@@ -32,0 +36,0 @@ it.skip('recovery', function (done) {

@@ -11,2 +11,3 @@ const Queue: ((...args: any[]) => any)[] = [];

function dequeue(): void {
scheduled = false;
let rem = Queue.length;

@@ -26,3 +27,2 @@ while (true) {

}
scheduled = false;
}

@@ -29,0 +29,0 @@

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc