Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

deep-equal-in-any-order

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deep-equal-in-any-order

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

  • 1.1.8
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
464K
decreased by-2.57%
Maintainers
1
Weekly downloads
 
Created

What is deep-equal-in-any-order?

The 'deep-equal-in-any-order' npm package is a utility for performing deep equality checks on JavaScript objects, arrays, and other data structures, with the added capability of ignoring the order of elements in arrays and objects. This is particularly useful for testing and validation scenarios where the order of elements should not affect the equality check.

What are deep-equal-in-any-order's main functionalities?

Deep Equality Check Ignoring Order

This feature allows you to perform deep equality checks on objects and arrays while ignoring the order of elements. The code sample demonstrates how to use the package with Chai for assertions.

const deepEqualInAnyOrder = require('deep-equal-in-any-order');
const chai = require('chai');
chai.use(deepEqualInAnyOrder);
const { expect } = chai;

const obj1 = { a: 1, b: [2, 3] };
const obj2 = { b: [3, 2], a: 1 };
expect(obj1).to.deep.equalInAnyOrder(obj2);

Array Equality Ignoring Order

This feature allows you to check the equality of arrays without considering the order of elements. The code sample shows how to use the package to assert that two arrays with the same elements in different orders are equal.

const deepEqualInAnyOrder = require('deep-equal-in-any-order');
const chai = require('chai');
chai.use(deepEqualInAnyOrder);
const { expect } = chai;

const arr1 = [1, 2, 3];
const arr2 = [3, 2, 1];
expect(arr1).to.deep.equalInAnyOrder(arr2);

Object Equality Ignoring Order

This feature allows you to check the equality of objects without considering the order of their properties. The code sample demonstrates how to use the package to assert that two objects with the same properties in different orders are equal.

const deepEqualInAnyOrder = require('deep-equal-in-any-order');
const chai = require('chai');
chai.use(deepEqualInAnyOrder);
const { expect } = chai;

const obj1 = { a: 1, b: 2, c: 3 };
const obj2 = { c: 3, b: 2, a: 1 };
expect(obj1).to.deep.equalInAnyOrder(obj2);

Other packages similar to deep-equal-in-any-order

Keywords

FAQs

Package last updated on 14 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc