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

Function mapEquiv

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

Source from the content-addressed store, hash-verified

876}
877
878function mapEquiv(a, b, mode, memo) {
879 let array;
880
881 for (const { 0: key2, 1: item2 } of b) {
882 if (typeof key2 === 'object' && key2 !== null) {
883 if (array === undefined) {
884 if (a.size === 1) {
885 const { 0: key1, 1: item1 } = a.entries().next().value;
886 return innerDeepEqual(key1, key2, mode, memo) &&
887 innerDeepEqual(item1, item2, mode, memo);
888 }
889 array = [];
890 }
891 array.push(key2);
892 } else {
893 // By directly retrieving the value we prevent another b.has(key2) check in
894 // almost all possible cases.
895 const item1 = a.get(key2);
896 if (((item1 === undefined && !a.has(key2)) ||
897 !innerDeepEqual(item1, item2, mode, memo))) {
898 if (mode !== kLoose)
899 return false;
900 // Fast path to detect missing string, symbol, undefined and null
901 // keys.
902 if (!mapMightHaveLoosePrim(a, b, key2, item2, memo))
903 return false;
904 if (array === undefined) {
905 array = [];
906 }
907 array.push(key2);
908 }
909 }
910 }
911
912 if (array === undefined) {
913 return true;
914 }
915
916 if (mode === kPartial) {
917 return partialObjectMapEquiv(array, a, b, mode, memo);
918 }
919
920 return mapObjectEquiv(array, a, b, mode, memo);
921}
922
923function partialSparseArrayEquiv(a, b, mode, memos, startA, startB) {
924 let aPos = startA;

Callers 1

objEquivFunction · 0.85

Calls 9

innerDeepEqualFunction · 0.85
mapMightHaveLoosePrimFunction · 0.85
partialObjectMapEquivFunction · 0.85
mapObjectEquivFunction · 0.85
nextMethod · 0.65
getMethod · 0.65
hasMethod · 0.65
entriesMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…