2.0.4 • Published 2 years ago

diffler v2.0.4

Weekly downloads
296
License
MIT
Repository
github
Last release
2 years ago

Motivation

To compare JSON objects containing asset metadata for a digital library. Upon change of any metadata, we'd store these changes as an audit trail and email asset stakeholders for review and approval of the changes.

Dependencies

diffler is written with Node v12 in mind. Tests depend on Mocha.

Usage

npm version

npm install diffler

Params

obj1 and obj2 are two JSON objects for comparison.

Return

If same: returns {} (empty object)

If different: A JSON object with preserved path structure. The resulting values will be an object with from and to fields.

Example

const diffler = require("diffler");

const before = { name: "omgaz", location: "London" };
const after = { name: "omgaz", location: "Melbourne" };

const difference = diffler(before, after);
console.log(difference); // { location: { from: "London", to: "Melbourne" } }

Tests

Build Status

If you'd like to run tests, check out the whole project. You'll need NodeJS installed. Tests use Mocha.

  npm install
  npm test