Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
index.js16 linesDownload Raw Back to esm
1import { parse, sep, normalize as norm } from 'node:path';
2function* commonArrayMembers(a, b) {
3    const [l, s] = a.length > b.length ? [a, b] : [b, a];
4    for (const x of s) {
5        if (x === l.shift())
6            yield x;
7        else
8            break;
9    }
10}
11const cap = (a, b) => a === b ? a
12    : !a || !b ? null
13        : parse(a).root !== parse(b).root ? null
14            : [...commonArrayMembers(norm(a).split(sep), norm(b).split(sep))].join(sep);
15export const commonAncestorPath = (...paths) => paths.reduce(cap);
16//# sourceMappingURL=index.js.map
codekingpro/portable-devtools · Team Ai