variable-diff

Visual diff between javascript variables

MIT 5 个版本
安装
npm install variable-diff
yarn add variable-diff
pnpm add variable-diff
bun add variable-diff
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.

Build Status

Screenshot

Use

npm install variable-diff
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
版本列表
2.0.2 2020-09-01
2.0.1 2019-09-25
2.0.0 2019-09-25
1.1.0 2016-02-10
1.0.0 2016-02-06