human-object-diff
Advanced tools
Comparing version 1.0.0 to 2.0.0
17
index.js
@@ -1,1 +0,16 @@ | ||
module.exports = require('./src/diff'); | ||
const diff = require('./src/engine'); | ||
const defaults = require('./src/engine/utils/defaults'); | ||
class DiffEngine { | ||
constructor(config = {}) { | ||
config = { ...defaults, ...config }; | ||
const { templates, ...conf } = config; | ||
this.config = conf; | ||
this.templates = { ...defaults.templates, ...templates }; | ||
this.sentenceDiffs = []; | ||
this.sentences = []; | ||
this.diff = diff.bind(this); | ||
} | ||
} | ||
module.exports = DiffEngine; |
{ | ||
"name": "human-object-diff", | ||
"description": "Human Readable Difference Between Two Objects", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"author": "Spencer Snyder <sasnyde2@gmail.com> (http://spencersnyder.io/)", | ||
@@ -26,14 +26,14 @@ "bugs": { | ||
"devDependencies": { | ||
"@commitlint/cli": "latest", | ||
"@commitlint/config-conventional": "latest", | ||
"ava": "latest", | ||
"codecov": "latest", | ||
"cross-env": "latest", | ||
"eslint": "latest", | ||
"@commitlint/cli": "^8.3.5", | ||
"@commitlint/config-conventional": "^8.3.4", | ||
"ava": "^3.4.0", | ||
"codecov": "^3.6.5", | ||
"cross-env": "^7.0.0", | ||
"eslint": "^6.8.0", | ||
"eslint-config-xo-lass": "latest", | ||
"fixpack": "latest", | ||
"husky": "latest", | ||
"lint-staged": "latest", | ||
"nyc": "latest", | ||
"xo": "latest" | ||
"fixpack": "^3.0.5", | ||
"husky": "^4.2.3", | ||
"lint-staged": "^10.0.8", | ||
"nyc": "^15.0.0", | ||
"xo": "^0.27.1" | ||
}, | ||
@@ -40,0 +40,0 @@ "engines": { |
const test = require('ava'); | ||
const hr = require('..'); | ||
const HRDiff = require('..'); | ||
test.beforeEach(t => { | ||
t.context.hr = hr; | ||
t.context.hr = new HRDiff().diff; | ||
}); | ||
@@ -7,0 +7,0 @@ |
const test = require('ava'); | ||
const hr = require('..'); | ||
const HR = require('..'); | ||
@@ -13,3 +13,3 @@ test.beforeEach(t => { | ||
}; | ||
t.context.hr = (lhs, rhs) => hr(lhs, rhs, { templates }); | ||
t.context.hr = new HR({ templates }).diff; | ||
}); | ||
@@ -16,0 +16,0 @@ |
const test = require('ava'); | ||
const hr = require('..'); | ||
const HR = require('..'); | ||
test.beforeEach(t => { | ||
t.context.hr = (lhs, rhs) => hr(lhs, rhs, { ignoreArrays: true }); | ||
t.context.hr = new HR({ ignoreArrays: true }).diff; | ||
}); | ||
@@ -12,3 +12,3 @@ | ||
test('processes an array', t => { | ||
test('ignores arrays', t => { | ||
const lhs = { | ||
@@ -15,0 +15,0 @@ foo: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], |
const test = require('ava'); | ||
const hr = require('..'); | ||
const HR = require('..'); | ||
test.beforeEach(t => { | ||
t.context.hr = hr; | ||
t.context.hr = config => new HR(config).diff; | ||
}); | ||
@@ -29,3 +29,3 @@ | ||
t.deepEqual(t.context.hr(lhs, rhs, { prefilter: ['baz', 'foo'] }), [ | ||
t.deepEqual(t.context.hr({ prefilter: ['baz', 'foo'] })(lhs, rhs), [ | ||
'"Bar", with a value of "hello" (at Obj.bar) was changed to "hello world"', | ||
@@ -58,3 +58,3 @@ '"Chip", with a value of "dale" (at Obj.chip) was removed', | ||
t.deepEqual(t.context.hr(lhs, rhs, { prefilter: (path, key) => key === 2 }), [ | ||
t.deepEqual(t.context.hr({ prefilter: (path, key) => key === 2 })(lhs, rhs), [ | ||
'"Bar", with a value of "hello" (at Obj.bar) was changed to "hello world"', | ||
@@ -61,0 +61,0 @@ '"Baz", with a value of "12" (at Obj.baz) was changed to "10"', |
const test = require('ava'); | ||
const hr = require('..'); | ||
const HR = require('..'); | ||
test.beforeEach(t => { | ||
const sensitivePaths = ['foo', 'bar', 'biz', 'arr', 'arr2', 'arr3']; | ||
t.context.hr = (lhs, rhs) => hr(lhs, rhs, { sensitivePaths }); | ||
t.context.hr = new HR({ sensitivePaths }).diff; | ||
}); | ||
@@ -8,0 +8,0 @@ |
const test = require('ava'); | ||
const hr = require('..'); | ||
const HR = require('..'); | ||
test.beforeEach(t => { | ||
t.context.hr = hr; | ||
t.context.hr = new HR().diff; | ||
}); | ||
@@ -7,0 +7,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
30183
28
556