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 1.0.0 to 1.0.1

4

CHANGELOG.md

@@ -5,4 +5,8 @@ # Change Log

## [1.0.1] - 2020-03-09
### Changed
- Improve types
## [1.0.0] - 2020-03-08
### Added
- Initial release

2

dist/index.esm.js

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

var t=Symbol(),r=Symbol(),e=Symbol(),n=function(t){try{var r=Object.getPrototypeOf(t);return r===Object.prototype||r===Array.prototype}catch(t){return!1}},i=function(o,u,f){if(!n(o))return o;var s,a=o[e]||o,c=f&&f.get(a);return c||(((s={}).r=function(t){if(!this.t){var r=this.a.get(this.o);r||(r=new Set,this.a.set(this.o,r)),r.add(t)}},s.u=function(){this.t=!0,this.a.delete(this.o)},s.get=function(t,r){return r===e?this.o:(this.r(r),i(t[r],this.a,this.c))},s.has=function(t,e){return e===r?(this.u(),!0):(this.r(e),e in t)},s.ownKeys=function(r){return this.r(t),Reflect.ownKeys(r)},c=s).p=new Proxy(function(t){return Object.isFrozen(t)?Array.isArray(t)?Array.from(t):Object.assign({},t):t}(a),c),c.o=a,c.t=!1,f&&f.set(a,c)),c.a=u,c.c=f,c.p},o=function(t,r){var e=Reflect.ownKeys(t),n=Reflect.ownKeys(r);return e.length!==n.length||e.some(function(t,r){return t!==n[r]})},u=1,f=2,s=4,a=8,c=function r(e,n,i,u,f){if(void 0===f&&(f=0),e===n&&0==(2&f))return!1;if("object"!=typeof e||null===e)return!0;if("object"!=typeof n||null===n)return!0;var s=i.get(e);if(!s)return 0==(1&f);if(u&&0==(2&f)){var a,c=u.get(e);if(c&&c.n===n)return c.g||!1;u.set(e,((a={}).n=n,a))}var l,y=null,h=s,b=Array.isArray(h),g=0;for(h=b?h:h[Symbol.iterator]();;){var v;if(b){if(g>=h.length)break;v=h[g++]}else{if((g=h.next()).done)break;v=g.value}var p=v,j=p===t?o(e,n):r(e[p],n[p],i,u,f>>>2<<2|f>>>2);if(!0!==j&&!1!==j||(y=j),y)break}return null===y&&(y=0==(1&f)),u&&0==(2&f)&&u.set(e,((l={}).n=n,l.g=y,l)),y},l=function(t){return!!n(t)&&r in t},y=function(t){return n(t)&&t[e]||null};export{u as MODE_ASSUME_UNCHANGED_IF_UNAFFECTED,s as MODE_ASSUME_UNCHANGED_IF_UNAFFECTED_IN_DEEP,f as MODE_IGNORE_REF_EQUALITY,a as MODE_IGNORE_REF_EQUALITY_IN_DEEP,i as createDeepProxy,y as getUntrackedObject,c as isDeepChanged,l as trackMemo};
var t=Symbol(),r=Symbol(),e=Symbol(),n=function(t){try{var r=Object.getPrototypeOf(t);return r===Object.prototype||r===Array.prototype}catch(t){return!1}},i=function(o,u,f){if(!n(o))return o;var s,a=o[e]||o,c=f&&f.get(a);return c||(((s={}).r=function(t){if(!this.t){var r=this.a.get(this.o);r||(r=new Set,this.a.set(this.o,r)),r.add(t)}},s.u=function(){this.t=!0,this.a.delete(this.o)},s.get=function(t,r){return r===e?this.o:(this.r(r),i(t[r],this.a,this.c))},s.has=function(t,e){return e===r?(this.u(),!0):(this.r(e),e in t)},s.ownKeys=function(r){return this.r(t),Reflect.ownKeys(r)},c=s).p=new Proxy(function(t){return Object.isFrozen(t)?Array.isArray(t)?Array.from(t):Object.assign({},t):t}(a),c),c.o=a,c.t=!1,f&&f.set(a,c)),c.a=u,c.c=f,c.p},o=function(t,r){var e=Reflect.ownKeys(t),n=Reflect.ownKeys(r);return e.length!==n.length||e.some(function(t,r){return t!==n[r]})},u=1,f=2,s=4,a=8,c=function r(e,n,i,u,f){if(void 0===f&&(f=0),e===n&&0==(2&f))return!1;if("object"!=typeof e||null===e)return!0;if("object"!=typeof n||null===n)return!0;var s=i.get(e);if(!s)return 0==(1&f);if(u&&0==(2&f)){var a,c=u.get(e);if(c&&c.n===n)return c.g;u.set(e,((a={}).n=n,a.g=!1,a))}var l,y=null,h=s,b=Array.isArray(h),g=0;for(h=b?h:h[Symbol.iterator]();;){var v;if(b){if(g>=h.length)break;v=h[g++]}else{if((g=h.next()).done)break;v=g.value}var p=v,j=p===t?o(e,n):r(e[p],n[p],i,u,f>>>2<<2|f>>>2);if(!0!==j&&!1!==j||(y=j),y)break}return null===y&&(y=0==(1&f)),u&&0==(2&f)&&u.set(e,((l={}).n=n,l.g=y,l)),y},l=function(t){return!!n(t)&&r in t},y=function(t){return n(t)&&t[e]||null};export{u as MODE_ASSUME_UNCHANGED_IF_UNAFFECTED,s as MODE_ASSUME_UNCHANGED_IF_UNAFFECTED_IN_DEEP,f as MODE_IGNORE_REF_EQUALITY,a as MODE_IGNORE_REF_EQUALITY_IN_DEEP,i as createDeepProxy,y as getUntrackedObject,c as isDeepChanged,l as trackMemo};
//# sourceMappingURL=index.esm.js.map

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

var t=Symbol(),e=Symbol(),r=Symbol(),n=function(t){try{var e=Object.getPrototypeOf(t);return e===Object.prototype||e===Array.prototype}catch(t){return!1}},o=function(i,s,u){if(!n(i))return i;var a,f=i[r]||i,c=u&&u.get(f);return c||(((a={}).r=function(t){if(!this.t){var e=this.a.get(this.o);e||(e=new Set,this.a.set(this.o,e)),e.add(t)}},a.u=function(){this.t=!0,this.a.delete(this.o)},a.get=function(t,e){return e===r?this.o:(this.r(e),o(t[e],this.a,this.c))},a.has=function(t,r){return r===e?(this.u(),!0):(this.r(r),r in t)},a.ownKeys=function(e){return this.r(t),Reflect.ownKeys(e)},c=a).p=new Proxy(function(t){return Object.isFrozen(t)?Array.isArray(t)?Array.from(t):Object.assign({},t):t}(f),c),c.o=f,c.t=!1,u&&u.set(f,c)),c.a=s,c.c=u,c.p},i=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]})};exports.MODE_ASSUME_UNCHANGED_IF_UNAFFECTED=1,exports.MODE_ASSUME_UNCHANGED_IF_UNAFFECTED_IN_DEEP=4,exports.MODE_IGNORE_REF_EQUALITY=2,exports.MODE_IGNORE_REF_EQUALITY_IN_DEEP=8,exports.createDeepProxy=o,exports.getUntrackedObject=function(t){return n(t)&&t[r]||null},exports.isDeepChanged=function e(r,n,o,s,u){if(void 0===u&&(u=0),r===n&&0==(2&u))return!1;if("object"!=typeof r||null===r)return!0;if("object"!=typeof n||null===n)return!0;var a=o.get(r);if(!a)return 0==(1&u);if(s&&0==(2&u)){var f,c=s.get(r);if(c&&c.n===n)return c.g||!1;s.set(r,((f={}).n=n,f))}var l,y=null,E=a,h=Array.isArray(E),p=0;for(E=h?E:E[Symbol.iterator]();;){var _;if(h){if(p>=E.length)break;_=E[p++]}else{if((p=E.next()).done)break;_=p.value}var b=_,g=b===t?i(r,n):e(r[b],n[b],o,s,u>>>2<<2|u>>>2);if(!0!==g&&!1!==g||(y=g),y)break}return null===y&&(y=0==(1&u)),s&&0==(2&u)&&s.set(r,((l={}).n=n,l.g=y,l)),y},exports.trackMemo=function(t){return!!n(t)&&e in t};
var t=Symbol(),e=Symbol(),r=Symbol(),n=function(t){try{var e=Object.getPrototypeOf(t);return e===Object.prototype||e===Array.prototype}catch(t){return!1}},o=function(i,s,u){if(!n(i))return i;var a,f=i[r]||i,c=u&&u.get(f);return c||(((a={}).r=function(t){if(!this.t){var e=this.a.get(this.o);e||(e=new Set,this.a.set(this.o,e)),e.add(t)}},a.u=function(){this.t=!0,this.a.delete(this.o)},a.get=function(t,e){return e===r?this.o:(this.r(e),o(t[e],this.a,this.c))},a.has=function(t,r){return r===e?(this.u(),!0):(this.r(r),r in t)},a.ownKeys=function(e){return this.r(t),Reflect.ownKeys(e)},c=a).p=new Proxy(function(t){return Object.isFrozen(t)?Array.isArray(t)?Array.from(t):Object.assign({},t):t}(f),c),c.o=f,c.t=!1,u&&u.set(f,c)),c.a=s,c.c=u,c.p},i=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]})};exports.MODE_ASSUME_UNCHANGED_IF_UNAFFECTED=1,exports.MODE_ASSUME_UNCHANGED_IF_UNAFFECTED_IN_DEEP=4,exports.MODE_IGNORE_REF_EQUALITY=2,exports.MODE_IGNORE_REF_EQUALITY_IN_DEEP=8,exports.createDeepProxy=o,exports.getUntrackedObject=function(t){return n(t)&&t[r]||null},exports.isDeepChanged=function e(r,n,o,s,u){if(void 0===u&&(u=0),r===n&&0==(2&u))return!1;if("object"!=typeof r||null===r)return!0;if("object"!=typeof n||null===n)return!0;var a=o.get(r);if(!a)return 0==(1&u);if(s&&0==(2&u)){var f,c=s.get(r);if(c&&c.n===n)return c.g;s.set(r,((f={}).n=n,f.g=!1,f))}var l,y=null,E=a,h=Array.isArray(E),p=0;for(E=h?E:E[Symbol.iterator]();;){var _;if(h){if(p>=E.length)break;_=E[p++]}else{if((p=E.next()).done)break;_=p.value}var g=_,b=g===t?i(r,n):e(r[g],n[g],o,s,u>>>2<<2|u>>>2);if(!0!==b&&!1!==b||(y=b),y)break}return null===y&&(y=0==(1&u)),s&&0==(2&u)&&s.set(r,((l={}).n=n,l.g=y,l)),y},exports.trackMemo=function(t){return!!n(t)&&e in t};
//# sourceMappingURL=index.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=t||self).proxyCompare={})}(this,function(t){var e=Symbol(),r=Symbol(),n=Symbol(),o=function(t){try{var e=Object.getPrototypeOf(t);return e===Object.prototype||e===Array.prototype}catch(t){return!1}},i=function(t,f,u){if(!o(t))return t;var s,a=t[n]||t,c=u&&u.get(a);return c||(((s={}).r=function(t){if(!this.t){var e=this.a.get(this.o);e||(e=new Set,this.a.set(this.o,e)),e.add(t)}},s.u=function(){this.t=!0,this.a.delete(this.o)},s.get=function(t,e){return e===n?this.o:(this.r(e),i(t[e],this.a,this.c))},s.has=function(t,e){return e===r?(this.u(),!0):(this.r(e),e in t)},s.ownKeys=function(t){return this.r(e),Reflect.ownKeys(t)},c=s).p=new Proxy(function(t){return Object.isFrozen(t)?Array.isArray(t)?Array.from(t):Object.assign({},t):t}(a),c),c.o=a,c.t=!1,u&&u.set(a,c)),c.a=f,c.c=u,c.p},f=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.MODE_ASSUME_UNCHANGED_IF_UNAFFECTED=1,t.MODE_ASSUME_UNCHANGED_IF_UNAFFECTED_IN_DEEP=4,t.MODE_IGNORE_REF_EQUALITY=2,t.MODE_IGNORE_REF_EQUALITY_IN_DEEP=8,t.createDeepProxy=i,t.getUntrackedObject=function(t){return o(t)&&t[n]||null},t.isDeepChanged=function t(r,n,o,i,u){if(void 0===u&&(u=0),r===n&&0==(2&u))return!1;if("object"!=typeof r||null===r)return!0;if("object"!=typeof n||null===n)return!0;var s=o.get(r);if(!s)return 0==(1&u);if(i&&0==(2&u)){var a,c=i.get(r);if(c&&c.n===n)return c.g||!1;i.set(r,((a={}).n=n,a))}var y,l=null,h=s,E=Array.isArray(h),p=0;for(h=E?h:h[Symbol.iterator]();;){var _;if(E){if(p>=h.length)break;_=h[p++]}else{if((p=h.next()).done)break;_=p.value}var b=_,d=b===e?f(r,n):t(r[b],n[b],o,i,u>>>2<<2|u>>>2);if(!0!==d&&!1!==d||(l=d),l)break}return null===l&&(l=0==(1&u)),i&&0==(2&u)&&i.set(r,((y={}).n=n,y.g=l,y)),l},t.trackMemo=function(t){return!!o(t)&&r in t}});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).proxyCompare={})}(this,function(t){var e=Symbol(),r=Symbol(),n=Symbol(),o=function(t){try{var e=Object.getPrototypeOf(t);return e===Object.prototype||e===Array.prototype}catch(t){return!1}},i=function(t,f,u){if(!o(t))return t;var s,a=t[n]||t,c=u&&u.get(a);return c||(((s={}).r=function(t){if(!this.t){var e=this.a.get(this.o);e||(e=new Set,this.a.set(this.o,e)),e.add(t)}},s.u=function(){this.t=!0,this.a.delete(this.o)},s.get=function(t,e){return e===n?this.o:(this.r(e),i(t[e],this.a,this.c))},s.has=function(t,e){return e===r?(this.u(),!0):(this.r(e),e in t)},s.ownKeys=function(t){return this.r(e),Reflect.ownKeys(t)},c=s).p=new Proxy(function(t){return Object.isFrozen(t)?Array.isArray(t)?Array.from(t):Object.assign({},t):t}(a),c),c.o=a,c.t=!1,u&&u.set(a,c)),c.a=f,c.c=u,c.p},f=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.MODE_ASSUME_UNCHANGED_IF_UNAFFECTED=1,t.MODE_ASSUME_UNCHANGED_IF_UNAFFECTED_IN_DEEP=4,t.MODE_IGNORE_REF_EQUALITY=2,t.MODE_IGNORE_REF_EQUALITY_IN_DEEP=8,t.createDeepProxy=i,t.getUntrackedObject=function(t){return o(t)&&t[n]||null},t.isDeepChanged=function t(r,n,o,i,u){if(void 0===u&&(u=0),r===n&&0==(2&u))return!1;if("object"!=typeof r||null===r)return!0;if("object"!=typeof n||null===n)return!0;var s=o.get(r);if(!s)return 0==(1&u);if(i&&0==(2&u)){var a,c=i.get(r);if(c&&c.n===n)return c.g;i.set(r,((a={}).n=n,a.g=!1,a))}var y,l=null,h=s,E=Array.isArray(h),p=0;for(h=E?h:h[Symbol.iterator]();;){var _;if(E){if(p>=h.length)break;_=h[p++]}else{if((p=h.next()).done)break;_=p.value}var b=_,g=b===e?f(r,n):t(r[b],n[b],o,i,u>>>2<<2|u>>>2);if(!0!==g&&!1!==g||(l=g),l)break}return null===l&&(l=0==(1&u)),i&&0==(2&u)&&i.set(r,((y={}).n=n,y.g=l,y)),l},t.trackMemo=function(t){return!!o(t)&&r in t}});
//# sourceMappingURL=index.umd.js.map

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

declare type Affected = WeakMap<object, Set<string | number | symbol>>;
/**

@@ -14,3 +13,3 @@ * create a proxy

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

@@ -31,5 +30,4 @@ export declare const MODE_IGNORE_REF_EQUALITY = 2;

*/
export declare const isDeepChanged: (origObj: unknown, nextObj: unknown, affected: Affected, cache?: WeakMap<object, unknown> | undefined, mode?: number) => boolean;
export declare const isDeepChanged: (origObj: unknown, nextObj: unknown, affected: WeakMap<object, unknown>, cache?: WeakMap<object, unknown> | undefined, mode?: number) => boolean;
export declare const trackMemo: (obj: unknown) => boolean;
export declare const getUntrackedObject: <T>(obj: T) => T | null;
export {};
{
"name": "proxy-compare",
"description": "Compare two objects using accessed properties with Proxy",
"version": "1.0.0",
"version": "1.0.1",
"author": "Daishi Kato",

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

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

- `obj` **T**
- `affected` **Affected**
- `affected` **[WeakMap](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakMap)&lt;[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object), any>**
- `proxyCache` **[WeakMap](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakMap)&lt;[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object), any>?**

@@ -88,3 +88,3 @@

- `nextObj` **any**
- `affected` **Affected**
- `affected` **[WeakMap](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakMap)&lt;[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object), any>**
- `cache` **[WeakMap](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/WeakMap)&lt;[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object), any>?**

@@ -91,0 +91,0 @@ - `mode` (optional, default `0`)

@@ -111,3 +111,3 @@ // symbols

obj: T,
affected: Affected,
affected: WeakMap<object, unknown>,
proxyCache?: WeakMap<object, unknown>,

@@ -132,3 +132,3 @@ ): T => {

}
proxyHandler[AFFECTED_PROPERTY] = affected;
proxyHandler[AFFECTED_PROPERTY] = affected as Affected;
proxyHandler[PROXY_CACHE_PROPERTY] = proxyCache as ProxyCache<object>;

@@ -158,3 +158,3 @@ return proxyHandler[PROXY_PROPERTY];

[NEXT_OBJECT_PROPERTY]: object;
[CHANGED_PROPERTY]?: boolean;
[CHANGED_PROPERTY]: boolean;
}>;

@@ -176,3 +176,3 @@

nextObj: unknown,
affected: Affected,
affected: WeakMap<object, unknown>,
cache?: WeakMap<object, unknown>,

@@ -184,3 +184,3 @@ mode = 0,

if (typeof nextObj !== 'object' || nextObj === null) return true;
const used = affected.get(origObj);
const used = (affected as Affected).get(origObj);
if (!used) return (mode & MODE_ASSUME_UNCHANGED_IF_UNAFFECTED) === 0;

@@ -190,8 +190,11 @@ if (cache && (mode & MODE_IGNORE_REF_EQUALITY) === 0) {

if (hit && hit[NEXT_OBJECT_PROPERTY] === nextObj) {
return hit[CHANGED_PROPERTY] || false;
return hit[CHANGED_PROPERTY];
}
// for object with cycles (CHANGED_PROPERTY is `undefined`)
cache.set(origObj, { [NEXT_OBJECT_PROPERTY]: nextObj });
// for object with cycles
(cache as DeepChangedCache).set(origObj, {
[NEXT_OBJECT_PROPERTY]: nextObj,
[CHANGED_PROPERTY]: false,
});
}
let changed = null;
let changed: boolean | null = null;
// eslint-disable-next-line no-restricted-syntax

@@ -198,0 +201,0 @@ for (const key of used) {

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