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

shallowequal

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shallowequal

Like lodash isEqualWith but for shallow equal.

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7.7M
increased by5.47%
Maintainers
1
Weekly downloads
 
Created

What is shallowequal?

The shallowequal npm package is a simple utility for performing shallow equality checks on objects or values. It is primarily used to compare the values of two objects to determine if they are equivalent in terms of their direct properties, without deeply traversing any nested objects. This can be particularly useful in optimizations where a deep equality check is unnecessary or too costly in terms of performance.

What are shallowequal's main functionalities?

Shallow Equality Check for Objects

This feature allows you to compare two objects to see if they have the same top-level properties with the same values, without checking for deep equality.

const shallowequal = require('shallowequal');
const obj1 = { a: 1, b: 2 };
const obj2 = { a: 1, b: 2 };
const areEqual = shallowequal(obj1, obj2); // true

Shallow Equality Check with Custom Comparer

This feature allows you to perform a shallow equality check between two objects, but with a custom comparison function for the values, enabling more flexible comparisons.

const shallowequal = require('shallowequal');
const obj1 = { a: 1, b: '2' };
const obj2 = { a: 1, b: 2 };
const areEqual = shallowequal(obj1, obj2, (val1, val2) => String(val1) === String(val2)); // true

Other packages similar to shallowequal

Keywords

FAQs

Package last updated on 23 May 2017

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