1.0.13 • Published 6 years ago

js-compact-diff v1.0.13

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

js-compact-diff

Javascript Diff representation between objects (in a compacted way)

Overview

import diff from 'js-compact-diff';

const a = {
  foo: 'bar',
  baz: [1, 2, 3],
  bar: true,
  fooBar: {
    baz: [2, 1],
    bazBar:  {
      bar: 'test'
    }
  }
};

const b = {
  bar: true,
  foo: 'baz',
  fooBar: {
    baz: [1, 2],
    bazBar:  {
      bar: 'test'
    }
  }
};
const c = diff.changes(a, b);
console.log(c);

/** WILL OUTPUT :
{
  _: ['baz'],
  foo: 'baz',
  fooBar: {
    baz: [1, 2]
  }
}
**/

// In order to rebuild B from A :
const bBis = diff.apply(a, c);

API

  • diff.changes : retrieves a list of changes between original and updated node
  • diff.apply : apply changes over an original node

License

MIT

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago