Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
index.js20 linesDownload Raw Back to commonjs
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.commonAncestorPath = void 0;
4const node_path_1 = require("node:path");
5function* commonArrayMembers(a, b) {
6    const [l, s] = a.length > b.length ? [a, b] : [b, a];
7    for (const x of s) {
8        if (x === l.shift())
9            yield x;
10        else
11            break;
12    }
13}
14const cap = (a, b) => a === b ? a
15    : !a || !b ? null
16        : (0, node_path_1.parse)(a).root !== (0, node_path_1.parse)(b).root ? null
17            : [...commonArrayMembers((0, node_path_1.normalize)(a).split(node_path_1.sep), (0, node_path_1.normalize)(b).split(node_path_1.sep))].join(node_path_1.sep);
18const commonAncestorPath = (...paths) => paths.reduce(cap);
19exports.commonAncestorPath = commonAncestorPath;
20//# sourceMappingURL=index.js.map
codekingpro/portable-devtools · Team Ai