dai-shi / proxy-compare

Compare two objects using accessed properties with Proxy
https://www.npmjs.com/package/proxy-compare
MIT License
283 stars 18 forks source link

fix: methods which will intecept by ownKeys should get the same resul… #33

Closed Hunter-Gu closed 2 years ago

Hunter-Gu commented 2 years ago

I think the APIs which will intercept by ownKeys() should get the same result as exhausting all properties.

For example:

const s1 = { a: { b: 'b' }, c: 'c' };
const a1 = new WeakMap();
const p1 = createProxy(s1, a1);

p1.a;
p1.c;

isChanged(s1, { a: { b: 'b' }, c: 'c' }, a1); // true

should be the same as:

const s1 = { a: { b: 'b' }, c: 'c' };
const a1 = new WeakMap();
const p1 = createProxy(s1, a1);

Object.keys(p1);

isChanged(s1, { a: { b: 'b' }, c: 'c' }, a1); // false, Ooops!
codesandbox-ci[bot] commented 2 years ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 678a2582fe6b79c077bb38a14dde37abdbd02d38:

Sandbox Source
Vanilla Configuration
Vanilla Typescript Configuration
React Configuration
React Typescript Configuration
Hunter-Gu commented 2 years ago

Oh, I got it. The ownKeys only care about the changes of keys.