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.5.0 to 2.5.1

2

dist/index.modern.js

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

const e=Symbol(),t=Symbol(),r="a",n="w";let o=(e,t)=>new Proxy(e,t);const s=Object.getPrototypeOf,c=new WeakMap,l=e=>e&&(c.has(e)?c.get(e):s(e)===Object.prototype||s(e)===Array.prototype),f=e=>"object"==typeof e&&null!==e,i=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(s(e),t)},u=e=>e[t]||e,a=(s,c,f,p)=>{if(!l(s))return s;let g=p&&p.get(s);if(!g){const e=u(s);g=(e=>Object.values(Object.getOwnPropertyDescriptors(e)).some(e=>!e.configurable&&!e.writable))(e)?[e,i(e)]:[e],null==p||p.set(s,g)}const[y,h]=g;let w=f&&f.get(y);return w&&w[1].f===!!h||(w=((o,s)=>{const c={f:s};let l=!1;const f=(e,t)=>{if(!l){let s=c[r].get(o);if(s||(s={},c[r].set(o,s)),e===n)s[n]=!0;else{let r=s[e];r||(r=new Set,s[e]=r),r.add(t)}}},i={get:(e,n)=>n===t?o:(f("k",n),a(Reflect.get(e,n),c[r],c.c)),has:(t,n)=>n===e?(l=!0,c[r].delete(o),!0):(f("h",n),Reflect.has(t,n)),getOwnPropertyDescriptor:(e,t)=>(f("o",t),Reflect.getOwnPropertyDescriptor(e,t)),ownKeys:e=>(f(n),Reflect.ownKeys(e))};return s&&(i.set=i.deleteProperty=()=>!1),[i,c]})(y,!!h),w[1].p=o(h||y,w[0]),f&&f.set(y,w)),w[1][r]=c,w[1].c=f,w[1].p},p=(e,t,r,o)=>{if(Object.is(e,t))return!1;if(!f(e)||!f(t))return!0;const s=r.get(u(e));if(!s)return!0;if(o){const r=o.get(e);if(r&&r.n===t)return r.g;o.set(e,{n:t,g:!1})}let c=null;try{for(const r of s.h||[])if(c=Reflect.has(e,r)!==Reflect.has(t,r),c)return c;if(!0===s[n]){if(c=((e,t)=>{const r=Reflect.ownKeys(e),n=Reflect.ownKeys(t);return r.length!==n.length||r.some((e,t)=>e!==n[t])})(e,t),c)return c}else for(const r of s.o||[])if(c=!!Reflect.getOwnPropertyDescriptor(e,r)!=!!Reflect.getOwnPropertyDescriptor(t,r),c)return c;for(const n of s.k||[])if(c=p(e[n],t[n],r,o),c)return c;return null===c&&(c=!0),c}finally{o&&o.set(e,{n:t,g:c})}},g=t=>!!l(t)&&e in t,y=e=>l(e)&&e[t]||null,h=(e,t=!0)=>{c.set(e,t)},w=(e,t,r)=>{const o=[],s=new WeakSet,c=(e,l)=>{if(s.has(e))return;f(e)&&s.add(e);const i=f(e)&&t.get(u(e));if(i){var a,p;if(null==(a=i.h)||a.forEach(e=>{const t=`:has(${String(e)})`;o.push(l?[...l,t]:[t])}),!0===i[n]){const e=":ownKeys";o.push(l?[...l,e]:[e])}else{var g;null==(g=i.o)||g.forEach(e=>{const t=`:hasOwn(${String(e)})`;o.push(l?[...l,t]:[t])})}null==(p=i.k)||p.forEach(t=>{r&&!("value"in(Object.getOwnPropertyDescriptor(e,t)||{}))||c(e[t],l?[...l,t]:[t])})}else l&&o.push(l)};return c(e),o},O=e=>{o=e};export{w as affectedToPathList,a as createProxy,y as getUntracked,p as isChanged,h as markToTrack,O as replaceNewProxy,g as trackMemo};
const e=Symbol(),t=Symbol(),r="a",n="w";let o=(e,t)=>new Proxy(e,t);const s=Object.getPrototypeOf,c=new WeakMap,l=e=>e&&(c.has(e)?c.get(e):s(e)===Object.prototype||s(e)===Array.prototype),f=e=>"object"==typeof e&&null!==e,i=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(s(e),t)},u=e=>e[t]||e,a=(s,c,f,p)=>{if(!l(s))return s;let g=p&&p.get(s);if(!g){const e=u(s);g=(e=>Object.values(Object.getOwnPropertyDescriptors(e)).some(e=>!e.configurable&&!e.writable))(e)?[e,i(e)]:[e],null==p||p.set(s,g)}const[y,h]=g;let w=f&&f.get(y);return w&&w[1].f===!!h||(w=((o,s)=>{const c={f:s};let l=!1;const f=(e,t)=>{if(!l){let s=c[r].get(o);if(s||(s={},c[r].set(o,s)),e===n)s[n]=!0;else{let r=s[e];r||(r=new Set,s[e]=r),r.add(t)}}},i={get:(e,n)=>n===t?o:(f("k",n),a(Reflect.get(e,n),c[r],c.c,c.t)),has:(t,n)=>n===e?(l=!0,c[r].delete(o),!0):(f("h",n),Reflect.has(t,n)),getOwnPropertyDescriptor:(e,t)=>(f("o",t),Reflect.getOwnPropertyDescriptor(e,t)),ownKeys:e=>(f(n),Reflect.ownKeys(e))};return s&&(i.set=i.deleteProperty=()=>!1),[i,c]})(y,!!h),w[1].p=o(h||y,w[0]),f&&f.set(y,w)),w[1][r]=c,w[1].c=f,w[1].t=p,w[1].p},p=(e,t,r,o)=>{if(Object.is(e,t))return!1;if(!f(e)||!f(t))return!0;const s=r.get(u(e));if(!s)return!0;if(o){const r=o.get(e);if(r&&r.n===t)return r.g;o.set(e,{n:t,g:!1})}let c=null;try{for(const r of s.h||[])if(c=Reflect.has(e,r)!==Reflect.has(t,r),c)return c;if(!0===s[n]){if(c=((e,t)=>{const r=Reflect.ownKeys(e),n=Reflect.ownKeys(t);return r.length!==n.length||r.some((e,t)=>e!==n[t])})(e,t),c)return c}else for(const r of s.o||[])if(c=!!Reflect.getOwnPropertyDescriptor(e,r)!=!!Reflect.getOwnPropertyDescriptor(t,r),c)return c;for(const n of s.k||[])if(c=p(e[n],t[n],r,o),c)return c;return null===c&&(c=!0),c}finally{o&&o.set(e,{n:t,g:c})}},g=t=>!!l(t)&&e in t,y=e=>l(e)&&e[t]||null,h=(e,t=!0)=>{c.set(e,t)},w=(e,t,r)=>{const o=[],s=new WeakSet,c=(e,l)=>{if(s.has(e))return;f(e)&&s.add(e);const i=f(e)&&t.get(u(e));if(i){var a,p;if(null==(a=i.h)||a.forEach(e=>{const t=`:has(${String(e)})`;o.push(l?[...l,t]:[t])}),!0===i[n]){const e=":ownKeys";o.push(l?[...l,e]:[e])}else{var g;null==(g=i.o)||g.forEach(e=>{const t=`:hasOwn(${String(e)})`;o.push(l?[...l,t]:[t])})}null==(p=i.k)||p.forEach(t=>{r&&!("value"in(Object.getOwnPropertyDescriptor(e,t)||{}))||c(e[t],l?[...l,t]:[t])})}else l&&o.push(l)};return c(e),o},O=e=>{o=e};export{w as affectedToPathList,a as createProxy,y as getUntracked,p as isChanged,h as markToTrack,O as replaceNewProxy,g as trackMemo};
//# sourceMappingURL=index.modern.mjs.map

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e||self).proxyCompare={})}(this,function(e){function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function r(e,r){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,r){if(e){if("string"==typeof e)return t(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){n&&(e=n);var o=0;return function(){return o>=e.length?{done:!0}:{done:!1,value:e[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.")}var n=Symbol(),o=Symbol(),a="a",i="w",u=function(e,t){return new Proxy(e,t)},f=Object.getPrototypeOf,c=new WeakMap,l=function(e){return e&&(c.has(e)?c.get(e):f(e)===Object.prototype||f(e)===Array.prototype)},s=function(e){return"object"==typeof e&&null!==e},p=function(e){if(Array.isArray(e))return Array.from(e);var t=Object.getOwnPropertyDescriptors(e);return Object.values(t).forEach(function(e){e.configurable=!0}),Object.create(f(e),t)},y=function(e){return e[o]||e},v=function(e,t,r,f){if(!l(e))return e;var c=f&&f.get(e);if(!c){var s=y(e);c=function(e){return Object.values(Object.getOwnPropertyDescriptors(e)).some(function(e){return!e.configurable&&!e.writable})}(s)?[s,p(s)]:[s],null==f||f.set(e,c)}var g,h,d,b,w,m,O,j=c[0],P=c[1],S=r&&r.get(j);return S&&S[1].f===!!P||((g=j,h=!!P,(d={}).f=h,b=d,w=!1,m=function(e,t){if(!w){var r=b[a].get(g);if(r||b[a].set(g,r={}),e===i)r[i]=!0;else{var n=r[e];n||(n=new Set,r[e]=n),n.add(t)}}},O={get:function(e,t){return t===o?g:(m("k",t),v(Reflect.get(e,t),b[a],b.c))},has:function(e,t){return t===n?(w=!0,b[a].delete(g),!0):(m("h",t),Reflect.has(e,t))},getOwnPropertyDescriptor:function(e,t){return m("o",t),Reflect.getOwnPropertyDescriptor(e,t)},ownKeys:function(e){return m(i),Reflect.ownKeys(e)}},h&&(O.set=O.deleteProperty=function(){return!1}),S=[O,b])[1].p=u(P||j,S[0]),r&&r.set(j,S)),S[1][a]=t,S[1].c=r,S[1].p};e.affectedToPathList=function(e,t,r){var n=[],o=new WeakSet;return function e(a,u){if(!o.has(a)){s(a)&&o.add(a);var f=s(a)&&t.get(y(a));if(f){var c,l;if(null==(c=f.h)||c.forEach(function(e){var t=":has("+String(e)+")";n.push(u?[].concat(u,[t]):[t])}),!0===f[i]){var p=":ownKeys";n.push(u?[].concat(u,[p]):[p])}else{var v;null==(v=f.o)||v.forEach(function(e){var t=":hasOwn("+String(e)+")";n.push(u?[].concat(u,[t]):[t])})}null==(l=f.k)||l.forEach(function(t){r&&!("value"in(Object.getOwnPropertyDescriptor(a,t)||{}))||e(a[t],u?[].concat(u,[t]):[t])})}else u&&n.push(u)}}(e),n},e.createProxy=v,e.getUntracked=function(e){return l(e)&&e[o]||null},e.isChanged=function e(t,n,o,a){if(Object.is(t,n))return!1;if(!s(t)||!s(n))return!0;var u=o.get(y(t));if(!u)return!0;if(a){var f,c=a.get(t);if(c&&c.n===n)return c.g;a.set(t,((f={}).n=n,f.g=!1,f))}var l=null;try{for(var p,v=r(u.h||[]);!(p=v()).done;){var g=p.value;if(l=Reflect.has(t,g)!==Reflect.has(n,g))return l}if(!0===u[i]){if(l=function(e,t){var r=Reflect.ownKeys(e),n=Reflect.ownKeys(t);return r.length!==n.length||r.some(function(e,t){return e!==n[t]})}(t,n),l)return l}else for(var h,d=r(u.o||[]);!(h=d()).done;){var b=h.value;if(l=!!Reflect.getOwnPropertyDescriptor(t,b)!=!!Reflect.getOwnPropertyDescriptor(n,b))return l}for(var w,m=r(u.k||[]);!(w=m()).done;){var O=w.value;if(l=e(t[O],n[O],o,a))return l}return null===l&&(l=!0),l}finally{var j;a&&a.set(t,((j={}).n=n,j.g=l,j))}},e.markToTrack=function(e,t){void 0===t&&(t=!0),c.set(e,t)},e.replaceNewProxy=function(e){u=e},e.trackMemo=function(e){return!!l(e)&&n in e}});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e||self).proxyCompare={})}(this,function(e){function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function r(e,r){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,r){if(e){if("string"==typeof e)return t(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){n&&(e=n);var o=0;return function(){return o>=e.length?{done:!0}:{done:!1,value:e[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.")}var n=Symbol(),o=Symbol(),a="a",i="w",u=function(e,t){return new Proxy(e,t)},f=Object.getPrototypeOf,c=new WeakMap,l=function(e){return e&&(c.has(e)?c.get(e):f(e)===Object.prototype||f(e)===Array.prototype)},s=function(e){return"object"==typeof e&&null!==e},p=function(e){if(Array.isArray(e))return Array.from(e);var t=Object.getOwnPropertyDescriptors(e);return Object.values(t).forEach(function(e){e.configurable=!0}),Object.create(f(e),t)},y=function(e){return e[o]||e},v=function(e,t,r,f){if(!l(e))return e;var c=f&&f.get(e);if(!c){var s=y(e);c=function(e){return Object.values(Object.getOwnPropertyDescriptors(e)).some(function(e){return!e.configurable&&!e.writable})}(s)?[s,p(s)]:[s],null==f||f.set(e,c)}var g,h,d,b,w,m,O,j=c[0],P=c[1],S=r&&r.get(j);return S&&S[1].f===!!P||((g=j,h=!!P,(d={}).f=h,b=d,w=!1,m=function(e,t){if(!w){var r=b[a].get(g);if(r||b[a].set(g,r={}),e===i)r[i]=!0;else{var n=r[e];n||(n=new Set,r[e]=n),n.add(t)}}},O={get:function(e,t){return t===o?g:(m("k",t),v(Reflect.get(e,t),b[a],b.c,b.t))},has:function(e,t){return t===n?(w=!0,b[a].delete(g),!0):(m("h",t),Reflect.has(e,t))},getOwnPropertyDescriptor:function(e,t){return m("o",t),Reflect.getOwnPropertyDescriptor(e,t)},ownKeys:function(e){return m(i),Reflect.ownKeys(e)}},h&&(O.set=O.deleteProperty=function(){return!1}),S=[O,b])[1].p=u(P||j,S[0]),r&&r.set(j,S)),S[1][a]=t,S[1].c=r,S[1].t=f,S[1].p};e.affectedToPathList=function(e,t,r){var n=[],o=new WeakSet;return function e(a,u){if(!o.has(a)){s(a)&&o.add(a);var f=s(a)&&t.get(y(a));if(f){var c,l;if(null==(c=f.h)||c.forEach(function(e){var t=":has("+String(e)+")";n.push(u?[].concat(u,[t]):[t])}),!0===f[i]){var p=":ownKeys";n.push(u?[].concat(u,[p]):[p])}else{var v;null==(v=f.o)||v.forEach(function(e){var t=":hasOwn("+String(e)+")";n.push(u?[].concat(u,[t]):[t])})}null==(l=f.k)||l.forEach(function(t){r&&!("value"in(Object.getOwnPropertyDescriptor(a,t)||{}))||e(a[t],u?[].concat(u,[t]):[t])})}else u&&n.push(u)}}(e),n},e.createProxy=v,e.getUntracked=function(e){return l(e)&&e[o]||null},e.isChanged=function e(t,n,o,a){if(Object.is(t,n))return!1;if(!s(t)||!s(n))return!0;var u=o.get(y(t));if(!u)return!0;if(a){var f,c=a.get(t);if(c&&c.n===n)return c.g;a.set(t,((f={}).n=n,f.g=!1,f))}var l=null;try{for(var p,v=r(u.h||[]);!(p=v()).done;){var g=p.value;if(l=Reflect.has(t,g)!==Reflect.has(n,g))return l}if(!0===u[i]){if(l=function(e,t){var r=Reflect.ownKeys(e),n=Reflect.ownKeys(t);return r.length!==n.length||r.some(function(e,t){return e!==n[t]})}(t,n),l)return l}else for(var h,d=r(u.o||[]);!(h=d()).done;){var b=h.value;if(l=!!Reflect.getOwnPropertyDescriptor(t,b)!=!!Reflect.getOwnPropertyDescriptor(n,b))return l}for(var w,m=r(u.k||[]);!(w=m()).done;){var O=w.value;if(l=e(t[O],n[O],o,a))return l}return null===l&&(l=!0),l}finally{var j;a&&a.set(t,((j={}).n=n,j.g=l,j))}},e.markToTrack=function(e,t){void 0===t&&(t=!0),c.set(e,t)},e.replaceNewProxy=function(e){u=e},e.trackMemo=function(e){return!!l(e)&&n in e}});
//# sourceMappingURL=index.umd.js.map

@@ -0,0 +0,0 @@ declare let newProxy: <T extends object>(target: T, handler: ProxyHandler<T>) => T;

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

@@ -51,15 +51,15 @@ "repository": {

"devDependencies": {
"@types/jest": "^29.4.0",
"@typescript-eslint/eslint-plugin": "^5.52.0",
"@typescript-eslint/parser": "^5.52.0",
"@types/jest": "^29.5.1",
"@typescript-eslint/eslint-plugin": "^5.59.2",
"@typescript-eslint/parser": "^5.59.2",
"documentation": "^14.0.1",
"eslint": "^8.34.0",
"eslint": "^8.39.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.27.5",
"jest": "^29.4.2",
"jest": "^29.5.0",
"microbundle": "^0.15.1",
"npm-run-all": "^4.1.5",
"ts-jest": "^29.0.5",
"typescript": "^4.9.5"
"ts-jest": "^29.1.0",
"typescript": "^5.0.4"
}
}

@@ -12,3 +12,3 @@ # proxy-compare

This is an internal library used in [React Tracked](https://react-tracked.js.org).
This is an internal library used in state management libraries such as [React Tracked](https://react-tracked.js.org) and [Valtio](https://github.com/pmndrs/valtio).

@@ -15,0 +15,0 @@ ## Install

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

const PROXY_CACHE_PROPERTY = 'c';
const TARGET_CACHE_PROPERTY = 't';
const NEXT_OBJECT_PROPERTY = 'n';

@@ -80,2 +81,3 @@ const CHANGED_PROPERTY = 'g';

[PROXY_CACHE_PROPERTY]?: ProxyCache<object> | undefined;
[TARGET_CACHE_PROPERTY]?: TargetCache<object> | undefined;
[AFFECTED_PROPERTY]?: Affected;

@@ -137,2 +139,3 @@ }

state[PROXY_CACHE_PROPERTY],
state[TARGET_CACHE_PROPERTY],
);

@@ -239,2 +242,3 @@ },

handlerAndState[1][PROXY_CACHE_PROPERTY] = proxyCache as ProxyCache<object> | undefined;
handlerAndState[1][TARGET_CACHE_PROPERTY] = targetCache as TargetCache<object> | undefined;
return handlerAndState[1][PROXY_PROPERTY] as typeof target;

@@ -241,0 +245,0 @@ };

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