Socket
Socket
Sign inDemoInstall

deep-equal

Package Overview
Dependencies
49
Maintainers
1
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
20M
decreased by-1.17%
Maintainers
1
Install size
2.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.2.3 - 2023-11-08

Fixed

  • [readme] remove performance comment and highlight robustness instead #76 #106

Commits

  • Merge tag 'v1.1.2' c90525f
  • [Tests] port tests from main; only diff should be true/falses e02cadb
  • [Dev Deps] update @ljharb/eslint-config, auto-changelog, aud, eslint, set-publish-latest, tape 11bd45b
  • [Tests] update .github from default branch 58885d3
  • [readme] update readme from default branch b0bca9a
  • [Tests] add nyc for coverage e25bc37
  • [readme] update badge URLs, fix line breaking 1d58c6e
  • [Tests] use Buffer.from when available f0d4a42
  • [Tests] use has-proto 0263fb9
  • [Deps] update is-arguments, is-date-object, is-regex, object-is, regexp.prototype.flags 80c15ca
  • [meta] add missing engines.node e1d08a8
  • [meta] use npmignore to autogenerate an npmignore file e0770e5
  • [Deps] update is-date-object, is-regex, object-is, regexp.prototype.flags e4fb8c6
  • [Tests] handle ported test failures in iojs v2 3798ff4
  • [Deps] update call-bind, regexp.prototype.flags, which-typed-array 540e3a1
  • [Dev Deps] update eslint, @ljharb/eslint-config, tape 0f8ca75
  • [Tests] handle some additional test differences in node <= 0.10 197a220
  • [Dev Deps] update object.getownpropertydescriptors, tape 21851a6
  • [Dev Deps] update semver, tape dd440b2
  • [meta] add missing engines.node e158993
  • [meta] update .gitignore from default branch 6ee186b
  • [Deps] update get-intrinsic 6da4b86
  • [Dev Deps] update tape 6ada1ab
  • [Dev Deps] update tape 270d34b
  • [meta] fix URLs a269c18
  • [readme] update default branch name 030a63f
  • [Deps] update which-typed-array 2f0c327
  • [Tests] only use Buffer.from when it has a length of > 1 f7e5776

Readme

Source

deep-equal Version Badge

Node's assert.deepEqual() algorithm as a standalone module, that also works in browser environments.

It mirrors the robustness of node's own assert.deepEqual and is robust against later builtin modification.

github actions coverage License Downloads

npm badge

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 09 Nov 2023

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