Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.0.3 to 2.1.0

4

CHANGELOG.md

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

## [2.1.0] - 2022-03-16
### Added
- Support getOwnPropertyDescriptor handler #34
## [2.0.3] - 2022-02-28

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

2

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,l=(n,o)=>{let s=!1;const c=(e,t)=>{if(!s){let r=e.a.get(n);r||(r=new Set,e.a.set(n,r)),r.add(t)}},l={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)},ownKeys(t){return c(this,e),Reflect.ownKeys(t)}};return o&&(l.set=l.deleteProperty=()=>!1),l},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 i=o&&o.get(c);return i&&i.f===a||(i=l(c,a),i.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,i),o&&o.set(c,i)),i.a=t,i.c=o,i.p},i=(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 l=null;for(const c of s){const s=c===e?i(t,r):u(t[c],r[c],n,o);if(!0!==s&&!1!==s||(l=s),l)break}return null===l&&(l=!0),o&&o.set(t,{n:r,g:l}),l},f=e=>!!s(e)&&t in e,y=e=>s(e)&&e[r]||null,b=(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 l=t.get(e);l?l.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,b as markToTrack,f as trackMemo};
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

@@ -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)},f=function(t){return"object"==typeof t&&null!==t},c=function(t,e,a){if(!u(t))return t;var f=t[o]||t,s=function(t){return Object.isFrozen(t)||Object.values(Object.getOwnPropertyDescriptors(t)).some(function(t){return!t.writable})}(f),l=a&&a.get(f);return l&&l.f===s||((l=function(t,e){var i,a=!1,u=function(e,r){if(!a){var n=e.a.get(t);n||(n=new Set,e.a.set(t,n)),n.add(r)}},f=((i={}).f=e,i.get=function(e,r){return r===o?t:(u(this,r),c(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.ownKeys=function(t){return u(this,r),Reflect.ownKeys(t)},i);return e&&(f.set=f.deleteProperty=function(){return!1}),f}(f,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)}(f):f,l),a&&a.set(f,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)){f(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=c,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(!f(n)||!f(o))return!0;var u=i.get(n);if(!u)return!0;if(a){var c,l=a.get(n);if(l&&l.n===o)return l.g;a.set(n,((c={}).n=o,c.g=!1,c))}for(var y,p,d=null,b=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=b()).done;){var g=y.value,h=g===r?s(n,o):t(n[g],o[g],i,a);if(!0!==h&&!1!==h||(d=h),d)break}return null===d&&(d=!0),a&&a.set(n,((p={}).n=o,p.g=d,p)),d},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,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}});
//# sourceMappingURL=index.umd.js.map
{
"name": "proxy-compare",
"description": "Compare two objects using accessed properties with Proxy",
"version": "2.0.3",
"version": "2.1.0",
"author": "Daishi Kato",

@@ -49,6 +49,6 @@ "repository": {

"@types/jest": "^27.4.1",
"@typescript-eslint/eslint-plugin": "^5.12.1",
"@typescript-eslint/parser": "^5.12.1",
"@typescript-eslint/eslint-plugin": "^5.15.0",
"@typescript-eslint/parser": "^5.15.0",
"documentation": "^13.2.5",
"eslint": "^8.10.0",
"eslint": "^8.11.0",
"eslint-config-airbnb-base": "^15.0.0",

@@ -60,4 +60,4 @@ "eslint-plugin-import": "^2.25.4",

"ts-jest": "^27.1.3",
"typescript": "^4.5.5"
"typescript": "^4.6.2"
}
}

@@ -65,2 +65,3 @@ // symbols

has(target: T, key: string | symbol): boolean;
getOwnPropertyDescriptor(target: T, key: string | symbol): PropertyDescriptor | undefined;
ownKeys(target: T): (string | symbol)[];

@@ -73,3 +74,3 @@ set?(target: T, key: string | symbol, value: unknown): boolean;

let trackObject = false; // for trackMemo
const recordUsage = (h: ProxyHandler<T>, key: string | symbol) => {
const recordUsage = (h: ProxyHandler<T>, key: string | symbol, skipWithOwnKeys?: boolean) => {
if (!trackObject) {

@@ -81,3 +82,5 @@ let used = (h[AFFECTED_PROPERTY] as Affected).get(origObj);

}
used.add(key);
if (!skipWithOwnKeys || !used.has(OWN_KEYS_SYMBOL)) {
used.add(key);
}
}

@@ -107,9 +110,15 @@ };

}
// LIMITATION:
// We simply record the same as get.
// LIMITATION: We simply record the same as `get`.
// This means { a: {} } and { a: {} } is detected as changed,
// if 'a' in obj is handled.
// if `'a' in obj` is handled.
recordUsage(this, key);
return key in target;
},
getOwnPropertyDescriptor(target, key) {
// LIMITATION: We simply record the same as `get`.
// This means { a: {} } and { a: {} } is detected as changed,
// if `obj.getOwnPropertyDescriptor('a'))` is handled.
recordUsage(this, key, true);
return Object.getOwnPropertyDescriptor(target, key);
},
ownKeys(target) {

@@ -116,0 +125,0 @@ recordUsage(this, OWN_KEYS_SYMBOL);

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