diffler
v4.0.1
Published
A recursive JSON comparison script for humans
Maintainers
Readme
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.
Usage
npm install difflerParams
original and updated 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
ESM
import diffler from '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' } }CommonJS
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' } }Development
Requires Node 18+.
npm install
npm test
npm run buildScripts
| Command | Description |
| --------------------- | ----------------------------- |
| npm test | Run tests with Vitest |
| npm run test:terse | Run tests with minimal output |
| npm run test:watch | Run tests in watch mode |
| npm run lint | Check with Biome |
| npm run lint:fix | Auto-fix with Biome |
| npm run check-types | TypeScript type checking |
| npm run build | Build with Vite |
| npm run bench | Run performance benchmark |

