Socket
Socket
Sign inDemoInstall

recursive-comparator

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    recursive-comparator

Compare variables of any type with customizable parameters


Version published
Maintainers
1
Created

Readme

Source

Recursive Comparator

Fast optimized algorithm to compare two variables of any type in JavaScript. The algorithm supports recursive comparison with nested items and performs the operations in a comparative way - so that in case of differences it automatically returns "false" instead of continuing to compare. The order of elements is taken into account in any operation. The function also supports comparison functions that will dictate the behavior the comparator will use to check the data.

Versions

VersionBranch
developmentmain
1.1.6v1.1.6

Installation/Usage

To get the script just clone that repository (or get the version in "Releases" section) and import "compare" from "recursiveComparator.js" and use like the examples:

Without conditional function parameter:

compare([{a: 1}], [{a: 1}]); //(May be equal) True
compare([[1]], [[3]]); //(May be equal) False

With conditional function parameter:

compare([{a: 1}], [{a: 1}], (a, b) => !compare(a, b)); //(May pass in the function parameters) False
compare([{a: 1}], [{a: 1}], (a, b) => compare(a, b)); //(May pass in the function parameters) True

Information

Changelog - Test Results

Keywords

FAQs

Last updated on 02 Dec 2021

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