chbrown / rfc6902

Complete implementation of RFC6902 in TypeScript
https://chbrown.github.io/rfc6902/
326 stars 39 forks source link

Should Ignore member functions #93

Open childrentime opened 1 year ago

childrentime commented 1 year ago

It appears that it does not ignore member functions, but in reality, member functions are not necessary to be included in the patch result, and patch also resets member functions.

export class ChildStore<R> {
  /** we don't need patch this, but it will*/
  private getRoot: () => R;

  get $root() {
    return this.getRoot();
  }

  constructor(root: R) {
    this.getRoot = () => root;
  }
}

result:

[
  {
    op: 'add',
    path: '/childStore/getRoot',
    value: [Function (anonymous)]
  }
]

I think we should check if the value is a function and filter it out.