1.2.1 • Published 2 years ago

recursive-comparator-js v1.2.1

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

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.2.1 Hotfixv1.2.1
1.2.0v1.2.0
1.1.6v1.1.6

Installation/Usage

Via NPM:

npm install recursive-comparator-js

Manually:

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

Usage 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