Skip to content

Commit

Permalink
add deep object diff function to perform non-strict comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Moffitt authored and Ian Moffitt committed Mar 12, 2019
1 parent 79d246f commit 2c90b13
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
14 changes: 13 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const path = require('path');
const assert = require('yeoman-assert');
const _ = require('lodash');
const deep = require('deep-equal');
const deepdiff = require('deep-object-diff');

const ignored = [
'.git',
Expand Down Expand Up @@ -101,6 +102,17 @@ const util = module.exports = {

},

files: dir => fs.readdirSync(dir)
files: dir => fs.readdirSync(dir),

deepNotOnly: (obj1, obj2) => {

// Checks if object 2 contains all the items in object 1.
// It does this by doing an added Diff.
// Essentially, it checks to see if any items have been added in object 1.
// If every item matches, the result is an empty object.

return deepdiff.addedDiff(obj2, obj1);

}

};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "brei-util",
"version": "1.0.2",
"version": "1.0.3",
"description": "Utility functions for generator repos.",
"main": "index.js",
"scripts": {
Expand All @@ -18,6 +18,7 @@
"homepage": "https://github.com/BarkleyREI/brei-util#readme",
"dependencies": {
"deep-equal": "1.0.1",
"deep-object-diff": "^1.1.0",
"fs": "0.0.1-security",
"lodash": "4.17.11",
"yeoman-assert": "3.1.1"
Expand Down

0 comments on commit 2c90b13

Please sign in to comment.