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.0 to 2.4.1

4

CHANGELOG.md

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

## [2.4.1] - 2023-02-07
### Changed
- fix: remove unfrozen cache #53
## [2.4.0] - 2023-01-04

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

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=new WeakMap,a=e=>e[t]||e,u=(c,f,p)=>{if(!l(c))return c;const y=a(c),g=(e=>Object.isFrozen(e)||Object.values(Object.getOwnPropertyDescriptors(e)).some(e=>!e.writable))(y);let h=p&&p.get(y);return h&&h[1].f===g||(h=((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]})(y,g),h[1].p=o(g?(e=>{let t=i.get(e);if(!t){if(Array.isArray(e))t=Array.from(e);else{const r=Object.getOwnPropertyDescriptors(e);Object.values(r).forEach(e=>{e.configurable=!0}),t=Object.create(s(e),r)}i.set(e,t)}return t})(y):y,h[0]),p&&p.set(y,h)),h[1][r]=f,h[1].c=p,h[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(a(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})}},y=t=>!!l(t)&&e in t,g=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(a(e));if(i){var u,p;if(null==(u=i.h)||u.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 y;null==(y=i.o)||y.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,u as createProxy,g as getUntracked,p as isChanged,h as markToTrack,O as replaceNewProxy,y 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=>e[t]||e,u=(c,f,a)=>{if(!l(c))return c;const p=i(c),y=(e=>Object.isFrozen(e)||Object.values(Object.getOwnPropertyDescriptors(e)).some(e=>!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};
//# 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",f=function(e,t){return new Proxy(e,t)},u=Object.getPrototypeOf,c=new WeakMap,l=function(e){return e&&(c.has(e)?c.get(e):u(e)===Object.prototype||u(e)===Array.prototype)},s=function(e){return"object"==typeof e&&null!==e},p=new WeakMap,y=function(e){return e[o]||e},v=function(e,t,r){if(!l(e))return e;var c=y(e),s=function(e){return Object.isFrozen(e)||Object.values(Object.getOwnPropertyDescriptors(e)).some(function(e){return!e.writable})}(c),g=r&&r.get(c);return g&&g[1].f===s||((g=function(e,t){var r,f=((r={}).f=t,r),u=!1,c=function(t,r){if(!u){var n=f[a].get(e);if(n||f[a].set(e,n={}),t===i)n[i]=!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),v(Reflect.get(t,r),f[a],f.c))},has:function(t,r){return r===n?(u=!0,f[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(i),Reflect.ownKeys(e)}};return t&&(l.set=l.deleteProperty=function(){return!1}),[l,f]}(c,s))[1].p=f(s?function(e){var t=p.get(e);if(!t){if(Array.isArray(e))t=Array.from(e);else{var r=Object.getOwnPropertyDescriptors(e);Object.values(r).forEach(function(e){e.configurable=!0}),t=Object.create(u(e),r)}p.set(e,t)}return t}(c):c,g[0]),r&&r.set(c,g)),g[1][a]=t,g[1].c=r,g[1].p};e.affectedToPathList=function(e,t,r){var n=[],o=new WeakSet;return function e(a,f){if(!o.has(a)){s(a)&&o.add(a);var u=s(a)&&t.get(y(a));if(u){var c,l;if(null==(c=u.h)||c.forEach(function(e){var t=":has("+String(e)+")";n.push(f?[].concat(f,[t]):[t])}),!0===u[i]){var p=":ownKeys";n.push(f?[].concat(f,[p]):[p])}else{var v;null==(v=u.o)||v.forEach(function(e){var t=":hasOwn("+String(e)+")";n.push(f?[].concat(f,[t]):[t])})}null==(l=u.k)||l.forEach(function(t){r&&!("value"in(Object.getOwnPropertyDescriptor(a,t)||{}))||e(a[t],f?[].concat(f,[t]):[t])})}else f&&n.push(f)}}(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 f=o.get(y(t));if(!f)return!0;if(a){var u,c=a.get(t);if(c&&c.n===n)return c.g;a.set(t,((u={}).n=n,u.g=!1,u))}var l=null;try{for(var p,v=r(f.h||[]);!(p=v()).done;){var g=p.value;if(l=Reflect.has(t,g)!==Reflect.has(n,g))return l}if(!0===f[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(f.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(f.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){f=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){return e[o]||e},y=function(e,t,r){if(!l(e))return e;var c=p(e),s=function(e){return Object.isFrozen(e)||Object.values(Object.getOwnPropertyDescriptors(e)).some(function(e){return!e.writable})}(c),v=r&&r.get(c);return v&&v[1].f===s||((v=function(e,t){var r,u=((r={}).f=t,r),f=!1,c=function(t,r){if(!f){var n=u[a].get(e);if(n||u[a].set(e,n={}),t===i)n[i]=!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),u[a],u.c))},has:function(t,r){return r===n?(f=!0,u[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(i),Reflect.ownKeys(e)}};return t&&(l.set=l.deleteProperty=function(){return!1}),[l,u]}(c,s))[1].p=u(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,u){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(u?[].concat(u,[t]):[t])}),!0===f[i]){var y=":ownKeys";n.push(u?[].concat(u,[y]):[y])}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=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 u=o.get(p(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 y,v=r(u.h||[]);!(y=v()).done;){var g=y.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
{
"name": "proxy-compare",
"description": "Compare two objects using accessed properties with Proxy",
"version": "2.4.0",
"version": "2.4.1",
"author": "Daishi Kato",

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

"devDependencies": {
"@types/jest": "^29.2.5",
"@typescript-eslint/eslint-plugin": "^5.48.0",
"@typescript-eslint/parser": "^5.48.0",
"@types/jest": "^29.4.0",
"@typescript-eslint/eslint-plugin": "^5.51.0",
"@typescript-eslint/parser": "^5.51.0",
"documentation": "^14.0.1",
"eslint": "^8.31.0",
"eslint": "^8.33.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.26.0",
"jest": "^29.3.1",
"eslint-plugin-import": "^2.27.5",
"jest": "^29.4.2",
"microbundle": "^0.15.1",
"npm-run-all": "^4.1.5",
"ts-jest": "^29.0.3",
"typescript": "^4.9.4"
"ts-jest": "^29.0.5",
"typescript": "^4.9.5"
}
}
# proxy-compare
[![CI](https://img.shields.io/github/workflow/status/dai-shi/proxy-compare/CI)](https://github.com/dai-shi/proxy-compare/actions?query=workflow%3ACI)
[![CI](https://img.shields.io/github/actions/workflow/status/dai-shi/proxy-compare/ci.yml?branch=main)](https://github.com/dai-shi/proxy-compare/actions?query=workflow%3ACI)
[![npm](https://img.shields.io/npm/v/proxy-compare)](https://www.npmjs.com/package/proxy-compare)
[![size](https://img.shields.io/bundlephobia/minzip/proxy-compare)](https://bundlephobia.com/result?p=proxy-compare)
[![discord](https://img.shields.io/discord/627656437971288081)](https://discord.gg/MrQdmzd)

@@ -7,0 +8,0 @@ Compare two objects using accessed properties with Proxy

@@ -53,19 +53,12 @@ // symbols

// copy frozen object
const unfrozenCache = new WeakMap<object, object>();
const unfreeze = <T extends object>(obj: T): T => {
let unfrozen = unfrozenCache.get(obj);
if (!unfrozen) {
if (Array.isArray(obj)) {
// Arrays need a special way to copy
unfrozen = Array.from(obj);
} else {
// For non-array objects, we create a new object keeping the prototype
// with changing all configurable options (otherwise, proxies will complain)
const descriptors = Object.getOwnPropertyDescriptors(obj);
Object.values(descriptors).forEach((desc) => { desc.configurable = true; });
unfrozen = Object.create(getProto(obj), descriptors);
}
unfrozenCache.set(obj, unfrozen as object);
if (Array.isArray(obj)) {
// Arrays need a special way to copy
return Array.from(obj) as T;
}
return unfrozen as T;
// For non-array objects, we create a new object keeping the prototype
// with changing all configurable options (otherwise, proxies will complain)
const descriptors = Object.getOwnPropertyDescriptors(obj);
Object.values(descriptors).forEach((desc) => { desc.configurable = true; });
return Object.create(getProto(obj), descriptors);
};

@@ -72,0 +65,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