Socket
Socket
Sign inDemoInstall

deep-equal

Package Overview
Dependencies
74
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    deep-equal

node's assert.deepEqual algorithm


Version published
Weekly downloads
16M
decreased by-21.88%
Maintainers
2
Install size
7.07 MB
Created
Weekly downloads
 

Package description

What is deep-equal?

The deep-equal npm package is a library for performing deep equality checks between two values. It is useful for comparing objects, arrays, and other nested structures to determine if they are equivalent in structure and content, regardless of whether they are the same reference in memory.

What are deep-equal's main functionalities?

Deep comparison of objects and arrays

This feature allows you to compare objects and arrays to see if they are structurally identical, even if they are different instances.

const deepEqual = require('deep-equal');

const obj1 = { a: 1, b: { c: 1 } };
const obj2 = { a: 1, b: { c: 1 } };

console.log(deepEqual(obj1, obj2)); // true

Comparison with custom options

This feature allows you to specify options for the comparison, such as strict mode, which requires the values to be of the same type as well.

const deepEqual = require('deep-equal');

const obj1 = { a: 1 };
const obj2 = { a: '1' };
const options = { strict: true };

console.log(deepEqual(obj1, obj2, options)); // false

Other packages similar to deep-equal

Changelog

Source

v2.0.4 - 2020-10-01

Fixed

  • [meta] fix incorrect ./package.json exports entry #89

Commits

  • [Dev Deps] update eslint, @ljharb/eslint-config, auto-changelog d6bfee3
  • [Tests] account for node 14+ making two NaNs loosely deep equal 9367954
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, tape 86a159b
  • [Deps] update es-abstract, object-is, object.assign e87979d
  • [Deps] update es-abstract, is-regex d0cacca
  • [Dev Deps] update eslint, @ljharb/eslint-config, tape 375a9e1
  • [Dev Deps] update eslint, auto-changelog e562d4f
  • [Deps] update side-channel f092342

Readme

Source

deep-equal

Node's assert.deepEqual() algorithm as a standalone module.

This module is around 46 times faster than wrapping assert.deepEqual() in a try/catch.

build status

example

var equal = require('deep-equal');
console.dir([
    equal(
        { a : [ 2, 3 ], b : [ 4 ] },
        { a : [ 2, 3 ], b : [ 4 ] }
    ),
    equal(
        { x : 5, y : [6] },
        { x : 5, y : 6 }
    )
]);

methods

var deepEqual = require('deep-equal')

deepEqual(a, b, opts)

Compare objects a and b, returning whether they are equal according to a recursive equality algorithm.

If opts.strict is true, use strict equality (===) to compare leaf nodes. The default is to use coercive equality (==) because that's how assert.deepEqual() works by default.

install

With npm do:

npm install deep-equal

test

With npm do:

npm test

Keywords

FAQs

Last updated on 02 Oct 2020

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc