Socket
Socket
Sign inDemoInstall

shallow-equal

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shallow-equal

Minimalistic shallow equality check for arrays/objects


Version published
Weekly downloads
1.8M
decreased by-19.31%
Maintainers
1
Weekly downloads
 
Created

What is shallow-equal?

The shallow-equal npm package is primarily used to perform shallow equality checks on objects and arrays. This means it checks if two objects or arrays have the same values at the top level, without deeply checking nested objects or arrays. It is commonly used in React and other frameworks to optimize rendering by preventing unnecessary updates when data has not effectively changed.

What are shallow-equal's main functionalities?

Shallow equality check for objects

This feature allows you to compare two objects to determine if they have the same top-level properties with equal values.

const shallowEqual = require('shallow-equal/objects');
const obj1 = { a: 1, b: 2 };
const obj2 = { a: 1, b: 2 };
console.log(shallowEqual(obj1, obj2)); // true

Shallow equality check for arrays

This feature enables the comparison of two arrays to check if they contain the same elements in the same order, without considering nested arrays or objects.

const shallowEqual = require('shallow-equal/arrays');
const arr1 = [1, 2, 3];
const arr2 = [1, 2, 3];
console.log(shallowEqual(arr1, arr2)); // true

Other packages similar to shallow-equal

Keywords

FAQs

Package last updated on 06 Dec 2019

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