@mcabreradev/filter
Version:
A powerful, SQL-like array filtering library for TypeScript and JavaScript with advanced pattern matching, MongoDB-style operators, deep object comparison, and zero dependencies
12 lines (11 loc) • 672 B
JavaScript
import { TYPE_NAMES } from '../../constants';
import { compareAgainstAnyProperty, compareAllProperties } from '../property/property-compare.js';
export function compareObjects(actual, expected, comparator, config, anyPropertyKey, matchAgainstAnyProp, dontMatchWholeObject, expectedType, currentDepth) {
if (matchAgainstAnyProp) {
return compareAgainstAnyProperty(actual, expected, comparator, config, anyPropertyKey, dontMatchWholeObject, currentDepth);
}
if (expectedType === TYPE_NAMES.OBJECT) {
return compareAllProperties(actual, expected, comparator, config, anyPropertyKey, currentDepth);
}
return comparator(actual, expected);
}