jsdifflist

0.0.1-beta.2 • Public • Published

jsdifflist

Have you ever been staring at a screenfull of "expected" vs. "actual" JavaScript objects? Something like this?

(node:28742) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): 
Error: Expected { depth: 3, importId: 2, labor: 0, name: 'Maecenas gravida', parentImportId: 1,
qty: 1, unitCost: 39237.55, unitMeasure: 'EA', userId: '' } to equal depth: 3, importId: 2,
labor: 7382.00, name: 'Maecenas gravida', parentImportId: 1, unitCost: 39237.55, unitMeasure:
'EA', userID: '' }

Wouldn't you rather it look like this?

jsdifflist sample image

Now you can!

Current Limitations

  • Only one level supported (i.e., it will not show diffs in array/object properties)
  • Only two variables can currently be diffed
  • Map/Set diffing not supported

Usage

Install:

npm install --save jsdifflist

Import:

const jsdiff = require('jssdiflist');

Diff two variables:

const diff = jsdiff(varA, varB);

The return (diff) is an array containing all the properties found in varA and varB, and what the result of the comparison is.

Pretty console output:

console.log(jsdiff(varA, varB).toString());

HTML output:

console.log(jsdiff(varA, varB).toHtml());

Dependencies (5)

Dev Dependencies (4)

Package Sidebar

Install

npm i jsdifflist

Weekly Downloads

4

Version

0.0.1-beta.2

License

(MIT OR GPL-3)

Last publish

Collaborators

  • ethanbrown