ast-deep-contains
Like t.same assert on array of objects, where element order doesn't matter.
Install
This package is pure ESM. If you're not ready yet, install an older version of this program, 3.1.0 (npm i ast-deep-contains@3.1.0
).
npm i ast-deep-contains
Quick Take
import { strict as assert } from "assert";
import { deepContains } from "ast-deep-contains";
const gathered = [];
const errors = [];
const reference = [
{ c: "2" },
{ a: "1", b: "2", c: "3" },
{ x: "8", y: "9", z: "0" },
];
const structureToMatch = [
{ a: "1", b: "2", c: "3" },
{ x: "8", y: "9" },
];
deepContains(
reference,
structureToMatch,
(leftSideVal, rightSideVal) => {
gathered.push([leftSideVal, rightSideVal]);
},
(err) => {
errors.push(err);
},
);
assert.deepEqual(gathered, [
["1", "1"],
["2", "2"],
["3", "3"],
["8", "8"],
["9", "9"],
]);
assert.equal(errors.length, 0);
Documentation
Please visit codsen.com for a full description of the API.
Contributing
To report bugs or request features or assistance, raise an issue on GitHub.
Licence
MIT License.
Copyright © 2010-2024 Roy Revelt and other contributors.