Comparing version 2.0.13 to 2.0.14
@@ -77,3 +77,3 @@ "use strict"; | ||
} | ||
_this.name = "{" + names.join(', ') + "}"; | ||
_this.name = "{" + names.map(function (name) { return ((sources[name] && !sources[name].name && sources[name].name !== name) ? name + ": " + sources[name].name : name); }).join(', ') + "}"; | ||
return _this; | ||
@@ -80,0 +80,0 @@ } |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.immview=e():t.immview=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return t[r].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";var r=n(2);e.dispatcher=r.dispatcher;var i=n(3),o=n(4);e.Observable=o.Observable;var s=n(6);e.Combine=s.Combine,e.Merge=s.Combine;var u=n(9);e.Domain=u.Domain;var a=n(8);e.action=a.action;var c=n(1);e.diagnose=c.diagnose;var f=function(t){r.dispatcher.push(t,i.DispatcherPriorities.EXTERNAL)};e.dispatch=f},function(t,e){"use strict";var n=this&&this.__assign||Object.assign||function(t){for(var e,n=1,r=arguments.length;r>n;n++){e=arguments[n];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},r=function(){function t(){this.list=null,this.tableIsRequested=!1}return Object.defineProperty(t.prototype,"isOn",{get:function(){return void 0!==this.list},enumerable:!0,configurable:!0}),t.prototype.on=function(t){if(void 0===t&&(t={}),!window.performance)throw Error("Performance measurements are not available in this environment");this.options=n({tableDetails:!0,tableSummary:!0,tableClear:!0,timeline:!0},t),this.list=[]},t.prototype.off=function(){this.list=null,this.tableIsRequested=!1},t.prototype.measure=function(t){var e=this;if(this.list){if((this.options.tableDetails||this.options.tableSummary)&&!this.tableIsRequested){this.tableIsRequested=!0;var r=setInterval(function(){if(!e.tableIsRequested||null===e.list||0===e.list.length)return e.tableIsRequested=!1,void clearInterval(r);var t=e.list.splice(0).reduce(function(t,e){for(var r=function(r){if(r["action name"]===e["action name"])return{value:t.map(function(t){return t!==r?t:n({},r,{"duration in ms":r["duration in ms"]+e["duration in ms"],occurences:r.occurences+1})})}},i=0,o=t;o.length>i;i++){var s=o[i],u=r(s);if("object"==typeof u)return u.value}return t.concat([n({},e,{occurences:1})])},[]);e.options.tableClear&&console.clear(),e.options.tableDetails&&console.table(t.map(function(t){return{"action name":t["action name"],duration:t["duration in ms"]+" ms",occurences:t.occurences,"avg duration":t["duration in ms"]/t.occurences+" ms"}}));var i=t.reduce(function(t,e){return t+e["duration in ms"]},0);e.options.tableSummary&&console.table({all:{"duration in ms":i,"est. duration budget":500,"est. duration budget usage":i/500*100+"%"}})},1e3)}this.options.timeline&&window.performance.mark(t+"_start");var i=(this.options.tableDetails||this.options.tableSummary)&&window.performance.now();return function(){(e.options.tableDetails||e.options.tableSummary)&&e.list.push({"action name":t,"duration in ms":window.performance.now()-i}),e.options.timeline&&(window.performance.mark(t+"_end"),window.performance.measure(t,t+"_start",t+"_end"))}}},t}();e.Diagnose=r,e.diagnose=new r},function(t,e,n){"use strict";var r=n(7),i=new r.Dispatcher;e.dispatcher=i;var o=function(t,e){i.push(t,e),i.run()};e.dispatch=o;var s=function(t,e){return new Promise(function(n,r){var i,s,u;o(function(){try{s=t(),i=!0}catch(t){u=t,i=!1}},e),o(function(){i?n(s):r(u)},e)})};e.dispatchPromise=s},function(t,e){"use strict";var n;!function(t){t[t.OBSERVABLE=1]="OBSERVABLE",t[t.DOMAIN=2]="DOMAIN",t[t.BUFFER=3]="BUFFER",t[t.EXTERNAL=4]="EXTERNAL",t[t.DIAGNOSE=5]="DIAGNOSE",t[t.TEST=10]="TEST"}(n=e.DispatcherPriorities||(e.DispatcherPriorities={}))},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=n(5),o=n(3),s=n(2),u=n(1),a="undefined"!=typeof Symbol?Symbol("ObservableSymbol"):"ObservableSymbol",c=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.of=function(){for(var t=[],n=0;arguments.length>n;n++)t[n]=arguments[n];return e.from(t)},e.from=function(t){if(t[a]){var n=t[a](),r=new e;return n.subscribe(r),r.name=this.name+" >$",r}if(t[Symbol.iterator]){var r=new e(function(e){for(var n=e.next,r=e.error,i=e.complete,o=t[Symbol.iterator](),s=o.next();s.done===!1;s=o.next())s.value instanceof Error?r(s.value):n(s.value);i()});return r.name=(t[Symbol.toStringTag]||""+t||"#"+r.priority)+"$",r}throw Error("Observable.from incorrect input")},e.prototype.startWith=function(t){var n=new e;return n.next(t),this.subscribe(n),n.name=this.name+" [T, ...$]",n},e.prototype.map=function(t){var n=this,r=new e(function(e){var i=n.subscribe(function(n){try{var i=u.diagnose.isOn&&u.diagnose.measure("$> "+r.name),o=t(n);i&&i(),e.next(o)}catch(t){e.error(t)}},e.error,e.complete);return function(){return i.unsubscribe()}});return r.name=this.name+" |> "+(t.name||"#"+r.priority),r},e.prototype.flatten=function(){var t=this,n=new e(function(e){t.subscribe(function(t){t&&t.subscribe(function(t){e.next(t)},function(t){return e.error(t)})},e.error,e.complete)});return n.name=this.name+" $$>$",n},e.prototype.scan=function(t){var n=this,r=new e(function(e){var r,i=0,o=n.subscribe(function(n){try{r=t(r,n,i++),e.next(r)}catch(t){e.error(t)}},e.error,e.complete);return function(){return o.unsubscribe()}}),i=this.name+" +="+(t.name||"#"+r.priority);return r.name=i,r},e.prototype.filter=function(t){var n=this,r=new e(function(e){var r=n.subscribe(function(n){try{t(n)&&e.next(n)}catch(t){e.error(t)}},e.error,e.complete);return function(){return r.unsubscribe()}}),i=this.name+" ?"+(t.name||"#"+r.priority);return r.name=i,r},e.prototype.merge=function(){for(var t=[],n=0;arguments.length>n;n++)t[n]=arguments[n];var r=0,i=new e,o={start:function(){},next:function(t){i.next(t)},error:function(t){i.error(t)},complete:function(){r++,r===t.length+1&&i.complete()}};return this.subscribe(o),t.forEach(function(t){return t.subscribe(o)}),i.name="( "+[this].concat(t).map(function(t){return t.name}).join(" + ")+" )",i},e.prototype.distinct=function(){var t=this,n=new e(function(e){var n,r=!1;t.subscribe({start:function(){},next:function(t){r&&n===t||(r=!0,n=t,e.next(t))},error:function(t){e.error(t)},complete:function(){e.complete()}})});return n.name=this.name+" !==",n},e.prototype.bufferCount=function(t,n){var r=this,i=void 0===n?t:n,o=[],s=new e(function(e){var n=r.subscribe(function(n){o.push(n),o.length===t&&(e.next(o.slice()),o=o.splice(i,t-i))},e.error,function(){o.length>t-i&&e.next(o.slice()),e.complete()});return function(){return n.unsubscribe()}});return s.name=this.name+" >|>"+t+","+i,s},e.prototype.buffer=function(t){var n=this;void 0===t&&(t=0);var r=[],i=new e(function(e){var i=n.subscribe(function(n){r=t>0?[n].concat(r).splice(0,t):[n].concat(r),s.dispatch(function(){0!==r.length&&e.next(r.splice(0).reverse())},o.DispatcherPriorities.BUFFER)},e.error,function(){r.length>0&&e.next(r.splice(0).reverse()),e.complete()});return function(){return i.unsubscribe()}});return i.name=this.name+" >|>",i},e}(i.BaseObservable);e.Observable=c,c.prototype[a]=function(){return this}},function(t,e,n){"use strict";var r,i=n(2),o=n(3),s=n(1),u=n(10);!function(t){t[t.Next=0]="Next",t[t.Error=1]="Error",t[t.Complete=2]="Complete"}(r=e.MessageTypes||(e.MessageTypes={}));var a=function(){},c=function(){function t(e){var n=this;this.closed=!1;var i=this;return this.observers=[],this.priority=t.lastObservablePriority++,this.name=e&&"string"==typeof e.name&&e.name.length>0?e.name+"$":this.priority+"$",e?void(this.cancelSubscriber=e({next:function(t){n.pushMessage([r.Next,t,a])},error:function(t){n.pushMessage([r.Error,t,a])},complete:function(){n.pushMessage([r.Complete,,a])},get closed(){return i.observers.length>0}})||a):void(this.cancelSubscriber=a)}return t.prototype.previous=function(){return this.lastValue},t.prototype.start=function(){},t.prototype.next=function(t){this.pushMessage([r.Next,t,a])},t.prototype.error=function(t){this.pushMessage([r.Error,t,a])},t.prototype.complete=function(){this.pushMessage([r.Complete,,a])},t.prototype.subscribe=function(){for(var e=this,n=[],r=0;arguments.length>r;r++)n[r]=arguments[r];if(this.closed)return new u.Subscription(null,function(){return!1});if("object"!=typeof n[0]||null===n[0]){var i=n[0],o=void 0===i?a:i,s=n[1],c=void 0===s?a:s,f=n[2],p=void 0===f?a:f;return this.subscribe({start:a,next:o,error:c,complete:p})}var l=n[0];this.observers.push(l);var h=new u.Subscription(function(){e.observers=e.observers.filter(function(t){return t!==l})},function(){return e.observers.indexOf(l)>-1});return l.start(h),t.dispatchDigestMessages(),h},t.prototype.pushMessage=function(e){this.closed||(t.awaitingMessages.push([this,e]),t.dispatchDigestMessages())},t.dispatchDigestMessages=function(){i.dispatch(t.digestAwaitingMessages,o.DispatcherPriorities.OBSERVABLE)},t.digestAwaitingMessages=function(){var e=t.popMessage(),n=e[0],r=e[1];n&&!n.closed&&(t.digestNodeMessage(n,r),t.dispatchDigestMessages())},t.popMessage=function(){if(0===t.awaitingMessages.length)return[null,null];for(var e=0;t.awaitingMessages.length>e;e++){var n=t.awaitingMessages[e],r=n[0],i=void 0===r?null:r,o=n[1];if(i.observers.length)return t.awaitingMessages.splice(e,1),[i,o]}return[null,null]},t.digestNodeMessage=function(t,e){var n=e[0],u=e[2];if(n===r.Next){var c,f=e,p=f[1];if("function"==typeof p){var l=p,h=s.diagnose.isOn&&s.diagnose.measure("$> "+(t.name||"[anonymous]")+".next"+(l.name?"("+l.name+")":""));c=l(t.lastValue),h&&h()}else c=p;t.lastValue=c,t.observers.forEach(function(t){return t.next(c)})}else if(n===r.Error){var b=e,v=b[1];t.observers.forEach(function(t){return t.error(v)})}else n===r.Complete&&(t.cancelSubscriber(),t.cancelSubscriber=a,t.closed=!0,t.observers.splice(0).forEach(function(t){return t.complete()}));i.dispatch(u,o.DispatcherPriorities.OBSERVABLE)},t}();c.awaitingMessages=[],c.lastObservablePriority=0,e.BaseObservable=c},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=this&&this.__assign||Object.assign||function(t){for(var e,n=1,r=arguments.length;r>n;n++){e=arguments[n];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},o=n(4),s=function(t){function e(e){var n=t.call(this,function(t){var n=[],r=[],o=[],s={},u=[],a=function(a){return Object.prototype.hasOwnProperty.call(e,a)?(n.push(a),void u.push(e[a].subscribe(function(e){if(o&&o.push([a,e]),r.indexOf(a)<0&&r.push(a),n.length===r.length){if(o){for(var u={},c=[],f=[],p=0;o.length>p;p++)if(c.indexOf(o[p][0])<0){var l=o[p],h=l[0],b=l[1];u[h]=b,c.push(h)}else f.push(o[p]);return t.next(s=u),f.forEach(function(e){var n=e[0],r=e[1];t.next(s=i({},s,(o={},o[n]=r,o)));var o}),void(o=null)}t.next(s=i({},s,(v={},v[a]=e,v)));var v}}))):"continue"};for(var c in e)a(c);return function(){u.forEach(function(t){return t()})}})||this,r=[];for(var o in e){if(!Object.prototype.hasOwnProperty.call(e,o))return n;r.push(o)}return n.name="{"+r.join(", ")+"}",n}return r(e,t),e}(o.Observable);e.Combine=s},function(t,e){"use strict";var n=function(){function t(){this._isRunning=!1,this.subsequentCalls=0,this.tasks=[]}return Object.defineProperty(t.prototype,"isRunning",{get:function(){return this._isRunning},enumerable:!0,configurable:!0}),t.prototype.push=function(t,e){return this.tasks.push({priority:e,execute:t}),this},t.prototype.run=function(){var t=this;this._isRunning||(this._isRunning=!0,Promise.resolve().then(function(){return t.loop()}))},t.prototype.loop=function(){var t=this,e=this.findNextTask();return e?(this.subsequentCalls>1024&&this.tooManyCalls(),this.subsequentCalls++,void this.next(e.execute,function(){return t.loop()})):(this._isRunning=!1,void(this.subsequentCalls=0))},t.prototype.tooManyCalls=function(){"If you see this, that means your code sent too many subsequent messages.";"This situation is considered harmful, as it may introduce serious lag of your app."},t.prototype.findNextTask=function(){for(var t=null,e=0;this.tasks.length>e;e++)(null===t||this.tasks[t].priority>this.tasks[e].priority)&&(t=e);return null===t?null:this.tasks.splice(t,1)[0]},t.prototype.next=function(t,e){try{t()}catch(t){console.error(t.stack||t.message||t)}e()},t}();e.Dispatcher=n},function(t,e,n){"use strict";function r(t,e,n){var r=n.value;n.value=function(){for(var t=this,n=[],u=0;arguments.length>u;u++)n[u]=arguments[u];return o.dispatchPromise(function(){var i=s.diagnose.measure("<$ "+(t.name?t.name+".":"")+e),o=r.apply(t,n);return i&&i(),o},i.DispatcherPriorities.DOMAIN)}}var i=n(3),o=n(2),s=n(1);e.action=r},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=n(4),o=n(3),s=n(2),u=n(1),a=function(t){function e(e){var n=this;return e?n=t.call(this,function(){e.subscribe(n)})||this:void(n=t.call(this)||this)}return r(e,t),e.tagged=function(t){for(var n=[],r=1;arguments.length>r;r++)n[r-1]=arguments[r];var i=function(){for(var r=[],i=0;arguments.length>i;i++)r[i]=arguments[i];var o=e.create.apply(void 0,r);return o.name=t.reduce(function(t,e,r){return t+(r>0?n[r-1]:"")+e}),o};return i},e.create=function(){for(var t=[],n=0;arguments.length>n;n++)t[n]=arguments[n];var r,i,a,c;"string"==typeof t[0]&&(r=t.shift()),"object"==typeof t[0]&&null!==t[0]&&"function"==typeof t[0].subscribe&&(i=t.shift()),a=t.shift(),c=t.shift();var f=new e(i);if(f.name=void 0!==r?r:f.priority+"$!",a){var p=function(t){var e=t;return Object.prototype.hasOwnProperty.call(a,t)?void(f[t]=function(){for(var n=[],r=0;arguments.length>r;r++)n[r]=arguments[r];return s.dispatchPromise(function(){var r=u.diagnose.measure("<$ "+(f.name?f.name+".":"")+e),i=a[t].apply(f,n);return r&&r(),i},o.DispatcherPriorities.DOMAIN)}):"continue"};for(var l in a)p(l)}if(c)for(var h in c)Object.prototype.hasOwnProperty.call(c,h)&&(f[h]=c[h]);return f},e}(i.Observable);e.Domain=a},function(t,e){"use strict";var n=function(){function t(t,e){this.customUnsubscribe=t,this.isSubscriptionActive=e}return Object.defineProperty(t.prototype,"closed",{get:function(){return!this.isSubscriptionActive()},enumerable:!0,configurable:!0}),t.prototype.unsubscribe=function(){var t=this.customUnsubscribe;t&&(this.customUnsubscribe=null,t&&t())},t}();e.Subscription=n}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.immview=e():t.immview=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return t[r].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";var r=n(2);e.dispatcher=r.dispatcher;var i=n(3),o=n(4);e.Observable=o.Observable;var s=n(6);e.Combine=s.Combine,e.Merge=s.Combine;var a=n(9);e.Domain=a.Domain;var u=n(8);e.action=u.action;var c=n(1);e.diagnose=c.diagnose;var f=function(t){r.dispatcher.push(t,i.DispatcherPriorities.EXTERNAL)};e.dispatch=f},function(t,e){"use strict";var n=this&&this.__assign||Object.assign||function(t){for(var e,n=1,r=arguments.length;r>n;n++){e=arguments[n];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},r=function(){function t(){this.list=null,this.tableIsRequested=!1}return Object.defineProperty(t.prototype,"isOn",{get:function(){return void 0!==this.list},enumerable:!0,configurable:!0}),t.prototype.on=function(t){if(void 0===t&&(t={}),!window.performance)throw Error("Performance measurements are not available in this environment");this.options=n({tableDetails:!0,tableSummary:!0,tableClear:!0,timeline:!0},t),this.list=[]},t.prototype.off=function(){this.list=null,this.tableIsRequested=!1},t.prototype.measure=function(t){var e=this;if(this.list){if((this.options.tableDetails||this.options.tableSummary)&&!this.tableIsRequested){this.tableIsRequested=!0;var r=setInterval(function(){if(!e.tableIsRequested||null===e.list||0===e.list.length)return e.tableIsRequested=!1,void clearInterval(r);var t=e.list.splice(0).reduce(function(t,e){for(var r=function(r){if(r["action name"]===e["action name"])return{value:t.map(function(t){return t!==r?t:n({},r,{"duration in ms":r["duration in ms"]+e["duration in ms"],occurences:r.occurences+1})})}},i=0,o=t;o.length>i;i++){var s=o[i],a=r(s);if("object"==typeof a)return a.value}return t.concat([n({},e,{occurences:1})])},[]);e.options.tableClear&&console.clear(),e.options.tableDetails&&console.table(t.map(function(t){return{"action name":t["action name"],duration:t["duration in ms"]+" ms",occurences:t.occurences,"avg duration":t["duration in ms"]/t.occurences+" ms"}}));var i=t.reduce(function(t,e){return t+e["duration in ms"]},0);e.options.tableSummary&&console.table({all:{"duration in ms":i,"est. duration budget":500,"est. duration budget usage":i/500*100+"%"}})},1e3)}this.options.timeline&&window.performance.mark(t+"_start");var i=(this.options.tableDetails||this.options.tableSummary)&&window.performance.now();return function(){(e.options.tableDetails||e.options.tableSummary)&&e.list.push({"action name":t,"duration in ms":window.performance.now()-i}),e.options.timeline&&(window.performance.mark(t+"_end"),window.performance.measure(t,t+"_start",t+"_end"))}}},t}();e.Diagnose=r,e.diagnose=new r},function(t,e,n){"use strict";var r=n(7),i=new r.Dispatcher;e.dispatcher=i;var o=function(t,e){i.push(t,e),i.run()};e.dispatch=o;var s=function(t,e){return new Promise(function(n,r){var i,s,a;o(function(){try{s=t(),i=!0}catch(t){a=t,i=!1}},e),o(function(){i?n(s):r(a)},e)})};e.dispatchPromise=s},function(t,e){"use strict";var n;!function(t){t[t.OBSERVABLE=1]="OBSERVABLE",t[t.DOMAIN=2]="DOMAIN",t[t.BUFFER=3]="BUFFER",t[t.EXTERNAL=4]="EXTERNAL",t[t.DIAGNOSE=5]="DIAGNOSE",t[t.TEST=10]="TEST"}(n=e.DispatcherPriorities||(e.DispatcherPriorities={}))},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=n(5),o=n(3),s=n(2),a=n(1),u="undefined"!=typeof Symbol?Symbol("ObservableSymbol"):"ObservableSymbol",c=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.of=function(){for(var t=[],n=0;arguments.length>n;n++)t[n]=arguments[n];return e.from(t)},e.from=function(t){if(t[u]){var n=t[u](),r=new e;return n.subscribe(r),r.name=this.name+" >$",r}if(t[Symbol.iterator]){var r=new e(function(e){for(var n=e.next,r=e.error,i=e.complete,o=t[Symbol.iterator](),s=o.next();s.done===!1;s=o.next())s.value instanceof Error?r(s.value):n(s.value);i()});return r.name=(t[Symbol.toStringTag]||""+t||"#"+r.priority)+"$",r}throw Error("Observable.from incorrect input")},e.prototype.startWith=function(t){var n=new e;return n.next(t),this.subscribe(n),n.name=this.name+" [T, ...$]",n},e.prototype.map=function(t){var n=this,r=new e(function(e){var i=n.subscribe(function(n){try{var i=a.diagnose.isOn&&a.diagnose.measure("$> "+r.name),o=t(n);i&&i(),e.next(o)}catch(t){e.error(t)}},e.error,e.complete);return function(){return i.unsubscribe()}});return r.name=this.name+" |> "+(t.name||"#"+r.priority),r},e.prototype.flatten=function(){var t=this,n=new e(function(e){t.subscribe(function(t){t&&t.subscribe(function(t){e.next(t)},function(t){return e.error(t)})},e.error,e.complete)});return n.name=this.name+" $$>$",n},e.prototype.scan=function(t,n){var r=this,i=new e(function(e){var i=n,o=0,s=r.subscribe(function(n){try{i=t(i,n,o++),e.next(i)}catch(t){e.error(t)}},e.error,e.complete);return function(){return s.unsubscribe()}}),o=this.name+" +="+(t.name||"#"+i.priority);return i.name=o,i},e.prototype.filter=function(t){var n=this,r=new e(function(e){var r=n.subscribe(function(n){try{t(n)&&e.next(n)}catch(t){e.error(t)}},e.error,e.complete);return function(){return r.unsubscribe()}}),i=this.name+" ?"+(t.name||"#"+r.priority);return r.name=i,r},e.prototype.merge=function(){for(var t=[],n=0;arguments.length>n;n++)t[n]=arguments[n];var r=0,i=new e,o={start:function(){},next:function(t){i.next(t)},error:function(t){i.error(t)},complete:function(){r++,r===t.length+1&&i.complete()}};return this.subscribe(o),t.forEach(function(t){return t.subscribe(o)}),i.name="( "+[this].concat(t).map(function(t){return t.name}).join(" + ")+" )",i},e.prototype.distinct=function(t){var n=this,r=new e(function(e){var r,i=!1;n.subscribe({start:function(){},next:function(n){if(t){if(!t(r,n))return}else if(i&&r===n)return;i=!0,r=n,e.next(n)},error:function(t){e.error(t)},complete:function(){e.complete()}})});return r.name=this.name+" !=="+(t&&t.name?t.name:""),r},e.prototype.bufferCount=function(t,n){var r=this,i=void 0===n?t:n,o=[],s=new e(function(e){var n=r.subscribe(function(n){o.push(n),o.length===t&&(e.next(o.slice()),o=o.splice(i,t-i))},e.error,function(){o.length>t-i&&e.next(o.slice()),e.complete()});return function(){return n.unsubscribe()}});return s.name=this.name+" >|>"+t+","+i,s},e.prototype.buffer=function(t){var n=this;void 0===t&&(t=0);var r=[],i=new e(function(e){var i=n.subscribe(function(n){r=t>0?[n].concat(r).splice(0,t):[n].concat(r),s.dispatch(function(){0!==r.length&&e.next(r.splice(0).reverse())},o.DispatcherPriorities.BUFFER)},e.error,function(){r.length>0&&e.next(r.splice(0).reverse()),e.complete()});return function(){return i.unsubscribe()}});return i.name=this.name+" >|>",i},e}(i.BaseObservable);e.Observable=c,c.prototype[u]=function(){return this}},function(t,e,n){"use strict";var r,i=n(2),o=n(3),s=n(1),a=n(10);!function(t){t[t.Next=0]="Next",t[t.Error=1]="Error",t[t.Complete=2]="Complete"}(r=e.MessageTypes||(e.MessageTypes={}));var u=function(){},c=function(){function t(e){var n=this;this.closed=!1;var i=this;return this.observers=[],this.priority=t.lastObservablePriority++,this.name=e&&"string"==typeof e.name&&e.name.length>0?e.name+"$":this.priority+"$",e?void(this.cancelSubscriber=e({next:function(t){n.pushMessage([r.Next,t,u])},error:function(t){n.pushMessage([r.Error,t,u])},complete:function(){n.pushMessage([r.Complete,,u])},get closed(){return i.observers.length>0}})||u):void(this.cancelSubscriber=u)}return t.prototype.previous=function(){return this.lastValue},t.prototype.start=function(){},t.prototype.next=function(t){this.pushMessage([r.Next,t,u])},t.prototype.error=function(t){this.pushMessage([r.Error,t,u])},t.prototype.complete=function(){this.pushMessage([r.Complete,,u])},t.prototype.subscribe=function(){for(var e=this,n=[],r=0;arguments.length>r;r++)n[r]=arguments[r];if(this.closed)return new a.Subscription(null,function(){return!1});if("object"!=typeof n[0]||null===n[0]){var i=n[0],o=void 0===i?u:i,s=n[1],c=void 0===s?u:s,f=n[2],p=void 0===f?u:f;return this.subscribe({start:u,next:o,error:c,complete:p})}var l=n[0];this.observers.push(l);var h=new a.Subscription(function(){e.observers=e.observers.filter(function(t){return t!==l})},function(){return e.observers.indexOf(l)>-1});return l.start(h),t.dispatchDigestMessages(),h},t.prototype.pushMessage=function(e){this.closed||(t.awaitingMessages.push([this,e]),t.dispatchDigestMessages())},t.dispatchDigestMessages=function(){i.dispatch(t.digestAwaitingMessages,o.DispatcherPriorities.OBSERVABLE)},t.digestAwaitingMessages=function(){var e=t.popMessage(),n=e[0],r=e[1];n&&!n.closed&&(t.digestNodeMessage(n,r),t.dispatchDigestMessages())},t.popMessage=function(){if(0===t.awaitingMessages.length)return[null,null];for(var e=0;t.awaitingMessages.length>e;e++){var n=t.awaitingMessages[e],r=n[0],i=void 0===r?null:r,o=n[1];if(i.observers.length)return t.awaitingMessages.splice(e,1),[i,o]}return[null,null]},t.digestNodeMessage=function(t,e){var n=e[0],a=e[2];if(n===r.Next){var c,f=e,p=f[1];if("function"==typeof p){var l=p,h=s.diagnose.isOn&&s.diagnose.measure("$> "+(t.name||"[anonymous]")+".next"+(l.name?"("+l.name+")":""));c=l(t.lastValue),h&&h()}else c=p;t.lastValue=c,t.observers.forEach(function(t){return t.next(c)})}else if(n===r.Error){var b=e,v=b[1];t.observers.forEach(function(t){return t.error(v)})}else n===r.Complete&&(t.cancelSubscriber(),t.cancelSubscriber=u,t.closed=!0,t.observers.splice(0).forEach(function(t){return t.complete()}));i.dispatch(a,o.DispatcherPriorities.OBSERVABLE)},t}();c.awaitingMessages=[],c.lastObservablePriority=0,e.BaseObservable=c},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=this&&this.__assign||Object.assign||function(t){for(var e,n=1,r=arguments.length;r>n;n++){e=arguments[n];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},o=n(4),s=function(t){function e(e){var n=t.call(this,function(t){var n=[],r=[],o=[],s={},a=[],u=function(u){return Object.prototype.hasOwnProperty.call(e,u)?(n.push(u),void a.push(e[u].subscribe(function(e){if(o&&o.push([u,e]),r.indexOf(u)<0&&r.push(u),n.length===r.length){if(o){for(var a={},c=[],f=[],p=0;o.length>p;p++)if(c.indexOf(o[p][0])<0){var l=o[p],h=l[0],b=l[1];a[h]=b,c.push(h)}else f.push(o[p]);return t.next(s=a),f.forEach(function(e){var n=e[0],r=e[1];t.next(s=i({},s,(o={},o[n]=r,o)));var o}),void(o=null)}t.next(s=i({},s,(v={},v[u]=e,v)));var v}}))):"continue"};for(var c in e)u(c);return function(){a.forEach(function(t){return t()})}})||this,r=[];for(var o in e){if(!Object.prototype.hasOwnProperty.call(e,o))return n;r.push(o)}return n.name="{"+r.map(function(t){return e[t]&&!e[t].name&&e[t].name!==t?t+": "+e[t].name:t}).join(", ")+"}",n}return r(e,t),e}(o.Observable);e.Combine=s},function(t,e){"use strict";var n=function(){function t(){this._isRunning=!1,this.subsequentCalls=0,this.tasks=[]}return Object.defineProperty(t.prototype,"isRunning",{get:function(){return this._isRunning},enumerable:!0,configurable:!0}),t.prototype.push=function(t,e){return this.tasks.push({priority:e,execute:t}),this},t.prototype.run=function(){var t=this;this._isRunning||(this._isRunning=!0,Promise.resolve().then(function(){return t.loop()}))},t.prototype.loop=function(){var t=this,e=this.findNextTask();return e?(this.subsequentCalls>1024&&this.tooManyCalls(),this.subsequentCalls++,void this.next(e.execute,function(){return t.loop()})):(this._isRunning=!1,void(this.subsequentCalls=0))},t.prototype.tooManyCalls=function(){"If you see this, that means your code sent too many subsequent messages.";"This situation is considered harmful, as it may introduce serious lag of your app."},t.prototype.findNextTask=function(){for(var t=null,e=0;this.tasks.length>e;e++)(null===t||this.tasks[t].priority>this.tasks[e].priority)&&(t=e);return null===t?null:this.tasks.splice(t,1)[0]},t.prototype.next=function(t,e){try{t()}catch(t){console.error(t.stack||t.message||t)}e()},t}();e.Dispatcher=n},function(t,e,n){"use strict";function r(t,e,n){var r=n.value;n.value=function(){for(var t=this,n=[],a=0;arguments.length>a;a++)n[a]=arguments[a];return o.dispatchPromise(function(){var i=s.diagnose.measure("<$ "+(t.name?t.name+".":"")+e),o=r.apply(t,n);return i&&i(),o},i.DispatcherPriorities.DOMAIN)}}var i=n(3),o=n(2),s=n(1);e.action=r},function(t,e,n){"use strict";var r=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},i=n(4),o=n(3),s=n(2),a=n(1),u=function(t){function e(e){var n=this;return e?n=t.call(this,function(){e.subscribe(n)})||this:void(n=t.call(this)||this)}return r(e,t),e.tagged=function(t){for(var n=[],r=1;arguments.length>r;r++)n[r-1]=arguments[r];var i=function(){for(var r=[],i=0;arguments.length>i;i++)r[i]=arguments[i];var o=e.create.apply(void 0,r);return o.name=t.reduce(function(t,e,r){return t+(r>0?n[r-1]:"")+e}),o};return i},e.create=function(){for(var t=[],n=0;arguments.length>n;n++)t[n]=arguments[n];var r,i,u,c;"string"==typeof t[0]&&(r=t.shift()),"object"==typeof t[0]&&null!==t[0]&&"function"==typeof t[0].subscribe&&(i=t.shift()),u=t.shift(),c=t.shift();var f=new e(i);if(f.name=void 0!==r?r:f.priority+"$!",u){var p=function(t){var e=t;return Object.prototype.hasOwnProperty.call(u,t)?void(f[t]=function(){for(var n=[],r=0;arguments.length>r;r++)n[r]=arguments[r];return s.dispatchPromise(function(){var r=a.diagnose.measure("<$ "+(f.name?f.name+".":"")+e),i=u[t].apply(f,n);return r&&r(),i},o.DispatcherPriorities.DOMAIN)}):"continue"};for(var l in u)p(l)}if(c)for(var h in c)Object.prototype.hasOwnProperty.call(c,h)&&(f[h]=c[h]);return f},e}(i.Observable);e.Domain=u},function(t,e){"use strict";var n=function(){function t(t,e){this.customUnsubscribe=t,this.isSubscriptionActive=e}return Object.defineProperty(t.prototype,"closed",{get:function(){return!this.isSubscriptionActive()},enumerable:!0,configurable:!0}),t.prototype.unsubscribe=function(){var t=this.customUnsubscribe;t&&(this.customUnsubscribe=null,t&&t())},t}();e.Subscription=n}])}); | ||
//# sourceMappingURL=immview.js.map |
@@ -8,8 +8,8 @@ import { BaseObservable } from './BaseObservable'; | ||
flatten<U>(this: Observable<Observable<U>>): Observable<U>; | ||
scan<U>(reductor: (accumulator: U, value: T, index: number) => U): Observable<U>; | ||
scan<U>(reductor: (accumulator: U, value: T, index: number) => U, defaultValue?: U): Observable<U>; | ||
filter(filter: (value: T) => boolean): Observable<T>; | ||
merge(...others: Observable<T>[]): Observable<T>; | ||
distinct(): Observable<T>; | ||
distinct(comparator?: (prev: T, next: T) => boolean): Observable<T>; | ||
bufferCount(bufferWindow: number, customBufferStep?: number): Observable<T[]>; | ||
buffer(maxLastValues?: number): Observable<T[]>; | ||
} |
@@ -86,6 +86,6 @@ "use strict"; | ||
}; | ||
Observable.prototype.scan = function (reductor) { | ||
Observable.prototype.scan = function (reductor, defaultValue) { | ||
var _this = this; | ||
var newObservable = new Observable(function (observer) { | ||
var summary; | ||
var summary = defaultValue; | ||
var index = 0; | ||
@@ -147,3 +147,3 @@ var subscription = _this.subscribe(function (value) { | ||
}; | ||
Observable.prototype.distinct = function () { | ||
Observable.prototype.distinct = function (comparator) { | ||
var _this = this; | ||
@@ -156,4 +156,10 @@ var newObservable = new Observable(function (observer) { | ||
next: function (value) { | ||
if (everPushed && last === value) | ||
return; | ||
if (comparator) { | ||
if (!comparator(last, value)) | ||
return; | ||
} | ||
else { | ||
if (everPushed && last === value) | ||
return; | ||
} | ||
everPushed = true; | ||
@@ -167,3 +173,3 @@ last = value; | ||
}); | ||
newObservable.name = this.name + " !=="; | ||
newObservable.name = this.name + " !==" + (comparator ? (!!comparator.name ? comparator.name : '') : ''); | ||
return newObservable; | ||
@@ -170,0 +176,0 @@ }; |
@@ -68,13 +68,27 @@ "use strict"; | ||
}); | ||
it('can scan messages, and reduce output', function (done) { | ||
var pushValues = [1, 2, 3]; | ||
var expectedValues = [2, 6, 12]; | ||
var result = []; | ||
Observable_1.Observable.from(pushValues).scan(function (summary, value) { return (summary | 0) + value * 2; }).subscribe(function (value) { | ||
result.push(value); | ||
expect(value).toBe(expectedValues.shift()); | ||
if (result.length === 3) { | ||
setTimeout(done); | ||
} | ||
describe('can scan messages, and reduce output', function () { | ||
it('without default value', function (done) { | ||
var pushValues = [1, 2, 3]; | ||
var expectedValues = [2, 6, 12]; | ||
var result = []; | ||
Observable_1.Observable.from(pushValues).scan(function (summary, value) { return (summary | 0) + value * 2; }).subscribe(function (value) { | ||
result.push(value); | ||
expect(value).toBe(expectedValues.shift()); | ||
if (result.length === 3) { | ||
setTimeout(done); | ||
} | ||
}); | ||
}); | ||
it('with a default value', function (done) { | ||
var pushValues = [1, 2, 3]; | ||
var expectedValues = [5, 9, 15]; | ||
var result = []; | ||
Observable_1.Observable.from(pushValues).scan(function (summary, value) { return summary + value * 2; }, 3).subscribe(function (value) { | ||
result.push(value); | ||
expect(value).toBe(expectedValues.shift()); | ||
if (result.length === 3) { | ||
setTimeout(done); | ||
} | ||
}); | ||
}); | ||
}); | ||
@@ -220,12 +234,24 @@ it('can map messages', function (done) { | ||
}); | ||
it('creates a stream with only distinct values', function (done) { | ||
var values = []; | ||
var ref = {}; | ||
Observable_1.Observable.of(1, 2, 2, 3, ref, ref, 1).distinct().subscribe(function (v) { | ||
values.push(v); | ||
describe('creates a stream with only distinct values', function () { | ||
it('without a comparator', function (done) { | ||
var values = []; | ||
var ref = {}; | ||
Observable_1.Observable.of(1, 2, 2, 3, ref, ref, 1).distinct().subscribe(function (v) { values.push(v); }); | ||
DispatcherInstance_1.dispatch(function () { | ||
expect(values).toEqual([1, 2, 3, ref, 1]); | ||
done(); | ||
}, TEST); | ||
}); | ||
DispatcherInstance_1.dispatch(function () { | ||
expect(values).toEqual([1, 2, 3, ref, 1]); | ||
done(); | ||
}, TEST); | ||
it('with a comparator', function (done) { | ||
var values = []; | ||
var ref = {}; | ||
Observable_1.Observable | ||
.of(1, 2, 2, 3, ref, ref, 1) | ||
.distinct(function (prev, next) { return (typeof prev !== typeof next); }) | ||
.subscribe(function (v) { values.push(v); }); | ||
DispatcherInstance_1.dispatch(function () { | ||
expect(values).toEqual([1, ref, 1]); | ||
done(); | ||
}, TEST); | ||
}); | ||
}); | ||
@@ -232,0 +258,0 @@ it('can take buffered messages with default interval', function (done) { |
18
docs.md
@@ -45,2 +45,5 @@ <!-- TOC --> | ||
**Stream is immediately completed after all values are pushed.** | ||
If you wish to create a stream and kickstart it with a value(s), use `startWith`. | ||
--- | ||
@@ -52,2 +55,5 @@ ### Observable.`from` | ||
**Stream is immediately completed after all values are pushed.** | ||
If you wish to create a stream and kickstart it with a value(s), use `startWith`. | ||
--- | ||
@@ -122,3 +128,3 @@ ### Observable.prototype.`previous` | ||
### Observable.prototype.`scan` | ||
`(accumulator: (summary: U, value: T, index: number) => U): Observable<U>` | ||
`(accumulator: (summary: U, value: T, index: number) => U, defaultValue?: U): Observable<U>` | ||
@@ -129,4 +135,4 @@ Creates a derivative stream of values where | ||
getting last pushed value and new value that has been pushed by parent `Observable`. | ||
Result of the function is next value of newly created `Observable`. | ||
First call is with summary being undefined unless `defautValue` is also passed. | ||
@@ -149,3 +155,3 @@ --- | ||
### Observable.prototype.`distinct` | ||
`(): Observable<T>` | ||
`(comparator?: (prev: T, next: T) => boolean): Observable<T>` | ||
@@ -155,2 +161,6 @@ Creates a derivative stream of values | ||
If `comparator` is passed, it is going to be used | ||
to determine if a value is distinct from previous one. | ||
Otherwise strict equal is incorporated. | ||
--- | ||
@@ -221,3 +231,3 @@ ### Observable.prototype.`buffer` | ||
### Domain.create | ||
`( source: observable<t> , actions: { [name: string]: () => promise<any> | void }, fields: {}) => Domain` | ||
`( name?: string, source?: observable<t>, actions: { [name: string]: () => promise<any> | void }, fields?: {}) => Domain` | ||
@@ -224,0 +234,0 @@ `Domain` class by design is the only thing that should be exported and used (maybe with an exception of type definitions) outside of `Domain`s scope. |
{ | ||
"name": "immview", | ||
"version": "2.0.13", | ||
"version": "2.0.14", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
310074
2131