# deep-equal-in-any-order

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

Latest version **2.2.0** (published 2026-02-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install deep-equal-in-any-order
pnpm add deep-equal-in-any-order
yarn add deep-equal-in-any-order
bun add deep-equal-in-any-order
```

## Health

**Score 58/100 (C)** — status: stable.

Positive: has types package; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 2.2.0 |
| Published | 2026-02-22 |
| First published | 2017-11-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/deep-equal-in-any-order) |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 16 |
| Author | oprogramador |
| Maintainers | oprogramador |
| Keywords | chai, plugin, chai-plugin, arrays, objects, any, order, deep, equal |

## Links

- npm: https://www.npmjs.com/package/deep-equal-in-any-order
- Repository: https://github.com/oprogramador/deep-equal-in-any-order
- Homepage: https://github.com/oprogramador/deep-equal-in-any-order#readme
- Issues: https://github.com/oprogramador/deep-equal-in-any-order/issues
- npm.io page: https://npm.io/package/deep-equal-in-any-order

## Dependencies (1)

- [sort-any](https://npm.io/package/sort-any.md) ^4.0.0

## Recent versions

- 2.2.0 (latest) — 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
- … 41 more at https://npm.io/package/deep-equal-in-any-order/versions

## README

# deep-equal-in-any-order

[![MIT License](https://img.shields.io/badge/license-mit-green.svg?style=flat-square)](https://opensource.org/licenses/MIT)
[![Build Status](https://travis-ci.com/oprogramador/deep-equal-in-any-order.svg?branch=master)](https://travis-ci.com/oprogramador/deep-equal-in-any-order
)

[![NPM status](https://nodei.co/npm/deep-equal-in-any-order.png?downloads=true&stars=true)](https://npmjs.org/package/deep-equal-in-any-order
)

[Chai](https://www.chaijs.com/) 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`
```js
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`
```js
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] }] } });
```

---
_Source: https://npm.io/package/deep-equal-in-any-order · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
