MCPcopy Index your code
hub / github.com/nodejs/node / mapObjectEquiv

Function mapObjectEquiv

lib/internal/util/comparisons.js:835–876  ·  view source on GitHub ↗
(array, a, b, mode, memo)

Source from the content-addressed store, hash-verified

833}
834
835function mapObjectEquiv(array, a, b, mode, memo) {
836 let direction = 1;
837 let start = 0;
838 let end = array.length - 1;
839 const comparator = mode !== kLoose ? objectComparisonStart : innerDeepEqual;
840 const extraChecks = mode === kLoose || array.length !== a.size;
841
842 for (const { 0: key1, 1: item1 } of a) {
843 if (extraChecks && (typeof key1 !== 'object' || key1 === null)) {
844 if (b.has(key1)) {
845 if (mode !== kLoose || innerDeepEqual(item1, b.get(key1), mode, memo)) {
846 continue;
847 }
848 } else if (mode !== kLoose) {
849 return false;
850 }
851 }
852
853 let innerStart = start;
854 if (direction === 1) {
855 const key2 = array[start];
856 if (comparator(key1, key2, mode, memo) && innerDeepEqual(item1, b.get(key2), mode, memo)) {
857 start += 1;
858 continue;
859 }
860 if (start === end) {
861 return false;
862 }
863 direction = -1;
864 innerStart += 1;
865 }
866 const key2 = array[end];
867 if ((!comparator(key1, key2, mode, memo) || !innerDeepEqual(item1, b.get(key2), mode, memo))) {
868 direction = 1;
869 if (!arrayHasEqualMapElement(array, key1, item1, b, mode, memo, comparator, innerStart, end)) {
870 return false;
871 }
872 }
873 end -= 1;
874 }
875 return true;
876}
877
878function mapEquiv(a, b, mode, memo) {
879 let array;

Callers 1

mapEquivFunction · 0.85

Calls 5

innerDeepEqualFunction · 0.85
comparatorFunction · 0.85
arrayHasEqualMapElementFunction · 0.85
hasMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…