js-crud-diff
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

js-crud-diff

Create a difference of the to object

const before = {
      a: {
        b: {
          c: '',
          d: {
            e: '',
            g: ''
          }
        }
      },
      a2: {
        b2: '',
        c2: ''
      }
    }
    const after = {
      a: {
        b: {
          c: '',
          d: {
            e: ''
          }
        },
        newProp: {
          a: ''
        }
      },
      a2: {
        b2: 'asa'
      }
    }

    const difference = diff(before, after)
    // value of the difference
    // {
    //   a: {
    //     b: {
    //       d: {
    //         g: { // g deleted. original value was an empty string
    //           deleted: ''
    //         }
    //       }
    //     },
    //     newProp: { // newProp created with value {a: ''}
    //       created: {
    //         a: ''
    //       }
    //     }
    //   },
    //   a2: {
    //     b2: { // b2 modified
    //       after: 'asa', // new value
    //       before: '' // original value
    //     },
    //     c2: { // c2 deleted original value was an empty string
    //       deleted: ''
    //     }
    //   }
    // }

Readme

Keywords

Package Sidebar

Install

npm i js-crud-diff

Weekly Downloads

12

Version

2.0.0

License

MIT

Unpacked Size

4.03 kB

Total Files

4

Last publish

Collaborators

  • ert78gb