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.4.2 to 2.5.0

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=>e[t]||e,u=(c,f,a)=>{if(!l(c))return c;const p=i(c),y=(e=>Object.values(Object.getOwnPropertyDescriptors(e)).some(e=>!e.configurable&&!e.writable))(p);let g=a&&a.get(p);return g&&g[1].f===y||(g=((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),u(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]})(p,y),g[1].p=o(y?(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)})(p):p,g[0]),a&&a.set(p,g)),g[1][r]=f,g[1].c=a,g[1].p},a=(e,t,r,o)=>{if(Object.is(e,t))return!1;if(!f(e)||!f(t))return!0;const s=r.get(i(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=a(e[n],t[n],r,o),c)return c;return null===c&&(c=!0),c}finally{o&&o.set(e,{n:t,g:c})}},p=t=>!!l(t)&&e in t,y=e=>l(e)&&e[t]||null,g=(e,t=!0)=>{c.set(e,t)},h=(e,t,r)=>{const o=[],s=new WeakSet,c=(e,l)=>{if(s.has(e))return;f(e)&&s.add(e);const u=f(e)&&t.get(i(e));if(u){var a,p;if(null==(a=u.h)||a.forEach(e=>{const t=`:has(${String(e)})`;o.push(l?[...l,t]:[t])}),!0===u[n]){const e=":ownKeys";o.push(l?[...l,e]:[e])}else{var y;null==(y=u.o)||y.forEach(e=>{const t=`:hasOwn(${String(e)})`;o.push(l?[...l,t]:[t])})}null==(p=u.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},w=e=>{o=e};export{h as affectedToPathList,u as createProxy,y as getUntracked,a as isChanged,g as markToTrack,w as replaceNewProxy,p 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)),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};
//# 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",u="w",i=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){return e[o]||e},y=function(e,t,r){if(!l(e))return e;var c=p(e),s=function(e){return Object.values(Object.getOwnPropertyDescriptors(e)).some(function(e){return!e.configurable&&!e.writable})}(c),v=r&&r.get(c);return v&&v[1].f===s||((v=function(e,t){var r,i=((r={}).f=t,r),f=!1,c=function(t,r){if(!f){var n=i[a].get(e);if(n||i[a].set(e,n={}),t===u)n[u]=!0;else{var o=n[t];o||(o=new Set,n[t]=o),o.add(r)}}},l={get:function(t,r){return r===o?e:(c("k",r),y(Reflect.get(t,r),i[a],i.c))},has:function(t,r){return r===n?(f=!0,i[a].delete(e),!0):(c("h",r),Reflect.has(t,r))},getOwnPropertyDescriptor:function(e,t){return c("o",t),Reflect.getOwnPropertyDescriptor(e,t)},ownKeys:function(e){return c(u),Reflect.ownKeys(e)}};return t&&(l.set=l.deleteProperty=function(){return!1}),[l,i]}(c,s))[1].p=i(s?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)}(c):c,v[0]),r&&r.set(c,v)),v[1][a]=t,v[1].c=r,v[1].p};e.affectedToPathList=function(e,t,r){var n=[],o=new WeakSet;return function e(a,i){if(!o.has(a)){s(a)&&o.add(a);var f=s(a)&&t.get(p(a));if(f){var c,l;if(null==(c=f.h)||c.forEach(function(e){var t=":has("+String(e)+")";n.push(i?[].concat(i,[t]):[t])}),!0===f[u]){var y=":ownKeys";n.push(i?[].concat(i,[y]):[y])}else{var v;null==(v=f.o)||v.forEach(function(e){var t=":hasOwn("+String(e)+")";n.push(i?[].concat(i,[t]):[t])})}null==(l=f.k)||l.forEach(function(t){r&&!("value"in(Object.getOwnPropertyDescriptor(a,t)||{}))||e(a[t],i?[].concat(i,[t]):[t])})}else i&&n.push(i)}}(e),n},e.createProxy=y,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 i=o.get(p(t));if(!i)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 y,v=r(i.h||[]);!(y=v()).done;){var g=y.value;if(l=Reflect.has(t,g)!==Reflect.has(n,g))return l}if(!0===i[u]){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(i.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(i.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){i=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))},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}});
//# sourceMappingURL=index.umd.js.map

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

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

@@ -36,0 +36,0 @@ * Compare changes on objects.

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

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

"@types/jest": "^29.4.0",
"@typescript-eslint/eslint-plugin": "^5.51.0",
"@typescript-eslint/parser": "^5.51.0",
"@typescript-eslint/eslint-plugin": "^5.52.0",
"@typescript-eslint/parser": "^5.52.0",
"documentation": "^14.0.1",
"eslint": "^8.33.0",
"eslint": "^8.34.0",
"eslint-config-airbnb-base": "^15.0.0",

@@ -58,0 +58,0 @@ "eslint-plugin-import": "^2.27.5",

@@ -85,2 +85,6 @@ // symbols

>;
type TargetCache<T extends object> = WeakMap<
object,
readonly [target: T, copiedTarget?: T]
>;

@@ -199,6 +203,18 @@ const createProxyHandler = <T extends object>(origObj: T, isTargetCopied: boolean) => {

proxyCache?: WeakMap<object, unknown>,
targetCache?: WeakMap<object, unknown>,
): T => {
if (!isObjectToTrack(obj)) return obj;
const target = getOriginalObject(obj);
const isTargetCopied = needsToCopyTargetObject(target);
let targetAndCopied = (
targetCache && (targetCache as TargetCache<typeof obj>).get(obj)
);
if (!targetAndCopied) {
const target = getOriginalObject(obj);
if (needsToCopyTargetObject(target)) {
targetAndCopied = [target, copyTargetObject(target)];
} else {
targetAndCopied = [target];
}
targetCache?.set(obj, targetAndCopied);
}
const [target, copiedTarget] = targetAndCopied;
let handlerAndState = (

@@ -209,7 +225,7 @@ proxyCache && (proxyCache as ProxyCache<typeof target>).get(target)

!handlerAndState
|| handlerAndState[1][IS_TARGET_COPIED_PROPERTY] !== isTargetCopied
|| handlerAndState[1][IS_TARGET_COPIED_PROPERTY] !== !!copiedTarget
) {
handlerAndState = createProxyHandler<typeof target>(target, isTargetCopied);
handlerAndState = createProxyHandler<typeof target>(target, !!copiedTarget);
handlerAndState[1][PROXY_PROPERTY] = newProxy(
isTargetCopied ? copyTargetObject(target) : target,
copiedTarget || target,
handlerAndState[0],

@@ -216,0 +232,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