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.7 to 0.0.8

src/lib/monad/sequence/member/instance/dropUntil.test.ts

6

dist/spica.min.js

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

/*! spica v0.0.7 https://github.com/falsandtru/spica | (c) 2016, falsandtru | undefined License (undefined) */
define="function"==typeof define&&define.amd?define:function(){"use strict";var e="spica",t={};return function n(r,i,o){return o?void o.apply(this,i.map(function(e){switch(e){case"require":return"function"==typeof require?require:void 0;case"exports":return-1===r.indexOf("/")?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;r>n;++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 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 o=i[2],u=i[3];if(!o)try{var c=u(t);n&&(r[r.length]=c)}catch(s){void 0!==s&&null!==s&&void console.error(s+"")}},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(o){void 0!==o&&null!==o&&void console.error(o)}},void 0),n)try{void n(t,r)}catch(i){void console.error(i)}},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 o=0;o<t.length;++o){var u=t[o],c=this.refsBelow_(r[u]);i=n.concat(i,c),0===c.length&&(void delete r[u],void t.splice(t.indexOf(u),1),void--o)}return i},e.prototype.seekNode_=function(e){for(var t=this.node_,n=0,r=e;n<r.length;n++){var i=r[n],o=t.childrenMap;o[i+""]||(void t.childrenList.push(i+""),t.childrenList=t.childrenList.sort(),o[i+""]={parent:t,childrenMap:Object.create(null),childrenList:[],registers:[]}),t=o[i+""]}return t},e.prototype.throwTypeErrorIfInvalidSubscriber_=function(e,t){switch(typeof e){case"function":return;default:throw new TypeError("Spica: Observable: Invalid subscriber.\n "+e)}},e}();t.Observable=r}),define("src/lib/sqid",["require","exports"],function(e,t){"use strict";function n(e){return void 0===e?(1e15+ ++r+"").slice(1):(1e15+e+"").slice(1)}var r=0;t.sqid=n}),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/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 o=function(){function e(){this.store=new Map,this.weakstore=new WeakMap}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:e instanceof Array?"9:[ "+this.stringifyArray(e)+" ]":"9:{ "+(this.weakstore.has(e)?this.weakstore.get(e):this.stringifyObject(e)||this.weakstore.set(e,n.sqid()))+" }"}},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,o=t;i<o.length;i++){var u=o[i];n+=this.stringify(u)+": "+this.stringify(e[u])}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=o}),define("src/lib/tick",["require","exports"],function(e,t){"use strict";var n;!function(e){function t(e){void i.push(e),void r()}function n(){void r(),void--o;for(var e=i.length;e-- >0;)void i.shift()()}function r(){if(0!==i.length)for(;o<u.length;)void setTimeout(n,u[o%u.length]),void++o}e.queue=t;var i=[],o=0,u=[0,4,10,20,25].reverse()}(n||(n={}));var r=Function("return typeof process === 'object' && typeof window !== 'object'")();t.Tick=r?Function("return fn => process.nextTick(fn)")():n.queue}),define("src/lib/thenable",["require","exports"],function(e,t){"use strict";function n(e){return!!e&&"object"==typeof e&&void 0!==e.then}t.isThenable=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/collection/datamap","src/lib/tick","src/lib/thenable","src/lib/concat","src/lib/noop"],function(e,t,n,r,i,o,u,c){"use strict";function s(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(var n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}var a=function(){function e(t){var i=this,o=void 0===t?{}:t,u=o.name,s=void 0===u?"":u,a=o.dependencies,f=void 0===a?[]:a,d=o.retry,l=void 0===d?!1:d,h=o.timeout,p=void 0===h?0:h,v=o.destructor,b=void 0===v?c.noop:v;if(this.deps=new r.DataMap,this.events={exec:new n.Observable,fail: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,dependenciesStack:[]},this.queue=[],this.constructor===e)throw new Error("Spica: Supervisor: Cannot instantiate abstract classes.");this.name=s,void f.reduce(function(e,t){var n=t[0],r=t[1];return void i.deps.set(n,r)},void 0),this.retry=l,this.timeout=p,this.destructor_=b,void++this.constructor.count}return e.prototype.destructor=function(e){for(void this.checkState(),this.alive=!1;this.queue.length>0;){var t=this.queue.shift(),n=t[0],r=t[1];void this.events.loss.emit(n,[n,void 0,r])}try{void this.destructor_(e)}catch(i){void console.error(i)}void--this.constructor.count,void Object.freeze(this)},e.prototype.schedule=function(){var e=this;this.alive&&(this.scheduled||(void i.Tick(function(t){e.alive&&(e.scheduled=!1,void e.drain())}),this.scheduled=!0))},e.prototype.register=function(e,t){if(void this.checkState(),!this.registerable)throw new Error("Spica: Supervisor: Supervisor "+this.name+" cannot register process during the exiting.");return e=u.concat([],e),void this.schedule(),new d(this,this.workerSharedResource,e,t,this.deps.get(e)||[]).terminate},e.prototype.call=function(e,t,n,r){var i=this;void 0===n&&(n=this.timeout),void 0===r&&(r=c.noop),void this.checkState(),e=u.concat([],e),void this.queue.push([e,t,function(e,t){return void r(t,e)},n,Date.now()]),void this.schedule(),n>0!=!1&&void setTimeout(function(){return i.drain(e)},n)},e.prototype.cast=function(e,t,n){void 0===n&&(n=this.retry),void this.checkState();var r=this.procs.reflect(e,new f.Call(t));return 0===r.length&&void this.events.fail.emit(e,[e,void 0,t]),r.length>0||!n?r:this.cast(e,t,!1)},e.prototype.refs=function(e){return void this.checkState(),this.procs.refs(e).map(function(e){var t=(e[0],e[1]),n=t(void 0);return[n.namespace,n.process,n.terminate]})},e.prototype.terminate=function(e,t){void this.checkState(),void 0===e&&(this.registerable=!1),void this.procs.emit(e||[],new f.Exit(t)),void this.procs.off(e||[]),void 0===e&&void this.destructor(t)},e.prototype.checkState=function(){if(!this.alive)throw new Error("Spica: Supervisor: Supervisor "+this.name+" already exited.")},e.prototype.drain=function(e){void 0===e&&(e=[]);for(var t,n=Date.now(),r=function(r){var o=i.queue[r],u=o[0],c=o[1],s=o[2],a=o[3],d=o[4],l=e.every(function(e,t){return e===u[t]})?i.procs.reflect(u,new f.Call(c)):[];if(0===l.length&&void i.events.fail.emit(u,[u,void 0,c]),0===l.length&&d+a>n)return t=r,"continue";if(0===r?void i.queue.shift():void i.queue.splice(r,1),void--r,0===l.length&&void i.events.loss.emit(u,[u,void 0,c]),!s)return t=r,"continue";try{void s(c,l)}catch(h){void console.error(h)}t=r},i=this,o=0;o<this.queue.length;++o){r(o);o=t}},e.count=0,e.procs=0,e}();t.Supervisor=a;var f;!function(e){var t=function(){function e(){}return e}(),n=function(e){function t(t){e.call(this),this.namespace=t}return __extends(t,e),t}(t);e.Deps=n;var r=function(e){function t(t){e.call(this),this.data=t}return __extends(t,e),t}(t);e.Call=r;var i=function(e){function t(t){e.call(this),this.reason=t}return __extends(t,e),t}(t);e.Exit=i}(f||(f={}));var d=function(){function e(t,n,r,i,o){var u=this;this.sv=t,this.sharedResource=n,this.namespace=r,this.process=i,this.dependencies=o,this.alive=!0,this.called=!1,this.concurrency=1,this.receive=function(t){return e.prototype.receive.call(u,t)},this.terminate=function(t){return e.prototype.terminate.call(u,t)},this.sharedResource.allRefsCache=void 0,void++this.sv.constructor.procs,void this.sharedResource.procs.on(r,this.receive)}return e.prototype.destructor=function(e){void this.checkState(),void this.sharedResource.procs.off(this.namespace,this.receive),this.alive=!1,void--this.sv.constructor.procs,this.sharedResource.allRefsCache=void 0,void Object.freeze(this),void this.sv.events.exit.emit(this.namespace,[this.namespace,this.process,e])},e.prototype.tryDependencyResolving=function(e){if(this.receive(new f.Deps(this.namespace)))return void(this.sharedResource.dependenciesStack=[]);throw void(this.sharedResource.dependenciesStack=[])},e.prototype.receive=function(e){var t=this;if(void this.checkState(),void 0===e)return this;if(e instanceof f.Deps){if(e.namespace.length!==this.namespace.length)return!1;if(0===this.concurrency)return!1;for(var n=0,r=this.sharedResource.dependenciesStack;n<r.length;n++){var i=r[n];if(s(this.namespace,i))return!0}return void this.sharedResource.dependenciesStack.push(this.namespace),this.dependencies.every(function(e){return(t.sharedResource.allRefsCache=t.sharedResource.allRefsCache||t.sharedResource.procs.refs([])).some(function(t){var n=t[0],r=t[1];return s(n,e)&&!!r(new f.Deps(e))})})}if(e instanceof f.Call){if(0===this.concurrency)throw void 0;void this.tryDependencyResolving(e),this.called||(this.called=!0,void this.sv.events.exec.emit(this.namespace,[this.namespace,this.process]));try{void--this.concurrency;var u=(0,this.process)(e.data);return o.isThenable(u)?void u.then(function(e){void t.sv.schedule(),t.alive&&void++t.concurrency},function(e){void t.sv.schedule(),t.alive&&(void++t.concurrency,void t.terminate(e))}):void++this.concurrency,u}catch(c){throw void void this.terminate(c)}}if(e instanceof f.Exit)throw void void this.terminate(e.reason);throw new TypeError("Spica: Supervisor: Invalid command: "+e)},e.prototype.terminate=function(e){void this.destructor(e)},e.prototype.checkState=function(){if(!this.alive)throw new Error("Spica: Supervisor: Process "+this.namespace+"/"+this.process+" already exited.")},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(){e.apply(this,arguments)}return __extends(t,e),t}(n.Lazy);t.Functor=r}),define("src/lib/monad/monad",["require","exports","src/lib/monad/functor"],function(e,t,n){"use strict";var r=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t}(n.Functor);t.Monad=r}),define("src/lib/monad/maybe.impl",["require","exports","src/lib/monad/monad"],function(e,t,n){"use strict";var r=function(e){function t(t){e.call(this,t),this.thunk=t}return __extends(t,e),t.prototype.bind=function(e){var n=this;return new t(function(){var r=n.evaluate();if(r instanceof i)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 "+r)})},t.prototype.fmap=function(e){return this.bind(function(t){return new i(e(t))})},t.prototype.extract=function(e){return this.evaluate().extract(e)},t}(n.Monad);t.Maybe=r;var i=function(e){function t(t){e.call(this),this.val_=t}return __extends(t,e),t.prototype.bind=function(e){var t=this;return new r(function(){return t}).bind(e)},t.prototype.extract=function(e){return this.val_},t}(r);t.Just=i;var o=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.prototype.bind=function(e){return this},t.prototype.fmap=function(e){return this},t.prototype.extract=function(e){if(!e)throw void 0;return e()},t}(r);t.Nothing=o}),define("src/lib/monad/maybe",["require","exports","src/lib/monad/maybe.impl"],function(e,t,n){"use strict";var r;!function(e){function t(e){return new n.Just(e)}e.Just=t,e.Nothing=new n.Nothing,e.Return=t}(r=t.Maybe||(t.Maybe={})),t.Just=r.Just,t.Nothing=r.Nothing,t.Return=t.Just}),define("src/lib/monad/either.impl",["require","exports","src/lib/monad/monad"],function(e,t,n){"use strict";var r=function(e){function t(t){e.call(this,t),this.thunk=t}return __extends(t,e),t.prototype.bind=function(e){var n=this;return new t(function(){var r=n.evaluate();if(r instanceof i)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 "+r)})},t.prototype.fmap=function(e){return this.bind(function(t){return new o(e(t))})},t.prototype.extract=function(e){return this.evaluate().extract(e)},t}(n.Monad);t.Either=r;var i=function(e){function t(t){e.call(this),this.val_=t}return __extends(t,e),t.prototype.bind=function(e){return this},t.prototype.fmap=function(e){return this},t.prototype.extract=function(e){if(!e)throw this.val_;return e(this.val_)},t}(r);t.Left=i;var o=function(e){function t(t){e.call(this),this.val_=t}return __extends(t,e),t.prototype.bind=function(e){var t=this;return new r(function(){return t}).bind(e)},t.prototype.extract=function(e){return this.val_},t}(r);t.Right=o}),define("src/lib/monad/either",["require","exports","src/lib/monad/either.impl"],function(e,t,n){"use strict";var r;!function(e){function t(e){return new n.Left(e)}function r(e){return new n.Right(e)}e.Left=t,e.Right=r,e.Return=r}(r=t.Either||(t.Either={})),t.Left=r.Left,t.Right=r.Right,t.Return=r.Return}),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 o=function(){function e(){var e=this;this.canceled=!1,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,void(e.reason=t)}}return e}();t.Cancelable=o}),define("src/lib/monad/sequence/core",["require","exports","src/lib/monad/monad"],function(e,t,n){"use strict";var r=function(e){function t(t,n){e.call(this),this.cons=t,this.memory=n}return __extends(t,e),t}(n.Monad);t.Sequence=r;var r;!function(e){}(r=t.Sequence||(t.Sequence={}));var r;!function(e){function t(t,n){switch(arguments.length){case 0:return[];case 1:return[t];case 2:return[t,n];default:throw e.Exception.invalidConsError(arguments)}}function n(e){return r.iterator(e)!==i.done}e.cons=t;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,o){return e.isIterable(t)?o(t,function(){return n(r.iterator(t)(),i,o)}):i(t)}t.done=function(){return[void 0,t.done,-1]},t.when=n}(i=e.Iterator||(e.Iterator={})),e.isIterable=n;var o;!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}(o=e.Exception||(e.Exception={}))}(r=t.Sequence||(t.Sequence={}))}),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,o=n;i<o.length;i++){var u=o[i];if(void 0!==u&&null!==u)for(var c=0,s=Object.keys(Object(u));c<s.length;c++){var a=s[c],f=Object.getOwnPropertyDescriptor(Object(u),a);void 0!==f&&f.enumerable&&void e(a,Object(t),Object(u))}}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"Function":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"Function":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","src/lib/concat"],function(e,t,n,r){"use strict";function i(e){for(var t=[],i=1;i<arguments.length;i++)t[i-1]=arguments[i];return r.concat([e],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})}t.compose=i}),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(){e.apply(this,arguments)}return __extends(t,e),t.from=function(e){return new n.Sequence(function(t,n){return void 0===t&&(t=0),t<e.length?n(e[t],++t):n()})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=r}),define("src/lib/monad/sequence/member/static/write",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.write=function(e){return new n.Sequence(function(t,n){return e.length>0?n(e.shift(),e):n()})},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(){e.apply(this,arguments)}return __extends(t,e),t.random=function(e){switch(void 0===e&&(e=function(){return Math.random()}),!0){case Array.isArray(e):return this.random().map(function(t){return e[t*e.length|0]});default:return new n.Sequence(function(t,n){return n(e(),NaN)})}},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(){e.apply(this,arguments)}return __extends(t,e),t.zip=function(e,t){return new n.Sequence(function(r,i){var o=void 0===r?[function(){return e.iterate()},function(){return t.iterate()}]:r,u=o[0],c=o[1];return n.Sequence.Iterator.when(u(),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/union",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.union=function(e,t){function r(e,t,r){return new n.Sequence(function(i,o){var u=void 0===i?[function(){return t.iterate()},function(){return r.iterate()}]:i,c=u[0],s=u[1];return n.Sequence.Iterator.when(c(),function(){return n.Sequence.Iterator.when(s(),function(){return o()},function(e){return o(n.Sequence.Thunk.value(e),[n.Sequence.Iterator.done,n.Sequence.Thunk.iterator(e)])})},function(t){return n.Sequence.Iterator.when(s(),function(){return o(n.Sequence.Thunk.value(t),[n.Sequence.Thunk.iterator(t),n.Sequence.Iterator.done])},function(r){var i=e(n.Sequence.Thunk.value(t),n.Sequence.Thunk.value(r));return 0>i?o(n.Sequence.Thunk.value(t),[n.Sequence.Thunk.iterator(t),function(){return r}]):i>0?o(n.Sequence.Thunk.value(r),[function(){return t},n.Sequence.Thunk.iterator(r)]):o(n.Sequence.Thunk.value(t),[n.Sequence.Thunk.iterator(t),n.Sequence.Thunk.iterator(r)])})})})}return t.reduce(function(t,n){return r(e,t,n)})},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(){e.apply(this,arguments)}return __extends(t,e),t.intersect=function(e,t){function r(e,t,r){return new n.Sequence(function(i,o){var u=void 0===i?[function(){return t.iterate()},function(){return r.iterate()}]:i,c=u[0],s=u[1];return n.Sequence.Iterator.when(c(),function(){return o()},function(t,r){return n.Sequence.Iterator.when(s(),function(){return o()},function(i,u){var c=e(n.Sequence.Thunk.value(t),n.Sequence.Thunk.value(i));return 0>c?(s=function(){return i},r()):c>0?u():o(n.Sequence.Thunk.value(t),[n.Sequence.Thunk.iterator(t),n.Sequence.Thunk.iterator(i)])})})})}return t.reduce(function(t,n){return r(e,t,n)})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=r}),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(){e.apply(this,arguments)}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.memory?this.memory.has(t)?this.memory.get(t):this.memory.set(t,this.cons(e,n.Sequence.cons)).get(t):this.cons(e,n.Sequence.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=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.prototype.memoize=function(e){return void 0===e&&(e=this.memory||new Map),new n.Sequence(this.cons,this.memory||e)},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=r}),define("src/lib/monad/sequence/member/instance/read",["require","exports","src/lib/monad/sequence/core","src/lib/concat"],function(e,t,n,r){"use strict";var i=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.prototype.read=function(){for(var e=this,t=[],i=function(){return e.iterate()};;){var o=i();if(!n.Sequence.isIterable(o))return t;void r.concat(t,[n.Sequence.Thunk.value(o)]),i=n.Sequence.Thunk.iterator(o)}},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=i}),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(){e.apply(this,arguments)}return __extends(t,e),t.prototype.take=function(e){return this.takeWhile(function(t,n){return e>n})},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(){e.apply(this,arguments)}return __extends(t,e),t.prototype.drop=function(e){return this.dropWhile(function(t,n){return e>n})},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(){e.apply(this,arguments)}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),n.Sequence.Thunk.index(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(){e.apply(this,arguments)}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),n.Sequence.Thunk.index(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/until",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.prototype.until=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/fmap",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){e.apply(this,arguments)}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.cons()},function(t){return n.Sequence.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/bind",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.prototype.bind=function(e){var t=this;return new n.Sequence(function(r,i){var o=void 0===r?[function(){return t.iterate()},n.Sequence.Iterator.done]:r,u=o[0],c=o[1];return n.Sequence.Iterator.when(u(),function(){return i()},function(t,r){return c=c===n.Sequence.Iterator.done?function(){return e(n.Sequence.Thunk.value(t)).iterate()}:c,n.Sequence.Iterator.when(c(),function(){return c=n.Sequence.Iterator.done,r()},function(e){return i(n.Sequence.Thunk.value(e),[function(){return t},n.Sequence.Thunk.iterator(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(){e.apply(this,arguments)}return __extends(t,e),t.prototype.mapM=function(e){var t=this;return this.take(1).bind(function(){var i=t.read();switch(i.length){case 0:return n.Sequence.from([]);default:var o=i.shift();return e(o).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(){e.apply(this,arguments)}return __extends(t,e),t.prototype.filterM=function(e){var t=this;return this.take(1).bind(function(){var i=t.read();switch(i.length){case 0:return n.Sequence.from([[]]);default:var o=i.shift();return e(o).bind(function(t){return t?0===i.length?n.Sequence.from([[o]]):n.Sequence.from(i).filterM(e).fmap(function(e){return r.concat([o],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(){e.apply(this,arguments)}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.cons()},function(t){return n.Sequence.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(){e.apply(this,arguments)}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(){e.apply(this,arguments)}return __extends(t,e),t.prototype.scan=function(e,t){var r=this;return new n.Sequence(function(i){var o=void 0===i?[void 0,void 0]:i,u=o[0],c=void 0===u?t:u,s=o[1],a=void 0===s?function(){return r.iterate()}:s;return n.Sequence.Iterator.when(a(),function(){return n.Sequence.cons();
},function(t){return n.Sequence.cons(c=e(c,n.Sequence.Thunk.value(t)),[c,n.Sequence.Thunk.iterator(t)])})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=r}),define("src/lib/monad/sequence",["require","exports","src/lib/monad/sequence/core","src/lib/monad/sequence/member/static/from","src/lib/monad/sequence/member/static/write","src/lib/monad/sequence/member/static/random","src/lib/monad/sequence/member/static/zip","src/lib/monad/sequence/member/static/union","src/lib/monad/sequence/member/static/intersect","src/lib/monad/sequence/member/instance/iterate","src/lib/monad/sequence/member/instance/memoize","src/lib/monad/sequence/member/instance/read","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/until","src/lib/monad/sequence/member/instance/fmap","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/compose"],function(e,t,n,r,i,o,u,c,s,a,f,d,l,h,p,v,b,m,q,y,S,x,w,_,g){"use strict";t.Sequence=n.Sequence,g.compose(n.Sequence,r["default"],i["default"],o["default"],u["default"],c["default"],s["default"],a["default"],f["default"],d["default"],l["default"],h["default"],p["default"],v["default"],b["default"],m["default"],q["default"],y["default"],S["default"],x["default"],w["default"],_["default"])}),define("src/lib/collection/attrmap",["require","exports"],function(e,t){"use strict";var n=function(){function e(){this.store=new WeakMap}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 Map).get(e);return void r.set(t,n),this},e.prototype.has=function(e,t){return this.store.has(e)&&this.store.get(e).has(t)},e.prototype["delete"]=function(e,t){return void 0===t?this.store["delete"](e):this.store.has(e)?this.store.get(e)["delete"](t):!1},e}();t.AttrMap=n}),define("src/lib/collection/relationmap",["require","exports"],function(e,t){"use strict";var n=function(){function e(){this.store=new WeakMap}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 WeakMap).get(e);return void r.set(t,n),this},e.prototype.has=function(e,t){return this.store.has(e)&&this.store.get(e).has(t)},e.prototype["delete"]=function(e,t){return void 0===t?this.store["delete"](e):this.store.has(e)?this.store.get(e)["delete"](t):!1},e}();t.RelationMap=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.apply(t.apply(this,arguments)||this,arguments)}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(o([u(window.navigator),u(window.screen),u((new Date).getTimezoneOffset())].join()))}function r(){return i(o([u(process)].join()))}function i(e){return e.split("").reduce(function(e,t,n){return(+t*n+e)%1e9||e-+t},0)}function o(e){return e.split("").map(function(e){return e.charCodeAt(0)}).join("")}function u(e,t){if(void 0===t&&(t=5),t>0&&e&&"object"==typeof e){var n="{";for(var r in e)n+='"'+r+'": '+u(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=o,t.stringify=u}),define("src/lib/uuid",["require","exports","src/lib/fingerprint"],function(e,t,n){"use strict";function r(){var e=u=u*Date.now()%1e15;if(16>e||e>1e15)throw new Error("Spica: uuid: Invalid uuid dynamic seed.");for(var t="",n=0,r=o;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||100>i||i>1e15)throw new Error("Spica: uuid: Invalid uuid static seed.\n "+n.FINGERPRINT);var o=Object.freeze("xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".split("")),u=i;t.v4=r}),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/collection/datamap","src/lib/collection/attrmap","src/lib/collection/relationmap","src/lib/mixin","src/lib/tick","src/lib/fingerprint","src/lib/uuid","src/lib/sqid","src/lib/assign","src/lib/concat"],function(e,t,n,r,i,o,u,c,s,a,f,d,l,h,p,v,b,m){"use strict";t.Supervisor=n.Supervisor,t.Observable=r.Observable,t.Cancelable=i.Cancelable,t.Sequence=o.Sequence,t.Maybe=u.Maybe,t.Just=u.Just,t.Nothing=u.Nothing,t.Either=c.Either,t.Left=c.Left,t.Right=c.Right,t.DataMap=s.DataMap,t.AttrMap=a.AttrMap,t.RelationMap=f.RelationMap,t.Mixin=d.Mixin,t.Tick=l.Tick,t.FINGERPRINT=h.FINGERPRINT,t.uuid=p.v4,t.sqid=v.sqid,t.assign=b.assign,t.clone=b.clone,t.extend=b.extend,t.concat=m.concat}),define("spica",["require","exports","src/export"],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.8 https://github.com/falsandtru/spica | (c) 2016, falsandtru | undefined License (undefined) */
define="function"==typeof define&&define.amd?define:function(){"use strict";var e="spica",t={};return function n(r,i,o){return o?void o.apply(this,i.map(function(e){switch(e){case"require":return"function"==typeof require?require:void 0;case"exports":return-1===r.indexOf("/")?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;r>n;++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 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 o=i[2],u=i[3];if(!o)try{var c=u(t);n&&(r[r.length]=c)}catch(s){void 0!==s&&null!==s&&void console.error(s+"")}},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(o){void 0!==o&&null!==o&&void console.error(o)}},void 0),n)try{void n(t,r)}catch(i){void console.error(i)}},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 o=0;o<t.length;++o){var u=t[o],c=this.refsBelow_(r[u]);i=n.concat(i,c),0===c.length&&(void delete r[u],void t.splice(t.indexOf(u),1),void--o)}return i},e.prototype.seekNode_=function(e){for(var t=this.node_,n=0,r=e;n<r.length;n++){var i=r[n],o=t.childrenMap;o[i+""]||(void t.childrenList.push(i+""),t.childrenList=t.childrenList.sort(),o[i+""]={parent:t,childrenMap:Object.create(null),childrenList:[],registers:[]}),t=o[i+""]}return t},e.prototype.throwTypeErrorIfInvalidSubscriber_=function(e,t){switch(typeof e){case"function":return;default:throw new TypeError("Spica: Observable: Invalid subscriber.\n "+e)}},e}();t.Observable=r}),define("src/lib/sqid",["require","exports"],function(e,t){"use strict";function n(e){return void 0===e?(1e15+ ++r+"").slice(1):(1e15+e+"").slice(1)}var r=0;t.sqid=n}),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/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 o=function(){function e(){this.store=new Map,this.weakstore=new WeakMap}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.weakstore.has(e)?this.weakstore.get(e):this.stringifyObject(e)||this.weakstore.set(e,n.sqid()))+" }"}},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,o=t;i<o.length;i++){var u=o[i];n+=this.stringify(u)+": "+this.stringify(e[u])}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=o}),define("src/lib/tick",["require","exports"],function(e,t){"use strict";var n;!function(e){function t(e){void i.push(e),void r()}function n(){void r(),void--o;for(var e=i.length;e-- >0;)void i.shift()()}function r(){if(0!==i.length)for(;o<u.length;)void setTimeout(n,u[o%u.length]),void++o}e.queue=t;var i=[],o=0,u=[0,4,10,20,25].reverse()}(n||(n={}));var r=Function("return typeof process === 'object' && typeof window !== 'object'")();t.Tick=r?Function("return fn => process.nextTick(fn)")():n.queue}),define("src/lib/thenable",["require","exports"],function(e,t){"use strict";function n(e){return!!e&&"object"==typeof e&&void 0!==e.then}t.isThenable=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/collection/datamap","src/lib/tick","src/lib/thenable","src/lib/concat","src/lib/noop"],function(e,t,n,r,i,o,u,c){"use strict";function s(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(var n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}var a=function(){function e(t){var i=this,o=void 0===t?{}:t,u=o.name,s=void 0===u?"":u,a=o.dependencies,f=void 0===a?[]:a,d=o.retry,l=void 0===d?!1:d,h=o.timeout,p=void 0===h?0:h,v=o.destructor,m=void 0===v?c.noop:v;if(this.deps=new r.DataMap,this.events={exec:new n.Observable,fail: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,dependenciesStack:[]},this.queue=[],this.constructor===e)throw new Error("Spica: Supervisor: Cannot instantiate abstract classes.");this.name=s,void f.reduce(function(e,t){var n=t[0],r=t[1];return void i.deps.set(n,r)},void 0),this.retry=l,this.timeout=p,this.destructor_=m,void++this.constructor.count}return e.prototype.destructor=function(e){for(void this.checkState(),this.alive=!1;this.queue.length>0;){var t=this.queue.shift(),n=t[0],r=t[1];void this.events.loss.emit(n,[n,void 0,r])}try{void this.destructor_(e)}catch(i){void console.error(i)}void--this.constructor.count,void Object.freeze(this)},e.prototype.schedule=function(){var e=this;this.alive&&(this.scheduled||(void i.Tick(function(t){e.alive&&(e.scheduled=!1,void e.drain())}),this.scheduled=!0))},e.prototype.register=function(e,t){if(void this.checkState(),!this.registerable)throw new Error("Spica: Supervisor: Supervisor "+this.name+" cannot register process during the exiting.");return e=u.concat([],e),void this.schedule(),new d(this,this.workerSharedResource,e,t,this.deps.get(e)||[]).terminate},e.prototype.call=function(e,t,n,r){var i=this;void 0===n&&(n=this.timeout),void 0===r&&(r=c.noop),void this.checkState(),e=u.concat([],e),void this.queue.push([e,t,function(e,t){return void r(t,e)},n,Date.now()]),void this.schedule(),n>0!=!1&&void setTimeout(function(){return i.drain(e)},n)},e.prototype.cast=function(e,t,n){void 0===n&&(n=this.retry),void this.checkState();var r=this.procs.reflect(e,new f.Call(t));return 0===r.length&&void this.events.fail.emit(e,[e,void 0,t]),r.length>0||!n?r:this.cast(e,t,!1)},e.prototype.refs=function(e){return void this.checkState(),this.procs.refs(e).map(function(e){var t=(e[0],e[1]),n=t(void 0);return[n.namespace,n.process,n.terminate]})},e.prototype.terminate=function(e,t){void this.checkState(),void 0===e&&(this.registerable=!1),void this.procs.emit(e||[],new f.Exit(t)),void this.procs.off(e||[]),void 0===e&&void this.destructor(t)},e.prototype.checkState=function(){if(!this.alive)throw new Error("Spica: Supervisor: Supervisor "+this.name+" already exited.")},e.prototype.drain=function(e){void 0===e&&(e=[]);for(var t,n=Date.now(),r=function(r){var o=i.queue[r],u=o[0],c=o[1],s=o[2],a=o[3],d=o[4],l=e.every(function(e,t){return e===u[t]})?i.procs.reflect(u,new f.Call(c)):[];if(0===l.length&&void i.events.fail.emit(u,[u,void 0,c]),0===l.length&&d+a>n)return t=r,"continue";if(0===r?void i.queue.shift():void i.queue.splice(r,1),void--r,0===l.length&&void i.events.loss.emit(u,[u,void 0,c]),!s)return t=r,"continue";try{void s(c,l)}catch(h){void console.error(h)}t=r},i=this,o=0;o<this.queue.length;++o){r(o);o=t}},e.count=0,e.procs=0,e}();t.Supervisor=a;var f;!function(e){var t=function(){function e(){}return e}(),n=function(e){function t(t){e.call(this),this.namespace=t}return __extends(t,e),t}(t);e.Deps=n;var r=function(e){function t(t){e.call(this),this.data=t}return __extends(t,e),t}(t);e.Call=r;var i=function(e){function t(t){e.call(this),this.reason=t}return __extends(t,e),t}(t);e.Exit=i}(f||(f={}));var d=function(){function e(t,n,r,i,o){var u=this;this.sv=t,this.sharedResource=n,this.namespace=r,this.process=i,this.dependencies=o,this.alive=!0,this.called=!1,this.concurrency=1,this.receive=function(t){return e.prototype.receive.call(u,t)},this.terminate=function(t){return e.prototype.terminate.call(u,t)},this.sharedResource.allRefsCache=void 0,void++this.sv.constructor.procs,void this.sharedResource.procs.on(r,this.receive)}return e.prototype.destructor=function(e){void this.checkState(),void this.sharedResource.procs.off(this.namespace,this.receive),this.alive=!1,void--this.sv.constructor.procs,this.sharedResource.allRefsCache=void 0,void Object.freeze(this),void this.sv.events.exit.emit(this.namespace,[this.namespace,this.process,e])},e.prototype.tryDependencyResolving=function(e){if(this.receive(new f.Deps(this.namespace)))return void(this.sharedResource.dependenciesStack=[]);throw void(this.sharedResource.dependenciesStack=[])},e.prototype.receive=function(e){var t=this;if(void this.checkState(),void 0===e)return this;if(e instanceof f.Deps){if(e.namespace.length!==this.namespace.length)return!1;if(0===this.concurrency)return!1;for(var n=0,r=this.sharedResource.dependenciesStack;n<r.length;n++){var i=r[n];if(s(this.namespace,i))return!0}return void this.sharedResource.dependenciesStack.push(this.namespace),this.dependencies.every(function(e){return(t.sharedResource.allRefsCache=t.sharedResource.allRefsCache||t.sharedResource.procs.refs([])).some(function(t){var n=t[0],r=t[1];return s(n,e)&&!!r(new f.Deps(e))})})}if(e instanceof f.Call){if(0===this.concurrency)throw void 0;void this.tryDependencyResolving(e),this.called||(this.called=!0,void this.sv.events.exec.emit(this.namespace,[this.namespace,this.process]));try{void--this.concurrency;var u=(0,this.process)(e.data);return o.isThenable(u)?void u.then(function(e){void t.sv.schedule(),t.alive&&void++t.concurrency},function(e){void t.sv.schedule(),t.alive&&(void++t.concurrency,void t.terminate(e))}):void++this.concurrency,u}catch(c){throw void void this.terminate(c)}}if(e instanceof f.Exit)throw void void this.terminate(e.reason);throw new TypeError("Spica: Supervisor: Invalid command: "+e)},e.prototype.terminate=function(e){void this.destructor(e)},e.prototype.checkState=function(){if(!this.alive)throw new Error("Spica: Supervisor: Process "+this.namespace+"/"+this.process+" already exited.")},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(){e.apply(this,arguments)}return __extends(t,e),t}(n.Lazy);t.Functor=r}),define("src/lib/monad/monad",["require","exports","src/lib/monad/functor"],function(e,t,n){"use strict";var r=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t}(n.Functor);t.Monad=r}),define("src/lib/monad/maybe.impl",["require","exports","src/lib/monad/monad"],function(e,t,n){"use strict";var r=function(e){function t(t){e.call(this,t),this.thunk=t}return __extends(t,e),t.prototype.bind=function(e){var n=this;return new t(function(){var r=n.evaluate();if(r instanceof i)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 "+r)})},t.prototype.fmap=function(e){return this.bind(function(t){return new i(e(t))})},t.prototype.extract=function(e){return this.evaluate().extract(e)},t}(n.Monad);t.Maybe=r;var i=function(e){function t(t){e.call(this),this.val_=t}return __extends(t,e),t.prototype.bind=function(e){var t=this;return new r(function(){return t}).bind(e)},t.prototype.extract=function(e){return this.val_},t}(r);t.Just=i;var o=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.prototype.bind=function(e){return this},t.prototype.fmap=function(e){return this},t.prototype.extract=function(e){if(!e)throw void 0;return e()},t}(r);t.Nothing=o}),define("src/lib/monad/maybe",["require","exports","src/lib/monad/maybe.impl"],function(e,t,n){"use strict";var r;!function(e){function t(e){return new n.Just(e)}e.Just=t,e.Nothing=new n.Nothing,e.Return=t}(r=t.Maybe||(t.Maybe={})),t.Just=r.Just,t.Nothing=r.Nothing,t.Return=t.Just}),define("src/lib/monad/either.impl",["require","exports","src/lib/monad/monad"],function(e,t,n){"use strict";var r=function(e){function t(t){e.call(this,t),this.thunk=t}return __extends(t,e),t.prototype.bind=function(e){var n=this;return new t(function(){var r=n.evaluate();if(r instanceof i)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 "+r)})},t.prototype.fmap=function(e){return this.bind(function(t){return new o(e(t))})},t.prototype.extract=function(e){return this.evaluate().extract(e)},t}(n.Monad);t.Either=r;var i=function(e){function t(t){e.call(this),this.val_=t}return __extends(t,e),t.prototype.bind=function(e){return this},t.prototype.fmap=function(e){return this},t.prototype.extract=function(e){if(!e)throw this.val_;return e(this.val_)},t}(r);t.Left=i;var o=function(e){function t(t){e.call(this),this.val_=t}return __extends(t,e),t.prototype.bind=function(e){var t=this;return new r(function(){return t}).bind(e)},t.prototype.extract=function(e){return this.val_},t}(r);t.Right=o}),define("src/lib/monad/either",["require","exports","src/lib/monad/either.impl"],function(e,t,n){"use strict";var r;!function(e){function t(e){return new n.Left(e)}function r(e){return new n.Right(e)}e.Left=t,e.Right=r,e.Return=r}(r=t.Either||(t.Either={})),t.Left=r.Left,t.Right=r.Right,t.Return=r.Return}),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 o=function(){function e(){var e=this;this.canceled=!1,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,void(e.reason=t)}}return e}();t.Cancelable=o}),define("src/lib/monad/sequence/core",["require","exports","src/lib/monad/monad"],function(e,t,n){"use strict";var r=function(e){function t(t,n){e.call(this),this.cons=t,this.memory=n}return __extends(t,e),t}(n.Monad);t.Sequence=r;var r;!function(e){}(r=t.Sequence||(t.Sequence={}));var r;!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,o){return e.isIterable(t)?o(t,function(){return n(r.iterator(t)(),i,o)}):i(t)}t.done=function(){return[void 0,t.done,-1]},t.when=n}(i=e.Iterator||(e.Iterator={})),e.isIterable=t;var o;!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}(o=e.Exception||(e.Exception={}))}(r=t.Sequence||(t.Sequence={}))}),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(){e.apply(this,arguments)}return __extends(t,e),t.from=function(e){return new n.Sequence(function(t,n){return void 0===t&&(t=0),t<e.length?n(e[t],++t):n()})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=r}),define("src/lib/monad/sequence/member/static/write",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.write=function(e){return new n.Sequence(function(t,n){return e.length>0?n(e.shift(),e):n()})},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(){e.apply(this,arguments)}return __extends(t,e),t.random=function(e){switch(void 0===e&&(e=function(){return Math.random()}),!0){case Array.isArray(e):return this.random().map(function(t){return e[t*e.length|0]});default:return new n.Sequence(function(t,n){return n(e(),NaN)})}},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";function r(e,t){return new n.Sequence(function(r,i){var o=void 0===r?[function(){return e.iterate()},function(){return t.iterate()}]:r,u=o[0],c=o[1];return n.Sequence.Iterator.when(u(),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(){e.apply(this,arguments)}return __extends(t,e),t.concat=function(e){return Array.isArray(e)?e.reduce(function(e,t){return r(e,t)},n.Sequence.from([])):e.bind(function(e){return Array.isArray(e)?n.Sequence.from(e):e})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=i}),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(){e.apply(this,arguments)}return __extends(t,e),t.zip=function(e,t){return new n.Sequence(function(r,i){var o=void 0===r?[function(){return e.iterate()},function(){return t.iterate()}]:r,u=o[0],c=o[1];return n.Sequence.Iterator.when(u(),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/union",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";function r(e,t,r){return new n.Sequence(function(i,o){var u=void 0===i?[function(){return t.iterate()},function(){return r.iterate()}]:i,c=u[0],s=u[1];return n.Sequence.Iterator.when(c(),function(){return n.Sequence.Iterator.when(s(),function(){return o()},function(e){return o(n.Sequence.Thunk.value(e),[n.Sequence.Iterator.done,n.Sequence.Thunk.iterator(e)])})},function(t){return n.Sequence.Iterator.when(s(),function(){return o(n.Sequence.Thunk.value(t),[n.Sequence.Thunk.iterator(t),n.Sequence.Iterator.done])},function(r){var i=e(n.Sequence.Thunk.value(t),n.Sequence.Thunk.value(r));return 0>i?o(n.Sequence.Thunk.value(t),[n.Sequence.Thunk.iterator(t),s]):i>0?o(n.Sequence.Thunk.value(r),[c,n.Sequence.Thunk.iterator(r)]):o(n.Sequence.Thunk.value(t),[n.Sequence.Thunk.iterator(t),n.Sequence.Thunk.iterator(r)])})})})}var i=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.union=function(e,t){return t.reduce(function(t,n){return r(e,t,n)})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=i}),define("src/lib/monad/sequence/member/static/intersect",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";function r(e,t,r){return new n.Sequence(function(i,o){var u=void 0===i?[function(){return t.iterate()},function(){return r.iterate()}]:i,c=u[0],s=u[1];return n.Sequence.Iterator.when(c(),function(){return o()},function(t,r){return n.Sequence.Iterator.when(s(),function(){return o()},function(i,u){var c=e(n.Sequence.Thunk.value(t),n.Sequence.Thunk.value(i));return 0>c?(s=function(){return i},r()):c>0?u():o(n.Sequence.Thunk.value(t),[n.Sequence.Thunk.iterator(t),n.Sequence.Thunk.iterator(i)])})})})}var i=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.intersect=function(e,t){return t.reduce(function(t,n){return r(e,t,n)})},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(){e.apply(this,arguments)}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.memory?this.memory.has(t)?this.memory.get(t):this.memory.set(t,this.cons(e,n.Sequence.Data.cons)).get(t):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=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.prototype.memoize=function(e){return void 0===e&&(e=this.memory||new Map),new n.Sequence(this.cons,this.memory||e)},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=r}),define("src/lib/monad/sequence/member/instance/read",["require","exports","src/lib/monad/sequence/core","src/lib/concat"],function(e,t,n,r){"use strict";var i=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.prototype.read=function(){for(var e=this,t=[],i=function(){return e.iterate()};;){var o=i();if(!n.Sequence.isIterable(o))return t;void r.concat(t,[n.Sequence.Thunk.value(o)]),i=n.Sequence.Thunk.iterator(o)}},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=i}),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(){e.apply(this,arguments)}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(r(),function(){return i()},function(t){return n.Sequence.Thunk.index(t)<e?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/drop",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){e.apply(this,arguments)}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(){e.apply(this,arguments)}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(){e.apply(this,arguments)}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(){e.apply(this,arguments)}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(){e.apply(this,arguments)}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(){e.apply(this,arguments)}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/bind",["require","exports","src/lib/monad/sequence/core"],function(e,t,n){"use strict";var r=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.prototype.bind=function(e){var t=this;return new n.Sequence(function(r,i){var o=void 0===r?[function(){return t.iterate()},n.Sequence.Iterator.done]:r,u=o[0],c=o[1];return n.Sequence.Iterator.when(u(),function(){return i()},function(t,r){return c=c===n.Sequence.Iterator.done?function(){return e(n.Sequence.Thunk.value(t)).iterate()}:c,n.Sequence.Iterator.when(c(),function(){return c=n.Sequence.Iterator.done,r()},function(e){return i(n.Sequence.Thunk.value(e),[function(){return t},n.Sequence.Thunk.iterator(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(){e.apply(this,arguments)}return __extends(t,e),t.prototype.mapM=function(e){var t=this;return this.take(1).bind(function(){var i=t.read();switch(i.length){case 0:return n.Sequence.from([]);default:var o=i.shift();return e(o).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(){e.apply(this,arguments)}return __extends(t,e),t.prototype.filterM=function(e){var t=this;return this.take(1).bind(function(){var i=t.read();switch(i.length){case 0:return n.Sequence.from([[]]);default:var o=i.shift();return e(o).bind(function(t){return t?0===i.length?n.Sequence.from([[o]]):n.Sequence.from(i).filterM(e).fmap(function(e){return r.concat([o],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(){e.apply(this,arguments)}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(){e.apply(this,arguments)}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(){e.apply(this,arguments)}return __extends(t,e),t.prototype.scan=function(e,t){var r=this;return new n.Sequence(function(i){var o=void 0===i?[void 0,void 0]:i,u=o[0],c=void 0===u?t:u,s=o[1],a=void 0===s?function(){return r.iterate()}:s;return n.Sequence.Iterator.when(a(),function(){return n.Sequence.Data.cons()},function(t){return n.Sequence.Data.cons(c=e(c,n.Sequence.Thunk.value(t)),[c,n.Sequence.Thunk.iterator(t)])})})},t}(n.Sequence);Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=r}),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,o=n;i<o.length;i++){var u=o[i];if(void 0!==u&&null!==u)for(var c=0,s=Object.keys(Object(u));c<s.length;c++){var a=s[c],f=Object.getOwnPropertyDescriptor(Object(u),a);void 0!==f&&f.enumerable&&void e(a,Object(t),Object(u))}}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"Function":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"Function":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","src/lib/concat"],function(e,t,n,r){"use strict";function i(e){for(var t=[],i=1;i<arguments.length;i++)t[i-1]=arguments[i];return r.concat([e],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})}t.compose=i}),define("src/lib/monad/sequence",["require","exports","src/lib/monad/sequence/core","src/lib/monad/sequence/member/static/from","src/lib/monad/sequence/member/static/write","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/union","src/lib/monad/sequence/member/static/intersect","src/lib/monad/sequence/member/instance/iterate","src/lib/monad/sequence/member/instance/memoize","src/lib/monad/sequence/member/instance/read","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/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/compose"],function(e,t,n,r,i,o,u,c,s,a,f,d,l,h,p,v,m,b,q,y,S,x,w,_,g,k,T){"use strict";t.Sequence=n.Sequence,T.compose(n.Sequence,r["default"],i["default"],o["default"],u["default"],c["default"],s["default"],a["default"],f["default"],d["default"],l["default"],h["default"],p["default"],v["default"],m["default"],b["default"],q["default"],y["default"],S["default"],x["default"],w["default"],_["default"],g["default"],k["default"])}),define("src/lib/collection/attrmap",["require","exports"],function(e,t){"use strict";var n=function(){function e(){this.store=new WeakMap}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 Map).get(e);return void r.set(t,n),this},e.prototype.has=function(e,t){return this.store.has(e)&&this.store.get(e).has(t)},e.prototype["delete"]=function(e,t){return void 0===t?this.store["delete"](e):this.store.has(e)?this.store.get(e)["delete"](t):!1},e}();t.AttrMap=n}),define("src/lib/collection/relationmap",["require","exports"],function(e,t){"use strict";var n=function(){function e(){this.store=new WeakMap}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 WeakMap).get(e);return void r.set(t,n),this},e.prototype.has=function(e,t){return this.store.has(e)&&this.store.get(e).has(t)},e.prototype["delete"]=function(e,t){return void 0===t?this.store["delete"](e):this.store.has(e)?this.store.get(e)["delete"](t):!1},e}();t.RelationMap=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.apply(t.apply(this,arguments)||this,arguments)}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(o([u(window.navigator),u(window.screen),u((new Date).getTimezoneOffset())].join()))}function r(){return i(o([u(process)].join()))}function i(e){return e.split("").reduce(function(e,t,n){return(+t*n+e)%1e9||e-+t},0)}function o(e){return e.split("").map(function(e){return e.charCodeAt(0)}).join("")}function u(e,t){if(void 0===t&&(t=5),t>0&&e&&"object"==typeof e){var n="{";for(var r in e)n+='"'+r+'": '+u(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=o,t.stringify=u}),define("src/lib/uuid",["require","exports","src/lib/fingerprint"],function(e,t,n){"use strict";function r(){var e=u=u*Date.now()%1e15;if(16>e||e>1e15)throw new Error("Spica: uuid: Invalid uuid dynamic seed.");for(var t="",n=0,r=o;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||100>i||i>1e15)throw new Error("Spica: uuid: Invalid uuid static seed.\n "+n.FINGERPRINT);var o=Object.freeze("xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".split("")),u=i;t.v4=r}),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/collection/datamap","src/lib/collection/attrmap","src/lib/collection/relationmap","src/lib/mixin","src/lib/tick","src/lib/fingerprint","src/lib/uuid","src/lib/sqid","src/lib/assign","src/lib/concat"],function(e,t,n,r,i,o,u,c,s,a,f,d,l,h,p,v,m,b){"use strict";t.Supervisor=n.Supervisor,t.Observable=r.Observable,t.Cancelable=i.Cancelable,t.Sequence=o.Sequence,t.Maybe=u.Maybe,t.Just=u.Just,t.Nothing=u.Nothing,t.Either=c.Either,t.Left=c.Left,t.Right=c.Right,t.DataMap=s.DataMap,t.AttrMap=a.AttrMap,t.RelationMap=f.RelationMap,t.Mixin=d.Mixin,t.Tick=l.Tick,t.FINGERPRINT=h.FINGERPRINT,t.uuid=p.v4,t.sqid=v.sqid,t.assign=m.assign,t.clone=m.clone,t.extend=m.extend,t.concat=b.concat}),define("spica",["require","exports","src/export"],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.7",
"version": "0.0.8",
"description": "Supervisor, Observable, Sequence, Maybe, Either and some utils.",

@@ -5,0 +5,0 @@ "private": false,

@@ -25,3 +25,3 @@ import {sqid} from '../sqid';

}
if (key instanceof Array) {
if (Array.isArray(key)) {
return `9:[ ${this.stringifyArray(<any[]>key)} ]`;

@@ -28,0 +28,0 @@ }

@@ -5,2 +5,3 @@ import {Sequence} from './sequence/core';

import random from './sequence/member/static/random';
import concat from './sequence/member/static/concat';
import zip from './sequence/member/static/zip';

@@ -16,3 +17,4 @@ import union from './sequence/member/static/union';

import dropWhile from './sequence/member/instance/dropWhile';
import until from './sequence/member/instance/until';
import takeUntil from './sequence/member/instance/takeUntil';
import dropUntil from './sequence/member/instance/dropUntil';
import fmap from './sequence/member/instance/fmap';

@@ -32,2 +34,3 @@ import bind from './sequence/member/instance/bind';

random,
concat,
zip,

@@ -43,3 +46,4 @@ union,

dropWhile,
until,
takeUntil,
dropUntil,
fmap,

@@ -46,0 +50,0 @@ bind,

@@ -12,3 +12,3 @@ import {Monad} from '../monad';

export namespace Sequence {
export declare function from<T>(as: T[]): Sequence<T, T>;
export declare function from<T>(as: T[]): Sequence<T, number>;
export declare function write<T>(as: T[]): Sequence<T, T[]>;

@@ -18,2 +18,5 @@ export declare function random(): Sequence<number, number>;

export declare function random<T>(as: T[]): Sequence<T, Sequence.Iterator<number>>;
export declare function concat<T>(ss: Sequence<T, any>[]): Sequence<T, [Sequence.Iterator<T>, Sequence.Iterator<T>]>;
export declare function concat<T>(ss: Sequence<Sequence<T, any>, any>): Sequence<T, [Sequence.Iterator<T[]>, Sequence.Iterator<T>]>;
export declare function concat<T>(ss: Sequence<T[], any>): Sequence<T, [Sequence.Iterator<T[]>, Sequence.Iterator<T>]>;
export declare function zip<T, U>(a: Sequence<T, any>, b: Sequence<U, any>): Sequence<[T, U], [Sequence.Iterator<T>, Sequence.Iterator<U>]>;

@@ -24,4 +27,4 @@ export declare function union<T>(cmp: (a: T, b: T) => number, ss: Sequence<T, any>[]): Sequence<T, [Sequence.Iterator<T>, Sequence.Iterator<T>]>;

export interface Sequence<T, S> {
iterate(): Sequence.Thunk<T>;
read(): T[];
iterate(): Sequence.Thunk<T>;
fmap<U>(f: (p: T) => U): Sequence<U, Sequence.Iterator<T>>;

@@ -36,5 +39,6 @@ bind<U>(f: (p: T) => Sequence<U, any>): Sequence<U, [Sequence.Iterator<T>, Sequence.Iterator<U>]>;

drop(n: number): Sequence<T, Sequence.Iterator<T>>;
takeWhile(f: (p: T, i: number) => boolean): Sequence<T, Sequence.Iterator<T>>;
dropWhile(f: (p: T, i: number) => boolean): Sequence<T, Sequence.Iterator<T>>;
until(f: (p: T) => boolean): Sequence<T, Sequence.Iterator<T>>;
takeWhile(f: (p: T) => boolean): Sequence<T, Sequence.Iterator<T>>;
dropWhile(f: (p: T) => boolean): Sequence<T, Sequence.Iterator<T>>;
takeUntil(f: (p: T) => boolean): Sequence<T, Sequence.Iterator<T>>;
dropUntil(f: (p: T) => boolean): Sequence<T, Sequence.Iterator<T>>;
memoize(memory?: Map<number, Sequence.Data<T, S>>): Sequence<T, S>;

@@ -44,16 +48,17 @@ }

export namespace Sequence {
export function cons<T, S>(value?: T, next?: S): Sequence.Data<T, S> {
switch (arguments.length) {
case 0:
return <Sequence.Data<T, S>>[];
case 1:
return <Sequence.Data<T, S>><[]>[value];
case 2:
return <Sequence.Data<T, S>>[value, next];
default:
throw Sequence.Exception.invalidConsError(arguments);
export type Data<T, S> = [T, S];
export namespace Data {
export function cons<T, S>(value?: T, next?: S): Sequence.Data<T, S> {
switch (arguments.length) {
case 0:
return <Sequence.Data<T, S>>[];
case 1:
return <Sequence.Data<T, S>><[]>[value];
case 2:
return <Sequence.Data<T, S>>[value, next];
default:
throw Sequence.Exception.invalidConsError(arguments);
}
}
}
export type Data<T, S> = [T, S];
export type Thunk<T> = [T, Iterator<T>, number];

@@ -60,0 +65,0 @@ export namespace Thunk {

@@ -5,4 +5,2 @@ import {Sequence} from '../../../sequence';

const nat = new Sequence<number, number>((n = 0, cons) => cons(n, n + 1));
const double = nat.map(n => n * 2);
const triple = nat.map(n => n * 3);

@@ -9,0 +7,0 @@ describe('bind', () => {

import {Sequence} from '../../core';
import {compose} from '../../../../compose';

@@ -4,0 +3,0 @@ export default class <T, S> extends Sequence<T, S> {

@@ -5,4 +5,2 @@ import {Sequence} from '../../../sequence';

const nat = new Sequence<number, number>((n = 0, cons) => cons(n, n + 1));
const double = nat.map(n => n * 2);
const triple = nat.map(n => n * 3);

@@ -9,0 +7,0 @@ describe('drop', () => {

import {Sequence} from '../../core';
import {compose} from '../../../../compose';
export default class <T, S> extends Sequence<T, S> {
public drop(n: number): Sequence<T, Sequence.Iterator<T>> {
return this.dropWhile((_, i) => i < n);
return new Sequence<T, Sequence.Iterator<T>>((iter = () => this.iterate(), cons) =>
Sequence.Iterator.when(
iter(),
() => cons(),
(thunk, recur) =>
Sequence.Thunk.index(thunk) < n
? recur()
: cons(Sequence.Thunk.value(thunk), Sequence.Thunk.iterator(thunk))));
}
}

@@ -5,4 +5,2 @@ import {Sequence} from '../../../sequence';

const nat = new Sequence<number, number>((n = 0, cons) => cons(n, n + 1));
const double = nat.map(n => n * 2);
const triple = nat.map(n => n * 3);

@@ -58,3 +56,3 @@ describe('dropWhile', () => {

it('0 take', () => {
it('0', () => {
assert.deepStrictEqual(

@@ -68,3 +66,3 @@ nat

it('1 take', () => {
it('1', () => {
assert.deepStrictEqual(

@@ -78,3 +76,3 @@ nat

it('2 take', () => {
it('2', () => {
assert.deepStrictEqual(

@@ -81,0 +79,0 @@ nat

import {Sequence} from '../../core';
import {compose} from '../../../../compose';
export default class <T, S> extends Sequence<T, S> {
public dropWhile(f: (p: T, i: number) => boolean): Sequence<T, Sequence.Iterator<T>> {
public dropWhile(f: (p: T) => boolean): Sequence<T, Sequence.Iterator<T>> {
return new Sequence<T, Sequence.Iterator<T>>((iter = () => this.iterate(), cons) =>

@@ -11,3 +10,3 @@ Sequence.Iterator.when(

(thunk, recur) =>
f(Sequence.Thunk.value(thunk), Sequence.Thunk.index(thunk))
f(Sequence.Thunk.value(thunk))
? recur()

@@ -14,0 +13,0 @@ : cons(Sequence.Thunk.value(thunk), Sequence.Thunk.iterator(thunk))));

@@ -5,4 +5,2 @@ import {Sequence} from '../../../sequence';

const nat = new Sequence<number, number>((n = 0, cons) => cons(n, n + 1));
const double = nat.map(n => n * 2);
const triple = nat.map(n => n * 3);

@@ -9,0 +7,0 @@ describe('filter', () => {

import {Sequence} from '../../core';
import {compose} from '../../../../compose';

@@ -4,0 +3,0 @@ export default class <T, S> extends Sequence<T, S> {

@@ -5,4 +5,2 @@ import {Sequence} from '../../../sequence';

const nat = new Sequence<number, number>((n = 0, cons) => cons(n, n + 1));
const double = nat.map(n => n * 2);
const triple = nat.map(n => n * 3);

@@ -9,0 +7,0 @@ describe('filterM', () => {

import {Sequence} from '../../core';
import {compose} from '../../../../compose';
import {concat} from '../../../../concat';

@@ -4,0 +3,0 @@

@@ -5,4 +5,2 @@ import {Sequence} from '../../../sequence';

const nat = new Sequence<number, number>((n = 0, cons) => cons(n, n + 1));
const double = nat.map(n => n * 2);
const triple = nat.map(n => n * 3);

@@ -9,0 +7,0 @@ describe('fmap', () => {

import {Sequence} from '../../core';
import {compose} from '../../../../compose';

@@ -9,5 +8,5 @@ export default class <T, S> extends Sequence<T, S> {

iter(),
() => Sequence.cons<U, Sequence.Iterator<T>>(),
thunk => Sequence.cons<U, Sequence.Iterator<T>>(f(Sequence.Thunk.value(thunk)), Sequence.Thunk.iterator(thunk))));
() => Sequence.Data.cons<U, Sequence.Iterator<T>>(),
thunk => Sequence.Data.cons<U, Sequence.Iterator<T>>(f(Sequence.Thunk.value(thunk)), Sequence.Thunk.iterator(thunk))));
}
}
import {Sequence} from '../../../sequence';
describe('Unit: lib/monad/sequence/member/iterate', () => {
const nat = new Sequence<number, number>((n = 0, cons) => cons(n, n + 1));
const double = nat.map(n => n * 2);
const triple = nat.map(n => n * 3);
describe('iterate', () => {

@@ -9,0 +5,0 @@ it('', () => {

import {Sequence} from '../../core';
import {compose} from '../../../../compose';

@@ -12,4 +11,4 @@ export default class <T, S> extends Sequence<T, S> {

? this.memory.get(i)
: this.memory.set(i, this.cons(p, Sequence.cons)).get(i)
: this.cons(p, Sequence.cons);
: this.memory.set(i, this.cons(p, Sequence.Data.cons)).get(i)
: this.cons(p, Sequence.Data.cons);
switch (data.length) {

@@ -16,0 +15,0 @@ case 0:

@@ -5,4 +5,2 @@ import {Sequence} from '../../../sequence';

const nat = new Sequence<number, number>((n = 0, cons) => cons(n, n + 1));
const double = nat.map(n => n * 2);
const triple = nat.map(n => n * 3);

@@ -9,0 +7,0 @@ describe('map', () => {

import {Sequence} from '../../core';
import {compose} from '../../../../compose';

@@ -9,5 +8,5 @@ export default class <T, S> extends Sequence<T, S> {

iter(),
() => Sequence.cons<U, Sequence.Iterator<T>>(),
thunk => Sequence.cons<U, Sequence.Iterator<T>>(f(Sequence.Thunk.value(thunk), Sequence.Thunk.index(thunk)), Sequence.Thunk.iterator(thunk))));
() => Sequence.Data.cons<U, Sequence.Iterator<T>>(),
thunk => Sequence.Data.cons<U, Sequence.Iterator<T>>(f(Sequence.Thunk.value(thunk), Sequence.Thunk.index(thunk)), Sequence.Thunk.iterator(thunk))));
}
}

@@ -5,4 +5,2 @@ import {Sequence} from '../../../sequence';

const nat = new Sequence<number, number>((n = 0, cons) => cons(n, n + 1));
const double = nat.map(n => n * 2);
const triple = nat.map(n => n * 3);

@@ -9,0 +7,0 @@ describe('mapM', () => {

import {Sequence} from '../../core';
import {compose} from '../../../../compose';
import {concat} from '../../../../concat';

@@ -4,0 +3,0 @@

import {Sequence} from '../../../sequence';
describe('Unit: lib/monad/sequence/member/memoize', () => {
const nat = new Sequence<number, number>((n = 0, cons) => cons(n, n + 1));
const double = nat.map(n => n * 2);
const triple = nat.map(n => n * 3);
describe('memoize', () => {

@@ -9,0 +5,0 @@ it('write unmemoized', () => {

import {Sequence} from '../../core';
import {compose} from '../../../../compose';

@@ -4,0 +3,0 @@ export default class <T, S> extends Sequence<T, S> {

import {Sequence} from '../../core';
import {compose} from '../../../../compose';
import {concat} from '../../../../concat';

@@ -4,0 +3,0 @@

import {Sequence} from '../../../sequence';
describe('Unit: lib/monad/sequence/member/scan', () => {
const nat = new Sequence<number, number>((n = 0, cons) => cons(n, n + 1));
const double = nat.map(n => n * 2);
const triple = nat.map(n => n * 3);
describe('scan', () => {

@@ -9,0 +5,0 @@ it('0', () => {

import {Sequence} from '../../core';
import {compose} from '../../../../compose';

@@ -9,5 +8,5 @@ export default class <T, S> extends Sequence<T, S> {

iter(),
() => Sequence.cons<U, [U, Sequence.Iterator<T>]>(),
() => Sequence.Data.cons<U, [U, Sequence.Iterator<T>]>(),
thunk =>
Sequence.cons<U, [U, Sequence.Iterator<T>]>(
Sequence.Data.cons<U, [U, Sequence.Iterator<T>]>(
prev = f(prev, Sequence.Thunk.value(thunk)),

@@ -14,0 +13,0 @@ [prev, Sequence.Thunk.iterator(thunk)])));

@@ -5,4 +5,2 @@ import {Sequence} from '../../../sequence';

const nat = new Sequence<number, number>((n = 0, cons) => cons(n, n + 1));
const double = nat.map(n => n * 2);
const triple = nat.map(n => n * 3);

@@ -9,0 +7,0 @@ describe('take', () => {

import {Sequence} from '../../core';
import {compose} from '../../../../compose';
export default class <T, S> extends Sequence<T, S> {
public take(n: number): Sequence<T, Sequence.Iterator<T>> {
return this.takeWhile((_, i) => i < n);
return new Sequence<T, Sequence.Iterator<T>>((iter = () => this.iterate(), cons) =>
Sequence.Iterator.when(
iter(),
() => cons(),
thunk =>
Sequence.Thunk.index(thunk) < n
? cons(Sequence.Thunk.value(thunk), Sequence.Thunk.iterator(thunk))
: cons()));
}
}

@@ -5,4 +5,2 @@ import {Sequence} from '../../../sequence';

const nat = new Sequence<number, number>((n = 0, cons) => cons(n, n + 1));
const double = nat.map(n => n * 2);
const triple = nat.map(n => n * 3);

@@ -66,3 +64,3 @@ describe('takeWhile', () => {

it('1 take', () => {
it('1', () => {
assert.deepStrictEqual(

@@ -75,3 +73,3 @@ nat

it('2 take', () => {
it('2', () => {
assert.deepStrictEqual(

@@ -84,3 +82,3 @@ nat

it('1 all', () => {
it('3', () => {
assert.deepStrictEqual(

@@ -87,0 +85,0 @@ nat

import {Sequence} from '../../core';
import {compose} from '../../../../compose';
export default class <T, S> extends Sequence<T, S> {
public takeWhile(f: (p: T, i: number) => boolean): Sequence<T, Sequence.Iterator<T>> {
public takeWhile(f: (p: T) => boolean): Sequence<T, Sequence.Iterator<T>> {
return new Sequence<T, Sequence.Iterator<T>>((iter = () => this.iterate(), cons) =>

@@ -11,3 +10,3 @@ Sequence.Iterator.when(

thunk =>
f(Sequence.Thunk.value(thunk), Sequence.Thunk.index(thunk))
f(Sequence.Thunk.value(thunk))
? cons(Sequence.Thunk.value(thunk), Sequence.Thunk.iterator(thunk))

@@ -14,0 +13,0 @@ : cons()));

import {Sequence} from '../../../sequence';
describe('Unit: lib/monad/sequence/member/static/from', () => {
const nat = new Sequence<number, number>((n = 0, cons) => cons(n, n + 1));
const double = nat.map(n => n * 2);
const triple = nat.map(n => n * 3);
describe('Sequence.from', () => {

@@ -9,0 +5,0 @@ it('array', () => {

import {Sequence} from '../../core';
import {compose} from '../../../../compose';

@@ -4,0 +3,0 @@ export default class <T, S> extends Sequence<T, S> {

@@ -29,6 +29,6 @@ import {Sequence} from '../../../sequence';

assert.deepStrictEqual(
Sequence.intersect((a, b) => a - b, [double.dropWhile(n => n < 6).until(n => n === 12), triple]).take(2).read(),
Sequence.intersect((a, b) => a - b, [double.dropWhile(n => n < 6).takeUntil(n => n === 12), triple]).take(2).read(),
[6, 12]);
assert.deepStrictEqual(
Sequence.intersect((a, b) => a - b, [triple, double.dropWhile(n => n < 6).until(n => n === 12)]).take(2).read(),
Sequence.intersect((a, b) => a - b, [triple, double.dropWhile(n => n < 6).takeUntil(n => n === 12)]).take(2).read(),
[6, 12]);

@@ -35,0 +35,0 @@ });

import {Sequence} from '../../core';
import {compose} from '../../../../compose';

@@ -7,20 +6,20 @@ export default class <T, S> extends Sequence<T, S> {

return ss.reduce((a, b) => intersect(cmp, a, b));
}
}
function intersect<T>(cmp: (a: T, b: T) => number, a: Sequence<T, any>, b: Sequence<T, any>): Sequence<T, [Sequence.Iterator<T>, Sequence.Iterator<T>]> {
return new Sequence<T, [Sequence.Iterator<T>, Sequence.Iterator<T>]>(([ai, bi] = [() => a.iterate(), () => b.iterate()], cons) =>
function intersect<T>(cmp: (a: T, b: T) => number, a: Sequence<T, any>, b: Sequence<T, any>): Sequence<T, [Sequence.Iterator<T>, Sequence.Iterator<T>]> {
return new Sequence<T, [Sequence.Iterator<T>, Sequence.Iterator<T>]>(([ai, bi] = [() => a.iterate(), () => b.iterate()], cons) =>
Sequence.Iterator.when(
ai(),
() => cons(),
(at, ar) =>
Sequence.Iterator.when(
ai(),
bi(),
() => cons(),
(at, ar) =>
Sequence.Iterator.when(
bi(),
() => cons(),
(bt, br) => {
const result = cmp(Sequence.Thunk.value(at), Sequence.Thunk.value(bt));
if (result < 0) return bi = () => bt, ar();
if (result > 0) return br();
return cons(Sequence.Thunk.value(at), [Sequence.Thunk.iterator(at), Sequence.Thunk.iterator(bt)]);
})));
}
}
(bt, br) => {
const result = cmp(Sequence.Thunk.value(at), Sequence.Thunk.value(bt));
if (result < 0) return bi = () => bt, ar();
if (result > 0) return br();
return cons(Sequence.Thunk.value(at), [Sequence.Thunk.iterator(at), Sequence.Thunk.iterator(bt)]);
})));
}
import {Sequence} from '../../../sequence';
describe('Unit: lib/monad/sequence/member/static/random', () => {
const nat = new Sequence<number, number>((n = 0, cons) => cons(n, n + 1));
const double = nat.map(n => n * 2);
const triple = nat.map(n => n * 3);
describe('Sequence.random', () => {

@@ -9,0 +5,0 @@ it('number', () => {

import {Sequence} from '../../core';
import {compose} from '../../../../compose';

@@ -4,0 +3,0 @@ export default class <T, S> extends Sequence<T, S> {

@@ -29,6 +29,6 @@ import {Sequence} from '../../../sequence';

assert.deepStrictEqual(
Sequence.union((a, b) => a - b, [double.dropWhile(n => n < 6).until(n => n === 12), triple]).take(8).read(),
Sequence.union((a, b) => a - b, [double.dropWhile(n => n < 6).takeUntil(n => n === 12), triple]).take(8).read(),
[0, 3, 6, 8, 9, 10, 12, 15]);
assert.deepStrictEqual(
Sequence.union((a, b) => a - b, [triple, double.dropWhile(n => n < 6).until(n => n === 12)]).take(8).read(),
Sequence.union((a, b) => a - b, [triple, double.dropWhile(n => n < 6).takeUntil(n => n === 12)]).take(8).read(),
[0, 3, 6, 8, 9, 10, 12, 15]);

@@ -35,0 +35,0 @@ });

import {Sequence} from '../../core';
import {compose} from '../../../../compose';

@@ -7,24 +6,24 @@ export default class <T, S> extends Sequence<T, S> {

return ss.reduce((a, b) => union(cmp, a, b));
}
}
function union<T>(cmp: (a: T, b: T) => number, a: Sequence<T, any>, b: Sequence<T, any>): Sequence<T, [Sequence.Iterator<T>, Sequence.Iterator<T>]> {
return new Sequence<T, [Sequence.Iterator<T>, Sequence.Iterator<T>]>(([ai, bi] = [() => a.iterate(), () => b.iterate()], cons) =>
function union<T>(cmp: (a: T, b: T) => number, a: Sequence<T, any>, b: Sequence<T, any>): Sequence<T, [Sequence.Iterator<T>, Sequence.Iterator<T>]> {
return new Sequence<T, [Sequence.Iterator<T>, Sequence.Iterator<T>]>(([ai, bi] = [() => a.iterate(), () => b.iterate()], cons) =>
Sequence.Iterator.when(
ai(),
() =>
Sequence.Iterator.when(
ai(),
() =>
Sequence.Iterator.when(
bi(),
() => cons(),
bt => cons(Sequence.Thunk.value(bt), [Sequence.Iterator.done, Sequence.Thunk.iterator(bt)])),
at =>
Sequence.Iterator.when(
bi(),
() => cons(Sequence.Thunk.value(at), [Sequence.Thunk.iterator(at), Sequence.Iterator.done]),
bt => {
const result = cmp(Sequence.Thunk.value(at), Sequence.Thunk.value(bt));
if (result < 0) return cons(Sequence.Thunk.value(at), [Sequence.Thunk.iterator(at), () => bt]);
if (result > 0) return cons(Sequence.Thunk.value(bt), [() => at, Sequence.Thunk.iterator(bt)]);
return cons(Sequence.Thunk.value(at), [Sequence.Thunk.iterator(at), Sequence.Thunk.iterator(bt)]);
})));
}
}
bi(),
() => cons(),
bt => cons(Sequence.Thunk.value(bt), [Sequence.Iterator.done, Sequence.Thunk.iterator(bt)])),
at =>
Sequence.Iterator.when(
bi(),
() => cons(Sequence.Thunk.value(at), [Sequence.Thunk.iterator(at), Sequence.Iterator.done]),
bt => {
const result = cmp(Sequence.Thunk.value(at), Sequence.Thunk.value(bt));
if (result < 0) return cons(Sequence.Thunk.value(at), [Sequence.Thunk.iterator(at), bi]);
if (result > 0) return cons(Sequence.Thunk.value(bt), [ai, Sequence.Thunk.iterator(bt)]);
return cons(Sequence.Thunk.value(at), [Sequence.Thunk.iterator(at), Sequence.Thunk.iterator(bt)]);
})));
}
import {Sequence} from '../../../sequence';
describe('Unit: lib/monad/sequence/member/static/write', () => {
const nat = new Sequence<number, number>((n = 0, cons) => cons(n, n + 1));
const double = nat.map(n => n * 2);
const triple = nat.map(n => n * 3);
describe('Sequence.write', () => {

@@ -9,0 +5,0 @@ it('array', () => {

import {Sequence} from '../../core';
import {compose} from '../../../../compose';

@@ -4,0 +3,0 @@ export default class <T, S> extends Sequence<T, S> {

@@ -5,4 +5,2 @@ import {Sequence} from '../../../sequence';

const nat = new Sequence<number, number>((n = 0, cons) => cons(n, n + 1));
const double = nat.map(n => n * 2);
const triple = nat.map(n => n * 3);

@@ -9,0 +7,0 @@ describe('Sequence.zip', () => {

import {Sequence} from '../../core';
import {compose} from '../../../../compose';

@@ -4,0 +3,0 @@ export default class <T, S> extends Sequence<T, S> {

@@ -78,3 +78,3 @@ import {Observer, Publisher} from 'spica';

void this.emit(namespace, <D>data, (_, r) => results = r);
assert(results instanceof Array);
assert(Array.isArray(results));
return results;

@@ -81,0 +81,0 @@ }

@@ -85,3 +85,3 @@ /**

export class Sequence<T, S> extends Monad<T> {
static from<T>(as: T[]): Sequence<T, T>;
static from<T>(as: T[]): Sequence<T, number>;
static write<T>(as: T[]): Sequence<T, T[]>;

@@ -92,7 +92,10 @@ static random(): Sequence<number, number>;

static zip<T, U>(a: Sequence<T, any>, b: Sequence<U, any>): Sequence<[T, U], [Sequence.Iterator<T>, Sequence.Iterator<U>]>;
static concat<T>(ss: Sequence<T, any>[]): Sequence<T, [Sequence.Iterator<T>, Sequence.Iterator<T>]>;
static concat<T>(ss: Sequence<Sequence<T, any>, any>): Sequence<T, [Sequence.Iterator<T[]>, Sequence.Iterator<T>]>;
static concat<T>(ss: Sequence<T[], any>): Sequence<T, [Sequence.Iterator<T[]>, Sequence.Iterator<T>]>;
static union<T>(cmp: (a: T, b: T) => number, ss: Sequence<T, any>[]): Sequence<T, [Sequence.Iterator<T>, Sequence.Iterator<T>]>;
static intersect<T>(cmp: (a: T, b: T) => number, ss: Sequence<T, any>[]): Sequence<T, [Sequence.Iterator<T>, Sequence.Iterator<T>]>;
constructor(cons: (p: S, cons: (value?: T, next?: S) => Sequence.Data<T, S>) => Sequence.Data<T, S>);
iterate(): Sequence.Thunk<T>;
read(): T[];
iterate(): Sequence.Thunk<T>;
fmap<U>(f: (p: T) => U): Sequence<U, Sequence.Iterator<T>>;

@@ -107,5 +110,6 @@ bind<U>(f: (p: T) => Sequence<U, any>): Sequence<U, [Sequence.Iterator<T>, Sequence.Iterator<U>]>;

drop(n: number): Sequence<T, Sequence.Iterator<T>>;
takeWhile(f: (p: T, i: number) => boolean): Sequence<T, Sequence.Iterator<T>>;
dropWhile(f: (p: T, i: number) => boolean): Sequence<T, Sequence.Iterator<T>>;
until(f: (p: T) => boolean): Sequence<T, Sequence.Iterator<T>>;
takeWhile(f: (p: T) => boolean): Sequence<T, Sequence.Iterator<T>>;
dropWhile(f: (p: T) => boolean): Sequence<T, Sequence.Iterator<T>>;
takeUntil(f: (p: T) => boolean): Sequence<T, Sequence.Iterator<T>>;
dropUntil(f: (p: T) => boolean): Sequence<T, Sequence.Iterator<T>>;
memoize(memory?: Map<number, Sequence.Data<T, S>>): Sequence<T, S>;

@@ -112,0 +116,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