MCPcopy Create free account
hub / github.com/nodejs/node / partsMatch

Method partsMatch

deps/minimatch/index.js:1509–1544  ·  view source on GitHub ↗
(a, b, emptyGSMatch = false)

Source from the content-addressed store, hash-verified

1507 return globParts.filter((gs) => gs.length);
1508 }
1509 partsMatch(a, b, emptyGSMatch = false) {
1510 let ai = 0;
1511 let bi = 0;
1512 let result = [];
1513 let which = "";
1514 while (ai < a.length && bi < b.length) {
1515 if (a[ai] === b[bi]) {
1516 result.push(which === "b" ? b[bi] : a[ai]);
1517 ai++;
1518 bi++;
1519 } else if (emptyGSMatch && a[ai] === "**" && b[bi] === a[ai + 1]) {
1520 result.push(a[ai]);
1521 ai++;
1522 } else if (emptyGSMatch && b[bi] === "**" && a[ai] === b[bi + 1]) {
1523 result.push(b[bi]);
1524 bi++;
1525 } else if (a[ai] === "*" && b[bi] && (this.options.dot || !b[bi].startsWith(".")) && b[bi] !== "**") {
1526 if (which === "b")
1527 return false;
1528 which = "a";
1529 result.push(a[ai]);
1530 ai++;
1531 bi++;
1532 } else if (b[bi] === "*" && a[ai] && (this.options.dot || !a[ai].startsWith(".")) && a[ai] !== "**") {
1533 if (which === "a")
1534 return false;
1535 which = "b";
1536 result.push(b[bi]);
1537 ai++;
1538 bi++;
1539 } else {
1540 return false;
1541 }
1542 }
1543 return a.length === b.length && result;
1544 }
1545 parseNegate() {
1546 if (this.nonegate)
1547 return;

Callers 1

secondPhasePreProcessMethod · 0.80

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected