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

Function partialObjectMapEquiv

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

Source from the content-addressed store, hash-verified

775}
776
777function partialObjectMapEquiv(array, a, b, mode, memo) {
778 let aPos = 0;
779 let direction = 1;
780 let start = 0;
781 let end = array.length - 1;
782 for (const { 0: key1, 1: item1 } of a) {
783 aPos++;
784 if (typeof key1 === 'object' && key1 !== null) {
785 let innerStart = start;
786 if (direction === 1) {
787 const key2 = array[start];
788 if (objectComparisonStart(key1, key2, mode, memo) && innerDeepEqual(item1, b.get(key2), mode, memo)) {
789 if (start === end) {
790 return true;
791 }
792 start += 1;
793 continue;
794 }
795 if (start === end) {
796 // The last element of map b might match a later element in map a.
797 continue;
798 }
799 direction = -1;
800 innerStart += 1;
801 }
802 let matched = true;
803 const key2 = array[end];
804 if (!objectComparisonStart(key1, key2, mode, memo) || !innerDeepEqual(item1, b.get(key2), mode, memo)) {
805 direction = 1;
806 matched = arrayHasEqualMapElement(array, key1, item1, b, mode, memo, objectComparisonStart, innerStart, end);
807 }
808 if (matched) {
809 if (start === end) {
810 return true;
811 }
812 end -= 1;
813 }
814 }
815 if (a.size - aPos <= end - start) {
816 return false;
817 }
818 }
819 return false;
820}
821
822function arrayHasEqualMapElement(array, key1, item1, b, mode, memo, comparator, start, end) {
823 for (let i = end - 1; i >= start; i--) {

Callers 1

mapEquivFunction · 0.85

Calls 4

objectComparisonStartFunction · 0.85
innerDeepEqualFunction · 0.85
arrayHasEqualMapElementFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…