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.
npm install diffleroriginal and updated are two JSON objects for comparison.
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.
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' } }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' } }Requires Node 18+.
npm install
npm test
npm run build| 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 |
