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

Function partialObjectSetEquiv

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

Source from the content-addressed store, hash-verified

626}
627
628function partialObjectSetEquiv(array, a, b, mode, memo) {
629 let aPos = 0;
630 let direction = 1;
631 let start = 0;
632 let end = array.length - 1;
633 for (const val1 of a) {
634 aPos++;
635 if (!b.has(val1)) {
636 let innerStart = start;
637 if (direction === 1) {
638 if (innerDeepEqual(val1, array[start], mode, memo)) {
639 if (start === end) {
640 return true;
641 }
642 start += 1;
643 continue;
644 }
645 if (start === end) {
646 // The last element of set b might match a later element in set a.
647 continue;
648 }
649 direction = -1;
650 innerStart += 1;
651 }
652 let matched = true;
653 if (!innerDeepEqual(val1, array[end], mode, memo)) {
654 direction = 1;
655 matched = arrayHasEqualElement(array, val1, mode, memo, innerDeepEqual, innerStart, end);
656 }
657 if (matched) {
658 if (start === end) {
659 return true;
660 }
661 end -= 1;
662 }
663 }
664 if (a.size - aPos <= end - start) {
665 return false;
666 }
667 }
668 return false;
669}
670
671function arrayHasEqualElement(array, val1, mode, memo, comparator, start, end) {
672 for (let i = end - 1; i >= start; i--) {

Callers 1

setEquivFunction · 0.85

Calls 3

innerDeepEqualFunction · 0.85
arrayHasEqualElementFunction · 0.85
hasMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…