/RecursiveComparator.TS

Compare two variables of actually any type in TypeScript/JavaScript

Primary LanguageTypeScriptMIT LicenseMIT

RecursiveComparator.TS

v2.0.0

Simplified algorithm to compare two variables of any type. This repository can be cloned and the code converted to vanilla JavaScript.

Installation:

  • Clone this repository or copy the "recursiveComparator.ts" file content
  • Optional: convert the code to JavaScript using a transpilation tool like Babel
  • Use it in your application by importing "compare" from "path/to/file"

Usage:

compare(variable1, variable2, filterFunction)

Example:

compare<number>(1, 2, (a, b) => a === b); //False
compare<number>(1, 2, (a, b) => a !== b); //True