deep-equal-in-any-order
Advanced tools
Comparing version 1.0.8 to 1.0.9
'use strict'; | ||
var _lodash = require('lodash'); | ||
var _lodash2 = _interopRequireDefault(_lodash); | ||
var _sortAny = require('sort-any'); | ||
var _sortAny2 = _interopRequireDefault(_sortAny); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const sortDeep = object => { | ||
if (!Array.isArray(object)) { | ||
if (!(typeof object === 'object') || object === null) { | ||
return object; | ||
} | ||
return _lodash2.default.mapValues(object, sortDeep); | ||
} | ||
return (0, _sortAny2.default)(object.map(sortDeep)); | ||
}; | ||
module.exports = (chai, utils) => { | ||
const { Assertion } = chai; | ||
utils.addMethod(Assertion.prototype, 'equalInAnyOrder', () => {}); | ||
utils.addMethod(Assertion.prototype, 'equalInAnyOrder', function equalInAnyOrder(b) { | ||
const a = this.__flags.object; | ||
const { negate } = this.__flags; | ||
if (negate) { | ||
new Assertion(sortDeep(a)).to.not.deep.equal(sortDeep(b)); | ||
} else { | ||
new Assertion(sortDeep(a)).to.deep.equal(sortDeep(b)); | ||
} | ||
}); | ||
}; |
{ | ||
"name": "deep-equal-in-any-order", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "chai plugin to match objects and arrays deep equality with arrays (including nested ones) being in any order", | ||
@@ -50,3 +50,7 @@ "main": "build/index.js", | ||
"sinon-chai": "^2.9.0" | ||
}, | ||
"dependencies": { | ||
"lodash": "^4.17.10", | ||
"sort-any": "^1.1.12" | ||
} | ||
} |
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
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
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
2991
26
0
2
+ Addedlodash@^4.17.10
+ Addedsort-any@^1.1.12
+ Addedlodash@4.17.21(transitive)
+ Addedsort-any@1.2.9(transitive)