Socket
Socket
Sign inDemoInstall

proxy-compare

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

proxy-compare - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

4

CHANGELOG.md

@@ -5,2 +5,6 @@ # Change Log

## [2.2.0] - 2022-06-14
### Added
- Support nested proxy #38
## [2.1.0] - 2022-03-16

@@ -7,0 +11,0 @@ ### Added

4

dist/index.modern.js

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

const e=Symbol(),t=Symbol(),r=Symbol(),n=Object.getPrototypeOf,o=new WeakMap,s=e=>e&&(o.has(e)?o.get(e):n(e)===Object.prototype||n(e)===Array.prototype),c=e=>"object"==typeof e&&null!==e,i=(n,o)=>{let s=!1;const c=(t,r,o)=>{if(!s){let s=t.a.get(n);s||(s=new Set,t.a.set(n,s)),o&&s.has(e)||s.add(r)}},i={f:o,get(e,t){return t===r?n:(c(this,t),a(e[t],this.a,this.c))},has(e,r){return r===t?(s=!0,this.a.delete(n),!0):(c(this,r),r in e)},getOwnPropertyDescriptor(e,t){return c(this,t,!0),Object.getOwnPropertyDescriptor(e,t)},ownKeys(t){return c(this,e),Reflect.ownKeys(t)}};return o&&(i.set=i.deleteProperty=()=>!1),i},a=(e,t,o)=>{if(!s(e))return e;const c=e[r]||e,a=(e=>Object.isFrozen(e)||Object.values(Object.getOwnPropertyDescriptors(e)).some(e=>!e.writable))(c);let l=o&&o.get(c);return l&&l.f===a||(l=i(c,a),l.p=new Proxy(a?(e=>{if(Array.isArray(e))return Array.from(e);const t=Object.getOwnPropertyDescriptors(e);return Object.values(t).forEach(e=>{e.configurable=!0}),Object.create(n(e),t)})(c):c,l),o&&o.set(c,l)),l.a=t,l.c=o,l.p},l=(e,t)=>{const r=Reflect.ownKeys(e),n=Reflect.ownKeys(t);return r.length!==n.length||r.some((e,t)=>e!==n[t])},u=(t,r,n,o)=>{if(Object.is(t,r))return!1;if(!c(t)||!c(r))return!0;const s=n.get(t);if(!s)return!0;if(o){const e=o.get(t);if(e&&e.n===r)return e.g;o.set(t,{n:r,g:!1})}let i=null;for(const c of s){const s=c===e?l(t,r):u(t[c],r[c],n,o);if(!0!==s&&!1!==s||(i=s),i)break}return null===i&&(i=!0),o&&o.set(t,{n:r,g:i}),i},f=e=>!!s(e)&&t in e,y=e=>s(e)&&e[r]||null,p=(e,t=!0)=>{o.set(e,t)},g=(e,t)=>{const r=[],n=new WeakSet,o=(e,s)=>{if(n.has(e))return;c(e)&&n.add(e);const i=t.get(e);i?i.forEach(t=>{o(e[t],s?[...s,t]:[t])}):s&&r.push(s)};return o(e),r};export{g as affectedToPathList,a as createProxy,y as getUntracked,u as isChanged,p as markToTrack,f as trackMemo};
//# sourceMappingURL=index.modern.mjs.map
const e=Symbol(),t=Symbol(),r=Symbol(),n=Object.getPrototypeOf,o=new WeakMap,s=e=>e&&(o.has(e)?o.get(e):n(e)===Object.prototype||n(e)===Array.prototype),c=e=>"object"==typeof e&&null!==e,i=(n,o)=>{let s=!1;const c=(t,r,o)=>{if(!s){let s=t.a.get(n);s||(s=new Set,t.a.set(n,s)),o&&s.has(e)||s.add(r)}},i={f:o,get(e,t){return t===r?n:(c(this,t),l(e[t],this.a,this.c))},has(e,r){return r===t?(s=!0,this.a.delete(n),!0):(c(this,r),r in e)},getOwnPropertyDescriptor(e,t){return c(this,t,!0),Object.getOwnPropertyDescriptor(e,t)},ownKeys(t){return c(this,e),Reflect.ownKeys(t)}};return o&&(i.set=i.deleteProperty=()=>!1),i},a=e=>e[r]||e,l=(e,t,r)=>{if(!s(e))return e;const o=a(e),c=(e=>Object.isFrozen(e)||Object.values(Object.getOwnPropertyDescriptors(e)).some(e=>!e.writable))(o);let l=r&&r.get(o);return l&&l.f===c||(l=i(o,c),l.p=new Proxy(c?(e=>{if(Array.isArray(e))return Array.from(e);const t=Object.getOwnPropertyDescriptors(e);return Object.values(t).forEach(e=>{e.configurable=!0}),Object.create(n(e),t)})(o):o,l),r&&r.set(o,l)),l.a=t,l.c=r,l.p},u=(e,t)=>{const r=Reflect.ownKeys(e),n=Reflect.ownKeys(t);return r.length!==n.length||r.some((e,t)=>e!==n[t])},f=(t,r,n,o)=>{if(Object.is(t,r))return!1;if(!c(t)||!c(r))return!0;const s=n.get(a(t));if(!s)return!0;if(o){const e=o.get(t);if(e&&e.n===r)return e.g;o.set(t,{n:r,g:!1})}let i=null;for(const c of s){const s=c===e?u(t,r):f(t[c],r[c],n,o);if(!0!==s&&!1!==s||(i=s),i)break}return null===i&&(i=!0),o&&o.set(t,{n:r,g:i}),i},y=e=>!!s(e)&&t in e,p=e=>s(e)&&e[r]||null,g=(e,t=!0)=>{o.set(e,t)},b=(e,t)=>{const r=[],n=new WeakSet,o=(e,s)=>{if(n.has(e))return;c(e)&&n.add(e);const i=c(e)&&t.get(a(e));i?i.forEach(t=>{o(e[t],s?[...s,t]:[t])}):s&&r.push(s)};return o(e),r};export{b as affectedToPathList,l as createProxy,p as getUntracked,f as isChanged,g as markToTrack,y as trackMemo};
//# sourceMappingURL=index.modern.js.map

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t||self).proxyCompare={})}(this,function(t){function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var r=Symbol(),n=Symbol(),o=Symbol(),i=Object.getPrototypeOf,a=new WeakMap,u=function(t){return t&&(a.has(t)?a.get(t):i(t)===Object.prototype||i(t)===Array.prototype)},c=function(t){return"object"==typeof t&&null!==t},f=function(t,e,a){if(!u(t))return t;var c=t[o]||t,s=function(t){return Object.isFrozen(t)||Object.values(Object.getOwnPropertyDescriptors(t)).some(function(t){return!t.writable})}(c),l=a&&a.get(c);return l&&l.f===s||((l=function(t,e){var i,a=!1,u=function(e,n,o){if(!a){var i=e.a.get(t);i||(i=new Set,e.a.set(t,i)),o&&i.has(r)||i.add(n)}},c=((i={}).f=e,i.get=function(e,r){return r===o?t:(u(this,r),f(e[r],this.a,this.c))},i.has=function(e,r){return r===n?(a=!0,this.a.delete(t),!0):(u(this,r),r in e)},i.getOwnPropertyDescriptor=function(t,e){return u(this,e,!0),Object.getOwnPropertyDescriptor(t,e)},i.ownKeys=function(t){return u(this,r),Reflect.ownKeys(t)},i);return e&&(c.set=c.deleteProperty=function(){return!1}),c}(c,s)).p=new Proxy(s?function(t){if(Array.isArray(t))return Array.from(t);var e=Object.getOwnPropertyDescriptors(t);return Object.values(e).forEach(function(t){t.configurable=!0}),Object.create(i(t),e)}(c):c,l),a&&a.set(c,l)),l.a=e,l.c=a,l.p},s=function(t,e){var r=Reflect.ownKeys(t),n=Reflect.ownKeys(e);return r.length!==n.length||r.some(function(t,e){return t!==n[e]})};t.affectedToPathList=function(t,e){var r=[],n=new WeakSet;return function t(o,i){if(!n.has(o)){c(o)&&n.add(o);var a=e.get(o);a?a.forEach(function(e){t(o[e],i?[].concat(i,[e]):[e])}):i&&r.push(i)}}(t),r},t.createProxy=f,t.getUntracked=function(t){return u(t)&&t[o]||null},t.isChanged=function t(n,o,i,a){if(Object.is(n,o))return!1;if(!c(n)||!c(o))return!0;var u=i.get(n);if(!u)return!0;if(a){var f,l=a.get(n);if(l&&l.n===o)return l.g;a.set(n,((f={}).n=o,f.g=!1,f))}for(var y,p,b=null,d=function(t,r){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(n)return(n=n.call(t)).next.bind(n);if(Array.isArray(t)||(n=function(t,r){if(t){if("string"==typeof t)return e(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,r):void 0}}(t))){n&&(t=n);var o=0;return function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(u);!(y=d()).done;){var g=y.value,h=g===r?s(n,o):t(n[g],o[g],i,a);if(!0!==h&&!1!==h||(b=h),b)break}return null===b&&(b=!0),a&&a.set(n,((p={}).n=o,p.g=b,p)),b},t.markToTrack=function(t,e){void 0===e&&(e=!0),a.set(t,e)},t.trackMemo=function(t){return!!u(t)&&n in t}});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t||self).proxyCompare={})}(this,function(t){function e(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var r=Symbol(),n=Symbol(),o=Symbol(),i=Object.getPrototypeOf,u=new WeakMap,a=function(t){return t&&(u.has(t)?u.get(t):i(t)===Object.prototype||i(t)===Array.prototype)},c=function(t){return"object"==typeof t&&null!==t},f=function(t){return t[o]||t},s=function(t,e,u){if(!a(t))return t;var c=f(t),l=function(t){return Object.isFrozen(t)||Object.values(Object.getOwnPropertyDescriptors(t)).some(function(t){return!t.writable})}(c),y=u&&u.get(c);return y&&y.f===l||((y=function(t,e){var i,u=!1,a=function(e,n,o){if(!u){var i=e.a.get(t);i||(i=new Set,e.a.set(t,i)),o&&i.has(r)||i.add(n)}},c=((i={}).f=e,i.get=function(e,r){return r===o?t:(a(this,r),s(e[r],this.a,this.c))},i.has=function(e,r){return r===n?(u=!0,this.a.delete(t),!0):(a(this,r),r in e)},i.getOwnPropertyDescriptor=function(t,e){return a(this,e,!0),Object.getOwnPropertyDescriptor(t,e)},i.ownKeys=function(t){return a(this,r),Reflect.ownKeys(t)},i);return e&&(c.set=c.deleteProperty=function(){return!1}),c}(c,l)).p=new Proxy(l?function(t){if(Array.isArray(t))return Array.from(t);var e=Object.getOwnPropertyDescriptors(t);return Object.values(e).forEach(function(t){t.configurable=!0}),Object.create(i(t),e)}(c):c,y),u&&u.set(c,y)),y.a=e,y.c=u,y.p},l=function(t,e){var r=Reflect.ownKeys(t),n=Reflect.ownKeys(e);return r.length!==n.length||r.some(function(t,e){return t!==n[e]})};t.affectedToPathList=function(t,e){var r=[],n=new WeakSet;return function t(o,i){if(!n.has(o)){c(o)&&n.add(o);var u=c(o)&&e.get(f(o));u?u.forEach(function(e){t(o[e],i?[].concat(i,[e]):[e])}):i&&r.push(i)}}(t),r},t.createProxy=s,t.getUntracked=function(t){return a(t)&&t[o]||null},t.isChanged=function t(n,o,i,u){if(Object.is(n,o))return!1;if(!c(n)||!c(o))return!0;var a=i.get(f(n));if(!a)return!0;if(u){var s,y=u.get(n);if(y&&y.n===o)return y.g;u.set(n,((s={}).n=o,s.g=!1,s))}for(var p,b,d=null,g=function(t,r){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(n)return(n=n.call(t)).next.bind(n);if(Array.isArray(t)||(n=function(t,r){if(t){if("string"==typeof t)return e(t,r);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?e(t,r):void 0}}(t))){n&&(t=n);var o=0;return function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(a);!(p=g()).done;){var h=p.value,v=h===r?l(n,o):t(n[h],o[h],i,u);if(!0!==v&&!1!==v||(d=v),d)break}return null===d&&(d=!0),u&&u.set(n,((b={}).n=o,b.g=d,b)),d},t.markToTrack=function(t,e){void 0===e&&(e=!0),u.set(t,e)},t.trackMemo=function(t){return!!a(t)&&n in t}});
//# sourceMappingURL=index.umd.js.map

@@ -32,3 +32,3 @@ /**

*/
export declare const createProxy: <T>(obj: T, affected: WeakMap<object, unknown>, proxyCache?: WeakMap<object, unknown> | undefined) => T;
export declare const createProxy: <T>(obj: T, affected: WeakMap<object, unknown>, proxyCache?: WeakMap<object, unknown>) => T;
/**

@@ -43,4 +43,4 @@ * Compare changes on objects.

*
* @param {object} origObj - The original object to compare.
* @param {object} nextObj - Object to compare with the original one.
* @param {object} prevObj - The previous object to compare.
* @param {object} nextObj - Object to compare with the previous one.
* @param {WeakMap<object, unknown>} affected -

@@ -56,16 +56,16 @@ * WeakMap that holds the tracking of which properties in the proxied object were accessed.

*
* const original = { a: "1", c: "2", d: { e: "3" } };
* const obj = { a: "1", c: "2", d: { e: "3" } };
* const affected = new WeakMap();
*
* const proxy = createProxy(original, affected);
* const proxy = createProxy(obj, affected);
*
* proxy.a
*
* isChanged(original, { a: "1" }, affected) // false
* isChanged(obj, { a: "1" }, affected) // false
*
* proxy.a = "2"
*
* isChanged(original, { a: "1" }, affected) // true
* isChanged(obj, { a: "1" }, affected) // true
*/
export declare const isChanged: (origObj: unknown, nextObj: unknown, affected: WeakMap<object, unknown>, cache?: WeakMap<object, unknown> | undefined) => boolean;
export declare const isChanged: (prevObj: unknown, nextObj: unknown, affected: WeakMap<object, unknown>, cache?: WeakMap<object, unknown>) => boolean;
export declare const trackMemo: (obj: unknown) => boolean;

@@ -89,3 +89,3 @@ /**

*
* Obejct.is(original, originalFromProxy) // true
* Object.is(original, originalFromProxy) // true
* isChanged(original, originalFromProxy, affected) // false

@@ -102,5 +102,5 @@ */

*
* @param {object} obj - Object to mark as tracked or not.
* @param {mark} boolean - Boolean indicating whether you want to track this object or not.
* @returns {undefined} - No return.
* @param obj - Object to mark as tracked or not.
* @param mark - Boolean indicating whether you want to track this object or not.
* @returns No return.
*

@@ -107,0 +107,0 @@ * @example

{
"name": "proxy-compare",
"description": "Compare two objects using accessed properties with Proxy",
"version": "2.1.0",
"version": "2.2.0",
"author": "Daishi Kato",

@@ -31,9 +31,12 @@ "repository": {

"compile": "microbundle build -f modern,umd",
"postcompile": "cp dist/index.modern.mjs dist/index.modern.js && cp dist/index.modern.mjs.map dist/index.modern.js.map",
"postcompile": "cp dist/index.modern.js dist/index.modern.mjs && cp dist/index.modern.js.map dist/index.modern.mjs.map",
"test": "run-s eslint tsc-test jest",
"eslint": "eslint --ext .js,.ts --ignore-pattern dist .",
"jest": "jest --preset ts-jest/presets/js-with-ts __tests__/*.ts",
"jest": "jest",
"tsc-test": "tsc --project . --noEmit",
"apidoc": "documentation readme --section API --markdown-toc false --parse-extension ts src/*.ts"
},
"jest": {
"preset": "ts-jest/presets/js-with-ts"
},
"keywords": [

@@ -49,15 +52,15 @@ "proxy",

"devDependencies": {
"@types/jest": "^27.4.1",
"@typescript-eslint/eslint-plugin": "^5.15.0",
"@typescript-eslint/parser": "^5.15.0",
"@types/jest": "^28.1.1",
"@typescript-eslint/eslint-plugin": "^5.28.0",
"@typescript-eslint/parser": "^5.28.0",
"documentation": "^13.2.5",
"eslint": "^8.11.0",
"eslint": "^8.17.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.25.4",
"jest": "^27.5.1",
"microbundle": "^0.14.2",
"eslint-plugin-import": "^2.26.0",
"jest": "^28.1.1",
"microbundle": "^0.15.0",
"npm-run-all": "^4.1.5",
"ts-jest": "^27.1.3",
"typescript": "^4.6.2"
"ts-jest": "^28.0.5",
"typescript": "^4.7.3"
}
}

@@ -101,4 +101,4 @@ # proxy-compare

* `origObj` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The original object to compare.
* `nextObj` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object to compare with the original one.
* `prevObj` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The previous object to compare.
* `nextObj` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object to compare with the previous one.
* `affected` **[WeakMap](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakMap)<[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object), unknown>** WeakMap that holds the tracking of which properties in the proxied object were accessed.

@@ -113,14 +113,14 @@ * `cache` **[WeakMap](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakMap)<[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object), unknown>?** WeakMap that holds a cache of the comparisons for better performance with repetitive comparisons,

const original = { a: "1", c: "2", d: { e: "3" } };
const obj = { a: "1", c: "2", d: { e: "3" } };
const affected = new WeakMap();
const proxy = createProxy(original, affected);
const proxy = createProxy(obj, affected);
proxy.a
isChanged(original, { a: "1" }, affected) // false
isChanged(obj, { a: "1" }, affected) // false
proxy.a = "2"
isChanged(original, { a: "1" }, affected) // true
isChanged(obj, { a: "1" }, affected) // true
```

@@ -151,3 +151,3 @@

Obejct.is(original, originalFromProxy) // true
Object.is(original, originalFromProxy) // true
isChanged(original, originalFromProxy, affected) // false

@@ -170,4 +170,3 @@ ```

* `obj` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object to mark as tracked or not.
* `mark` (optional, default `true`)
* `boolean` **mark** Boolean indicating whether you want to track this object or not.
* `mark` Boolean indicating whether you want to track this object or not. (optional, default `true`)

@@ -193,3 +192,3 @@ #### Examples

Returns **[undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined)** No return.
Returns **any** No return.

@@ -196,0 +195,0 @@ ## Projects using this library

@@ -61,3 +61,3 @@ // symbols

[PROXY_PROPERTY]?: T;
[PROXY_CACHE_PROPERTY]?: ProxyCache<object>;
[PROXY_CACHE_PROPERTY]?: ProxyCache<object> | undefined;
[AFFECTED_PROPERTY]?: Affected;

@@ -132,2 +132,9 @@ get(target: T, key: string | symbol): unknown;

const getOriginalObject = <T extends object>(obj: T) => (
// unwrap proxy
(obj as { [GET_ORIGINAL_SYMBOL]?: typeof obj })[GET_ORIGINAL_SYMBOL]
// otherwise
|| obj
);
/**

@@ -170,6 +177,3 @@ * Create a proxy.

if (!isObjectToTrack(obj)) return obj;
const origObj = (
obj as { [GET_ORIGINAL_SYMBOL]?: typeof obj }
)[GET_ORIGINAL_SYMBOL]; // unwrap proxy
const target = origObj || obj;
const target = getOriginalObject(obj);
const frozen = isFrozen(target);

@@ -194,7 +198,7 @@ let proxyHandler: ProxyHandler<typeof target> | undefined = (

const isOwnKeysChanged = (origObj: object, nextObj: object) => {
const origKeys = Reflect.ownKeys(origObj);
const isOwnKeysChanged = (prevObj: object, nextObj: object) => {
const prevKeys = Reflect.ownKeys(prevObj);
const nextKeys = Reflect.ownKeys(nextObj);
return origKeys.length !== nextKeys.length
|| origKeys.some((k, i) => k !== nextKeys[i]);
return prevKeys.length !== nextKeys.length
|| prevKeys.some((k, i) => k !== nextKeys[i]);
};

@@ -216,4 +220,4 @@

*
* @param {object} origObj - The original object to compare.
* @param {object} nextObj - Object to compare with the original one.
* @param {object} prevObj - The previous object to compare.
* @param {object} nextObj - Object to compare with the previous one.
* @param {WeakMap<object, unknown>} affected -

@@ -229,18 +233,18 @@ * WeakMap that holds the tracking of which properties in the proxied object were accessed.

*
* const original = { a: "1", c: "2", d: { e: "3" } };
* const obj = { a: "1", c: "2", d: { e: "3" } };
* const affected = new WeakMap();
*
* const proxy = createProxy(original, affected);
* const proxy = createProxy(obj, affected);
*
* proxy.a
*
* isChanged(original, { a: "1" }, affected) // false
* isChanged(obj, { a: "1" }, affected) // false
*
* proxy.a = "2"
*
* isChanged(original, { a: "1" }, affected) // true
* isChanged(obj, { a: "1" }, affected) // true
*/
export const isChanged = (
origObj: unknown,
prevObj: unknown,
nextObj: unknown,

@@ -250,10 +254,10 @@ affected: WeakMap<object, unknown>,

): boolean => {
if (Object.is(origObj, nextObj)) {
if (Object.is(prevObj, nextObj)) {
return false;
}
if (!isObject(origObj) || !isObject(nextObj)) return true;
const used = (affected as Affected).get(origObj);
if (!isObject(prevObj) || !isObject(nextObj)) return true;
const used = (affected as Affected).get(getOriginalObject(prevObj));
if (!used) return true;
if (cache) {
const hit = (cache as ChangedCache).get(origObj);
const hit = (cache as ChangedCache).get(prevObj);
if (hit && hit[NEXT_OBJECT_PROPERTY] === nextObj) {

@@ -263,3 +267,3 @@ return hit[CHANGED_PROPERTY];

// for object with cycles
(cache as ChangedCache).set(origObj, {
(cache as ChangedCache).set(prevObj, {
[NEXT_OBJECT_PROPERTY]: nextObj,

@@ -272,5 +276,5 @@ [CHANGED_PROPERTY]: false,

for (const key of used) {
const c = key === OWN_KEYS_SYMBOL ? isOwnKeysChanged(origObj, nextObj)
const c = key === OWN_KEYS_SYMBOL ? isOwnKeysChanged(prevObj, nextObj)
: isChanged(
(origObj as any)[key],
(prevObj as any)[key],
(nextObj as any)[key],

@@ -285,3 +289,3 @@ affected,

if (cache) {
cache.set(origObj, {
cache.set(prevObj, {
[NEXT_OBJECT_PROPERTY]: nextObj,

@@ -319,3 +323,3 @@ [CHANGED_PROPERTY]: changed,

*
* Obejct.is(original, originalFromProxy) // true
* Object.is(original, originalFromProxy) // true
* isChanged(original, originalFromProxy, affected) // false

@@ -338,5 +342,5 @@ */

*
* @param {object} obj - Object to mark as tracked or not.
* @param {mark} boolean - Boolean indicating whether you want to track this object or not.
* @returns {undefined} - No return.
* @param obj - Object to mark as tracked or not.
* @param mark - Boolean indicating whether you want to track this object or not.
* @returns No return.
*

@@ -378,3 +382,3 @@ * @example

}
const used = (affected as Affected).get(x as object);
const used = isObject(x) && (affected as Affected).get(getOriginalObject(x));
if (used) {

@@ -381,0 +385,0 @@ used.forEach((key) => {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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