Socket
Socket
Sign inDemoInstall

@nx-js/observer-util

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nx-js/observer-util - npm Package Compare versions

Comparing version 4.1.2 to 4.1.3

15

dist/cjs.es5.js

@@ -10,3 +10,3 @@ 'use strict';

// this will be used to save (obj.key -> reaction) connections later
connectionStore.set(obj, Object.create(null));
connectionStore.set(obj, new Map());
}

@@ -24,5 +24,6 @@

var reactionsForObj = connectionStore.get(target);
var reactionsForKey = reactionsForObj[key];
var reactionsForKey = reactionsForObj.get(key);
if (!reactionsForKey) {
reactionsForObj[key] = reactionsForKey = new Set();
reactionsForKey = new Set();
reactionsForObj.set(key, reactionsForKey);
}

@@ -45,5 +46,5 @@ // save the fact that the key is used by the reaction during its current run

if (type === 'clear') {
for (var key$1 in reactionsForTarget) {
addReactionsForKey(reactionsForKey, reactionsForTarget, key$1);
}
reactionsForTarget.forEach(function (_, key) {
addReactionsForKey(reactionsForKey, reactionsForTarget, key);
});
} else {

@@ -62,3 +63,3 @@ addReactionsForKey(reactionsForKey, reactionsForTarget, key);

function addReactionsForKey(reactionsForKey, reactionsForTarget, key) {
var reactions = reactionsForTarget[key];
var reactions = reactionsForTarget.get(key);
reactions && reactions.forEach(reactionsForKey.add, reactionsForKey);

@@ -65,0 +66,0 @@ }

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

'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var connectionStore=new WeakMap,ITERATION_KEY=Symbol('iteration key');function storeObservable(a){connectionStore.set(a,Object.create(null))}function registerReactionForOperation(a,b){var c=b.target,d=b.key,e=b.type;'iterate'===e&&(d=ITERATION_KEY);var f=connectionStore.get(c),g=f[d];g||(f[d]=g=new Set),g.has(a)||(g.add(a),a.cleaners.push(g))}function getReactionsForOperation(a){var b=a.target,c=a.key,d=a.type,e=connectionStore.get(b),f=new Set;if('clear'===d)for(var g in e)addReactionsForKey(f,e,g);else addReactionsForKey(f,e,c);if('add'===d||'delete'===d||'clear'===d){var h=Array.isArray(b)?'length':ITERATION_KEY;addReactionsForKey(f,e,h)}return f}function addReactionsForKey(a,b,c){var d=b[c];d&&d.forEach(a.add,a)}function releaseReaction(a){a.cleaners&&a.cleaners.forEach(releaseReactionKeyConnection,a),a.cleaners=[]}function releaseReactionKeyConnection(a){a.delete(this)}var runningReaction,isDebugging=!1;function runAsReaction(a,b,c,d){if(a.unobserved)return b.apply(c,d);releaseReaction(a);try{return runningReaction=a,b.apply(c,d)}finally{runningReaction=void 0}}function registerRunningReactionForOperation(a){runningReaction&&(debugOperation(runningReaction,a),registerReactionForOperation(runningReaction,a))}function queueReactionsForOperation(a){getReactionsForOperation(a).forEach(queueReaction,a)}function queueReaction(a){debugOperation(a,this),'function'==typeof a.scheduler?a.scheduler(a):'object'==typeof a.scheduler?a.scheduler.add(a):a()}function debugOperation(a,b){if(a.debugger&&!isDebugging)try{isDebugging=!0,a.debugger(b)}finally{isDebugging=!1}}function hasRunningReaction(){return runningReaction!==void 0}var IS_REACTION=Symbol('is reaction');function observe(a,b){void 0===b&&(b={});var c=a[IS_REACTION]?a:function b(){return runAsReaction(b,a,this,arguments)};return c.scheduler=b.scheduler,c.debugger=b.debugger,c[IS_REACTION]=!0,b.lazy||c(),c}function unobserve(a){a.unobserved||(a.unobserved=!0,releaseReaction(a)),'object'==typeof a.scheduler&&a.scheduler.delete(a)}var proxyToRaw=new WeakMap,rawToProxy=new WeakMap,getPrototypeOf=Object.getPrototypeOf,hasOwnProperty=Object.prototype.hasOwnProperty,instrumentations={has:function a(b){var c=proxyToRaw.get(this),d=getPrototypeOf(this);return registerRunningReactionForOperation({target:c,key:b,type:'has'}),d.has.apply(c,arguments)},get:function a(b){var c=proxyToRaw.get(this),d=getPrototypeOf(this);return registerRunningReactionForOperation({target:c,key:b,type:'get'}),d.get.apply(c,arguments)},add:function a(b){var c=proxyToRaw.get(this),d=getPrototypeOf(this),e=d.has.call(c,b),f=d.add.apply(c,arguments);return e||queueReactionsForOperation({target:c,key:b,value:b,type:'add'}),f},set:function a(b,c){var d=proxyToRaw.get(this),e=getPrototypeOf(this),f=e.has.call(d,b),g=e.get.call(d,b),h=e.set.apply(d,arguments);return f?c!==g&&queueReactionsForOperation({target:d,key:b,value:c,oldValue:g,type:'set'}):queueReactionsForOperation({target:d,key:b,value:c,type:'add'}),h},delete:function a(b){var c=proxyToRaw.get(this),d=getPrototypeOf(this),e=d.has.call(c,b),f=d.get?d.get.call(c,b):void 0,g=d.delete.apply(c,arguments);return e&&queueReactionsForOperation({target:c,key:b,oldValue:f,type:'delete'}),g},clear:function a(){var b=proxyToRaw.get(this),c=getPrototypeOf(this),d=0!==b.size,e=b instanceof Map?new Map(b):new Set(b),f=c.clear.apply(b,arguments);return d&&queueReactionsForOperation({target:b,oldTarget:e,type:'clear'}),f},forEach:function a(){var b=proxyToRaw.get(this),c=getPrototypeOf(this);return registerRunningReactionForOperation({target:b,type:'iterate'}),c.forEach.apply(b,arguments)},keys:function a(){var b=proxyToRaw.get(this),c=getPrototypeOf(this);return registerRunningReactionForOperation({target:b,type:'iterate'}),c.keys.apply(b,arguments)},values:function a(){var b=proxyToRaw.get(this),c=getPrototypeOf(this);return registerRunningReactionForOperation({target:b,type:'iterate'}),c.values.apply(b,arguments)},entries:function a(){var b=proxyToRaw.get(this),c=getPrototypeOf(this);return registerRunningReactionForOperation({target:b,type:'iterate'}),c.entries.apply(b,arguments)},get size(){var a=proxyToRaw.get(this),b=getPrototypeOf(this);return registerRunningReactionForOperation({target:a,type:'iterate'}),Reflect.get(b,'size',a)}};instrumentations[Symbol.iterator]=function(){var a=proxyToRaw.get(this),b=getPrototypeOf(this);return registerRunningReactionForOperation({target:a,type:'iterate'}),b[Symbol.iterator].apply(a,arguments)};var collectionHandlers={get:function a(b,c,d){return b=hasOwnProperty.call(instrumentations,c)?instrumentations:b,Reflect.get(b,c,d)}},globalObj=Function('return this')(),handlers=new Map([[Map,collectionHandlers],[Set,collectionHandlers],[WeakMap,collectionHandlers],[WeakSet,collectionHandlers],[Object,!1],[Array,!1],[Int8Array,!1],[Uint8Array,!1],[Uint8ClampedArray,!1],[Int16Array,!1],[Uint16Array,!1],[Int32Array,!1],[Uint32Array,!1],[Float32Array,!1],[Float64Array,!1]]);function shouldInstrument(a){var b=a.constructor,c='function'==typeof b&&b.name in globalObj&&globalObj[b.name]===b;return!c||handlers.has(b)}function getHandlers(a){return handlers.get(a.constructor)}var hasOwnProperty$1=Object.prototype.hasOwnProperty;function get(a,b,c){var d=Reflect.get(a,b,c);if('symbol'==typeof b||'function'==typeof d)return d;registerRunningReactionForOperation({target:a,key:b,receiver:c,type:'get'});var e=rawToProxy.get(d);if(hasRunningReaction()&&'object'==typeof d&&null!==d){if(e)return e;var f=Reflect.getOwnPropertyDescriptor(a,b);if(!f||!1!==f.writable||!1!==f.configurable)return observable(d)}return e||d}function has(a,b){var c=Reflect.has(a,b);return'symbol'==typeof b?c:(registerRunningReactionForOperation({target:a,key:b,type:'has'}),c)}function ownKeys(a){return registerRunningReactionForOperation({target:a,type:'iterate'}),Reflect.ownKeys(a)}function set(a,b,c,d){'object'==typeof c&&null!==c&&(c=proxyToRaw.get(c)||c);var e=hasOwnProperty$1.call(a,b),f=a[b],g=Reflect.set(a,b,c,d);return hasRunningReaction()?(console.error('Mutating observables in reactions is forbidden. You set '+b+' to '+c+'.'),g):'symbol'==typeof b||a!==proxyToRaw.get(d)?g:(e?c!==f&&queueReactionsForOperation({target:a,key:b,value:c,oldValue:f,receiver:d,type:'set'}):queueReactionsForOperation({target:a,key:b,value:c,receiver:d,type:'add'}),g)}function deleteProperty(a,b){var c=hasOwnProperty$1.call(a,b),d=a[b],e=Reflect.deleteProperty(a,b);return'symbol'!=typeof b&&c&&queueReactionsForOperation({target:a,key:b,oldValue:d,type:'delete'}),e}var baseHandlers={get:get,has:has,ownKeys:ownKeys,set:set,deleteProperty:deleteProperty};function observable(a){return void 0===a&&(a={}),proxyToRaw.has(a)||!shouldInstrument(a)?a:rawToProxy.get(a)||createObservable(a)}function createObservable(a){var b=getHandlers(a)||baseHandlers,c=new Proxy(a,b);return rawToProxy.set(a,c),proxyToRaw.set(c,a),storeObservable(a),c}function isObservable(a){return proxyToRaw.has(a)}function raw(a){return proxyToRaw.get(a)||a}exports.observe=observe,exports.unobserve=unobserve,exports.observable=observable,exports.isObservable=isObservable,exports.raw=raw;
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var connectionStore=new WeakMap,ITERATION_KEY=Symbol('iteration key');function storeObservable(a){connectionStore.set(a,new Map)}function registerReactionForOperation(a,b){var c=b.target,d=b.key,e=b.type;'iterate'===e&&(d=ITERATION_KEY);var f=connectionStore.get(c),g=f.get(d);g||(g=new Set,f.set(d,g)),g.has(a)||(g.add(a),a.cleaners.push(g))}function getReactionsForOperation(a){var b=a.target,c=a.key,d=a.type,e=connectionStore.get(b),f=new Set;if('clear'===d?e.forEach(function(a,b){addReactionsForKey(f,e,b)}):addReactionsForKey(f,e,c),'add'===d||'delete'===d||'clear'===d){var g=Array.isArray(b)?'length':ITERATION_KEY;addReactionsForKey(f,e,g)}return f}function addReactionsForKey(a,b,c){var d=b.get(c);d&&d.forEach(a.add,a)}function releaseReaction(a){a.cleaners&&a.cleaners.forEach(releaseReactionKeyConnection,a),a.cleaners=[]}function releaseReactionKeyConnection(a){a.delete(this)}var runningReaction,isDebugging=!1;function runAsReaction(a,b,c,d){if(a.unobserved)return b.apply(c,d);releaseReaction(a);try{return runningReaction=a,b.apply(c,d)}finally{runningReaction=void 0}}function registerRunningReactionForOperation(a){runningReaction&&(debugOperation(runningReaction,a),registerReactionForOperation(runningReaction,a))}function queueReactionsForOperation(a){getReactionsForOperation(a).forEach(queueReaction,a)}function queueReaction(a){debugOperation(a,this),'function'==typeof a.scheduler?a.scheduler(a):'object'==typeof a.scheduler?a.scheduler.add(a):a()}function debugOperation(a,b){if(a.debugger&&!isDebugging)try{isDebugging=!0,a.debugger(b)}finally{isDebugging=!1}}function hasRunningReaction(){return runningReaction!==void 0}var IS_REACTION=Symbol('is reaction');function observe(a,b){void 0===b&&(b={});var c=a[IS_REACTION]?a:function b(){return runAsReaction(b,a,this,arguments)};return c.scheduler=b.scheduler,c.debugger=b.debugger,c[IS_REACTION]=!0,b.lazy||c(),c}function unobserve(a){a.unobserved||(a.unobserved=!0,releaseReaction(a)),'object'==typeof a.scheduler&&a.scheduler.delete(a)}var proxyToRaw=new WeakMap,rawToProxy=new WeakMap,getPrototypeOf=Object.getPrototypeOf,hasOwnProperty=Object.prototype.hasOwnProperty,instrumentations={has:function a(b){var c=proxyToRaw.get(this),d=getPrototypeOf(this);return registerRunningReactionForOperation({target:c,key:b,type:'has'}),d.has.apply(c,arguments)},get:function a(b){var c=proxyToRaw.get(this),d=getPrototypeOf(this);return registerRunningReactionForOperation({target:c,key:b,type:'get'}),d.get.apply(c,arguments)},add:function a(b){var c=proxyToRaw.get(this),d=getPrototypeOf(this),e=d.has.call(c,b),f=d.add.apply(c,arguments);return e||queueReactionsForOperation({target:c,key:b,value:b,type:'add'}),f},set:function a(b,c){var d=proxyToRaw.get(this),e=getPrototypeOf(this),f=e.has.call(d,b),g=e.get.call(d,b),h=e.set.apply(d,arguments);return f?c!==g&&queueReactionsForOperation({target:d,key:b,value:c,oldValue:g,type:'set'}):queueReactionsForOperation({target:d,key:b,value:c,type:'add'}),h},delete:function a(b){var c=proxyToRaw.get(this),d=getPrototypeOf(this),e=d.has.call(c,b),f=d.get?d.get.call(c,b):void 0,g=d.delete.apply(c,arguments);return e&&queueReactionsForOperation({target:c,key:b,oldValue:f,type:'delete'}),g},clear:function a(){var b=proxyToRaw.get(this),c=getPrototypeOf(this),d=0!==b.size,e=b instanceof Map?new Map(b):new Set(b),f=c.clear.apply(b,arguments);return d&&queueReactionsForOperation({target:b,oldTarget:e,type:'clear'}),f},forEach:function a(){var b=proxyToRaw.get(this),c=getPrototypeOf(this);return registerRunningReactionForOperation({target:b,type:'iterate'}),c.forEach.apply(b,arguments)},keys:function a(){var b=proxyToRaw.get(this),c=getPrototypeOf(this);return registerRunningReactionForOperation({target:b,type:'iterate'}),c.keys.apply(b,arguments)},values:function a(){var b=proxyToRaw.get(this),c=getPrototypeOf(this);return registerRunningReactionForOperation({target:b,type:'iterate'}),c.values.apply(b,arguments)},entries:function a(){var b=proxyToRaw.get(this),c=getPrototypeOf(this);return registerRunningReactionForOperation({target:b,type:'iterate'}),c.entries.apply(b,arguments)},get size(){var a=proxyToRaw.get(this),b=getPrototypeOf(this);return registerRunningReactionForOperation({target:a,type:'iterate'}),Reflect.get(b,'size',a)}};instrumentations[Symbol.iterator]=function(){var a=proxyToRaw.get(this),b=getPrototypeOf(this);return registerRunningReactionForOperation({target:a,type:'iterate'}),b[Symbol.iterator].apply(a,arguments)};var collectionHandlers={get:function a(b,c,d){return b=hasOwnProperty.call(instrumentations,c)?instrumentations:b,Reflect.get(b,c,d)}},globalObj=Function('return this')(),handlers=new Map([[Map,collectionHandlers],[Set,collectionHandlers],[WeakMap,collectionHandlers],[WeakSet,collectionHandlers],[Object,!1],[Array,!1],[Int8Array,!1],[Uint8Array,!1],[Uint8ClampedArray,!1],[Int16Array,!1],[Uint16Array,!1],[Int32Array,!1],[Uint32Array,!1],[Float32Array,!1],[Float64Array,!1]]);function shouldInstrument(a){var b=a.constructor,c='function'==typeof b&&b.name in globalObj&&globalObj[b.name]===b;return!c||handlers.has(b)}function getHandlers(a){return handlers.get(a.constructor)}var hasOwnProperty$1=Object.prototype.hasOwnProperty;function get(a,b,c){var d=Reflect.get(a,b,c);if('symbol'==typeof b||'function'==typeof d)return d;registerRunningReactionForOperation({target:a,key:b,receiver:c,type:'get'});var e=rawToProxy.get(d);if(hasRunningReaction()&&'object'==typeof d&&null!==d){if(e)return e;var f=Reflect.getOwnPropertyDescriptor(a,b);if(!f||!1!==f.writable||!1!==f.configurable)return observable(d)}return e||d}function has(a,b){var c=Reflect.has(a,b);return'symbol'==typeof b?c:(registerRunningReactionForOperation({target:a,key:b,type:'has'}),c)}function ownKeys(a){return registerRunningReactionForOperation({target:a,type:'iterate'}),Reflect.ownKeys(a)}function set(a,b,c,d){'object'==typeof c&&null!==c&&(c=proxyToRaw.get(c)||c);var e=hasOwnProperty$1.call(a,b),f=a[b],g=Reflect.set(a,b,c,d);return hasRunningReaction()?(console.error('Mutating observables in reactions is forbidden. You set '+b+' to '+c+'.'),g):'symbol'==typeof b||a!==proxyToRaw.get(d)?g:(e?c!==f&&queueReactionsForOperation({target:a,key:b,value:c,oldValue:f,receiver:d,type:'set'}):queueReactionsForOperation({target:a,key:b,value:c,receiver:d,type:'add'}),g)}function deleteProperty(a,b){var c=hasOwnProperty$1.call(a,b),d=a[b],e=Reflect.deleteProperty(a,b);return'symbol'!=typeof b&&c&&queueReactionsForOperation({target:a,key:b,oldValue:d,type:'delete'}),e}var baseHandlers={get:get,has:has,ownKeys:ownKeys,set:set,deleteProperty:deleteProperty};function observable(a){return void 0===a&&(a={}),proxyToRaw.has(a)||!shouldInstrument(a)?a:rawToProxy.get(a)||createObservable(a)}function createObservable(a){var b=getHandlers(a)||baseHandlers,c=new Proxy(a,b);return rawToProxy.set(a,c),proxyToRaw.set(c,a),storeObservable(a),c}function isObservable(a){return proxyToRaw.has(a)}function raw(a){return proxyToRaw.get(a)||a}exports.observe=observe,exports.unobserve=unobserve,exports.observable=observable,exports.isObservable=isObservable,exports.raw=raw;

@@ -10,3 +10,3 @@ 'use strict';

// this will be used to save (obj.key -> reaction) connections later
connectionStore.set(obj, Object.create(null));
connectionStore.set(obj, new Map());
}

@@ -20,5 +20,6 @@

const reactionsForObj = connectionStore.get(target);
let reactionsForKey = reactionsForObj[key];
let reactionsForKey = reactionsForObj.get(key);
if (!reactionsForKey) {
reactionsForObj[key] = reactionsForKey = new Set();
reactionsForKey = new Set();
reactionsForObj.set(key, reactionsForKey);
}

@@ -37,5 +38,5 @@ // save the fact that the key is used by the reaction during its current run

if (type === 'clear') {
for (let key in reactionsForTarget) {
reactionsForTarget.forEach((_, key) => {
addReactionsForKey(reactionsForKey, reactionsForTarget, key);
}
});
} else {

@@ -54,3 +55,3 @@ addReactionsForKey(reactionsForKey, reactionsForTarget, key);

function addReactionsForKey(reactionsForKey, reactionsForTarget, key) {
const reactions = reactionsForTarget[key];
const reactions = reactionsForTarget.get(key);
reactions && reactions.forEach(reactionsForKey.add, reactionsForKey);

@@ -57,0 +58,0 @@ }

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

'use strict';Object.defineProperty(exports,'__esModule',{value:!0});const connectionStore=new WeakMap,ITERATION_KEY=Symbol('iteration key');function storeObservable(a){connectionStore.set(a,Object.create(null))}function registerReactionForOperation(a,{target:b,key:c,type:d}){'iterate'===d&&(c=ITERATION_KEY);const e=connectionStore.get(b);let f=e[c];f||(e[c]=f=new Set),f.has(a)||(f.add(a),a.cleaners.push(f))}function getReactionsForOperation({target:a,key:b,type:c}){const d=connectionStore.get(a),e=new Set;if('clear'===c)for(let a in d)addReactionsForKey(e,d,a);else addReactionsForKey(e,d,b);if('add'===c||'delete'===c||'clear'===c){const b=Array.isArray(a)?'length':ITERATION_KEY;addReactionsForKey(e,d,b)}return e}function addReactionsForKey(a,b,c){const d=b[c];d&&d.forEach(a.add,a)}function releaseReaction(a){a.cleaners&&a.cleaners.forEach(releaseReactionKeyConnection,a),a.cleaners=[]}function releaseReactionKeyConnection(a){a.delete(this)}let runningReaction,isDebugging=!1;function runAsReaction(a,b,c,d){if(a.unobserved)return b.apply(c,d);releaseReaction(a);try{return runningReaction=a,b.apply(c,d)}finally{runningReaction=void 0}}function registerRunningReactionForOperation(a){runningReaction&&(debugOperation(runningReaction,a),registerReactionForOperation(runningReaction,a))}function queueReactionsForOperation(a){getReactionsForOperation(a).forEach(queueReaction,a)}function queueReaction(a){debugOperation(a,this),'function'==typeof a.scheduler?a.scheduler(a):'object'==typeof a.scheduler?a.scheduler.add(a):a()}function debugOperation(a,b){if(a.debugger&&!isDebugging)try{isDebugging=!0,a.debugger(b)}finally{isDebugging=!1}}function hasRunningReaction(){return runningReaction!==void 0}const IS_REACTION=Symbol('is reaction');function observe(a,b={}){const c=a[IS_REACTION]?a:function b(){return runAsReaction(b,a,this,arguments)};return c.scheduler=b.scheduler,c.debugger=b.debugger,c[IS_REACTION]=!0,b.lazy||c(),c}function unobserve(a){a.unobserved||(a.unobserved=!0,releaseReaction(a)),'object'==typeof a.scheduler&&a.scheduler.delete(a)}const proxyToRaw=new WeakMap,rawToProxy=new WeakMap,getPrototypeOf=Object.getPrototypeOf,hasOwnProperty=Object.prototype.hasOwnProperty,instrumentations={has(a){const b=proxyToRaw.get(this),c=getPrototypeOf(this);return registerRunningReactionForOperation({target:b,key:a,type:'has'}),c.has.apply(b,arguments)},get(a){const b=proxyToRaw.get(this),c=getPrototypeOf(this);return registerRunningReactionForOperation({target:b,key:a,type:'get'}),c.get.apply(b,arguments)},add(a){const b=proxyToRaw.get(this),c=getPrototypeOf(this),d=c.has.call(b,a),e=c.add.apply(b,arguments);return d||queueReactionsForOperation({target:b,key:a,value:a,type:'add'}),e},set(a,b){const c=proxyToRaw.get(this),d=getPrototypeOf(this),e=d.has.call(c,a),f=d.get.call(c,a),g=d.set.apply(c,arguments);return e?b!==f&&queueReactionsForOperation({target:c,key:a,value:b,oldValue:f,type:'set'}):queueReactionsForOperation({target:c,key:a,value:b,type:'add'}),g},delete(a){const b=proxyToRaw.get(this),c=getPrototypeOf(this),d=c.has.call(b,a),e=c.get?c.get.call(b,a):void 0,f=c.delete.apply(b,arguments);return d&&queueReactionsForOperation({target:b,key:a,oldValue:e,type:'delete'}),f},clear(){const a=proxyToRaw.get(this),b=getPrototypeOf(this),c=0!==a.size,d=a instanceof Map?new Map(a):new Set(a),e=b.clear.apply(a,arguments);return c&&queueReactionsForOperation({target:a,oldTarget:d,type:'clear'}),e},forEach(){const a=proxyToRaw.get(this),b=getPrototypeOf(this);return registerRunningReactionForOperation({target:a,type:'iterate'}),b.forEach.apply(a,arguments)},keys(){const a=proxyToRaw.get(this),b=getPrototypeOf(this);return registerRunningReactionForOperation({target:a,type:'iterate'}),b.keys.apply(a,arguments)},values(){const a=proxyToRaw.get(this),b=getPrototypeOf(this);return registerRunningReactionForOperation({target:a,type:'iterate'}),b.values.apply(a,arguments)},entries(){const a=proxyToRaw.get(this),b=getPrototypeOf(this);return registerRunningReactionForOperation({target:a,type:'iterate'}),b.entries.apply(a,arguments)},[Symbol.iterator](){const a=proxyToRaw.get(this),b=getPrototypeOf(this);return registerRunningReactionForOperation({target:a,type:'iterate'}),b[Symbol.iterator].apply(a,arguments)},get size(){const a=proxyToRaw.get(this),b=getPrototypeOf(this);return registerRunningReactionForOperation({target:a,type:'iterate'}),Reflect.get(b,'size',a)}};var collectionHandlers={get(a,b,c){return a=hasOwnProperty.call(instrumentations,b)?instrumentations:a,Reflect.get(a,b,c)}};const globalObj=Function('return this')(),handlers=new Map([[Map,collectionHandlers],[Set,collectionHandlers],[WeakMap,collectionHandlers],[WeakSet,collectionHandlers],[Object,!1],[Array,!1],[Int8Array,!1],[Uint8Array,!1],[Uint8ClampedArray,!1],[Int16Array,!1],[Uint16Array,!1],[Int32Array,!1],[Uint32Array,!1],[Float32Array,!1],[Float64Array,!1]]);function shouldInstrument({constructor:a}){const b='function'==typeof a&&a.name in globalObj&&globalObj[a.name]===a;return!b||handlers.has(a)}function getHandlers(a){return handlers.get(a.constructor)}const hasOwnProperty$1=Object.prototype.hasOwnProperty;function get(a,b,c){const d=Reflect.get(a,b,c);if('symbol'==typeof b||'function'==typeof d)return d;registerRunningReactionForOperation({target:a,key:b,receiver:c,type:'get'});const e=rawToProxy.get(d);if(hasRunningReaction()&&'object'==typeof d&&null!==d){if(e)return e;const c=Reflect.getOwnPropertyDescriptor(a,b);if(!c||!1!==c.writable||!1!==c.configurable)return observable(d)}return e||d}function has(a,b){const c=Reflect.has(a,b);return'symbol'==typeof b?c:(registerRunningReactionForOperation({target:a,key:b,type:'has'}),c)}function ownKeys(a){return registerRunningReactionForOperation({target:a,type:'iterate'}),Reflect.ownKeys(a)}function set(a,b,c,d){'object'==typeof c&&null!==c&&(c=proxyToRaw.get(c)||c);const e=hasOwnProperty$1.call(a,b),f=a[b],g=Reflect.set(a,b,c,d);return hasRunningReaction()?(console.error(`Mutating observables in reactions is forbidden. You set ${b} to ${c}.`),g):'symbol'==typeof b||a!==proxyToRaw.get(d)?g:(e?c!==f&&queueReactionsForOperation({target:a,key:b,value:c,oldValue:f,receiver:d,type:'set'}):queueReactionsForOperation({target:a,key:b,value:c,receiver:d,type:'add'}),g)}function deleteProperty(a,b){const c=hasOwnProperty$1.call(a,b),d=a[b],e=Reflect.deleteProperty(a,b);return'symbol'!=typeof b&&c&&queueReactionsForOperation({target:a,key:b,oldValue:d,type:'delete'}),e}var baseHandlers={get,has,ownKeys,set,deleteProperty};function observable(a={}){return proxyToRaw.has(a)||!shouldInstrument(a)?a:rawToProxy.get(a)||createObservable(a)}function createObservable(a){const b=getHandlers(a)||baseHandlers,c=new Proxy(a,b);return rawToProxy.set(a,c),proxyToRaw.set(c,a),storeObservable(a),c}function isObservable(a){return proxyToRaw.has(a)}function raw(a){return proxyToRaw.get(a)||a}exports.observe=observe,exports.unobserve=unobserve,exports.observable=observable,exports.isObservable=isObservable,exports.raw=raw;
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});const connectionStore=new WeakMap,ITERATION_KEY=Symbol('iteration key');function storeObservable(a){connectionStore.set(a,new Map)}function registerReactionForOperation(a,{target:b,key:c,type:d}){'iterate'===d&&(c=ITERATION_KEY);const e=connectionStore.get(b);let f=e.get(c);f||(f=new Set,e.set(c,f)),f.has(a)||(f.add(a),a.cleaners.push(f))}function getReactionsForOperation({target:a,key:b,type:c}){const d=connectionStore.get(a),e=new Set;if('clear'===c?d.forEach((a,b)=>{addReactionsForKey(e,d,b)}):addReactionsForKey(e,d,b),'add'===c||'delete'===c||'clear'===c){const b=Array.isArray(a)?'length':ITERATION_KEY;addReactionsForKey(e,d,b)}return e}function addReactionsForKey(a,b,c){const d=b.get(c);d&&d.forEach(a.add,a)}function releaseReaction(a){a.cleaners&&a.cleaners.forEach(releaseReactionKeyConnection,a),a.cleaners=[]}function releaseReactionKeyConnection(a){a.delete(this)}let runningReaction,isDebugging=!1;function runAsReaction(a,b,c,d){if(a.unobserved)return b.apply(c,d);releaseReaction(a);try{return runningReaction=a,b.apply(c,d)}finally{runningReaction=void 0}}function registerRunningReactionForOperation(a){runningReaction&&(debugOperation(runningReaction,a),registerReactionForOperation(runningReaction,a))}function queueReactionsForOperation(a){getReactionsForOperation(a).forEach(queueReaction,a)}function queueReaction(a){debugOperation(a,this),'function'==typeof a.scheduler?a.scheduler(a):'object'==typeof a.scheduler?a.scheduler.add(a):a()}function debugOperation(a,b){if(a.debugger&&!isDebugging)try{isDebugging=!0,a.debugger(b)}finally{isDebugging=!1}}function hasRunningReaction(){return runningReaction!==void 0}const IS_REACTION=Symbol('is reaction');function observe(a,b={}){const c=a[IS_REACTION]?a:function b(){return runAsReaction(b,a,this,arguments)};return c.scheduler=b.scheduler,c.debugger=b.debugger,c[IS_REACTION]=!0,b.lazy||c(),c}function unobserve(a){a.unobserved||(a.unobserved=!0,releaseReaction(a)),'object'==typeof a.scheduler&&a.scheduler.delete(a)}const proxyToRaw=new WeakMap,rawToProxy=new WeakMap,getPrototypeOf=Object.getPrototypeOf,hasOwnProperty=Object.prototype.hasOwnProperty,instrumentations={has(a){const b=proxyToRaw.get(this),c=getPrototypeOf(this);return registerRunningReactionForOperation({target:b,key:a,type:'has'}),c.has.apply(b,arguments)},get(a){const b=proxyToRaw.get(this),c=getPrototypeOf(this);return registerRunningReactionForOperation({target:b,key:a,type:'get'}),c.get.apply(b,arguments)},add(a){const b=proxyToRaw.get(this),c=getPrototypeOf(this),d=c.has.call(b,a),e=c.add.apply(b,arguments);return d||queueReactionsForOperation({target:b,key:a,value:a,type:'add'}),e},set(a,b){const c=proxyToRaw.get(this),d=getPrototypeOf(this),e=d.has.call(c,a),f=d.get.call(c,a),g=d.set.apply(c,arguments);return e?b!==f&&queueReactionsForOperation({target:c,key:a,value:b,oldValue:f,type:'set'}):queueReactionsForOperation({target:c,key:a,value:b,type:'add'}),g},delete(a){const b=proxyToRaw.get(this),c=getPrototypeOf(this),d=c.has.call(b,a),e=c.get?c.get.call(b,a):void 0,f=c.delete.apply(b,arguments);return d&&queueReactionsForOperation({target:b,key:a,oldValue:e,type:'delete'}),f},clear(){const a=proxyToRaw.get(this),b=getPrototypeOf(this),c=0!==a.size,d=a instanceof Map?new Map(a):new Set(a),e=b.clear.apply(a,arguments);return c&&queueReactionsForOperation({target:a,oldTarget:d,type:'clear'}),e},forEach(){const a=proxyToRaw.get(this),b=getPrototypeOf(this);return registerRunningReactionForOperation({target:a,type:'iterate'}),b.forEach.apply(a,arguments)},keys(){const a=proxyToRaw.get(this),b=getPrototypeOf(this);return registerRunningReactionForOperation({target:a,type:'iterate'}),b.keys.apply(a,arguments)},values(){const a=proxyToRaw.get(this),b=getPrototypeOf(this);return registerRunningReactionForOperation({target:a,type:'iterate'}),b.values.apply(a,arguments)},entries(){const a=proxyToRaw.get(this),b=getPrototypeOf(this);return registerRunningReactionForOperation({target:a,type:'iterate'}),b.entries.apply(a,arguments)},[Symbol.iterator](){const a=proxyToRaw.get(this),b=getPrototypeOf(this);return registerRunningReactionForOperation({target:a,type:'iterate'}),b[Symbol.iterator].apply(a,arguments)},get size(){const a=proxyToRaw.get(this),b=getPrototypeOf(this);return registerRunningReactionForOperation({target:a,type:'iterate'}),Reflect.get(b,'size',a)}};var collectionHandlers={get(a,b,c){return a=hasOwnProperty.call(instrumentations,b)?instrumentations:a,Reflect.get(a,b,c)}};const globalObj=Function('return this')(),handlers=new Map([[Map,collectionHandlers],[Set,collectionHandlers],[WeakMap,collectionHandlers],[WeakSet,collectionHandlers],[Object,!1],[Array,!1],[Int8Array,!1],[Uint8Array,!1],[Uint8ClampedArray,!1],[Int16Array,!1],[Uint16Array,!1],[Int32Array,!1],[Uint32Array,!1],[Float32Array,!1],[Float64Array,!1]]);function shouldInstrument({constructor:a}){const b='function'==typeof a&&a.name in globalObj&&globalObj[a.name]===a;return!b||handlers.has(a)}function getHandlers(a){return handlers.get(a.constructor)}const hasOwnProperty$1=Object.prototype.hasOwnProperty;function get(a,b,c){const d=Reflect.get(a,b,c);if('symbol'==typeof b||'function'==typeof d)return d;registerRunningReactionForOperation({target:a,key:b,receiver:c,type:'get'});const e=rawToProxy.get(d);if(hasRunningReaction()&&'object'==typeof d&&null!==d){if(e)return e;const c=Reflect.getOwnPropertyDescriptor(a,b);if(!c||!1!==c.writable||!1!==c.configurable)return observable(d)}return e||d}function has(a,b){const c=Reflect.has(a,b);return'symbol'==typeof b?c:(registerRunningReactionForOperation({target:a,key:b,type:'has'}),c)}function ownKeys(a){return registerRunningReactionForOperation({target:a,type:'iterate'}),Reflect.ownKeys(a)}function set(a,b,c,d){'object'==typeof c&&null!==c&&(c=proxyToRaw.get(c)||c);const e=hasOwnProperty$1.call(a,b),f=a[b],g=Reflect.set(a,b,c,d);return hasRunningReaction()?(console.error(`Mutating observables in reactions is forbidden. You set ${b} to ${c}.`),g):'symbol'==typeof b||a!==proxyToRaw.get(d)?g:(e?c!==f&&queueReactionsForOperation({target:a,key:b,value:c,oldValue:f,receiver:d,type:'set'}):queueReactionsForOperation({target:a,key:b,value:c,receiver:d,type:'add'}),g)}function deleteProperty(a,b){const c=hasOwnProperty$1.call(a,b),d=a[b],e=Reflect.deleteProperty(a,b);return'symbol'!=typeof b&&c&&queueReactionsForOperation({target:a,key:b,oldValue:d,type:'delete'}),e}var baseHandlers={get,has,ownKeys,set,deleteProperty};function observable(a={}){return proxyToRaw.has(a)||!shouldInstrument(a)?a:rawToProxy.get(a)||createObservable(a)}function createObservable(a){const b=getHandlers(a)||baseHandlers,c=new Proxy(a,b);return rawToProxy.set(a,c),proxyToRaw.set(c,a),storeObservable(a),c}function isObservable(a){return proxyToRaw.has(a)}function raw(a){return proxyToRaw.get(a)||a}exports.observe=observe,exports.unobserve=unobserve,exports.observable=observable,exports.isObservable=isObservable,exports.raw=raw;

@@ -6,3 +6,3 @@ var connectionStore = new WeakMap();

// this will be used to save (obj.key -> reaction) connections later
connectionStore.set(obj, Object.create(null));
connectionStore.set(obj, new Map());
}

@@ -20,5 +20,6 @@

var reactionsForObj = connectionStore.get(target);
var reactionsForKey = reactionsForObj[key];
var reactionsForKey = reactionsForObj.get(key);
if (!reactionsForKey) {
reactionsForObj[key] = reactionsForKey = new Set();
reactionsForKey = new Set();
reactionsForObj.set(key, reactionsForKey);
}

@@ -41,5 +42,5 @@ // save the fact that the key is used by the reaction during its current run

if (type === 'clear') {
for (var key$1 in reactionsForTarget) {
addReactionsForKey(reactionsForKey, reactionsForTarget, key$1);
}
reactionsForTarget.forEach(function (_, key) {
addReactionsForKey(reactionsForKey, reactionsForTarget, key);
});
} else {

@@ -58,3 +59,3 @@ addReactionsForKey(reactionsForKey, reactionsForTarget, key);

function addReactionsForKey(reactionsForKey, reactionsForTarget, key) {
var reactions = reactionsForTarget[key];
var reactions = reactionsForTarget.get(key);
reactions && reactions.forEach(reactionsForKey.add, reactionsForKey);

@@ -61,0 +62,0 @@ }

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

var connectionStore=new WeakMap,ITERATION_KEY=Symbol('iteration key');function storeObservable(a){connectionStore.set(a,Object.create(null))}function registerReactionForOperation(a,b){var c=b.target,d=b.key,e=b.type;'iterate'===e&&(d=ITERATION_KEY);var f=connectionStore.get(c),g=f[d];g||(f[d]=g=new Set),g.has(a)||(g.add(a),a.cleaners.push(g))}function getReactionsForOperation(a){var b=a.target,c=a.key,d=a.type,e=connectionStore.get(b),f=new Set;if('clear'===d)for(var g in e)addReactionsForKey(f,e,g);else addReactionsForKey(f,e,c);if('add'===d||'delete'===d||'clear'===d){var h=Array.isArray(b)?'length':ITERATION_KEY;addReactionsForKey(f,e,h)}return f}function addReactionsForKey(a,b,c){var d=b[c];d&&d.forEach(a.add,a)}function releaseReaction(a){a.cleaners&&a.cleaners.forEach(releaseReactionKeyConnection,a),a.cleaners=[]}function releaseReactionKeyConnection(a){a.delete(this)}var runningReaction,isDebugging=!1;function runAsReaction(a,b,c,d){if(a.unobserved)return b.apply(c,d);releaseReaction(a);try{return runningReaction=a,b.apply(c,d)}finally{runningReaction=void 0}}function registerRunningReactionForOperation(a){runningReaction&&(debugOperation(runningReaction,a),registerReactionForOperation(runningReaction,a))}function queueReactionsForOperation(a){getReactionsForOperation(a).forEach(queueReaction,a)}function queueReaction(a){debugOperation(a,this),'function'==typeof a.scheduler?a.scheduler(a):'object'==typeof a.scheduler?a.scheduler.add(a):a()}function debugOperation(a,b){if(a.debugger&&!isDebugging)try{isDebugging=!0,a.debugger(b)}finally{isDebugging=!1}}function hasRunningReaction(){return runningReaction!==void 0}var IS_REACTION=Symbol('is reaction');function observe(a,b){void 0===b&&(b={});var c=a[IS_REACTION]?a:function b(){return runAsReaction(b,a,this,arguments)};return c.scheduler=b.scheduler,c.debugger=b.debugger,c[IS_REACTION]=!0,b.lazy||c(),c}function unobserve(a){a.unobserved||(a.unobserved=!0,releaseReaction(a)),'object'==typeof a.scheduler&&a.scheduler.delete(a)}var proxyToRaw=new WeakMap,rawToProxy=new WeakMap,getPrototypeOf=Object.getPrototypeOf,hasOwnProperty=Object.prototype.hasOwnProperty,instrumentations={has:function a(b){var c=proxyToRaw.get(this),d=getPrototypeOf(this);return registerRunningReactionForOperation({target:c,key:b,type:'has'}),d.has.apply(c,arguments)},get:function a(b){var c=proxyToRaw.get(this),d=getPrototypeOf(this);return registerRunningReactionForOperation({target:c,key:b,type:'get'}),d.get.apply(c,arguments)},add:function a(b){var c=proxyToRaw.get(this),d=getPrototypeOf(this),e=d.has.call(c,b),f=d.add.apply(c,arguments);return e||queueReactionsForOperation({target:c,key:b,value:b,type:'add'}),f},set:function a(b,c){var d=proxyToRaw.get(this),e=getPrototypeOf(this),f=e.has.call(d,b),g=e.get.call(d,b),h=e.set.apply(d,arguments);return f?c!==g&&queueReactionsForOperation({target:d,key:b,value:c,oldValue:g,type:'set'}):queueReactionsForOperation({target:d,key:b,value:c,type:'add'}),h},delete:function a(b){var c=proxyToRaw.get(this),d=getPrototypeOf(this),e=d.has.call(c,b),f=d.get?d.get.call(c,b):void 0,g=d.delete.apply(c,arguments);return e&&queueReactionsForOperation({target:c,key:b,oldValue:f,type:'delete'}),g},clear:function a(){var b=proxyToRaw.get(this),c=getPrototypeOf(this),d=0!==b.size,e=b instanceof Map?new Map(b):new Set(b),f=c.clear.apply(b,arguments);return d&&queueReactionsForOperation({target:b,oldTarget:e,type:'clear'}),f},forEach:function a(){var b=proxyToRaw.get(this),c=getPrototypeOf(this);return registerRunningReactionForOperation({target:b,type:'iterate'}),c.forEach.apply(b,arguments)},keys:function a(){var b=proxyToRaw.get(this),c=getPrototypeOf(this);return registerRunningReactionForOperation({target:b,type:'iterate'}),c.keys.apply(b,arguments)},values:function a(){var b=proxyToRaw.get(this),c=getPrototypeOf(this);return registerRunningReactionForOperation({target:b,type:'iterate'}),c.values.apply(b,arguments)},entries:function a(){var b=proxyToRaw.get(this),c=getPrototypeOf(this);return registerRunningReactionForOperation({target:b,type:'iterate'}),c.entries.apply(b,arguments)},get size(){var a=proxyToRaw.get(this),b=getPrototypeOf(this);return registerRunningReactionForOperation({target:a,type:'iterate'}),Reflect.get(b,'size',a)}};instrumentations[Symbol.iterator]=function(){var a=proxyToRaw.get(this),b=getPrototypeOf(this);return registerRunningReactionForOperation({target:a,type:'iterate'}),b[Symbol.iterator].apply(a,arguments)};var collectionHandlers={get:function a(b,c,d){return b=hasOwnProperty.call(instrumentations,c)?instrumentations:b,Reflect.get(b,c,d)}},globalObj=Function('return this')(),handlers=new Map([[Map,collectionHandlers],[Set,collectionHandlers],[WeakMap,collectionHandlers],[WeakSet,collectionHandlers],[Object,!1],[Array,!1],[Int8Array,!1],[Uint8Array,!1],[Uint8ClampedArray,!1],[Int16Array,!1],[Uint16Array,!1],[Int32Array,!1],[Uint32Array,!1],[Float32Array,!1],[Float64Array,!1]]);function shouldInstrument(a){var b=a.constructor,c='function'==typeof b&&b.name in globalObj&&globalObj[b.name]===b;return!c||handlers.has(b)}function getHandlers(a){return handlers.get(a.constructor)}var hasOwnProperty$1=Object.prototype.hasOwnProperty;function get(a,b,c){var d=Reflect.get(a,b,c);if('symbol'==typeof b||'function'==typeof d)return d;registerRunningReactionForOperation({target:a,key:b,receiver:c,type:'get'});var e=rawToProxy.get(d);if(hasRunningReaction()&&'object'==typeof d&&null!==d){if(e)return e;var f=Reflect.getOwnPropertyDescriptor(a,b);if(!f||!1!==f.writable||!1!==f.configurable)return observable(d)}return e||d}function has(a,b){var c=Reflect.has(a,b);return'symbol'==typeof b?c:(registerRunningReactionForOperation({target:a,key:b,type:'has'}),c)}function ownKeys(a){return registerRunningReactionForOperation({target:a,type:'iterate'}),Reflect.ownKeys(a)}function set(a,b,c,d){'object'==typeof c&&null!==c&&(c=proxyToRaw.get(c)||c);var e=hasOwnProperty$1.call(a,b),f=a[b],g=Reflect.set(a,b,c,d);return hasRunningReaction()?(console.error('Mutating observables in reactions is forbidden. You set '+b+' to '+c+'.'),g):'symbol'==typeof b||a!==proxyToRaw.get(d)?g:(e?c!==f&&queueReactionsForOperation({target:a,key:b,value:c,oldValue:f,receiver:d,type:'set'}):queueReactionsForOperation({target:a,key:b,value:c,receiver:d,type:'add'}),g)}function deleteProperty(a,b){var c=hasOwnProperty$1.call(a,b),d=a[b],e=Reflect.deleteProperty(a,b);return'symbol'!=typeof b&&c&&queueReactionsForOperation({target:a,key:b,oldValue:d,type:'delete'}),e}var baseHandlers={get:get,has:has,ownKeys:ownKeys,set:set,deleteProperty:deleteProperty};function observable(a){return void 0===a&&(a={}),proxyToRaw.has(a)||!shouldInstrument(a)?a:rawToProxy.get(a)||createObservable(a)}function createObservable(a){var b=getHandlers(a)||baseHandlers,c=new Proxy(a,b);return rawToProxy.set(a,c),proxyToRaw.set(c,a),storeObservable(a),c}function isObservable(a){return proxyToRaw.has(a)}function raw(a){return proxyToRaw.get(a)||a}export{observe,unobserve,observable,isObservable,raw};
var connectionStore=new WeakMap,ITERATION_KEY=Symbol('iteration key');function storeObservable(a){connectionStore.set(a,new Map)}function registerReactionForOperation(a,b){var c=b.target,d=b.key,e=b.type;'iterate'===e&&(d=ITERATION_KEY);var f=connectionStore.get(c),g=f.get(d);g||(g=new Set,f.set(d,g)),g.has(a)||(g.add(a),a.cleaners.push(g))}function getReactionsForOperation(a){var b=a.target,c=a.key,d=a.type,e=connectionStore.get(b),f=new Set;if('clear'===d?e.forEach(function(a,b){addReactionsForKey(f,e,b)}):addReactionsForKey(f,e,c),'add'===d||'delete'===d||'clear'===d){var g=Array.isArray(b)?'length':ITERATION_KEY;addReactionsForKey(f,e,g)}return f}function addReactionsForKey(a,b,c){var d=b.get(c);d&&d.forEach(a.add,a)}function releaseReaction(a){a.cleaners&&a.cleaners.forEach(releaseReactionKeyConnection,a),a.cleaners=[]}function releaseReactionKeyConnection(a){a.delete(this)}var runningReaction,isDebugging=!1;function runAsReaction(a,b,c,d){if(a.unobserved)return b.apply(c,d);releaseReaction(a);try{return runningReaction=a,b.apply(c,d)}finally{runningReaction=void 0}}function registerRunningReactionForOperation(a){runningReaction&&(debugOperation(runningReaction,a),registerReactionForOperation(runningReaction,a))}function queueReactionsForOperation(a){getReactionsForOperation(a).forEach(queueReaction,a)}function queueReaction(a){debugOperation(a,this),'function'==typeof a.scheduler?a.scheduler(a):'object'==typeof a.scheduler?a.scheduler.add(a):a()}function debugOperation(a,b){if(a.debugger&&!isDebugging)try{isDebugging=!0,a.debugger(b)}finally{isDebugging=!1}}function hasRunningReaction(){return runningReaction!==void 0}var IS_REACTION=Symbol('is reaction');function observe(a,b){void 0===b&&(b={});var c=a[IS_REACTION]?a:function b(){return runAsReaction(b,a,this,arguments)};return c.scheduler=b.scheduler,c.debugger=b.debugger,c[IS_REACTION]=!0,b.lazy||c(),c}function unobserve(a){a.unobserved||(a.unobserved=!0,releaseReaction(a)),'object'==typeof a.scheduler&&a.scheduler.delete(a)}var proxyToRaw=new WeakMap,rawToProxy=new WeakMap,getPrototypeOf=Object.getPrototypeOf,hasOwnProperty=Object.prototype.hasOwnProperty,instrumentations={has:function a(b){var c=proxyToRaw.get(this),d=getPrototypeOf(this);return registerRunningReactionForOperation({target:c,key:b,type:'has'}),d.has.apply(c,arguments)},get:function a(b){var c=proxyToRaw.get(this),d=getPrototypeOf(this);return registerRunningReactionForOperation({target:c,key:b,type:'get'}),d.get.apply(c,arguments)},add:function a(b){var c=proxyToRaw.get(this),d=getPrototypeOf(this),e=d.has.call(c,b),f=d.add.apply(c,arguments);return e||queueReactionsForOperation({target:c,key:b,value:b,type:'add'}),f},set:function a(b,c){var d=proxyToRaw.get(this),e=getPrototypeOf(this),f=e.has.call(d,b),g=e.get.call(d,b),h=e.set.apply(d,arguments);return f?c!==g&&queueReactionsForOperation({target:d,key:b,value:c,oldValue:g,type:'set'}):queueReactionsForOperation({target:d,key:b,value:c,type:'add'}),h},delete:function a(b){var c=proxyToRaw.get(this),d=getPrototypeOf(this),e=d.has.call(c,b),f=d.get?d.get.call(c,b):void 0,g=d.delete.apply(c,arguments);return e&&queueReactionsForOperation({target:c,key:b,oldValue:f,type:'delete'}),g},clear:function a(){var b=proxyToRaw.get(this),c=getPrototypeOf(this),d=0!==b.size,e=b instanceof Map?new Map(b):new Set(b),f=c.clear.apply(b,arguments);return d&&queueReactionsForOperation({target:b,oldTarget:e,type:'clear'}),f},forEach:function a(){var b=proxyToRaw.get(this),c=getPrototypeOf(this);return registerRunningReactionForOperation({target:b,type:'iterate'}),c.forEach.apply(b,arguments)},keys:function a(){var b=proxyToRaw.get(this),c=getPrototypeOf(this);return registerRunningReactionForOperation({target:b,type:'iterate'}),c.keys.apply(b,arguments)},values:function a(){var b=proxyToRaw.get(this),c=getPrototypeOf(this);return registerRunningReactionForOperation({target:b,type:'iterate'}),c.values.apply(b,arguments)},entries:function a(){var b=proxyToRaw.get(this),c=getPrototypeOf(this);return registerRunningReactionForOperation({target:b,type:'iterate'}),c.entries.apply(b,arguments)},get size(){var a=proxyToRaw.get(this),b=getPrototypeOf(this);return registerRunningReactionForOperation({target:a,type:'iterate'}),Reflect.get(b,'size',a)}};instrumentations[Symbol.iterator]=function(){var a=proxyToRaw.get(this),b=getPrototypeOf(this);return registerRunningReactionForOperation({target:a,type:'iterate'}),b[Symbol.iterator].apply(a,arguments)};var collectionHandlers={get:function a(b,c,d){return b=hasOwnProperty.call(instrumentations,c)?instrumentations:b,Reflect.get(b,c,d)}},globalObj=Function('return this')(),handlers=new Map([[Map,collectionHandlers],[Set,collectionHandlers],[WeakMap,collectionHandlers],[WeakSet,collectionHandlers],[Object,!1],[Array,!1],[Int8Array,!1],[Uint8Array,!1],[Uint8ClampedArray,!1],[Int16Array,!1],[Uint16Array,!1],[Int32Array,!1],[Uint32Array,!1],[Float32Array,!1],[Float64Array,!1]]);function shouldInstrument(a){var b=a.constructor,c='function'==typeof b&&b.name in globalObj&&globalObj[b.name]===b;return!c||handlers.has(b)}function getHandlers(a){return handlers.get(a.constructor)}var hasOwnProperty$1=Object.prototype.hasOwnProperty;function get(a,b,c){var d=Reflect.get(a,b,c);if('symbol'==typeof b||'function'==typeof d)return d;registerRunningReactionForOperation({target:a,key:b,receiver:c,type:'get'});var e=rawToProxy.get(d);if(hasRunningReaction()&&'object'==typeof d&&null!==d){if(e)return e;var f=Reflect.getOwnPropertyDescriptor(a,b);if(!f||!1!==f.writable||!1!==f.configurable)return observable(d)}return e||d}function has(a,b){var c=Reflect.has(a,b);return'symbol'==typeof b?c:(registerRunningReactionForOperation({target:a,key:b,type:'has'}),c)}function ownKeys(a){return registerRunningReactionForOperation({target:a,type:'iterate'}),Reflect.ownKeys(a)}function set(a,b,c,d){'object'==typeof c&&null!==c&&(c=proxyToRaw.get(c)||c);var e=hasOwnProperty$1.call(a,b),f=a[b],g=Reflect.set(a,b,c,d);return hasRunningReaction()?(console.error('Mutating observables in reactions is forbidden. You set '+b+' to '+c+'.'),g):'symbol'==typeof b||a!==proxyToRaw.get(d)?g:(e?c!==f&&queueReactionsForOperation({target:a,key:b,value:c,oldValue:f,receiver:d,type:'set'}):queueReactionsForOperation({target:a,key:b,value:c,receiver:d,type:'add'}),g)}function deleteProperty(a,b){var c=hasOwnProperty$1.call(a,b),d=a[b],e=Reflect.deleteProperty(a,b);return'symbol'!=typeof b&&c&&queueReactionsForOperation({target:a,key:b,oldValue:d,type:'delete'}),e}var baseHandlers={get:get,has:has,ownKeys:ownKeys,set:set,deleteProperty:deleteProperty};function observable(a){return void 0===a&&(a={}),proxyToRaw.has(a)||!shouldInstrument(a)?a:rawToProxy.get(a)||createObservable(a)}function createObservable(a){var b=getHandlers(a)||baseHandlers,c=new Proxy(a,b);return rawToProxy.set(a,c),proxyToRaw.set(c,a),storeObservable(a),c}function isObservable(a){return proxyToRaw.has(a)}function raw(a){return proxyToRaw.get(a)||a}export{observe,unobserve,observable,isObservable,raw};

@@ -6,3 +6,3 @@ const connectionStore = new WeakMap();

// this will be used to save (obj.key -> reaction) connections later
connectionStore.set(obj, Object.create(null));
connectionStore.set(obj, new Map());
}

@@ -16,5 +16,6 @@

const reactionsForObj = connectionStore.get(target);
let reactionsForKey = reactionsForObj[key];
let reactionsForKey = reactionsForObj.get(key);
if (!reactionsForKey) {
reactionsForObj[key] = reactionsForKey = new Set();
reactionsForKey = new Set();
reactionsForObj.set(key, reactionsForKey);
}

@@ -33,5 +34,5 @@ // save the fact that the key is used by the reaction during its current run

if (type === 'clear') {
for (let key in reactionsForTarget) {
reactionsForTarget.forEach((_, key) => {
addReactionsForKey(reactionsForKey, reactionsForTarget, key);
}
});
} else {

@@ -50,3 +51,3 @@ addReactionsForKey(reactionsForKey, reactionsForTarget, key);

function addReactionsForKey(reactionsForKey, reactionsForTarget, key) {
const reactions = reactionsForTarget[key];
const reactions = reactionsForTarget.get(key);
reactions && reactions.forEach(reactionsForKey.add, reactionsForKey);

@@ -53,0 +54,0 @@ }

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

const connectionStore=new WeakMap,ITERATION_KEY=Symbol('iteration key');function storeObservable(a){connectionStore.set(a,Object.create(null))}function registerReactionForOperation(a,{target:b,key:c,type:d}){'iterate'===d&&(c=ITERATION_KEY);const e=connectionStore.get(b);let f=e[c];f||(e[c]=f=new Set),f.has(a)||(f.add(a),a.cleaners.push(f))}function getReactionsForOperation({target:a,key:b,type:c}){const d=connectionStore.get(a),e=new Set;if('clear'===c)for(let a in d)addReactionsForKey(e,d,a);else addReactionsForKey(e,d,b);if('add'===c||'delete'===c||'clear'===c){const b=Array.isArray(a)?'length':ITERATION_KEY;addReactionsForKey(e,d,b)}return e}function addReactionsForKey(a,b,c){const d=b[c];d&&d.forEach(a.add,a)}function releaseReaction(a){a.cleaners&&a.cleaners.forEach(releaseReactionKeyConnection,a),a.cleaners=[]}function releaseReactionKeyConnection(a){a.delete(this)}let runningReaction,isDebugging=!1;function runAsReaction(a,b,c,d){if(a.unobserved)return b.apply(c,d);releaseReaction(a);try{return runningReaction=a,b.apply(c,d)}finally{runningReaction=void 0}}function registerRunningReactionForOperation(a){runningReaction&&(debugOperation(runningReaction,a),registerReactionForOperation(runningReaction,a))}function queueReactionsForOperation(a){getReactionsForOperation(a).forEach(queueReaction,a)}function queueReaction(a){debugOperation(a,this),'function'==typeof a.scheduler?a.scheduler(a):'object'==typeof a.scheduler?a.scheduler.add(a):a()}function debugOperation(a,b){if(a.debugger&&!isDebugging)try{isDebugging=!0,a.debugger(b)}finally{isDebugging=!1}}function hasRunningReaction(){return runningReaction!==void 0}const IS_REACTION=Symbol('is reaction');function observe(a,b={}){const c=a[IS_REACTION]?a:function b(){return runAsReaction(b,a,this,arguments)};return c.scheduler=b.scheduler,c.debugger=b.debugger,c[IS_REACTION]=!0,b.lazy||c(),c}function unobserve(a){a.unobserved||(a.unobserved=!0,releaseReaction(a)),'object'==typeof a.scheduler&&a.scheduler.delete(a)}const proxyToRaw=new WeakMap,rawToProxy=new WeakMap,getPrototypeOf=Object.getPrototypeOf,hasOwnProperty=Object.prototype.hasOwnProperty,instrumentations={has(a){const b=proxyToRaw.get(this),c=getPrototypeOf(this);return registerRunningReactionForOperation({target:b,key:a,type:'has'}),c.has.apply(b,arguments)},get(a){const b=proxyToRaw.get(this),c=getPrototypeOf(this);return registerRunningReactionForOperation({target:b,key:a,type:'get'}),c.get.apply(b,arguments)},add(a){const b=proxyToRaw.get(this),c=getPrototypeOf(this),d=c.has.call(b,a),e=c.add.apply(b,arguments);return d||queueReactionsForOperation({target:b,key:a,value:a,type:'add'}),e},set(a,b){const c=proxyToRaw.get(this),d=getPrototypeOf(this),e=d.has.call(c,a),f=d.get.call(c,a),g=d.set.apply(c,arguments);return e?b!==f&&queueReactionsForOperation({target:c,key:a,value:b,oldValue:f,type:'set'}):queueReactionsForOperation({target:c,key:a,value:b,type:'add'}),g},delete(a){const b=proxyToRaw.get(this),c=getPrototypeOf(this),d=c.has.call(b,a),e=c.get?c.get.call(b,a):void 0,f=c.delete.apply(b,arguments);return d&&queueReactionsForOperation({target:b,key:a,oldValue:e,type:'delete'}),f},clear(){const a=proxyToRaw.get(this),b=getPrototypeOf(this),c=0!==a.size,d=a instanceof Map?new Map(a):new Set(a),e=b.clear.apply(a,arguments);return c&&queueReactionsForOperation({target:a,oldTarget:d,type:'clear'}),e},forEach(){const a=proxyToRaw.get(this),b=getPrototypeOf(this);return registerRunningReactionForOperation({target:a,type:'iterate'}),b.forEach.apply(a,arguments)},keys(){const a=proxyToRaw.get(this),b=getPrototypeOf(this);return registerRunningReactionForOperation({target:a,type:'iterate'}),b.keys.apply(a,arguments)},values(){const a=proxyToRaw.get(this),b=getPrototypeOf(this);return registerRunningReactionForOperation({target:a,type:'iterate'}),b.values.apply(a,arguments)},entries(){const a=proxyToRaw.get(this),b=getPrototypeOf(this);return registerRunningReactionForOperation({target:a,type:'iterate'}),b.entries.apply(a,arguments)},[Symbol.iterator](){const a=proxyToRaw.get(this),b=getPrototypeOf(this);return registerRunningReactionForOperation({target:a,type:'iterate'}),b[Symbol.iterator].apply(a,arguments)},get size(){const a=proxyToRaw.get(this),b=getPrototypeOf(this);return registerRunningReactionForOperation({target:a,type:'iterate'}),Reflect.get(b,'size',a)}};var collectionHandlers={get(a,b,c){return a=hasOwnProperty.call(instrumentations,b)?instrumentations:a,Reflect.get(a,b,c)}};const globalObj=Function('return this')(),handlers=new Map([[Map,collectionHandlers],[Set,collectionHandlers],[WeakMap,collectionHandlers],[WeakSet,collectionHandlers],[Object,!1],[Array,!1],[Int8Array,!1],[Uint8Array,!1],[Uint8ClampedArray,!1],[Int16Array,!1],[Uint16Array,!1],[Int32Array,!1],[Uint32Array,!1],[Float32Array,!1],[Float64Array,!1]]);function shouldInstrument({constructor:a}){const b='function'==typeof a&&a.name in globalObj&&globalObj[a.name]===a;return!b||handlers.has(a)}function getHandlers(a){return handlers.get(a.constructor)}const hasOwnProperty$1=Object.prototype.hasOwnProperty;function get(a,b,c){const d=Reflect.get(a,b,c);if('symbol'==typeof b||'function'==typeof d)return d;registerRunningReactionForOperation({target:a,key:b,receiver:c,type:'get'});const e=rawToProxy.get(d);if(hasRunningReaction()&&'object'==typeof d&&null!==d){if(e)return e;const c=Reflect.getOwnPropertyDescriptor(a,b);if(!c||!1!==c.writable||!1!==c.configurable)return observable(d)}return e||d}function has(a,b){const c=Reflect.has(a,b);return'symbol'==typeof b?c:(registerRunningReactionForOperation({target:a,key:b,type:'has'}),c)}function ownKeys(a){return registerRunningReactionForOperation({target:a,type:'iterate'}),Reflect.ownKeys(a)}function set(a,b,c,d){'object'==typeof c&&null!==c&&(c=proxyToRaw.get(c)||c);const e=hasOwnProperty$1.call(a,b),f=a[b],g=Reflect.set(a,b,c,d);return hasRunningReaction()?(console.error(`Mutating observables in reactions is forbidden. You set ${b} to ${c}.`),g):'symbol'==typeof b||a!==proxyToRaw.get(d)?g:(e?c!==f&&queueReactionsForOperation({target:a,key:b,value:c,oldValue:f,receiver:d,type:'set'}):queueReactionsForOperation({target:a,key:b,value:c,receiver:d,type:'add'}),g)}function deleteProperty(a,b){const c=hasOwnProperty$1.call(a,b),d=a[b],e=Reflect.deleteProperty(a,b);return'symbol'!=typeof b&&c&&queueReactionsForOperation({target:a,key:b,oldValue:d,type:'delete'}),e}var baseHandlers={get,has,ownKeys,set,deleteProperty};function observable(a={}){return proxyToRaw.has(a)||!shouldInstrument(a)?a:rawToProxy.get(a)||createObservable(a)}function createObservable(a){const b=getHandlers(a)||baseHandlers,c=new Proxy(a,b);return rawToProxy.set(a,c),proxyToRaw.set(c,a),storeObservable(a),c}function isObservable(a){return proxyToRaw.has(a)}function raw(a){return proxyToRaw.get(a)||a}export{observe,unobserve,observable,isObservable,raw};
const connectionStore=new WeakMap,ITERATION_KEY=Symbol('iteration key');function storeObservable(a){connectionStore.set(a,new Map)}function registerReactionForOperation(a,{target:b,key:c,type:d}){'iterate'===d&&(c=ITERATION_KEY);const e=connectionStore.get(b);let f=e.get(c);f||(f=new Set,e.set(c,f)),f.has(a)||(f.add(a),a.cleaners.push(f))}function getReactionsForOperation({target:a,key:b,type:c}){const d=connectionStore.get(a),e=new Set;if('clear'===c?d.forEach((a,b)=>{addReactionsForKey(e,d,b)}):addReactionsForKey(e,d,b),'add'===c||'delete'===c||'clear'===c){const b=Array.isArray(a)?'length':ITERATION_KEY;addReactionsForKey(e,d,b)}return e}function addReactionsForKey(a,b,c){const d=b.get(c);d&&d.forEach(a.add,a)}function releaseReaction(a){a.cleaners&&a.cleaners.forEach(releaseReactionKeyConnection,a),a.cleaners=[]}function releaseReactionKeyConnection(a){a.delete(this)}let runningReaction,isDebugging=!1;function runAsReaction(a,b,c,d){if(a.unobserved)return b.apply(c,d);releaseReaction(a);try{return runningReaction=a,b.apply(c,d)}finally{runningReaction=void 0}}function registerRunningReactionForOperation(a){runningReaction&&(debugOperation(runningReaction,a),registerReactionForOperation(runningReaction,a))}function queueReactionsForOperation(a){getReactionsForOperation(a).forEach(queueReaction,a)}function queueReaction(a){debugOperation(a,this),'function'==typeof a.scheduler?a.scheduler(a):'object'==typeof a.scheduler?a.scheduler.add(a):a()}function debugOperation(a,b){if(a.debugger&&!isDebugging)try{isDebugging=!0,a.debugger(b)}finally{isDebugging=!1}}function hasRunningReaction(){return runningReaction!==void 0}const IS_REACTION=Symbol('is reaction');function observe(a,b={}){const c=a[IS_REACTION]?a:function b(){return runAsReaction(b,a,this,arguments)};return c.scheduler=b.scheduler,c.debugger=b.debugger,c[IS_REACTION]=!0,b.lazy||c(),c}function unobserve(a){a.unobserved||(a.unobserved=!0,releaseReaction(a)),'object'==typeof a.scheduler&&a.scheduler.delete(a)}const proxyToRaw=new WeakMap,rawToProxy=new WeakMap,getPrototypeOf=Object.getPrototypeOf,hasOwnProperty=Object.prototype.hasOwnProperty,instrumentations={has(a){const b=proxyToRaw.get(this),c=getPrototypeOf(this);return registerRunningReactionForOperation({target:b,key:a,type:'has'}),c.has.apply(b,arguments)},get(a){const b=proxyToRaw.get(this),c=getPrototypeOf(this);return registerRunningReactionForOperation({target:b,key:a,type:'get'}),c.get.apply(b,arguments)},add(a){const b=proxyToRaw.get(this),c=getPrototypeOf(this),d=c.has.call(b,a),e=c.add.apply(b,arguments);return d||queueReactionsForOperation({target:b,key:a,value:a,type:'add'}),e},set(a,b){const c=proxyToRaw.get(this),d=getPrototypeOf(this),e=d.has.call(c,a),f=d.get.call(c,a),g=d.set.apply(c,arguments);return e?b!==f&&queueReactionsForOperation({target:c,key:a,value:b,oldValue:f,type:'set'}):queueReactionsForOperation({target:c,key:a,value:b,type:'add'}),g},delete(a){const b=proxyToRaw.get(this),c=getPrototypeOf(this),d=c.has.call(b,a),e=c.get?c.get.call(b,a):void 0,f=c.delete.apply(b,arguments);return d&&queueReactionsForOperation({target:b,key:a,oldValue:e,type:'delete'}),f},clear(){const a=proxyToRaw.get(this),b=getPrototypeOf(this),c=0!==a.size,d=a instanceof Map?new Map(a):new Set(a),e=b.clear.apply(a,arguments);return c&&queueReactionsForOperation({target:a,oldTarget:d,type:'clear'}),e},forEach(){const a=proxyToRaw.get(this),b=getPrototypeOf(this);return registerRunningReactionForOperation({target:a,type:'iterate'}),b.forEach.apply(a,arguments)},keys(){const a=proxyToRaw.get(this),b=getPrototypeOf(this);return registerRunningReactionForOperation({target:a,type:'iterate'}),b.keys.apply(a,arguments)},values(){const a=proxyToRaw.get(this),b=getPrototypeOf(this);return registerRunningReactionForOperation({target:a,type:'iterate'}),b.values.apply(a,arguments)},entries(){const a=proxyToRaw.get(this),b=getPrototypeOf(this);return registerRunningReactionForOperation({target:a,type:'iterate'}),b.entries.apply(a,arguments)},[Symbol.iterator](){const a=proxyToRaw.get(this),b=getPrototypeOf(this);return registerRunningReactionForOperation({target:a,type:'iterate'}),b[Symbol.iterator].apply(a,arguments)},get size(){const a=proxyToRaw.get(this),b=getPrototypeOf(this);return registerRunningReactionForOperation({target:a,type:'iterate'}),Reflect.get(b,'size',a)}};var collectionHandlers={get(a,b,c){return a=hasOwnProperty.call(instrumentations,b)?instrumentations:a,Reflect.get(a,b,c)}};const globalObj=Function('return this')(),handlers=new Map([[Map,collectionHandlers],[Set,collectionHandlers],[WeakMap,collectionHandlers],[WeakSet,collectionHandlers],[Object,!1],[Array,!1],[Int8Array,!1],[Uint8Array,!1],[Uint8ClampedArray,!1],[Int16Array,!1],[Uint16Array,!1],[Int32Array,!1],[Uint32Array,!1],[Float32Array,!1],[Float64Array,!1]]);function shouldInstrument({constructor:a}){const b='function'==typeof a&&a.name in globalObj&&globalObj[a.name]===a;return!b||handlers.has(a)}function getHandlers(a){return handlers.get(a.constructor)}const hasOwnProperty$1=Object.prototype.hasOwnProperty;function get(a,b,c){const d=Reflect.get(a,b,c);if('symbol'==typeof b||'function'==typeof d)return d;registerRunningReactionForOperation({target:a,key:b,receiver:c,type:'get'});const e=rawToProxy.get(d);if(hasRunningReaction()&&'object'==typeof d&&null!==d){if(e)return e;const c=Reflect.getOwnPropertyDescriptor(a,b);if(!c||!1!==c.writable||!1!==c.configurable)return observable(d)}return e||d}function has(a,b){const c=Reflect.has(a,b);return'symbol'==typeof b?c:(registerRunningReactionForOperation({target:a,key:b,type:'has'}),c)}function ownKeys(a){return registerRunningReactionForOperation({target:a,type:'iterate'}),Reflect.ownKeys(a)}function set(a,b,c,d){'object'==typeof c&&null!==c&&(c=proxyToRaw.get(c)||c);const e=hasOwnProperty$1.call(a,b),f=a[b],g=Reflect.set(a,b,c,d);return hasRunningReaction()?(console.error(`Mutating observables in reactions is forbidden. You set ${b} to ${c}.`),g):'symbol'==typeof b||a!==proxyToRaw.get(d)?g:(e?c!==f&&queueReactionsForOperation({target:a,key:b,value:c,oldValue:f,receiver:d,type:'set'}):queueReactionsForOperation({target:a,key:b,value:c,receiver:d,type:'add'}),g)}function deleteProperty(a,b){const c=hasOwnProperty$1.call(a,b),d=a[b],e=Reflect.deleteProperty(a,b);return'symbol'!=typeof b&&c&&queueReactionsForOperation({target:a,key:b,oldValue:d,type:'delete'}),e}var baseHandlers={get,has,ownKeys,set,deleteProperty};function observable(a={}){return proxyToRaw.has(a)||!shouldInstrument(a)?a:rawToProxy.get(a)||createObservable(a)}function createObservable(a){const b=getHandlers(a)||baseHandlers,c=new Proxy(a,b);return rawToProxy.set(a,c),proxyToRaw.set(c,a),storeObservable(a),c}function isObservable(a){return proxyToRaw.has(a)}function raw(a){return proxyToRaw.get(a)||a}export{observe,unobserve,observable,isObservable,raw};
{
"name": "@nx-js/observer-util",
"version": "4.1.2",
"version": "4.1.3",
"description": "Simple transparent reactivity with 100% language coverage. Made with ES6 Proxies.",

@@ -5,0 +5,0 @@ "main": "dist/cjs.es5.js",

@@ -5,3 +5,3 @@ # The Observer Utility

[![Build](https://img.shields.io/circleci/project/github/nx-js/observer-util/master.svg)](https://circleci.com/gh/nx-js/observer-util/tree/master) [![Coverage Status](https://coveralls.io/repos/github/nx-js/observer-util/badge.svg)](https://coveralls.io/github/nx-js/observer-util) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) [![Package size](http://img.badgesize.io/https://unpkg.com/@nx-js/observer-util/dist/umd.es6.min.js?compression=gzip&label=minzip_size)](https://unpkg.com/@nx-js/observer-util/dist/umd.es6.min.js) [![Version](https://img.shields.io/npm/v/@nx-js/observer-util.svg)](https://www.npmjs.com/package/@nx-js/observer-util) [![dependencies Status](https://david-dm.org/nx-js/observer-util/status.svg)](https://david-dm.org/nx-js/observer-util) [![License](https://img.shields.io/npm/l/@nx-js/observer-util.svg)](https://www.npmjs.com/package/@nx-js/observer-util)
[![Build](https://img.shields.io/circleci/project/github/nx-js/observer-util/master.svg)](https://circleci.com/gh/nx-js/observer-util/tree/master) [![Coverage Status](https://coveralls.io/repos/github/nx-js/observer-util/badge.svg)](https://coveralls.io/github/nx-js/observer-util) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) [![Package size](https://img.shields.io/bundlephobia/minzip/@nx-js/observer-util.svg)](https://bundlephobia.com/result?p=@nx-js/observer-util) [![Version](https://img.shields.io/npm/v/@nx-js/observer-util.svg)](https://www.npmjs.com/package/@nx-js/observer-util) [![dependencies Status](https://david-dm.org/nx-js/observer-util/status.svg)](https://david-dm.org/nx-js/observer-util) [![License](https://img.shields.io/npm/l/@nx-js/observer-util.svg)](https://www.npmjs.com/package/@nx-js/observer-util)

@@ -18,11 +18,11 @@ <details>

* [Usage](#usage)
+ [Observables](#observables)
+ [Reactions](#reactions)
+ [Reaction scheduling](#reaction-scheduling)
* [Observables](#observables)
* [Reactions](#reactions)
* [Reaction scheduling](#reaction-scheduling)
* [API](#api)
+ [Proxy = observable(object)](#proxy--observableobject)
+ [boolean = isObservable(object)](#boolean--isobservableobject)
+ [reaction = observe(function, config)](#reaction--observefunction-config)
+ [unobserve(reaction)](#unobservereaction)
+ [obj = raw(observable)](#obj--rawobservable)
* [Proxy = observable(object)](#proxy--observableobject)
* [boolean = isObservable(object)](#boolean--isobservableobject)
* [reaction = observe(function, config)](#reaction--observefunction-config)
* [unobserve(reaction)](#unobservereaction)
* [obj = raw(observable)](#obj--rawobservable)
* [Platform support](#platform-support)

@@ -48,3 +48,3 @@ * [Alternative builds](#alternative-builds)

- [React Easy State](https://github.com/solkimicreb/react-easy-state) is a state management solution for React with a minimal learning curve.
* [React Easy State](https://github.com/solkimicreb/react-easy-state) is a state management solution for React with a minimal learning curve.

@@ -66,8 +66,8 @@ ## Installation

```js
import { observable } from '@nx-js/observer-util'
import { observable } from '@nx-js/observer-util';
const counter = observable({ num: 0 })
const counter = observable({ num: 0 });
// observables behave like plain JS objects
counter.num = 12
counter.num = 12;
```

@@ -82,9 +82,9 @@

```js
import { observable, observe } from '@nx-js/observer-util'
import { observable, observe } from '@nx-js/observer-util';
const counter = observable({ num: 0 })
const countLogger = observe(() => console.log(counter.num))
const counter = observable({ num: 0 });
const countLogger = observe(() => console.log(counter.num));
// this calls countLogger and logs 1
counter.num++
counter.num++;
```

@@ -95,3 +95,3 @@

```js
import { store, view } from 'react-easy-state'
import { store, view } from 'react-easy-state';

@@ -101,9 +101,9 @@ // this is an observable store

num: 0,
up () {
this.num++
up() {
this.num++;
}
})
});
// this is a reactive component, which re-renders whenever counter.num changes
const UserComp = view(() => <div onClick={counter.up}>{counter.num}</div>)
const UserComp = view(() => <div onClick={counter.up}>{counter.num}</div>);
```

@@ -117,9 +117,9 @@

```js
import { observable, observe } from '@nx-js/observer-util'
import { observable, observe } from '@nx-js/observer-util';
const profile = observable()
observe(() => console.log(profile.name))
const profile = observable();
observe(() => console.log(profile.name));
// logs 'Bob'
profile.name = 'Bob'
profile.name = 'Bob';
```

@@ -132,3 +132,3 @@

```js
import { observable, observe } from '@nx-js/observer-util'
import { observable, observe } from '@nx-js/observer-util';

@@ -141,8 +141,8 @@ const person = observable({

age: 22
})
});
observe(() => console.log(`${person.name.first} ${person.name.last}`))
observe(() => console.log(`${person.name.first} ${person.name.last}`));
// logs 'Bob Smith'
person.name.first = 'Bob'
person.name.first = 'Bob';
```

@@ -155,3 +155,3 @@

```js
import { observable, observe } from '@nx-js/observer-util'
import { observable, observe } from '@nx-js/observer-util';

@@ -161,11 +161,11 @@ const person = observable({

lastName: 'Smith',
get name () {
return `${firstName} ${lastName}`
get name() {
return `${firstName} ${lastName}`;
}
})
});
observe(() => console.log(person.name))
observe(() => console.log(person.name));
// logs 'Ann Smith'
observable.firstName = 'Ann'
person.firstName = 'Ann';
```

@@ -178,3 +178,3 @@

```js
import { observable, observe } from '@nx-js/observer-util'
import { observable, observe } from '@nx-js/observer-util';

@@ -184,14 +184,14 @@ const person = observable({

name: 'Potato'
})
});
observe(() => {
if (person.gender === 'male') {
console.log(`Mr. ${person.name}`)
console.log(`Mr. ${person.name}`);
} else {
console.log(`Ms. ${person.name}`)
console.log(`Ms. ${person.name}`);
}
})
});
// logs 'Ms. Potato'
person.gender = 'female'
person.gender = 'female';
```

@@ -204,16 +204,16 @@

```js
import { observable, observe } from '@nx-js/observer-util'
import { observable, observe } from '@nx-js/observer-util';
const users = observable([])
const users = observable([]);
observe(() => console.log(users.join(', ')))
observe(() => console.log(users.join(', ')));
// logs 'Bob'
users.push('Bob')
users.push('Bob');
// logs 'Bob, John'
users.push('John')
users.push('John');
// logs 'Bob'
users.pop()
users.pop();
```

@@ -226,17 +226,17 @@

```js
import { observable, observe } from '@nx-js/observer-util'
import { observable, observe } from '@nx-js/observer-util';
const people = observable(new Map())
const people = observable(new Map());
observe(() => {
for (let [name, age] of people) {
console.log(`${name}, ${age}`)
console.log(`${name}, ${age}`);
}
})
});
// logs 'Bob, 22'
people.set('Bob', 22)
people.set('Bob', 22);
// logs 'Bob, 22' and 'John, 35'
people.set('John', 35)
people.set('John', 35);
```

@@ -249,3 +249,3 @@

```js
import { observable, observe } from '@nx-js/observer-util'
import { observable, observe } from '@nx-js/observer-util';

@@ -255,16 +255,16 @@ const defaultUser = observable({

job: 'developer'
})
const user = observable(Object.create(defaultUser))
});
const user = observable(Object.create(defaultUser));
// logs 'Unknown is a developer'
observe(() => console.log(`${user.name} is a ${user.job}`))
observe(() => console.log(`${user.name} is a ${user.job}`));
// logs 'Bob is a developer'
user.name = 'Bob'
user.name = 'Bob';
// logs 'Bob is a stylist'
user.job = 'stylist'
user.job = 'stylist';
// logs 'Unknown is a stylist'
delete user.name
delete user.name;
```

@@ -279,12 +279,12 @@

```js
import { observable, observe } from '@nx-js/observer-util'
import { observable, observe } from '@nx-js/observer-util';
// this scheduler delays reactions by 1 second
const scheduler = reaction => setTimeout(reaction, 1000)
const scheduler = reaction => setTimeout(reaction, 1000);
const person = observable({ name: 'Josh' })
observe(() => console.log(person.name), { scheduler })
const person = observable({ name: 'Josh' });
observe(() => console.log(person.name), { scheduler });
// this logs 'Barbie' after a one second delay
person.name = 'Barbie'
person.name = 'Barbie';
```

@@ -302,10 +302,10 @@

```js
import { observe } from '@nx-js/observer-util'
import { observe } from '@nx-js/observer-util';
class ReactiveComp extends BaseComp {
constructor () {
constructor() {
// ...
this.render = observe(this.render, {
scheduler: () => this.setState()
})
});
}

@@ -322,16 +322,16 @@ }

```js
import { observable, observe } from '@nx-js/observer-util'
import { observable, observe } from '@nx-js/observer-util';
const reactions = new Set()
const person = observable({ name: 'Josh' })
observe(() => console.log(person), { scheduler: reactions })
const reactions = new Set();
const person = observable({ name: 'Josh' });
observe(() => console.log(person), { scheduler: reactions });
// this throttles reactions to run with a minimal 1 second interval
setInterval(() => {
reactions.forEach(reaction => reaction())
}, 1000)
reactions.forEach(reaction => reaction());
}, 1000);
// these will cause { name: 'Barbie', age: 30 } to be logged once
person.name = 'Barbie'
person.age = 87
person.name = 'Barbie';
person.age = 87;
```

@@ -346,16 +346,17 @@

```js
import { observable, observe } from '@nx-js/observer-util'
import { Queue, priorities } from '@nx-js/queue-util'
import { observable, observe } from '@nx-js/observer-util';
import { Queue, priorities } from '@nx-js/queue-util';
const scheduler = new Queue(priorities.LOW)
const person = observable({ name: 'Josh' })
observe(() => console.log(person), { scheduler })
const scheduler = new Queue(priorities.LOW);
const person = observable({ name: 'Josh' });
observe(() => console.log(person), { scheduler });
// these will cause { name: 'Barbie', age: 30 } to be logged once
// when everything is idle and there is free time to do it
person.name = 'Barbie'
person.age = 87
person.name = 'Barbie';
person.age = 87;
```
Queues are automatically scheduling reactions - based on their priority - but they can also be stopped, started and cleared manually at any time. Learn more about them [here]().
</details>

@@ -369,5 +370,5 @@

- If no argument is provided, it returns an empty observable object.
- If an object is passed as argument, it wraps the passed object in an observable.
- If an observable object is passed, it returns the passed observable object.
* If no argument is provided, it returns an empty observable object.
* If an object is passed as argument, it wraps the passed object in an observable.
* If an observable object is passed, it returns the passed observable object.

@@ -384,7 +385,7 @@ ### boolean = isObservable(object)

- `lazy`: A boolean, which controls if the reaction is executed when it is created or not. If it is true, the reaction has to be called once manually to trigger the reactivity process. Defaults to false.
* `lazy`: A boolean, which controls if the reaction is executed when it is created or not. If it is true, the reaction has to be called once manually to trigger the reactivity process. Defaults to false.
- `scheduler`: A function, which is called with the reaction when it is scheduled to run. It can also be an object with an `add` and `delete` method - which schedule and unschedule reactions. The default scheduler runs the reaction synchronously on observable mutations. You can learn more about reaction scheduling in the [related docs section](#reaction-scheduling).
* `scheduler`: A function, which is called with the reaction when it is scheduled to run. It can also be an object with an `add` and `delete` method - which schedule and unschedule reactions. The default scheduler runs the reaction synchronously on observable mutations. You can learn more about reaction scheduling in the [related docs section](#reaction-scheduling).
- `debugger`: An optional function. It is called with contextual metadata object on basic operations - like set, get, delete, etc. The metadata object can be used to determine why the operation wired or scheduled the reaction and it always has enough data to reverse the operation. The debugger is always called before the scheduler.
* `debugger`: An optional function. It is called with contextual metadata object on basic operations - like set, get, delete, etc. The metadata object can be used to determine why the operation wired or scheduled the reaction and it always has enough data to reverse the operation. The debugger is always called before the scheduler.

@@ -396,9 +397,9 @@ ### unobserve(reaction)

```js
import { observable, observe, unobserve } from '@nx-js/observer-util'
import { observable, observe, unobserve } from '@nx-js/observer-util';
const counter = observable({ num: 0 })
const logger = observe(() => console.log(counter.num))
const counter = observable({ num: 0 });
const logger = observe(() => console.log(counter.num));
// after this the logger won't be automatically called on counter.num changes
unobserve(logger)
unobserve(logger);
```

@@ -413,12 +414,12 @@

```js
import { observable, observe, raw } from '@nx-js/observer-util'
import { observable, observe, raw } from '@nx-js/observer-util';
const person = observable()
const logger = observe(() => console.log(person.name))
const person = observable();
const logger = observe(() => console.log(person.name));
// this logs 'Bob'
person.name = 'Bob'
person.name = 'Bob';
// `name` is used from the raw non-reactive object, this won't log anything
raw(person).name = 'John'
raw(person).name = 'John';
```

@@ -429,12 +430,12 @@

```js
import { observable, observe, raw } from '@nx-js/observer-util'
import { observable, observe, raw } from '@nx-js/observer-util';
const person = observable({ age: 20 })
observe(() => console.log(`${person.name}: ${raw(person).age}`))
const person = observable({ age: 20 });
observe(() => console.log(`${person.name}: ${raw(person).age}`));
// this logs 'Bob: 20'
person.name = 'Bob'
person.name = 'Bob';
// `age` is used from the raw non-reactive object, this won't log anything
person.age = 33
person.age = 33;
```

@@ -444,9 +445,9 @@

- Node: 6.5 and above
- Chrome: 49 and above
- Firefox: 38 and above
- Safari: 10 and above
- Edge: 12 and above
- Opera: 36 and above
- IE is not supported
* Node: 6.5 and above
* Chrome: 49 and above
* Firefox: 38 and above
* Safari: 10 and above
* Edge: 12 and above
* Opera: 36 and above
* IE is not supported

@@ -457,6 +458,6 @@ ## Alternative builds

- `@nx-js/observer-util/dist/es.es6.js` exposes an ES6 build with ES6 modules.
- `@nx-js/observer-util/dist/es.es5.js` exposes an ES5 build with ES6 modules.
- `@nx-js/observer-util/dist/cjs.es6.js` exposes an ES6 build with commonJS modules.
- `@nx-js/observer-util/dist/cjs.es5.js` exposes an ES5 build with commonJS modules.
* `@nx-js/observer-util/dist/es.es6.js` exposes an ES6 build with ES6 modules.
* `@nx-js/observer-util/dist/es.es5.js` exposes an ES5 build with ES6 modules.
* `@nx-js/observer-util/dist/cjs.es6.js` exposes an ES6 build with commonJS modules.
* `@nx-js/observer-util/dist/cjs.es5.js` exposes an ES5 build with commonJS modules.

@@ -463,0 +464,0 @@ If you use a bundler, set up an alias for `@nx-js/observer-util` to point to your desired build. You can learn how to do it with webpack [here](https://webpack.js.org/configuration/resolve/#resolve-alias) and with rollup [here](https://github.com/rollup/rollup-plugin-alias#usage).

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc