deep-equal-in-any-order

chai plugin to match objects and arrays deep equality with arrays (including nested ones) being in any order

MIT 56 个版本
安装
npm install deep-equal-in-any-order
yarn add deep-equal-in-any-order
pnpm add deep-equal-in-any-order
bun add deep-equal-in-any-order
README

deep-equal-in-any-order

MIT License Build Status

NPM status

Chai plugin to match objects and arrays deep equality with arrays (including nested ones) being in any order.

It works in similar way as deep.equal but it doesn't checks the arrays order (at any level of nested objects and arrays). The array elements can be any JS entity (boolean, null, number, string, object, array...).

install

npm i --save deep-equal-in-any-order

or

yarn add deep-equal-in-any-order

usage

expect

const deepEqualInAnyOrder = require('deep-equal-in-any-order');
const chai = require('chai');

chai.use(deepEqualInAnyOrder);

const { expect } = chai;

expect([1, 2]).to.deep.equalInAnyOrder([2, 1]);
expect([1, 2]).to.not.deep.equalInAnyOrder([2, 1, 3]);
expect({ foo: [1, 2], bar: [4, 89, 22] }).to.deep.equalInAnyOrder({ foo: [2, 1], bar: [4, 22, 89] });
expect({ foo: ['foo-1', 'foo-2', [1, 2], null ] }).to.deep.equalInAnyOrder({ foo: [null, [1, 2], 'foo-1', 'foo-2'] });
expect({ foo: [1, 2], bar: { baz: ['a', 'b', { lorem: [5, 6] }] } }).to.deep.equalInAnyOrder({ foo: [2, 1], bar: { baz: ['b', 'a', { lorem: [6, 5] }] } });

assert

const deepEqualInAnyOrder = require('deep-equal-in-any-order');
const chai = require('chai');

chai.use(deepEqualInAnyOrder);

const { assert } = chai;

assert.deepEqualInAnyOrder([1, 2], [2, 1]);
assert.notDeepEqualInAnyOrder(1, 2], [2, 1, 3]);
assert.deepEqualInAnyOrder({ foo: [1, 2], bar: [4, 89, 22] }, { foo: [2, 1], bar: [4, 22, 89] });
assert.deepEqualInAnyOrder({ foo: ['foo-1', 'foo-2', [1, 2], null ] }, { foo: [null, [1, 2], 'foo-1', 'foo-2'] });
assert.deepEqualInAnyOrder({ foo: [1, 2], bar: { baz: ['a', 'b', { lorem: [5, 6] }] } }, { foo: [2, 1], bar: { baz: ['b', 'a', { lorem: [6, 5] }] } });
版本列表
2.2.0 2026-02-22
2.1.0 2025-09-02
2.0.6 2023-03-19
2.0.5 2023-03-04
2.0.4 2023-02-26
2.0.3 2023-02-11
2.0.2 2022-12-29
2.0.1 2022-12-05
2.0.0 2022-07-03
1.1.20 2022-07-02
1.1.19 2022-05-23
1.1.18 2022-05-10
1.1.17 2022-04-05
1.1.16 2022-04-05
1.1.15 2021-10-04
1.1.14 2021-10-04
1.1.13 2021-09-07
1.1.12 2021-09-07
1.1.11 2021-09-04
1.1.10 2021-08-10
1.1.9 2021-08-08
1.1.8 2021-06-14
1.1.7 2021-05-31
1.1.6 2021-05-29
1.1.5 2021-05-29
1.1.4 2021-04-04
1.1.3 2021-04-03
1.1.2 2021-04-03
1.1.1 2021-03-31
1.1.0 2021-03-31
1.0.28 2020-07-16
1.0.27 2020-04-03
1.0.26 2020-04-03
1.0.25 2020-03-15
1.0.24 2020-02-13
1.0.21 2019-08-27
1.0.20 2019-08-27
1.0.19 2019-08-23
1.0.18 2019-08-09
1.0.17 2019-08-09
1.0.16 2019-07-13
1.0.15 2019-07-13
1.0.14 2019-07-12
1.0.13 2019-02-22
1.0.12 2019-02-18
1.0.11 2019-02-18
1.0.10 2018-04-29
1.0.9 2018-04-29
1.0.8 2018-01-28
1.0.7 2018-01-28
1.0.6 2018-01-28
1.0.5 2018-01-23
1.0.3 2018-01-23
1.0.2 2018-01-23
1.0.1 2018-01-22
1.0.0 2017-11-11