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

Function setObjectEquiv

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

Source from the content-addressed store, hash-verified

680}
681
682function setObjectEquiv(array, a, b, mode, memo) {
683 let direction = 1;
684 let start = 0;
685 let end = array.length - 1;
686 const comparator = mode !== kLoose ? objectComparisonStart : innerDeepEqual;
687 const extraChecks = mode === kLoose || array.length !== a.size;
688 for (const val1 of a) {
689 if (extraChecks) {
690 if (typeof val1 === 'object') {
691 if (b.has(val1)) {
692 continue;
693 }
694 } else if (b.has(val1)) {
695 continue;
696 } else if (mode !== kLoose) {
697 return false;
698 }
699 }
700
701 let innerStart = start;
702 if (direction === 1) {
703 if (comparator(val1, array[start], mode, memo)) {
704 start += 1;
705 continue;
706 }
707 if (start === end) {
708 return false;
709 }
710 direction = -1;
711 innerStart += 1;
712 }
713 if (!comparator(val1, array[end], mode, memo)) {
714 direction = 1;
715 if (!arrayHasEqualElement(array, val1, mode, memo, comparator, innerStart, end)) {
716 return false;
717 }
718 }
719 end -= 1;
720 }
721 return true;
722}
723
724function compareSmallSets(a, b, val, iteratorB, mode, memo) {
725 const iteratorA = a.values();

Callers 1

setEquivFunction · 0.85

Calls 3

comparatorFunction · 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…