arch-stream
Advanced tools
Comparing version 0.0.60 to 0.0.61
@@ -1,2 +0,2 @@ | ||
/*! arch-stream v0.0.60 https://github.com/falsandtru/arch-stream | (c) 2015, falsandtru | MIT Licence */ | ||
/*! arch-stream v0.0.61 https://github.com/falsandtru/arch-stream | (c) 2015, falsandtru | MIT Licence */ | ||
/*! Included: Fingerprintjs2 https://github.com/Valve/fingerprintjs2 | (c) 2015 Valentin Vasilyev (valentin.vasilyev@outlook.com) | MIT License. */ | ||
@@ -907,3 +907,3 @@ /*! Link: MIT Lisence http://www.opensource.org/licenses/mit-license.php */ | ||
if (separator_ === void 0) { | ||
separator_ = RegNothing; | ||
separator_ = ''; | ||
} | ||
@@ -923,3 +923,3 @@ this.separator_ = separator_; | ||
void this.throwTypeErrorIfInvalidSubscriber_(type, subscriber); | ||
void this.seek_(this.map_, type.toString().split(this.separator_)).list.push([ | ||
void this.seek_(this.map_, type.toString().split(this.separator_ || RegNothing)).list.push([ | ||
subscriber, | ||
@@ -929,3 +929,2 @@ equals, | ||
]); | ||
void this.cache_.delete(type); | ||
void this.drain_(type); | ||
@@ -938,3 +937,3 @@ return this; | ||
void this.cache_.delete(type); | ||
void this.seek_(this.map_, type.toString().split(this.separator_)).list.some(function (_a, i, list) { | ||
void this.seek_(this.map_, type.toString().split(this.separator_ || RegNothing)).list.some(function (_a, i, list) { | ||
var equals = _a[1]; | ||
@@ -959,3 +958,3 @@ if (!equals(subscriber)) | ||
void this.cache_.delete(type); | ||
var set = this.seek_(this.map_, type.toString().split(this.separator_)); | ||
var set = this.seek_(this.map_, type.toString().split(this.separator_ || RegNothing)); | ||
set.map = Object.create(null); | ||
@@ -980,3 +979,3 @@ set.list = []; | ||
}; | ||
Observable.prototype.aggregate = function (type, accumulator) { | ||
Observable.prototype.absorb = function (type, accumulator) { | ||
void this.emit(type, accumulator); | ||
@@ -1010,3 +1009,3 @@ return accumulator; | ||
while (queue.length > 0) { | ||
var collection = this.cache_.get(type) || this.cache_.set(type, this.collect_(this.seek_(this.map_, type.toString().split(this.separator_)))); | ||
var collection = this.cache_.get(type) || this.cache_.set(type, this.collect_(this.seek_(this.map_, type.toString().split(this.separator_ || RegNothing)))); | ||
var q = queue.shift(); | ||
@@ -1042,5 +1041,7 @@ try { | ||
case 1: { | ||
void this.cache_.delete(names.join(this.separator_)); | ||
return namespace(map, names.shift()); | ||
} | ||
default: { | ||
void this.cache_.delete(names.join(this.separator_)); | ||
return this.seek_(namespace(map, names.shift()).map, names); | ||
@@ -1047,0 +1048,0 @@ } |
@@ -1,4 +0,4 @@ | ||
/*! arch-stream v0.0.60 https://github.com/falsandtru/arch-stream | (c) 2015, falsandtru | MIT Licence */ | ||
/*! arch-stream v0.0.61 https://github.com/falsandtru/arch-stream | (c) 2015, falsandtru | MIT Licence */ | ||
/*! Included: Fingerprintjs2 https://github.com/Valve/fingerprintjs2 | (c) 2015 Valentin Vasilyev (valentin.vasilyev@outlook.com) | MIT License. */ | ||
/*! Link: MIT Lisence http://www.opensource.org/licenses/mit-license.php */ | ||
define="function"==typeof define&&define.amd?define:function(){"use strict";var t="arch-stream",e={};return function r(i,n,o){return o?void o.apply(this,n.map(function(t){switch(t){case"require":return"function"==typeof require?require:void 0;case"exports":return-1===i.indexOf("/")?e[i]="undefined"==typeof exports?window[i]=window[i]||{}:exports:e[i]=e.hasOwnProperty(i)?e[i]:{};default:return".d"===t.slice(-2)&&{}||e.hasOwnProperty(t)&&e[t]||"function"==typeof require&&require(t)||window[t]}})):void r(t,i,n)}}();var __extends=this&&this.__extends||function(t,e){function r(){this.constructor=t}for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)};define("src/lib/thenable",["require","exports"],function(t,e){"use strict";function r(t){return!!t&&"object"==typeof t&&void 0!==t.then}e.isThenable=r}),define("src/lib/tick",["require","exports"],function(t,e){"use strict";var r;!function(t){function e(t){void n.push(t),void i()}function r(){void i(),void--o;for(var t=n.length;t-- >0;)void n.shift()()}function i(){if(0!==n.length)if(s)for(;2>o;)void Promise.resolve().then(r),void++o;else for(;o<u.length;)void setTimeout(r,u[o%u.length]),void++o}t.queue=e;var n=[],o=0,s="function"==typeof Promise,u=[0,4,10,20,25].reverse()}(r||(r={}));var i=Function("return typeof process === 'object' && typeof window !== 'object'")();e.Tick=i?Function("return fn => process.nextTick(fn)")():r.queue}),define("src/lib/message",["require","exports","src/lib/thenable","src/lib/tick"],function(t,e,r,i){"use strict";function n(t){return t}var o=Object.create(null),s=function(){function t(t,e){void 0===e&&(e=n),this.parent=t,this.listener=e,this.memory_=o,this.collection_=[],this.transform_=!1,this.listeners_=[],t&&(this.parent.child_=this)}return t.prototype.root=function(){return this.parent?this.parent.root():this},t.prototype.collect_=function(){if(this.collection_.length>0)return this.collection_;var t=this,e=[];do void e.push(t);while(t=t.child_);return this.collection_=e},t.prototype.transport_=function(t,e){function i(t,i,u){function c(t){o=!0,i=u?t:i,s&&n.child_&&void n.child_.send(i,e)}return t.every(function(t){n=t,n.memory_=i;var e=n.listener(n.memory_);return r.isThenable(e)?(o=!1,void e.then(c,c),o):(i=u?e:i,!0)})}var n,o=!1,s=!1,u=i(this.collect_(),t,this.transform_);s=!0,u&&"function"==typeof e&&void e(t)},t.prototype.clone=function(){function e(r){return r.parent?new t(e(r.parent),r.listener):new t(void 0,r.listener)}return e(this)},t.prototype.connect=function(t){return this.parent.child_=t,t.parent=this.parent,this},t.prototype.send=function(t,e,r){switch(!0){case"function"==typeof e:return this.send(t,!1,e);case e===!0:return void i.Tick(this.transport_.bind(this,t,r)),this;case e===!1:default:return void this.transport_(t,r),this}},t.prototype.recv=function(e){var r=new t(this);return this.listener=e,this.collection_=[],this.memory_!==o&&void this.send(this.memory_),r},t.prototype.trans=function(t){return this.transform_=!0,this.recv(t)},t.prototype.then=function(e,r){var i=this,o=new t;return this.child_=void 0,this.listener=n,this.listeners_.push(o),this.trans(function(t){var e=i.listeners_;i.listeners_=[],function r(){try{for(;e.length>0;)e.shift().send(t)}catch(i){void console.error(i),void r()}}()}),o.trans(e)},t}();e.Message=s}),define("src/lib/throttle",["require","exports"],function(t,e){"use strict";var r=function(){function t(){this.queue_=[],this.processing_=[],this.limit_=1/0,this.volume_=1/0}return t.prototype.isDrainable_=function(){return this.processing_.length<this.volume_},t.prototype.discharger_=function(t,e){},t.prototype.flow=function(t,e,r){void 0===e&&(e=1/0),void 0===r&&(r=function(){return null}),this.volume_=t,this.limit_=e,this.discharger_=r},t.prototype.enqueue=function(t){if(this.isDrainable_())return void this.processing_.push(t),void this.resolver_(t),!0;this.queue_.push(t);do void this.discharger_(this.queue_,this.processing_);while(this.processing_.length+this.queue_.length>this.limit_);return!1},t.prototype.dequeue=function(t){var e=this.processing_.indexOf(t);e>0?void this.processing_.splice(e,1):void this.processing_.shift(),this.queue_.length>0&&this.isDrainable_()&&void this.enqueue(this.queue_.shift())},t.prototype.register=function(t){this.resolver_=t},t}();Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r}),define("src/lib/noop",["require","exports"],function(t,e){"use strict";function r(){}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r}),define("src/stream/modular",["require","exports","src/lib/throttle","src/lib/tick","src/lib/noop"],function(t,e,r,i,n){"use strict";var o=function(){function t(t,e,r){var n=this;void 0===e&&(e=1),this.procs=t,this.count=e,this.branched=r,this.read=this.read.bind(this),this.write=this.write.bind(this),void i.Tick(function(t){return 0<n.count&&n.count<1/0&&n.throwCountDeprivedError()})}return t.prototype.compose_=function(){this.last_=this.procs.map(function(t){return t.clone()}).reduce(function(t,e){return t.connect(e.root())&&e}),this.first_=this.last_.root()},t.prototype.wrap=function(t){function e(e){return function(r){return t(r,e)}}void this.compose_();var r=this.last_;do r=r.parent,r.listener=e(r.listener);while(r.parent);return this.procs=[this.last_],this},t.prototype.read_=function(t){void--this.count,this.count<0&&void this.throwCountExceededError(),void this.compose_(),void this.last_.recv(t)},t.prototype.read=function(t){var e=this;void 0===t&&(t=n["default"]);var r=!1;return void this.read_(function(n){e.flow_&&void i.Tick(function(){return void e.flow_.dequeue(n)}),r&&void t(n)}),r=!0,this},t.prototype.write_=function(t,e){void this.first_.send(t,e)},t.prototype.write=function(t,e){return this.flow_?void this.flow_.enqueue(t):void this.write_(t,e),this},t.prototype.flow=function(t,e,i){var n=this;return void 0===e&&(e=1/0),this.flow_=new r["default"],void this.flow_.flow(t,e,i),void this.flow_.register(function(t){return n.write_(t)}),this},t.prototype.throwCountExceededError=function(){throw new Error("ArchStream: Import and read counts are exeeded.")},t.prototype.throwCountDeprivedError=function(){throw this.count=0,new Error("ArchStream: Import and read counts are not deprived.")},t}();e.ModularStream=o}),define("src/stream/compose",["require","exports","src/stream/modular"],function(t,e,r){"use strict";var i=function(){function t(t){this.extract_=t,this.procs_=[],this.branched_=0}return t.prototype.register=function(t){var e=this.procs_.length;return void t.reduceRight(function(t,r,i){return t[i+e]=r,t},this.procs_),this},t.prototype["import"]=function(e,r){var i=this;return void this.throwErrorIfNotImportable_(e,r),r&&(e=(new t)["import"](e)["export"]().wrap(function(t,e){return i.extract_(t)instanceof r?e(t):0})),void--e.count,e.count<0&&void e.throwCountExceededError(),void this.register(e.procs),this},t.prototype["export"]=function(t){return new r.ModularStream(this.procs_,t,this.branched_)},t.prototype.throwErrorIfNotImportable_=function(t,e){e?((t.branched>0||this.branched_>1)&&(void--t.count,void this.throwConditionalImportError()),this.branched_=1):(t.branched>0&&this.branched_>0&&(void--t.count,void this.throwConditionalImportError()),this.branched_=t.branched>0?t.branched+1:t.branched)},t.prototype.throwConditionalImportError=function(){throw new Error("ArchStream: Conditional import cannot call from different streams.")},t}();e.ComposeStream=i}),define("src/stream/transform",["require","exports","src/lib/message","src/stream/compose","src/stream/modular"],function(t,e,r,i,n){"use strict";var o=function(){function t(t,e){var i=this;void 0===e&&(e=new r.Message),this.parent_=t,this.message_=e,this.proxies_=[],this.parent_&&void this.parent_.proxies_.reduce(function(t,e){return i.proxy(function(){return e})},void 0)}return t.prototype.pipe=function(e){return new t(this,this.message_.recv(e))},t.prototype["import"]=function(t,e){return t instanceof n.ModularStream?(new i.ComposeStream)["import"](t,e):new i.ComposeStream(t)},t.prototype["export"]=function(t){return(new i.ComposeStream).register([this.message_])["export"](t)},t.prototype.proxy=function(e){function r(e,i,n){function o(t){return Array.isArray(t)?t:[t]}var s=e.proxies_.filter(function(t){return"function"==typeof t[i]}).reduce(function(t,e){return o(e[i].apply(void 0,t)||t)},n),u="pipe";switch(i){case u:return t.prototype[i].call(e,s[0]);case"import":throw new Error("ArchStream: `import` method cannot extend by proxy.");case"export":return(c=t.prototype[i]).call.apply(c,[r(e,u,s)].concat(n));default:return r(e,u,s)}var c}var i=this,n="function"==typeof e?e():e;return this.proxies_.push(n),void Object.keys(n).filter(function(t){return t.length>0&&"_"!==t[0]&&"_"!==t[t.length-1]}).filter(function(t){return"function"==typeof n[t]}).reduce(function(t,e){return i[e]=function(){for(var t=[],n=0;n<arguments.length;n++)t[n-0]=arguments[n];return r(i,e,t)}},void 0),this},t}();e.ArchStream=o}),define("src/proxy/case",["require","exports"],function(t,e){"use strict";function r(t,e){function r(){for(var t=[],r=0;r<arguments.length;r++)t[r-0]=arguments[r];return function(r){var n=+i[e(r)+""];n>-1&&n<t.length&&t[n](r)}}var i=Object.create(null);return void t.reduce(function(t,e,r){return i[e+""]=r},void 0),function(t){return{pipe:r}}}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r}),define("src/proxy/hook",["require","exports","src/lib/noop"],function(t,e,r){"use strict";function i(t){function e(){for(var t=[],e=0;e<arguments.length;e++)t[e-0]=arguments[e];return t.map(function(t){return function(e){n(e),t(e),s(e)}})}var i=t.pre,n=void 0===i?r["default"]:i,o=t.post,s=void 0===o?r["default"]:o;return function(t){return{pipe:e}}}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=i}),define("src/proxy/responsibility",["require","exports","src/lib/noop"],function(t,e,r){"use strict";function i(){function t(t,i){return e.pipe=function(){for(var e=[],r=0;r<arguments.length;r++)e[r-0]=arguments[r];return e.map(function(e){return function(r){if(!(i(r)instanceof t))throw TypeError("ArchStream: ResponsibilityProxy: Uncovered internal entity.\n "+i(r).constructor);e(r)}})},e["export"]=function(){return function(e){i(e)instanceof t&&void Object.freeze(i(e))}},r["default"]}var e;return function(r){return e={rule:t}}}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=i}),define("src/lib/proxy",["require","exports","src/proxy/case","src/proxy/hook","src/proxy/responsibility"],function(t,e,r,i,n){"use strict";e.Proxy={Case:r["default"],Hook:i["default"],Responsibility:n["default"]}}),define("src/lib/timer",["require","exports"],function(t,e){"use strict";function r(t){var e=t.begin,i=void 0===e?0:e,n=t.end,o=void 0===n?864e5:n,s=t.step,u=void 0===s?function(t){return 3*(t||1)}:s,c=t.precond,a=void 0===c?function(){return!0}:c,h=t.task,p=void 0===h?function(){}:h,f=t.postcond,d=void 0===f?function(){return!0}:f,l=t.complete,v=void 0===l?function(){return 0}:l,_=t.error,y=void 0===_?function(){return 0}:_,m=t.timeout,b=void 0===m?function(){return 0}:m;i=0>i?-i:i,void setTimeout(function(){try{if(a()){var t=p();if(d())return void v(t)}}catch(e){return void y(e)}var n=u(i);return n>o?void b():void void r({precond:a,task:p,postcond:d,complete:v,timeout:b,begin:i+n,end:o-n,step:u})},i)}e.Timer=r}),define("src/lib/fingerprint",["require","exports"],function(t,e){"use strict";function r(){return n(o([s(window.navigator),s(window.screen),s((new Date).getTimezoneOffset()),s(u())].join()))}function i(){return n(o([s(process)].join()))}function n(t){return t.split("").reduce(function(t,e,r){return(+e*r+t)%1e9||t-+e},0)}function o(t){return t.split("").map(function(t){return t.charCodeAt(0)}).join("")}function s(t,e){if(void 0===e&&(e=5),e>0&&t&&"object"==typeof t){var r="{";for(var i in t)r+='"'+i+'": '+s(t[i],e-1)+",";return r+="}"}return!t||t.toString?'"'+t+'"':'"'+Object.prototype.toString.call(t)+'"'}function u(){var t=[],e=document.createElement("canvas");e.width=2e3,e.height=200,e.style.display="inline";var r=e.getContext("2d");return r.rect(0,0,10,10),r.rect(2,2,6,6),t.push("canvas winding:"+(r.isPointInPath(5,5,"evenodd")===!1?"yes":"no")),r.textBaseline="alphabetic",r.fillStyle="#f60",r.fillRect(125,1,62,20),r.fillStyle="#069",r.font="11pt no-real-font-123",r.fillText("Cwm fjordbank glyphs vext quiz, 😃",2,15),r.fillStyle="rgba(102, 204, 0, 0.7)",r.font="18pt Arial",r.fillText("Cwm fjordbank glyphs vext quiz, 😃",4,45),r.globalCompositeOperation="multiply",r.fillStyle="rgb(255,0,255)",r.beginPath(),r.arc(50,50,50,0,2*Math.PI,!0),r.closePath(),r.fill(),r.fillStyle="rgb(0,255,255)",r.beginPath(),r.arc(100,50,50,0,2*Math.PI,!0),r.closePath(),r.fill(),r.fillStyle="rgb(255,255,0)",r.beginPath(),r.arc(75,100,50,0,2*Math.PI,!0),r.closePath(),r.fill(),r.fillStyle="rgb(255,0,255)",r.arc(75,75,75,0,2*Math.PI,!0),r.arc(75,75,25,0,2*Math.PI,!0),r.fill("evenodd"),t.push("canvas fp:"+e.toDataURL()),t.join("~")}e.FINGERPRINT="object"==typeof window?r():i(),e.browser=r,e.server=i,e.compress=n,e.str2digit=o,e.stringify=s}),define("src/lib/uuid",["require","exports","src/lib/fingerprint"],function(t,e,r){"use strict";function i(t){void 0===t&&(t=Date.now());var e=parseInt(o+r.compress(r.str2digit(r.stringify(t)))+"",10)||0;if(16>e||e>1e15)throw new Error("ArchStream: uuid: Invalid uuid dynamic seed.\n "+t);return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(s,function(t){var r=Math.random()*e%16|0,i="x"==t?r:3&r|8;return i.toString(16)}).toLowerCase()}var n=r.compress(r.str2digit(r.stringify(Date.now()))),o=parseInt((r.FINGERPRINT+n)*Math.random()+"",10);if(!o||"number"!=typeof o||100>o||o>1e14)throw new Error("ArchStream: uuid: Invalid uuid static seed.\n "+r.FINGERPRINT+" + "+n);var s=/[xy]/g;e.v4=i}),define("src/lib/map",["require","exports"],function(t,e){"use strict";var r=function(){function t(){this.map_=Object.create(null),this.type_="",void this.reset_()}return t.prototype.get=function(t){return this.map_[t+""]},t.prototype.set=function(t,e){return this.type_||(this.type_=typeof t),void this.reset_(),this.map_[t+""]=e},t.prototype.has=function(t){return!!this.map_[t+""]||t+""in this.map_},t.prototype["delete"]=function(t){return void this.reset_(),delete this.map_[t+""],this},t.prototype.clear=function(){return void this.reset_(),this.map_=Object.create(null),this},t.prototype.reset_=function(){this.size_=NaN,this.entries_=void 0},Object.defineProperty(t.prototype,"size",{get:function(){return this.size_>=0?this.size_:this.size_=Object.keys(this.map_).length},enumerable:!0,configurable:!0}),t.prototype.entries=function(){var t=this;return this.entries_?this.entries_:this.entries_=Object.keys(this.map_).map(function(e){return["number"===t.type_?+e:e,t.map_[e]]})},t}();e.Map=r}),define("src/lib/observable",["require","exports","src/lib/map","src/lib/noop"],function(t,e,r,i){"use strict";var n=/$^/,o=function(){function t(t){void 0===t&&(t=n),this.separator_=t,this.map_=Object.create(null),this.cache_=new r.Map,this.emitId_=0,this.emitQueue_=[]}return t.prototype.on=function(t,e,r){return void 0===r&&(r=function(t){return t===e}),void this.throwTypeErrorIfInvalidSubscriber_(t,e),void this.seek_(this.map_,t.toString().split(this.separator_)).list.push([e,r,this.emitId_]),void this.cache_["delete"](t),void this.drain_(t),this},t.prototype.off=function(t,e){switch(typeof e){case"function":return void this.cache_["delete"](t),void this.seek_(this.map_,t.toString().split(this.separator_)).list.some(function(t,r,i){var n=t[1];if(!n(e))return!1;switch(r){case 0:return!void i.shift();case i.length-1:return!void i.pop();default:return!void i.splice(r,1)}}),this;case"undefined":void this.cache_["delete"](t);var r=this.seek_(this.map_,t.toString().split(this.separator_));return r.map=Object.create(null),r.list=[],this;default:throw this.throwTypeErrorIfInvalidSubscriber_(t,e)}},t.prototype.once=function(t,e){var r=this;return void this.throwTypeErrorIfInvalidSubscriber_(t,e),this.on(t,function(i){void r.off(t,e),void e(i)},function(t){return t===e})},t.prototype.aggregate=function(t,e){return void this.emit(t,e),e},t.prototype.emit=function(t,e,r){return void 0===e&&(e=i["default"]),void 0===r&&(r=i["default"]),t instanceof Object?this.emit_(t.type,t,e):this.emit_(t,e,r)},t.prototype.emit_=function(t,e,r){void 0===r&&(r=i["default"]);var n=this.emitQueue_;return void n.push([++this.emitId_,e,r]),void this.drain_(t),this},t.prototype.drain_=function(t){for(var e=this.emitQueue_;e.length>0;){var r=this.cache_.get(t)||this.cache_.set(t,this.collect_(this.seek_(this.map_,t.toString().split(this.separator_)))),i=e.shift();try{void r.reduce(function(t,e){var r=t[0],i=t[1],n=e[0],o=e[2];return o>=r?t:(e[2]=r,void n(i),t)},i)}catch(n){void e.unshift(i),n instanceof s||void console.error(n);continue}var o=i[1],u=i[2];void u(o)}return this.resetEmitIdIfPossible_(),this},t.prototype.seek_=function(t,e){function r(t,e){return t[e]&&t[e].map?t[e]:t[e]={map:Object.create(null),list:[]}}switch(e.length){case 0:throw new Error("ArchStream: Observable: Cannot use empty string for event type and namespace.");case 1:return r(t,e.shift());default:return this.seek_(r(t,e.shift()).map,e)}},t.prototype.collect_=function(t){var e=this,r=t.map,i=t.list;return Object.keys(r).reduce(function(t,i){return void t.unshift.apply(t,e.collect_(r[i])),0===t.length&&delete r[i],t},i.slice())},t.prototype.resetEmitIdIfPossible_=function(){return this.emitId_<5e8||this.emitQueue_.length>0?this:(void this.collect_({map:this.map_,list:[]}).reduce(function(t,e){return e[2]=t},this.emitId_=0),this)},t.prototype.throwTypeErrorIfInvalidSubscriber_=function(t,e){switch(typeof e){case"function":return;default:throw new TypeError("ArchStream: Observable: Invalid subscriber.\n "+e)}},t}();e.Observable=o;var s=function(t){function e(){t.apply(this,arguments)}return __extends(e,t),e}(Error);e.TestError=s}),define("src/lib/set",["require","exports","src/lib/map"],function(t,e,r){"use strict";var i=function(){function t(t){this.replacer_=t,this.map_=new r.Map}return t.prototype.get=function(t){return this.map_.get(t)},t.prototype.set=function(t,e){if(!this.has(t))return this.map_.set(t,e);if(!this.replacer_)throw new Error("Cannot overwrite value of set without replacer.");return this.map_.set(t,this.replacer_(this.get(t),e))},t.prototype.has=function(t){return this.map_.has(t)},t.prototype["delete"]=function(t){return void this.map_["delete"](t),this},t.prototype.clear=function(){return void this.map_.clear(),this},Object.defineProperty(t.prototype,"size",{get:function(){return this.map_.size},enumerable:!0,configurable:!0}),t.prototype.entries=function(){return this.map_.entries()},t}();e.Set=i}),define("src/lib/maybe.impl",["require","exports"],function(t,e){"use strict";var r=function(){function t(t){this.thunk_=t}return t.prototype.bind=function(e){var r=this;return new t(function(){var o=r.thunk_();switch(!0){case o instanceof i:return e(o.extract());case o instanceof n:return o;case o instanceof t:return o.bind(e);default:throw new TypeError("ArchStream: Maybe: Invalid monad value.\n "+o)}})},t.prototype.extract=function(t){return this.thunk_().extract(t)},t}();e.Maybe=r;var i=function(t){function e(e){t.call(this),this.val_=e}return __extends(e,t),e.prototype.bind=function(t){var e=this;return new r(function(){return e}).bind(t)},e.prototype.extract=function(t){return this.val_},e}(r);e.Just=i;var n=function(t){function e(){t.apply(this,arguments)}return __extends(e,t),e.prototype.bind=function(t){return this},e.prototype.extract=function(t){return t},e}(r);e.Nothing=n}),define("src/lib/maybe",["require","exports","src/lib/maybe.impl"],function(t,e,r){"use strict";var i;!function(t){function e(t){return new r.Just(t)}t.Just=e,t.Nothing=new r.Nothing,t.Return=e}(i=e.Maybe||(e.Maybe={})),e.Just=i.Just,e.Nothing=i.Nothing,e.Return=e.Just}),define("src/lib/either.impl",["require","exports"],function(t,e){"use strict";var r=function(){function t(t){this.thunk_=t}return t.prototype.bind=function(e){var r=this;return new t(function(){var o=r.thunk_();switch(!0){case o instanceof i:return o;case o instanceof n:return e(o.extract());case o instanceof t:return o.bind(e);default:throw new TypeError("ArchStream: Either: Invalid monad value.\n "+o)}})},t.prototype.extract=function(t){return this.thunk_().extract(t)},t}();e.Either=r;var i=function(t){function e(e){t.call(this),this.val_=e}return __extends(e,t),e.prototype.bind=function(t){return this},e.prototype.extract=function(t){return t?t(this.val_):this.val_},e}(r);e.Left=i;var n=function(t){function e(e){t.call(this),this.val_=e}return __extends(e,t),e.prototype.bind=function(t){var e=this;return new r(function(){return e}).bind(t)},e.prototype.extract=function(t){return this.val_},e}(r);e.Right=n}),define("src/lib/either",["require","exports","src/lib/either.impl"],function(t,e,r){"use strict";var i;!function(t){function e(t){return new r.Left(t)}function i(t){return new r.Right(t)}t.Left=e,t.Right=i,t.Return=i}(i=e.Either||(e.Either={})),e.Left=i.Left,e.Right=i.Right,e.Return=i.Return}),define("src/export",["require","exports","src/stream/transform","src/lib/message","src/lib/proxy","src/lib/proxy","src/lib/tick","src/lib/timer","src/lib/fingerprint","src/lib/uuid","src/lib/observable","src/lib/map","src/lib/set","src/lib/maybe","src/lib/either","./typings/arch-stream.d"],function(t,e,r,i,n,o,s,u,c,a,h,p,f,d,l){"use strict";function v(){return new r.ArchStream}function _(){return new i.Message}e.Proxy=o.Proxy,e.Tick=s.Tick,e.Timer=u.Timer,e.FINGERPRINT=c.FINGERPRINT,e.uuid=a.v4,e.Observable=h.Observable,e.Map=p.Map,e.Set=f.Set,e.Maybe=d.Maybe,e.Just=d.Just,e.Nothing=d.Nothing,e.Either=l.Either,e.Left=l.Left,e.Right=l.Right;var y={Msg:_,Proxy:n.Proxy};Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=v;var v;!function(t){t.Msg=y.Msg,t.Proxy=y.Proxy}(v||(v={})),e.Msg=_}),define("arch-stream",["require","exports","src/export","src/export"],function(t,e,r,i){"use strict";function n(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}n(r),e["default"]=i["default"]}); | ||
define="function"==typeof define&&define.amd?define:function(){"use strict";var t="arch-stream",e={};return function r(i,n,o){return o?void o.apply(this,n.map(function(t){switch(t){case"require":return"function"==typeof require?require:void 0;case"exports":return-1===i.indexOf("/")?e[i]="undefined"==typeof exports?window[i]=window[i]||{}:exports:e[i]=e.hasOwnProperty(i)?e[i]:{};default:return".d"===t.slice(-2)&&{}||e.hasOwnProperty(t)&&e[t]||"function"==typeof require&&require(t)||window[t]}})):void r(t,i,n)}}();var __extends=this&&this.__extends||function(t,e){function r(){this.constructor=t}for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)};define("src/lib/thenable",["require","exports"],function(t,e){"use strict";function r(t){return!!t&&"object"==typeof t&&void 0!==t.then}e.isThenable=r}),define("src/lib/tick",["require","exports"],function(t,e){"use strict";var r;!function(t){function e(t){void n.push(t),void i()}function r(){void i(),void--o;for(var t=n.length;t-- >0;)void n.shift()()}function i(){if(0!==n.length)if(s)for(;2>o;)void Promise.resolve().then(r),void++o;else for(;o<u.length;)void setTimeout(r,u[o%u.length]),void++o}t.queue=e;var n=[],o=0,s="function"==typeof Promise,u=[0,4,10,20,25].reverse()}(r||(r={}));var i=Function("return typeof process === 'object' && typeof window !== 'object'")();e.Tick=i?Function("return fn => process.nextTick(fn)")():r.queue}),define("src/lib/message",["require","exports","src/lib/thenable","src/lib/tick"],function(t,e,r,i){"use strict";function n(t){return t}var o=Object.create(null),s=function(){function t(t,e){void 0===e&&(e=n),this.parent=t,this.listener=e,this.memory_=o,this.collection_=[],this.transform_=!1,this.listeners_=[],t&&(this.parent.child_=this)}return t.prototype.root=function(){return this.parent?this.parent.root():this},t.prototype.collect_=function(){if(this.collection_.length>0)return this.collection_;var t=this,e=[];do void e.push(t);while(t=t.child_);return this.collection_=e},t.prototype.transport_=function(t,e){function i(t,i,u){function c(t){o=!0,i=u?t:i,s&&n.child_&&void n.child_.send(i,e)}return t.every(function(t){n=t,n.memory_=i;var e=n.listener(n.memory_);return r.isThenable(e)?(o=!1,void e.then(c,c),o):(i=u?e:i,!0)})}var n,o=!1,s=!1,u=i(this.collect_(),t,this.transform_);s=!0,u&&"function"==typeof e&&void e(t)},t.prototype.clone=function(){function e(r){return r.parent?new t(e(r.parent),r.listener):new t(void 0,r.listener)}return e(this)},t.prototype.connect=function(t){return this.parent.child_=t,t.parent=this.parent,this},t.prototype.send=function(t,e,r){switch(!0){case"function"==typeof e:return this.send(t,!1,e);case e===!0:return void i.Tick(this.transport_.bind(this,t,r)),this;case e===!1:default:return void this.transport_(t,r),this}},t.prototype.recv=function(e){var r=new t(this);return this.listener=e,this.collection_=[],this.memory_!==o&&void this.send(this.memory_),r},t.prototype.trans=function(t){return this.transform_=!0,this.recv(t)},t.prototype.then=function(e,r){var i=this,o=new t;return this.child_=void 0,this.listener=n,this.listeners_.push(o),this.trans(function(t){var e=i.listeners_;i.listeners_=[],function r(){try{for(;e.length>0;)e.shift().send(t)}catch(i){void console.error(i),void r()}}()}),o.trans(e)},t}();e.Message=s}),define("src/lib/throttle",["require","exports"],function(t,e){"use strict";var r=function(){function t(){this.queue_=[],this.processing_=[],this.limit_=1/0,this.volume_=1/0}return t.prototype.isDrainable_=function(){return this.processing_.length<this.volume_},t.prototype.discharger_=function(t,e){},t.prototype.flow=function(t,e,r){void 0===e&&(e=1/0),void 0===r&&(r=function(){return null}),this.volume_=t,this.limit_=e,this.discharger_=r},t.prototype.enqueue=function(t){if(this.isDrainable_())return void this.processing_.push(t),void this.resolver_(t),!0;this.queue_.push(t);do void this.discharger_(this.queue_,this.processing_);while(this.processing_.length+this.queue_.length>this.limit_);return!1},t.prototype.dequeue=function(t){var e=this.processing_.indexOf(t);e>0?void this.processing_.splice(e,1):void this.processing_.shift(),this.queue_.length>0&&this.isDrainable_()&&void this.enqueue(this.queue_.shift())},t.prototype.register=function(t){this.resolver_=t},t}();Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r}),define("src/lib/noop",["require","exports"],function(t,e){"use strict";function r(){}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r}),define("src/stream/modular",["require","exports","src/lib/throttle","src/lib/tick","src/lib/noop"],function(t,e,r,i,n){"use strict";var o=function(){function t(t,e,r){var n=this;void 0===e&&(e=1),this.procs=t,this.count=e,this.branched=r,this.read=this.read.bind(this),this.write=this.write.bind(this),void i.Tick(function(t){return 0<n.count&&n.count<1/0&&n.throwCountDeprivedError()})}return t.prototype.compose_=function(){this.last_=this.procs.map(function(t){return t.clone()}).reduce(function(t,e){return t.connect(e.root())&&e}),this.first_=this.last_.root()},t.prototype.wrap=function(t){function e(e){return function(r){return t(r,e)}}void this.compose_();var r=this.last_;do r=r.parent,r.listener=e(r.listener);while(r.parent);return this.procs=[this.last_],this},t.prototype.read_=function(t){void--this.count,this.count<0&&void this.throwCountExceededError(),void this.compose_(),void this.last_.recv(t)},t.prototype.read=function(t){var e=this;void 0===t&&(t=n["default"]);var r=!1;return void this.read_(function(n){e.flow_&&void i.Tick(function(){return void e.flow_.dequeue(n)}),r&&void t(n)}),r=!0,this},t.prototype.write_=function(t,e){void this.first_.send(t,e)},t.prototype.write=function(t,e){return this.flow_?void this.flow_.enqueue(t):void this.write_(t,e),this},t.prototype.flow=function(t,e,i){var n=this;return void 0===e&&(e=1/0),this.flow_=new r["default"],void this.flow_.flow(t,e,i),void this.flow_.register(function(t){return n.write_(t)}),this},t.prototype.throwCountExceededError=function(){throw new Error("ArchStream: Import and read counts are exeeded.")},t.prototype.throwCountDeprivedError=function(){throw this.count=0,new Error("ArchStream: Import and read counts are not deprived.")},t}();e.ModularStream=o}),define("src/stream/compose",["require","exports","src/stream/modular"],function(t,e,r){"use strict";var i=function(){function t(t){this.extract_=t,this.procs_=[],this.branched_=0}return t.prototype.register=function(t){var e=this.procs_.length;return void t.reduceRight(function(t,r,i){return t[i+e]=r,t},this.procs_),this},t.prototype["import"]=function(e,r){var i=this;return void this.throwErrorIfNotImportable_(e,r),r&&(e=(new t)["import"](e)["export"]().wrap(function(t,e){return i.extract_(t)instanceof r?e(t):0})),void--e.count,e.count<0&&void e.throwCountExceededError(),void this.register(e.procs),this},t.prototype["export"]=function(t){return new r.ModularStream(this.procs_,t,this.branched_)},t.prototype.throwErrorIfNotImportable_=function(t,e){e?((t.branched>0||this.branched_>1)&&(void--t.count,void this.throwConditionalImportError()),this.branched_=1):(t.branched>0&&this.branched_>0&&(void--t.count,void this.throwConditionalImportError()),this.branched_=t.branched>0?t.branched+1:t.branched)},t.prototype.throwConditionalImportError=function(){throw new Error("ArchStream: Conditional import cannot call from different streams.")},t}();e.ComposeStream=i}),define("src/stream/transform",["require","exports","src/lib/message","src/stream/compose","src/stream/modular"],function(t,e,r,i,n){"use strict";var o=function(){function t(t,e){var i=this;void 0===e&&(e=new r.Message),this.parent_=t,this.message_=e,this.proxies_=[],this.parent_&&void this.parent_.proxies_.reduce(function(t,e){return i.proxy(function(){return e})},void 0)}return t.prototype.pipe=function(e){return new t(this,this.message_.recv(e))},t.prototype["import"]=function(t,e){return t instanceof n.ModularStream?(new i.ComposeStream)["import"](t,e):new i.ComposeStream(t)},t.prototype["export"]=function(t){return(new i.ComposeStream).register([this.message_])["export"](t)},t.prototype.proxy=function(e){function r(e,i,n){function o(t){return Array.isArray(t)?t:[t]}var s=e.proxies_.filter(function(t){return"function"==typeof t[i]}).reduce(function(t,e){return o(e[i].apply(void 0,t)||t)},n),u="pipe";switch(i){case u:return t.prototype[i].call(e,s[0]);case"import":throw new Error("ArchStream: `import` method cannot extend by proxy.");case"export":return(c=t.prototype[i]).call.apply(c,[r(e,u,s)].concat(n));default:return r(e,u,s)}var c}var i=this,n="function"==typeof e?e():e;return this.proxies_.push(n),void Object.keys(n).filter(function(t){return t.length>0&&"_"!==t[0]&&"_"!==t[t.length-1]}).filter(function(t){return"function"==typeof n[t]}).reduce(function(t,e){return i[e]=function(){for(var t=[],n=0;n<arguments.length;n++)t[n-0]=arguments[n];return r(i,e,t)}},void 0),this},t}();e.ArchStream=o}),define("src/proxy/case",["require","exports"],function(t,e){"use strict";function r(t,e){function r(){for(var t=[],r=0;r<arguments.length;r++)t[r-0]=arguments[r];return function(r){var n=+i[e(r)+""];n>-1&&n<t.length&&t[n](r)}}var i=Object.create(null);return void t.reduce(function(t,e,r){return i[e+""]=r},void 0),function(t){return{pipe:r}}}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=r}),define("src/proxy/hook",["require","exports","src/lib/noop"],function(t,e,r){"use strict";function i(t){function e(){for(var t=[],e=0;e<arguments.length;e++)t[e-0]=arguments[e];return t.map(function(t){return function(e){n(e),t(e),s(e)}})}var i=t.pre,n=void 0===i?r["default"]:i,o=t.post,s=void 0===o?r["default"]:o;return function(t){return{pipe:e}}}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=i}),define("src/proxy/responsibility",["require","exports","src/lib/noop"],function(t,e,r){"use strict";function i(){function t(t,i){return e.pipe=function(){for(var e=[],r=0;r<arguments.length;r++)e[r-0]=arguments[r];return e.map(function(e){return function(r){if(!(i(r)instanceof t))throw TypeError("ArchStream: ResponsibilityProxy: Uncovered internal entity.\n "+i(r).constructor);e(r)}})},e["export"]=function(){return function(e){i(e)instanceof t&&void Object.freeze(i(e))}},r["default"]}var e;return function(r){return e={rule:t}}}Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=i}),define("src/lib/proxy",["require","exports","src/proxy/case","src/proxy/hook","src/proxy/responsibility"],function(t,e,r,i,n){"use strict";e.Proxy={Case:r["default"],Hook:i["default"],Responsibility:n["default"]}}),define("src/lib/timer",["require","exports"],function(t,e){"use strict";function r(t){var e=t.begin,i=void 0===e?0:e,n=t.end,o=void 0===n?864e5:n,s=t.step,u=void 0===s?function(t){return 3*(t||1)}:s,c=t.precond,a=void 0===c?function(){return!0}:c,h=t.task,p=void 0===h?function(){}:h,f=t.postcond,d=void 0===f?function(){return!0}:f,l=t.complete,v=void 0===l?function(){return 0}:l,_=t.error,y=void 0===_?function(){return 0}:_,m=t.timeout,b=void 0===m?function(){return 0}:m;i=0>i?-i:i,void setTimeout(function(){try{if(a()){var t=p();if(d())return void v(t)}}catch(e){return void y(e)}var n=u(i);return n>o?void b():void void r({precond:a,task:p,postcond:d,complete:v,timeout:b,begin:i+n,end:o-n,step:u})},i)}e.Timer=r}),define("src/lib/fingerprint",["require","exports"],function(t,e){"use strict";function r(){return n(o([s(window.navigator),s(window.screen),s((new Date).getTimezoneOffset()),s(u())].join()))}function i(){return n(o([s(process)].join()))}function n(t){return t.split("").reduce(function(t,e,r){return(+e*r+t)%1e9||t-+e},0)}function o(t){return t.split("").map(function(t){return t.charCodeAt(0)}).join("")}function s(t,e){if(void 0===e&&(e=5),e>0&&t&&"object"==typeof t){var r="{";for(var i in t)r+='"'+i+'": '+s(t[i],e-1)+",";return r+="}"}return!t||t.toString?'"'+t+'"':'"'+Object.prototype.toString.call(t)+'"'}function u(){var t=[],e=document.createElement("canvas");e.width=2e3,e.height=200,e.style.display="inline";var r=e.getContext("2d");return r.rect(0,0,10,10),r.rect(2,2,6,6),t.push("canvas winding:"+(r.isPointInPath(5,5,"evenodd")===!1?"yes":"no")),r.textBaseline="alphabetic",r.fillStyle="#f60",r.fillRect(125,1,62,20),r.fillStyle="#069",r.font="11pt no-real-font-123",r.fillText("Cwm fjordbank glyphs vext quiz, 😃",2,15),r.fillStyle="rgba(102, 204, 0, 0.7)",r.font="18pt Arial",r.fillText("Cwm fjordbank glyphs vext quiz, 😃",4,45),r.globalCompositeOperation="multiply",r.fillStyle="rgb(255,0,255)",r.beginPath(),r.arc(50,50,50,0,2*Math.PI,!0),r.closePath(),r.fill(),r.fillStyle="rgb(0,255,255)",r.beginPath(),r.arc(100,50,50,0,2*Math.PI,!0),r.closePath(),r.fill(),r.fillStyle="rgb(255,255,0)",r.beginPath(),r.arc(75,100,50,0,2*Math.PI,!0),r.closePath(),r.fill(),r.fillStyle="rgb(255,0,255)",r.arc(75,75,75,0,2*Math.PI,!0),r.arc(75,75,25,0,2*Math.PI,!0),r.fill("evenodd"),t.push("canvas fp:"+e.toDataURL()),t.join("~")}e.FINGERPRINT="object"==typeof window?r():i(),e.browser=r,e.server=i,e.compress=n,e.str2digit=o,e.stringify=s}),define("src/lib/uuid",["require","exports","src/lib/fingerprint"],function(t,e,r){"use strict";function i(t){void 0===t&&(t=Date.now());var e=parseInt(o+r.compress(r.str2digit(r.stringify(t)))+"",10)||0;if(16>e||e>1e15)throw new Error("ArchStream: uuid: Invalid uuid dynamic seed.\n "+t);return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(s,function(t){var r=Math.random()*e%16|0,i="x"==t?r:3&r|8;return i.toString(16)}).toLowerCase()}var n=r.compress(r.str2digit(r.stringify(Date.now()))),o=parseInt((r.FINGERPRINT+n)*Math.random()+"",10);if(!o||"number"!=typeof o||100>o||o>1e14)throw new Error("ArchStream: uuid: Invalid uuid static seed.\n "+r.FINGERPRINT+" + "+n);var s=/[xy]/g;e.v4=i}),define("src/lib/map",["require","exports"],function(t,e){"use strict";var r=function(){function t(){this.map_=Object.create(null),this.type_="",void this.reset_()}return t.prototype.get=function(t){return this.map_[t+""]},t.prototype.set=function(t,e){return this.type_||(this.type_=typeof t),void this.reset_(),this.map_[t+""]=e},t.prototype.has=function(t){return!!this.map_[t+""]||t+""in this.map_},t.prototype["delete"]=function(t){return void this.reset_(),delete this.map_[t+""],this},t.prototype.clear=function(){return void this.reset_(),this.map_=Object.create(null),this},t.prototype.reset_=function(){this.size_=NaN,this.entries_=void 0},Object.defineProperty(t.prototype,"size",{get:function(){return this.size_>=0?this.size_:this.size_=Object.keys(this.map_).length},enumerable:!0,configurable:!0}),t.prototype.entries=function(){var t=this;return this.entries_?this.entries_:this.entries_=Object.keys(this.map_).map(function(e){return["number"===t.type_?+e:e,t.map_[e]]})},t}();e.Map=r}),define("src/lib/observable",["require","exports","src/lib/map","src/lib/noop"],function(t,e,r,i){"use strict";var n=/$^/,o=function(){function t(t){void 0===t&&(t=""),this.separator_=t,this.map_=Object.create(null),this.cache_=new r.Map,this.emitId_=0,this.emitQueue_=[]}return t.prototype.on=function(t,e,r){return void 0===r&&(r=function(t){return t===e}),void this.throwTypeErrorIfInvalidSubscriber_(t,e),void this.seek_(this.map_,t.toString().split(this.separator_||n)).list.push([e,r,this.emitId_]),void this.drain_(t),this},t.prototype.off=function(t,e){switch(typeof e){case"function":return void this.cache_["delete"](t),void this.seek_(this.map_,t.toString().split(this.separator_||n)).list.some(function(t,r,i){var n=t[1];if(!n(e))return!1;switch(r){case 0:return!void i.shift();case i.length-1:return!void i.pop();default:return!void i.splice(r,1)}}),this;case"undefined":void this.cache_["delete"](t);var r=this.seek_(this.map_,t.toString().split(this.separator_||n));return r.map=Object.create(null),r.list=[],this;default:throw this.throwTypeErrorIfInvalidSubscriber_(t,e)}},t.prototype.once=function(t,e){var r=this;return void this.throwTypeErrorIfInvalidSubscriber_(t,e),this.on(t,function(i){void r.off(t,e),void e(i)},function(t){return t===e})},t.prototype.absorb=function(t,e){return void this.emit(t,e),e},t.prototype.emit=function(t,e,r){return void 0===e&&(e=i["default"]),void 0===r&&(r=i["default"]),t instanceof Object?this.emit_(t.type,t,e):this.emit_(t,e,r)},t.prototype.emit_=function(t,e,r){void 0===r&&(r=i["default"]);var n=this.emitQueue_;return void n.push([++this.emitId_,e,r]),void this.drain_(t),this},t.prototype.drain_=function(t){for(var e=this.emitQueue_;e.length>0;){var r=this.cache_.get(t)||this.cache_.set(t,this.collect_(this.seek_(this.map_,t.toString().split(this.separator_||n)))),i=e.shift();try{void r.reduce(function(t,e){var r=t[0],i=t[1],n=e[0],o=e[2];return o>=r?t:(e[2]=r,void n(i),t)},i)}catch(o){void e.unshift(i),o instanceof s||void console.error(o);continue}var u=i[1],c=i[2];void c(u)}return this.resetEmitIdIfPossible_(),this},t.prototype.seek_=function(t,e){function r(t,e){return t[e]&&t[e].map?t[e]:t[e]={map:Object.create(null),list:[]}}switch(e.length){case 0:throw new Error("ArchStream: Observable: Cannot use empty string for event type and namespace.");case 1:return void this.cache_["delete"](e.join(this.separator_)),r(t,e.shift());default:return void this.cache_["delete"](e.join(this.separator_)),this.seek_(r(t,e.shift()).map,e)}},t.prototype.collect_=function(t){var e=this,r=t.map,i=t.list;return Object.keys(r).reduce(function(t,i){return void t.unshift.apply(t,e.collect_(r[i])),0===t.length&&delete r[i],t},i.slice())},t.prototype.resetEmitIdIfPossible_=function(){return this.emitId_<5e8||this.emitQueue_.length>0?this:(void this.collect_({map:this.map_,list:[]}).reduce(function(t,e){return e[2]=t},this.emitId_=0),this)},t.prototype.throwTypeErrorIfInvalidSubscriber_=function(t,e){switch(typeof e){case"function":return;default:throw new TypeError("ArchStream: Observable: Invalid subscriber.\n "+e)}},t}();e.Observable=o;var s=function(t){function e(){t.apply(this,arguments)}return __extends(e,t),e}(Error);e.TestError=s}),define("src/lib/set",["require","exports","src/lib/map"],function(t,e,r){"use strict";var i=function(){function t(t){this.replacer_=t,this.map_=new r.Map}return t.prototype.get=function(t){return this.map_.get(t)},t.prototype.set=function(t,e){if(!this.has(t))return this.map_.set(t,e);if(!this.replacer_)throw new Error("Cannot overwrite value of set without replacer.");return this.map_.set(t,this.replacer_(this.get(t),e))},t.prototype.has=function(t){return this.map_.has(t)},t.prototype["delete"]=function(t){return void this.map_["delete"](t),this},t.prototype.clear=function(){return void this.map_.clear(),this},Object.defineProperty(t.prototype,"size",{get:function(){return this.map_.size},enumerable:!0,configurable:!0}),t.prototype.entries=function(){return this.map_.entries()},t}();e.Set=i}),define("src/lib/maybe.impl",["require","exports"],function(t,e){"use strict";var r=function(){function t(t){this.thunk_=t}return t.prototype.bind=function(e){var r=this;return new t(function(){var o=r.thunk_();switch(!0){case o instanceof i:return e(o.extract());case o instanceof n:return o;case o instanceof t:return o.bind(e);default:throw new TypeError("ArchStream: Maybe: Invalid monad value.\n "+o)}})},t.prototype.extract=function(t){return this.thunk_().extract(t)},t}();e.Maybe=r;var i=function(t){function e(e){t.call(this),this.val_=e}return __extends(e,t),e.prototype.bind=function(t){var e=this;return new r(function(){return e}).bind(t)},e.prototype.extract=function(t){return this.val_},e}(r);e.Just=i;var n=function(t){function e(){t.apply(this,arguments)}return __extends(e,t),e.prototype.bind=function(t){return this},e.prototype.extract=function(t){return t},e}(r);e.Nothing=n}),define("src/lib/maybe",["require","exports","src/lib/maybe.impl"],function(t,e,r){"use strict";var i;!function(t){function e(t){return new r.Just(t)}t.Just=e,t.Nothing=new r.Nothing,t.Return=e}(i=e.Maybe||(e.Maybe={})),e.Just=i.Just,e.Nothing=i.Nothing,e.Return=e.Just}),define("src/lib/either.impl",["require","exports"],function(t,e){"use strict";var r=function(){function t(t){this.thunk_=t}return t.prototype.bind=function(e){var r=this;return new t(function(){var o=r.thunk_();switch(!0){case o instanceof i:return o;case o instanceof n:return e(o.extract());case o instanceof t:return o.bind(e);default:throw new TypeError("ArchStream: Either: Invalid monad value.\n "+o)}})},t.prototype.extract=function(t){return this.thunk_().extract(t)},t}();e.Either=r;var i=function(t){function e(e){t.call(this),this.val_=e}return __extends(e,t),e.prototype.bind=function(t){return this},e.prototype.extract=function(t){return t?t(this.val_):this.val_},e}(r);e.Left=i;var n=function(t){function e(e){t.call(this),this.val_=e}return __extends(e,t),e.prototype.bind=function(t){var e=this;return new r(function(){return e}).bind(t)},e.prototype.extract=function(t){return this.val_},e}(r);e.Right=n}),define("src/lib/either",["require","exports","src/lib/either.impl"],function(t,e,r){"use strict";var i;!function(t){function e(t){return new r.Left(t)}function i(t){return new r.Right(t)}t.Left=e,t.Right=i,t.Return=i}(i=e.Either||(e.Either={})),e.Left=i.Left,e.Right=i.Right,e.Return=i.Return}),define("src/export",["require","exports","src/stream/transform","src/lib/message","src/lib/proxy","src/lib/proxy","src/lib/tick","src/lib/timer","src/lib/fingerprint","src/lib/uuid","src/lib/observable","src/lib/map","src/lib/set","src/lib/maybe","src/lib/either","./typings/arch-stream.d"],function(t,e,r,i,n,o,s,u,c,a,h,p,f,d,l){"use strict";function v(){return new r.ArchStream}function _(){return new i.Message}e.Proxy=o.Proxy,e.Tick=s.Tick,e.Timer=u.Timer,e.FINGERPRINT=c.FINGERPRINT,e.uuid=a.v4,e.Observable=h.Observable,e.Map=p.Map,e.Set=f.Set,e.Maybe=d.Maybe,e.Just=d.Just,e.Nothing=d.Nothing,e.Either=l.Either,e.Left=l.Left,e.Right=l.Right;var y={Msg:_,Proxy:n.Proxy};Object.defineProperty(e,"__esModule",{value:!0}),e["default"]=v;var v;!function(t){t.Msg=y.Msg,t.Proxy=y.Proxy}(v||(v={})),e.Msg=_}),define("arch-stream",["require","exports","src/export","src/export"],function(t,e,r,i){"use strict";function n(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}n(r),e["default"]=i["default"]}); |
{ | ||
"name": "arch-stream", | ||
"version": "0.0.60", | ||
"version": "0.0.61", | ||
"description": "Pipeline stream for software architecture of Domain-Driven Design and Data-Oriented Design.", | ||
@@ -44,2 +44,3 @@ "private": false, | ||
"gulp": "^3.9.0", | ||
"gulp-cached": "^1.1.0", | ||
"gulp-footer": "^1.0.5", | ||
@@ -50,3 +51,3 @@ "gulp-header": "^1.7.1", | ||
"gulp-rename": "^1.2.2", | ||
"gulp-tslint": "^4.3.0", | ||
"gulp-tslint": "^4.3.1", | ||
"gulp-typescript": "^2.10.0", | ||
@@ -71,3 +72,3 @@ "gulp-uglify": "^1.5.1", | ||
"tsd": "^0.6.5", | ||
"tslint": "^3.2.1", | ||
"tslint": "^3.2.2-dev.1", | ||
"typescript": "^1.8.0-dev.20160109" | ||
@@ -74,0 +75,0 @@ }, |
@@ -9,3 +9,3 @@ import {FINGERPRINT} from './fingerprint'; | ||
assert(!isNaN(FINGERPRINT)); | ||
assert(FINGERPRINT === parseInt(FINGERPRINT.toString())); | ||
assert(FINGERPRINT === parseInt(FINGERPRINT.toString(), 10)); | ||
}); | ||
@@ -12,0 +12,0 @@ |
@@ -34,3 +34,3 @@ import {Observable, TestError} from './observable'; | ||
.on('test', acc => acc.push(2)) | ||
.aggregate('test', []); | ||
.absorb('test', []); | ||
assert.deepEqual(agg, [1, 2]); | ||
@@ -120,4 +120,14 @@ done(); | ||
it('cache', function (done) { | ||
new Observable<string, number[]>('.') | ||
.on('test', ns => ns.push(0)) | ||
.once('test.0', ns => ns.push(1)) | ||
.on('test.0.0', ns => ns.push(2)) | ||
.on('test.0.0.0', ns => ns.push(3)) | ||
.emit('test.0', [], ns => assert.deepEqual(ns, [3, 2, 1])) | ||
.emit('test.0', [], ns => assert.deepEqual(ns, [3, 2]) || done()); | ||
}); | ||
}); | ||
}); |
@@ -32,3 +32,3 @@ import {IObservableObserver, IObservableConsumer, IObservablePublisher} from 'arch-stream'; | ||
implements IObservableObserver<T, D>, IObservableConsumer<T, D>, IObservablePublisher<T, D> { | ||
constructor(private separator_: string | RegExp = RegNothing) { | ||
constructor(private separator_: string = '') { | ||
} | ||
@@ -40,4 +40,3 @@ private map_: SubscriberMap<D> = Object.create(null); | ||
void this.throwTypeErrorIfInvalidSubscriber_(type, subscriber); | ||
void this.seek_(this.map_, type.toString().split(this.separator_)).list.push([subscriber, equals, this.emitId_]); | ||
void this.cache_.delete(type); | ||
void this.seek_(this.map_, type.toString().split(this.separator_ || RegNothing)).list.push([subscriber, equals, this.emitId_]); | ||
void this.drain_(type); | ||
@@ -50,3 +49,3 @@ return this; | ||
void this.cache_.delete(type); | ||
void this.seek_(this.map_, type.toString().split(this.separator_)).list | ||
void this.seek_(this.map_, type.toString().split(this.separator_ || RegNothing)).list | ||
.some(([, equals], i, list) => { | ||
@@ -70,3 +69,3 @@ if (!equals(subscriber)) return false; | ||
void this.cache_.delete(type); | ||
const set = this.seek_(this.map_, type.toString().split(this.separator_)); | ||
const set = this.seek_(this.map_, type.toString().split(this.separator_ || RegNothing)); | ||
set.map = Object.create(null); | ||
@@ -89,3 +88,3 @@ set.list = []; | ||
} | ||
public aggregate(type: T, accumulator: D): D { | ||
public absorb(type: T, accumulator: D): D { | ||
void this.emit(type, accumulator); | ||
@@ -112,3 +111,3 @@ return accumulator; | ||
while (queue.length > 0) { | ||
const collection = this.cache_.get(type) || this.cache_.set(type, this.collect_(this.seek_(this.map_, type.toString().split(this.separator_)))); | ||
const collection = this.cache_.get(type) || this.cache_.set(type, this.collect_(this.seek_(this.map_, type.toString().split(this.separator_ || RegNothing)))); | ||
const q = queue.shift(); | ||
@@ -146,5 +145,7 @@ try { | ||
case 1: { | ||
void this.cache_.delete(<T><any>names.join(this.separator_)); | ||
return namespace(map, names.shift()); | ||
} | ||
default: { | ||
void this.cache_.delete(<T><any>names.join(this.separator_)); | ||
return this.seek_(namespace(map, names.shift()).map, names); | ||
@@ -151,0 +152,0 @@ } |
@@ -14,3 +14,6 @@ import {ICallback, ITransformStream} from 'arch-stream'; | ||
function rule<V>(LocalEntity: new (..._: any[]) => V, extract: (entity: T) => V): ICallback<T> | ICallback<T>[] | ITransformStream<T, {}> { | ||
function rule<V>( | ||
LocalEntity: new (..._: any[]) => V, | ||
extract: (entity: T) => V | ||
): ICallback<T> | ICallback<T>[] | ITransformStream<T, {}> { | ||
proxy.pipe = (...args: ICallback<T>[]) => | ||
@@ -17,0 +20,0 @@ args |
10
tsd.json
@@ -9,17 +9,17 @@ { | ||
"mocha/mocha.d.ts": { | ||
"commit": "1984ea435fe9e93a012d50db7773db58ae5d494b" | ||
"commit": "70bf7e2bfeb0d5b1b651ef3219bcc65c8eec117e" | ||
}, | ||
"empower/empower.d.ts": { | ||
"commit": "1984ea435fe9e93a012d50db7773db58ae5d494b" | ||
"commit": "70bf7e2bfeb0d5b1b651ef3219bcc65c8eec117e" | ||
}, | ||
"power-assert/power-assert.d.ts": { | ||
"commit": "1984ea435fe9e93a012d50db7773db58ae5d494b" | ||
"commit": "70bf7e2bfeb0d5b1b651ef3219bcc65c8eec117e" | ||
}, | ||
"power-assert-formatter/power-assert-formatter.d.ts": { | ||
"commit": "1984ea435fe9e93a012d50db7773db58ae5d494b" | ||
"commit": "70bf7e2bfeb0d5b1b651ef3219bcc65c8eec117e" | ||
}, | ||
"benchmark/benchmark.d.ts": { | ||
"commit": "1984ea435fe9e93a012d50db7773db58ae5d494b" | ||
"commit": "70bf7e2bfeb0d5b1b651ef3219bcc65c8eec117e" | ||
} | ||
} | ||
} |
@@ -42,3 +42,3 @@ /** | ||
export interface IProxy<T, U> { | ||
[method: string]: () => U & this & ITransformStream<T, U & this> | ||
[method: string]: () => U & this & ITransformStream<T, U & this>; | ||
} | ||
@@ -135,7 +135,7 @@ export interface ITransformStream<T, U extends {}> extends Transform<T, ITransformStream<T, {}>>, Exportable<T, IModularStream<T>> { | ||
implements IObservableObserver<T, D>, IObservableConsumer<T, D>, IObservablePublisher<T, D> { | ||
constructor(separator?: string | RegExp) | ||
constructor(separator?: string) | ||
on(type: T, subscriber: Subscriber<D>): this; | ||
off(type: T, subscriber?: Subscriber<D>): this; | ||
once(type: T, subscriber: Subscriber<D>): this; | ||
aggregate(type: T, accumulator: D): D; | ||
absorb(type: T, accumulator: D): D; | ||
emit(type: T, data: D, tracker?: (data?: D) => any): this; | ||
@@ -142,0 +142,0 @@ emit(event: ObservableEvent<T, D>, tracker?: (event?: ObservableEvent<T, D>) => any): this; |
215009
5051
33