https://github.com/taylorhakes/variable-diff
Visual diff between 2 javascript variables
https://github.com/taylorhakes/variable-diff
Last synced: 3 months ago
JSON representation
Visual diff between 2 javascript variables
- Host: GitHub
- URL: https://github.com/taylorhakes/variable-diff
- Owner: taylorhakes
- License: mit
- Created: 2016-02-06T16:16:24.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-12-10T03:32:29.000Z (almost 3 years ago)
- Last Synced: 2025-07-06T12:41:00.757Z (3 months ago)
- Language: JavaScript
- Size: 175 KB
- Stars: 33
- Watchers: 2
- Forks: 10
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# variable-diff
Visual diff between 2 javascript variables. Shows only the difference and ignores keys that are the same. Diff is formatted in an easy to read format.[](https://travis-ci.org/taylorhakes/variable-diff)

## Use
```
npm install variable-diff
``````js
var diff = require('variable-diff');var result = diff({ a: 1, b: 2, d: 'hello' }, { a: 8, b: 2, c: 4});
console.log(result.text);// You can pass all or some of these options
var defaultOptions = {
indent: ' ',
newLine: '\n',
wrap: function wrap(type, text) {
return chalk[typeColors[type]](text);
},
color: true
};diff({ a: 1, b: 2, d: 'hello' }, { a: 8, b: 2, c: 4}, defaultOptions)
```### Test
```
npm test
```