Comparing version 1.7.1 to 1.7.2
#Changelog | ||
## 1.7.2 | ||
- fix: Proxy based immutability was getting in the way of native js functions due to shadowing of referential equality, so it has been disabled. | ||
## 1.7.1 | ||
@@ -4,0 +7,0 @@ - fix: object once immutabilized is not immutabilized again |
@@ -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(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0}),e.dispatch=e.Dispatcher=e.Reduce=e.Merge=e.Scan=e.Throttle=e.Debounce=e.Domain=e.View=e.Data=e.Observable=void 0;var i=r(1),o=n(i),u=r(12),s=n(u),a=r(13),c=n(a),f=r(6),l=n(f),d=r(8),h=n(d),p=r(9),m=n(p),b=r(10),y=n(b),g=r(14),v=n(g),_=r(11),j=n(_),w=r(3);e.Observable=o.default,e.Data=c.default,e.View=l.default,e.Domain=s.default,e.Debounce=h.default,e.Throttle=m.default,e.Scan=y.default,e.Merge=v.default,e.Reduce=j.default,e.Dispatcher=w.Dispatcher,e.dispatch=w.dispatch},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function o(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t}function u(){var t=this;this.structure=null,this.priority=u.nextPriority++,this.subscriptions=[function(e){t.structure=e}],this.closed=!1}function s(t){return void 0!==t&&null!==t}function a(t){return t}Object.defineProperty(e,"__esModule",{value:!0}),e.default=u;var c=r(2),f=i(c),l=r(3),d=i(l),h=r(4),p=r(5);n(p);u.nextPriority=0,u.prototype={structure:null,priority:0,subscriptions:[],closed:!1,read:function(){return this.structure},shouldObservableUpdate:function(t){return s(t)?"object"===(void 0===t?"undefined":o(t))?!(0,h.isImmutabilized)(t)||this.read()!==t:this.read()!==t:!1},consume:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a;f.queue(this,t,e)},digest:function(t){var e=this;this.digestCandidate||t instanceof Promise?this.digestCandidate=(this.digestCandidate||Promise.resolve()).then(function(){return t}).then(function(t){return e.flush(t)}):this.flush(t)},flush:function(t){if(this.shouldObservableUpdate(t))for(var e=0;this.subscriptions&&this.subscriptions.length>e;e++)this.subscriptions[e]((0,h.immutabilize)(t))},addSubscription:function(t){var e=this;return this.subscriptions.indexOf(t)<0&&this.subscriptions.push(t),function(){e.subscriptions=e.subscriptions.filter(function(e){return e!==t})}},subscribe:function(t){return t(this.read()),this.addSubscription(t)},destroy:function(){d.rejectContext(this),this.structure=null,this.subscriptions=[],Object.defineProperty?Object.defineProperty(this,"closed",{value:!0,writable:!1}):this.closed=!0},map:function(t){var e=r(6).default;return new e(this,t)},debounce:function(t){var e=r(8).default;return new e(this,t)},throttle:function(t){var e=r(9).default;return new e(this,t)},scan:function(t,e){var n=r(10).default;return new n(this,t,e)},reduce:function(t){var e=r(11).default;return new e(this,t)},info:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";try{var e=JSON.stringify(this.read()).substr(0,32);d.Dispatcher.logger.log("#"+this.priority+" "+t+" "+e)}catch(r){d.Dispatcher.logger.log("#"+this.priority+" "+t,this.read())}}}},function(t,e,r){"use strict";function n(t,e,r){(0,a.dispatchDataConsume)(function(){i(t,e,r),o()})}function i(t,e,r){for(var n=0;c.length>n;n++){if(c[n].observable.priority===t.priority)return void(c[n].data=e);if(c[n].observable.priority>t.priority)return void c.splice(n,0,{observable:t,data:e,process:r})}c.splice(c.length,0,{observable:t,data:e,process:r})}function o(){(0,a.dispatchDataWrite)(u)}function u(){if(c.length){var t=c.splice(0,1),e=s(t,1),r=e[0],n=r.observable,i=r.data,u=r.process;n.digest(u(i)),o()}}var s=function(){function t(t,e){var r=[],n=!0,i=!1,o=void 0;try{for(var u,s=t[Symbol.iterator]();!(n=(u=s.next()).done)&&(r.push(u.value),!e||r.length!==e);n=!0);}catch(a){i=!0,o=a}finally{try{!n&&s.return&&s.return()}finally{if(i)throw o}}return r}return function(e,r){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();Object.defineProperty(e,"__esModule",{value:!0}),e.queue=n;var a=r(3),c=[]},function(t,e){"use strict";function r(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t}function n(){var t=i();if(t){var e=t.context,r=t.action,n=t.args;r&&r.apply(e,n)}}function i(){var t=o();return t&&b.splice(b.indexOf(t),1),t}function o(){for(var t=-1,e=null,r=0;b.length>r;r++){var n=b[r].priority;n>t&&(e=b[r],t=n)}return e}function u(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:g;b.push({priority:n,action:t,context:e,args:r})}function s(t,e,r){l(t,e,r,v)}function a(t,e,r){l(t,e,r,_)}function c(t,e,r){l(t,e,r,j)}function f(t,e,r){l(t,e,r,g)}function l(t,e,r,n){u(t,e,r,n),d()}function d(){m||b.length>0&&(m=!0,w.tick(function(){try{n()}catch(t){h(t)}m=!1,d()}))}function h(t){w.logger.error(y+"Error occured while running a function"),"object"===(void 0===t?"undefined":r(t))?t.stack?w.logger.error(t.stack):w.logger.error(t.name,t.message):w.logger.error(t)}function p(t){b=b.filter(function(e){return e.context!==t})}Object.defineProperty(e,"__esModule",{value:!0});var m=!1,b=[],y="Immview::Dispatcher: ",g=0,v=1,_=2,j=3,w={dispatch:f,tick:function(t){t()},rejectContext:p,logger:console};e.default=w,e.Dispatcher=w,e.dispatch=l,e.dispatchDomainAction=s,e.dispatchDataWrite=a,e.dispatchDataConsume=c,e.dispatchExternal=f,e.rejectContext=p},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t}function o(t){return!!t[l]}function u(t){try{return[!0,JSON.stringify(t)]}catch(e){return[!1,""]}}function s(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:32;return t.length>e?t.substr(0,29).replace(/\r/g,"").replace(/\n/g,"")+"...":t}var a=function(){function t(t,e){var r=[],n=!0,i=!1,o=void 0;try{for(var u,s=t[Symbol.iterator]();!(n=(u=s.next()).done)&&(r.push(u.value),!e||r.length!==e);n=!0);}catch(a){i=!0,o=a}finally{try{!n&&s.return&&s.return()}finally{if(i)throw o}}return r}return function(e,r){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();Object.defineProperty(e,"__esModule",{value:!0}),e.immutabilize=void 0,e.isImmutabilized=o;var c=r(5),f=n(c),l="__$immutabilized",d=e.immutabilize="function"!=typeof Proxy?function(t){return t}:function(t){return"object"!==(void 0===t?"undefined":i(t))||null===t||void 0===t?t:o(t)?t:new Proxy(t,{get:function(e,r){return r===l?!0:"toString"===r?function(){return""+t}:d(e[r])},set:function(t,e,r,n){if("production"===f.default)return!1;var i=u(n),o=a(i,2),c=o[0],l=o[1];if(c)throw Error(["Immutabilizer: Object",s(l),"has been frozen in order to contain side-effects. You should not modify this object."].join(" "));throw Error("Immutabilizer: Unrepresentable object has been frozen in order to contain side-effects. You should not modify this object.")}})};e.default=d},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=void 0;try{n=function(){return"production"}()}catch(i){n="production"}e.default=n},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t}function o(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:u;if(d.default.call(this),t&&"object"===(void 0===t?"undefined":i(t)))return void(this.unsubs=t.subscribe?s(this,t,e):a(this,t,e));throw Error(m+"No sources to plug in")}function u(t){return t}function s(t,e,r){return t.digest(r(e.read())),[e.addSubscription(function(e){return t.consume(e,r)})]}function a(t,e,r){"production"!==p.default&&console.warn([m,"View usage for merging streams is deprecated since 1.7. Consider changing to Merge type of node."].join(" "));var n=new f.default,i=Object.keys(e);i.forEach(function(t){var r=e[t],i=r.read();n=n.set(t,i)});var o=i.map(function(i){return e[i].addSubscription(function(e){n=n.set(i,e),t.consume(n.clone(),r)})});return t.digest(r(n.clone())),o}Object.defineProperty(e,"__esModule",{value:!0}),e.default=o;var c=r(7),f=n(c),l=r(1),d=n(l),h=r(5),p=n(h),m="Immview::View: ";o.prototype=Object.create(d.default.prototype),o.prototype.destroy=function(){d.default.prototype.destroy.call(this),this.unsubs&&this.unsubs.forEach(function(t){return t()}),this.unsubs=null}},function(t,e){"use strict";function r(t){return Array.isArray(t)?t:Array.from(t)}function n(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t}function i(t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(this[e]=t[e])}Object.defineProperty(e,"__esModule",{value:!0}),e.default=i,i.prototype={clone:function(){return new i(this)},set:function(t,e){var r=new i(this);return r[t]=e,r},get:function(t){return this[t]},map:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this,r=new i;for(var n in this)Object.prototype.hasOwnProperty.call(this,n)&&(r[n]=t.call(e,this[n]));return r},toJS:function(){return this.map(function(t){return"object"===(void 0===t?"undefined":n(t))&&"function"==typeof t.toJS?t.toJS():t})},toObject:function(){return this},getIn:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=r(t),n=e[0],i=e.slice(1),o=arguments[1];return i.length?this.get(n).getIn(i,o):void 0===this.get(n)?o:this.get(n)},setIn:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=r(t),n=e[0],o=e.slice(1),u=arguments[1];return o.length?this.set(n,(this.get(n)||new i).setIn(o,u)):this.set(n,u)}}},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(u.default.call(this),!t||!t.subscribe)throw Error(s+"incorrect source");this.timeoutID=null,this.digest(t.read()),this.subscription=t.addSubscription(function(t){e.timeoutID&&clearTimeout(e.timeoutID),e.timeoutID=setTimeout(function(){e.timeoutID=null,e.consume(t)},r)})}Object.defineProperty(e,"__esModule",{value:!0}),e.default=i;var o=r(1),u=n(o),s="Immview::Debounce: ";i.prototype=Object.create(u.default.prototype),i.prototype.destroy=function(){this.timeoutID&&(clearTimeout(this.timeoutID),this.timeoutID=null),this.subscription&&this.subscription(),u.default.prototype.destroy.call(this)}},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(u.default.call(this),!t||!t.subscribe)throw Error(s+"incorrect source");this.timeoutID=null,this.timeoutedData=null,this.digest(t.read()),this.subscription=t.addSubscription(function(t){e.timeoutedData=t,e.timeoutID||(e.timeoutID=setTimeout(function(){e.timeoutID=null,e.consume(e.timeoutedData)},r))})}Object.defineProperty(e,"__esModule",{value:!0}),e.default=i;var o=r(1),u=n(o),s="Immview::Throttle: ";i.prototype=Object.create(u.default.prototype),i.prototype.destroy=function(){this.timeoutID&&(clearTimeout(this.timeoutID),this.timeoutID=null),this.subscription&&this.subscription(),u.default.prototype.destroy.call(this)}},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;a.default.apply(this);var i=u(o(n,r),r,t.read());this.digest(i),this.unsubscribe=t.addSubscription(function(t){i=u(i,r,t),e.consume(i)})}function o(t,e){if(null===t)return[];for(var r=[],n=0;e>n;n++)r.push(t);return r}function u(t,e,r){var n=t.slice(-1*e+1);return n.push(r),n}Object.defineProperty(e,"__esModule",{value:!0}),e.default=i;var s=r(1),a=n(s);i.prototype=Object.create(a.default.prototype),i.prototype.destroy=function(){a.default.prototype.destroy.apply(this),this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null)}},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){var r=this;if("production"!==a.default){if(!t)throw Error(c+" #"+this.priority+": No source");if(!t.subscribe)throw Error(c+" #"+this.priority+": Source is not an observable");if(!e)throw Error(c+" #"+this.priority+": No reducer provided")}u.default.call(this),this.unsubscribeFromSource=t.subscribe(function(t){r.consume(e(r.read(),t))})}Object.defineProperty(e,"__esModule",{value:!0});var o=r(1),u=n(o),s=r(5),a=n(s),c="Immview::Reduce";i.prototype=Object.create(u.default.prototype),i.prototype.destroy=function(){this.closed||(this.unsubscribeFromSource(),u.default.prototype.destroy.call(this))},e.default=i},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){if(!t.subscribe)throw Error(c+" stream source required");this.stream=t,o(this,e)}function o(t,e){if(!e)return void(t.actions=function(){return[]});var r=Object.keys(e);r.forEach(function(r){var n=e[r];if(void 0!==t[r])throw Error(""+c+r+" is reserved for Domain interface");if("function"!=typeof n)throw Error(""+c+r+" action is not a function");t[r]=function(){for(var e=arguments.length,r=Array(e),i=0;e>i;i++)r[i]=arguments[i];(0,u.dispatchDomainAction)(n,t,r)},t[r].originalLength=n.length||n.originalLength}),t._actionNames=r,t.actions=function(){return r}}Object.defineProperty(e,"__esModule",{value:!0}),e.default=i;var u=r(3),s=r(1),a=(n(s),function(){return null}),c="Immview::Domain: ";i.prototype={read:function(){return this.stream.read()},map:function(){for(var t=arguments.length,e=Array(t),r=0;t>r;r++)e[r]=arguments[r];return this.stream.map.apply(this.stream,e)},debounce:function(){for(var t=arguments.length,e=Array(t),r=0;t>r;r++)e[r]=arguments[r];return this.stream.debounce.apply(this.stream,e)},throttle:function(){for(var t=arguments.length,e=Array(t),r=0;t>r;r++)e[r]=arguments[r];return this.stream.throttle.apply(this.stream,e)},scan:function(){for(var t=arguments.length,e=Array(t),r=0;t>r;r++)e[r]=arguments[r];return this.stream.scan.apply(this.stream,e)},reduce:function(){for(var t=arguments.length,e=Array(t),r=0;t>r;r++)e[r]=arguments[r];return this.stream.reduce.apply(this.stream,e)},subscribe:function(){for(var t=arguments.length,e=Array(t),r=0;t>r;r++)e[r]=arguments[r];return this.stream.subscribe.apply(this.stream,e)},addSubscription:function(){for(var t=arguments.length,e=Array(t),r=0;t>r;r++)e[r]=arguments[r];return this.stream.addSubscription.apply(this.stream,e)},destroy:function(){var t=this;this.stream.destroy(),this.stream=null,(0,u.rejectContext)(this),this._actionNames.forEach(function(e){t[e]=a}),this._actionNames=null}}},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t){s.default.call(this),this.digest(t),this.pendingChanges=[]}function o(t){if(t.closed)return t.read();var e=t.pendingChanges.reduce(function(t,e){return e(t)},t.read());return t.pendingChanges=[],e}Object.defineProperty(e,"__esModule",{value:!0}),e.default=i;var u=r(1),s=n(u);i.prototype=Object.create(s.default.prototype),i.prototype.write=function(t){this.closed||("function"==typeof t?(this.pendingChanges.push(t),this.consume(this,o)):this.consume(t))},i.prototype.destroy=function(){s.default.prototype.destroy.call(this),this.pendingChanges=null}},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function o(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t}function u(t){var e=this;if(a.default.call(this),!t||"object"!==(void 0===t?"undefined":o(t)))throw Error(c+" No sources to plug in");var r=Object.keys(t),n=r.reduce(function(e,r){return Object.assign(i({},r,t[r].read()),e)},{});this.unsubs=r.map(function(r){return t[r].addSubscription(function(t){n=Object.assign({},n,i({},r,t)),e.consume(n)})}),this.digest(Object.assign({},n))}Object.defineProperty(e,"__esModule",{value:!0}),e.default=u;var s=r(1),a=n(s),c="Immview::Merge:";u.prototype=Object.create(a.default.prototype),u.prototype.destroy=function(){a.default.prototype.destroy.call(this),this.unsubs&&this.unsubs.forEach(function(t){return t()}),this.unsubs=null}}])}); | ||
!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(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}Object.defineProperty(e,"__esModule",{value:!0}),e.dispatch=e.Dispatcher=e.Reduce=e.Merge=e.Scan=e.Throttle=e.Debounce=e.Domain=e.View=e.Data=e.Observable=void 0;var i=r(1),o=n(i),u=r(11),s=n(u),a=r(12),c=n(a),f=r(5),l=n(f),d=r(7),h=n(d),p=r(8),m=n(p),g=r(9),y=n(g),b=r(13),v=n(b),_=r(10),j=n(_),O=r(3);e.Observable=o.default,e.Data=c.default,e.View=l.default,e.Domain=s.default,e.Debounce=h.default,e.Throttle=m.default,e.Scan=y.default,e.Merge=v.default,e.Reduce=j.default,e.Dispatcher=O.Dispatcher,e.dispatch=O.dispatch},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function o(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t}function u(){var t=this;this.structure=null,this.priority=u.nextPriority++,this.subscriptions=[function(e){t.structure=e}],this.closed=!1}function s(t){return void 0!==t&&null!==t}function a(t){return t}Object.defineProperty(e,"__esModule",{value:!0}),e.default=u;var c=r(2),f=i(c),l=r(3),d=i(l),h=r(4);n(h);u.nextPriority=0,u.prototype={structure:null,priority:0,subscriptions:[],closed:!1,read:function(){return this.structure},shouldObservableUpdate:function(t){return s(t)?"object"===(void 0===t?"undefined":o(t))?!0:this.read()!==t:!1},consume:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a;f.queue(this,t,e)},digest:function(t){var e=this;this.digestCandidate||t instanceof Promise?this.digestCandidate=(this.digestCandidate||Promise.resolve()).then(function(){return t}).then(function(t){return e.flush(t)}):this.flush(t)},flush:function(t){if(this.shouldObservableUpdate(t))for(var e=0;this.subscriptions&&this.subscriptions.length>e;e++)this.subscriptions[e](t)},addSubscription:function(t){var e=this;return this.subscriptions.indexOf(t)<0&&this.subscriptions.push(t),function(){e.subscriptions=e.subscriptions.filter(function(e){return e!==t})}},subscribe:function(t){return t(this.read()),this.addSubscription(t)},destroy:function(){d.rejectContext(this),this.structure=null,this.subscriptions=[],Object.defineProperty?Object.defineProperty(this,"closed",{value:!0,writable:!1}):this.closed=!0},map:function(t){var e=r(5).default;return new e(this,t)},debounce:function(t){var e=r(7).default;return new e(this,t)},throttle:function(t){var e=r(8).default;return new e(this,t)},scan:function(t,e){var n=r(9).default;return new n(this,t,e)},reduce:function(t){var e=r(10).default;return new e(this,t)},info:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";try{var e=JSON.stringify(this.read()).substr(0,32);d.Dispatcher.logger.log("#"+this.priority+" "+t+" "+e)}catch(r){d.Dispatcher.logger.log("#"+this.priority+" "+t,this.read())}}}},function(t,e,r){"use strict";function n(t,e,r){(0,a.dispatchDataConsume)(function(){i(t,e,r),o()})}function i(t,e,r){for(var n=0;c.length>n;n++){if(c[n].observable.priority===t.priority)return void(c[n].data=e);if(c[n].observable.priority>t.priority)return void c.splice(n,0,{observable:t,data:e,process:r})}c.splice(c.length,0,{observable:t,data:e,process:r})}function o(){(0,a.dispatchDataWrite)(u)}function u(){if(c.length){var t=c.splice(0,1),e=s(t,1),r=e[0],n=r.observable,i=r.data,u=r.process;n.digest(u(i)),o()}}var s=function(){function t(t,e){var r=[],n=!0,i=!1,o=void 0;try{for(var u,s=t[Symbol.iterator]();!(n=(u=s.next()).done)&&(r.push(u.value),!e||r.length!==e);n=!0);}catch(a){i=!0,o=a}finally{try{!n&&s.return&&s.return()}finally{if(i)throw o}}return r}return function(e,r){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();Object.defineProperty(e,"__esModule",{value:!0}),e.queue=n;var a=r(3),c=[]},function(t,e){"use strict";function r(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t}function n(){var t=i();if(t){var e=t.context,r=t.action,n=t.args;r&&r.apply(e,n)}}function i(){var t=o();return t&&g.splice(g.indexOf(t),1),t}function o(){for(var t=-1,e=null,r=0;g.length>r;r++){var n=g[r].priority;n>t&&(e=g[r],t=n)}return e}function u(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:b;g.push({priority:n,action:t,context:e,args:r})}function s(t,e,r){l(t,e,r,v)}function a(t,e,r){l(t,e,r,_)}function c(t,e,r){l(t,e,r,j)}function f(t,e,r){l(t,e,r,b)}function l(t,e,r,n){u(t,e,r,n),d()}function d(){m||g.length>0&&(m=!0,O.tick(function(){try{n()}catch(t){h(t)}m=!1,d()}))}function h(t){O.logger.error(y+"Error occured while running a function"),"object"===(void 0===t?"undefined":r(t))?t.stack?O.logger.error(t.stack):O.logger.error(t.name,t.message):O.logger.error(t)}function p(t){g=g.filter(function(e){return e.context!==t})}Object.defineProperty(e,"__esModule",{value:!0});var m=!1,g=[],y="Immview::Dispatcher: ",b=0,v=1,_=2,j=3,O={dispatch:f,tick:function(t){t()},rejectContext:p,logger:console};e.default=O,e.Dispatcher=O,e.dispatch=l,e.dispatchDomainAction=s,e.dispatchDataWrite=a,e.dispatchDataConsume=c,e.dispatchExternal=f,e.rejectContext=p},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=void 0;try{n=function(){return"production"}()}catch(i){n="production"}e.default=n},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t}function o(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:u;if(d.default.call(this),t&&"object"===(void 0===t?"undefined":i(t)))return void(this.unsubs=t.subscribe?s(this,t,e):a(this,t,e));throw Error(m+"No sources to plug in")}function u(t){return t}function s(t,e,r){return t.digest(r(e.read())),[e.addSubscription(function(e){return t.consume(e,r)})]}function a(t,e,r){"production"!==p.default&&console.warn([m,"View usage for merging streams is deprecated since 1.7. Consider changing to Merge type of node."].join(" "));var n=new f.default,i=Object.keys(e);i.forEach(function(t){var r=e[t],i=r.read();n=n.set(t,i)});var o=i.map(function(i){return e[i].addSubscription(function(e){n=n.set(i,e),t.consume(n.clone(),r)})});return t.digest(r(n.clone())),o}Object.defineProperty(e,"__esModule",{value:!0}),e.default=o;var c=r(6),f=n(c),l=r(1),d=n(l),h=r(4),p=n(h),m="Immview::View: ";o.prototype=Object.create(d.default.prototype),o.prototype.destroy=function(){d.default.prototype.destroy.call(this),this.unsubs&&this.unsubs.forEach(function(t){return t()}),this.unsubs=null}},function(t,e){"use strict";function r(t){return Array.isArray(t)?t:Array.from(t)}function n(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t}function i(t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(this[e]=t[e])}Object.defineProperty(e,"__esModule",{value:!0}),e.default=i,i.prototype={clone:function(){return new i(this)},set:function(t,e){var r=new i(this);return r[t]=e,r},get:function(t){return this[t]},map:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this,r=new i;for(var n in this)Object.prototype.hasOwnProperty.call(this,n)&&(r[n]=t.call(e,this[n]));return r},toJS:function(){return this.map(function(t){return"object"===(void 0===t?"undefined":n(t))&&"function"==typeof t.toJS?t.toJS():t})},toObject:function(){return this},getIn:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=r(t),n=e[0],i=e.slice(1),o=arguments[1];return i.length?this.get(n).getIn(i,o):void 0===this.get(n)?o:this.get(n)},setIn:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=r(t),n=e[0],o=e.slice(1),u=arguments[1];return o.length?this.set(n,(this.get(n)||new i).setIn(o,u)):this.set(n,u)}}},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(u.default.call(this),!t||!t.subscribe)throw Error(s+"incorrect source");this.timeoutID=null,this.digest(t.read()),this.subscription=t.addSubscription(function(t){e.timeoutID&&clearTimeout(e.timeoutID),e.timeoutID=setTimeout(function(){e.timeoutID=null,e.consume(t)},r)})}Object.defineProperty(e,"__esModule",{value:!0}),e.default=i;var o=r(1),u=n(o),s="Immview::Debounce: ";i.prototype=Object.create(u.default.prototype),i.prototype.destroy=function(){this.timeoutID&&(clearTimeout(this.timeoutID),this.timeoutID=null),this.subscription&&this.subscription(),u.default.prototype.destroy.call(this)}},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(u.default.call(this),!t||!t.subscribe)throw Error(s+"incorrect source");this.timeoutID=null,this.timeoutedData=null,this.digest(t.read()),this.subscription=t.addSubscription(function(t){e.timeoutedData=t,e.timeoutID||(e.timeoutID=setTimeout(function(){e.timeoutID=null,e.consume(e.timeoutedData)},r))})}Object.defineProperty(e,"__esModule",{value:!0}),e.default=i;var o=r(1),u=n(o),s="Immview::Throttle: ";i.prototype=Object.create(u.default.prototype),i.prototype.destroy=function(){this.timeoutID&&(clearTimeout(this.timeoutID),this.timeoutID=null),this.subscription&&this.subscription(),u.default.prototype.destroy.call(this)}},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t){var e=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;a.default.apply(this);var i=u(o(n,r),r,t.read());this.digest(i),this.unsubscribe=t.addSubscription(function(t){i=u(i,r,t),e.consume(i)})}function o(t,e){if(null===t)return[];for(var r=[],n=0;e>n;n++)r.push(t);return r}function u(t,e,r){var n=t.slice(-1*e+1);return n.push(r),n}Object.defineProperty(e,"__esModule",{value:!0}),e.default=i;var s=r(1),a=n(s);i.prototype=Object.create(a.default.prototype),i.prototype.destroy=function(){a.default.prototype.destroy.apply(this),this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=null)}},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){var r=this;if("production"!==a.default){if(!t)throw Error(c+" #"+this.priority+": No source");if(!t.subscribe)throw Error(c+" #"+this.priority+": Source is not an observable");if(!e)throw Error(c+" #"+this.priority+": No reducer provided")}u.default.call(this),this.unsubscribeFromSource=t.subscribe(function(t){r.consume(e(r.read(),t))})}Object.defineProperty(e,"__esModule",{value:!0});var o=r(1),u=n(o),s=r(4),a=n(s),c="Immview::Reduce";i.prototype=Object.create(u.default.prototype),i.prototype.destroy=function(){this.closed||(this.unsubscribeFromSource(),u.default.prototype.destroy.call(this))},e.default=i},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t,e){if(!t.subscribe)throw Error(c+" stream source required");this.stream=t,o(this,e)}function o(t,e){if(!e)return void(t.actions=function(){return[]});var r=Object.keys(e);r.forEach(function(r){var n=e[r];if(void 0!==t[r])throw Error(""+c+r+" is reserved for Domain interface");if("function"!=typeof n)throw Error(""+c+r+" action is not a function");t[r]=function(){for(var e=arguments.length,r=Array(e),i=0;e>i;i++)r[i]=arguments[i];(0,u.dispatchDomainAction)(n,t,r)},t[r].originalLength=n.length||n.originalLength}),t._actionNames=r,t.actions=function(){return r}}Object.defineProperty(e,"__esModule",{value:!0}),e.default=i;var u=r(3),s=r(1),a=(n(s),function(){return null}),c="Immview::Domain: ";i.prototype={read:function(){return this.stream.read()},map:function(){for(var t=arguments.length,e=Array(t),r=0;t>r;r++)e[r]=arguments[r];return this.stream.map.apply(this.stream,e)},debounce:function(){for(var t=arguments.length,e=Array(t),r=0;t>r;r++)e[r]=arguments[r];return this.stream.debounce.apply(this.stream,e)},throttle:function(){for(var t=arguments.length,e=Array(t),r=0;t>r;r++)e[r]=arguments[r];return this.stream.throttle.apply(this.stream,e)},scan:function(){for(var t=arguments.length,e=Array(t),r=0;t>r;r++)e[r]=arguments[r];return this.stream.scan.apply(this.stream,e)},reduce:function(){for(var t=arguments.length,e=Array(t),r=0;t>r;r++)e[r]=arguments[r];return this.stream.reduce.apply(this.stream,e)},subscribe:function(){for(var t=arguments.length,e=Array(t),r=0;t>r;r++)e[r]=arguments[r];return this.stream.subscribe.apply(this.stream,e)},addSubscription:function(){for(var t=arguments.length,e=Array(t),r=0;t>r;r++)e[r]=arguments[r];return this.stream.addSubscription.apply(this.stream,e)},destroy:function(){var t=this;this.stream.destroy(),this.stream=null,(0,u.rejectContext)(this),this._actionNames.forEach(function(e){t[e]=a}),this._actionNames=null}}},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t){s.default.call(this),this.digest(t),this.pendingChanges=[]}function o(t){if(t.closed)return t.read();var e=t.pendingChanges.reduce(function(t,e){return e(t)},t.read());return t.pendingChanges=[],e}Object.defineProperty(e,"__esModule",{value:!0}),e.default=i;var u=r(1),s=n(u);i.prototype=Object.create(s.default.prototype),i.prototype.write=function(t){this.closed||("function"==typeof t?(this.pendingChanges.push(t),this.consume(this,o)):this.consume(t))},i.prototype.destroy=function(){s.default.prototype.destroy.call(this),this.pendingChanges=null}},function(t,e,r){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function i(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function o(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t}function u(t){var e=this;if(a.default.call(this),!t||"object"!==(void 0===t?"undefined":o(t)))throw Error(c+" No sources to plug in");var r=Object.keys(t),n=r.reduce(function(e,r){return Object.assign(i({},r,t[r].read()),e)},{});this.unsubs=r.map(function(r){return t[r].addSubscription(function(t){n=Object.assign({},n,i({},r,t)),e.consume(n)})}),this.digest(Object.assign({},n))}Object.defineProperty(e,"__esModule",{value:!0}),e.default=u;var s=r(1),a=n(s),c="Immview::Merge:";u.prototype=Object.create(a.default.prototype),u.prototype.destroy=function(){a.default.prototype.destroy.call(this),this.unsubs&&this.unsubs.forEach(function(t){return t()}),this.unsubs=null}}])}); | ||
//# sourceMappingURL=immview.js.map |
{ | ||
"name": "immview", | ||
"version": "1.7.1", | ||
"version": "1.7.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/immview.js", |
import * as Digest from './Digest'; | ||
import * as DispatcherModule from './Dispatcher'; | ||
import {immutabilize, isImmutabilized} from './Immutabilize'; | ||
import env from './env'; | ||
@@ -35,3 +34,3 @@ | ||
if (typeof candidate === 'object') { | ||
return !isImmutabilized(candidate) || this.read() !== candidate; | ||
return true; | ||
} | ||
@@ -67,3 +66,3 @@ return this.read() !== candidate; | ||
for (let i = 0; this.subscriptions && i < this.subscriptions.length; i++) { | ||
this.subscriptions[i](immutabilize(candidate)); | ||
this.subscriptions[i](candidate); | ||
} | ||
@@ -70,0 +69,0 @@ } |
@@ -106,21 +106,2 @@ import Data from '../src/Data'; | ||
it('triggers reaction only for actual change', () => { | ||
let reactions = 0; | ||
const d = new Data(fromJS({ a: 1, b: { c: 2 } })); | ||
d.subscribe(() => { | ||
reactions++; | ||
}); | ||
expect(reactions).toBe(1); // subscription -> fake reaction | ||
d.write(map => map.set('d', 3)); // change -> reaction | ||
expect(reactions).toBe(2); | ||
d.write(map => map); // no change -> no reaction | ||
expect(reactions).toBe(2); | ||
d.write(map => map.set('d', 4)); // change -> reaction | ||
expect(reactions).toBe(3); | ||
}); | ||
it('can be unsubscribed from', () => { | ||
@@ -127,0 +108,0 @@ let reactions = 0; |
@@ -14,3 +14,2 @@ import './switchedTicker.spec'; | ||
import './classExtending'; | ||
import './immutabilize.spec'; | ||
import './asyncNodes.spec'; |
@@ -63,18 +63,3 @@ import { | ||
}); | ||
it('reacts only to actual changes', () => { | ||
expect(aMergeReactions).toBe(1); | ||
aData.write(v => v + 1); | ||
expect(aMergeReactions).toBe(2); | ||
aData.write(v => v); | ||
expect(aMergeReactions).toBe(2); | ||
aData.write(v => v + 1); | ||
expect(aMergeReactions).toBe(3); | ||
aData.write(v => v); | ||
expect(aMergeReactions).toBe(3); | ||
aData.write(v => v + 1); | ||
expect(aMergeReactions).toBe(4); | ||
expect(aMerge.read().source).toBe(4); | ||
}); | ||
}); | ||
}); |
@@ -69,17 +69,2 @@ import Domain from '../src/Domain'; | ||
it('reacts only to actual changes', function () { | ||
expect(vReactions).toBe(1); | ||
d.write(v => v.set('e', 4)); | ||
expect(vReactions).toBe(2); | ||
d.write(v => v.set('e', 4)); | ||
expect(vReactions).toBe(2); | ||
d.write(v => v.delete('e')); | ||
expect(vReactions).toBe(3); | ||
d.write(v => v.delete('e')); | ||
expect(vReactions).toBe(3); | ||
d.write(v => v.setIn(['e', 'f'], 6)); | ||
expect(vReactions).toBe(4); | ||
expect(v.read().getIn(['e', 'f'])).toBe(6); | ||
}); | ||
describe('derives from multiple reactors', function () { | ||
@@ -137,13 +122,2 @@ it('w/o processor func', function () { | ||
}); | ||
typeof window !== 'undefined' && | ||
window.Proxy && | ||
it('value given for processing is frozen', () => { | ||
expect(() => { | ||
new Data({ a: 1 }).map(v => { | ||
v.a = 2; | ||
return v; | ||
}).subscribe(v => console.log('WRONG', v)); | ||
}).toThrow(); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
186803
46
2039