1.0.13 • Published 7 years ago

js-compact-diff v1.0.13

Weekly downloads
1
License
MIT
Repository
github
Last release
7 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

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago