Cars project 3 do dokończenia

This commit is contained in:
aplikacje committed 2026-11-05 10:50:57 +01:00
1 parent 3b96ac1be8
commit b3be59a011
159 files changed
+9794 -3786

No files matched your search

+27 -15
View File
@@ -48,19 +48,24 @@ class Pattern {
// //host/share => ['//host/share/']
// //host/share/ => ['//host/share/']
// //host/share/x => ['//host/share/', 'x']
// //?/UNC/host/share/x => ['//?/UNC/host/share/', 'x']
// /etc => ['/', 'etc']
// / => ['/']
if (this.isUNC()) {
// '' / '' / 'host' / 'share'
const [p0, p1, p2, p3, ...prest] = this.#patternList;
const [g0, g1, g2, g3, ...grest] = this.#globList;
// '' / '' / 'host' / 'share', or
// '' / '' / '?' / 'UNC' / 'host' / 'share'
const n = this.#isLongUNC() ? 6 : 4;
const proot = this.#patternList.slice(0, n);
const groot = this.#globList.slice(0, n);
const prest = this.#patternList.slice(n);
const grest = this.#globList.slice(n);
if (prest[0] === '') {
// ends in /
prest.shift();
grest.shift();
}
const p = [p0, p1, p2, p3, ''].join('/');
const g = [g0, g1, g2, g3, ''].join('/');
const p = [...proot, ''].join('/');
const g = [...groot, ''].join('/');
this.#patternList = [p, ...prest];
this.#globList = [g, ...grest];
this.length = this.#patternList.length;
@@ -73,8 +78,8 @@ class Pattern {
prest.shift();
grest.shift();
}
const p = p1 + '/';
const g = g1 + '/';
const p = `${p1}/`;
const g = `${g1}/`;
this.#patternList = [p, ...prest];
this.#globList = [g, ...grest];
this.length = this.#patternList.length;
@@ -82,7 +87,7 @@ class Pattern {
}
}
[customInspect]() {
return 'Pattern <' + this.#globList.slice(this.#index).join('/') + '>';
return `Pattern <${this.#globList.slice(this.#index).join('/')}>`;
}
/**
* The first entry in the parsed list of patterns
@@ -103,10 +108,10 @@ class Pattern {
return this.#patternList[this.#index] === minimatch_1.GLOBSTAR;
}
/**
* true if pattern() returns a regexp
* true if pattern() returns a Matcher, for a portion with magic
*/
isRegExp() {
return this.#patternList[this.#index] instanceof RegExp;
isMatcher() {
return typeof this.#patternList[this.#index] === 'object';
}
/**
* The /-joined set of glob parts that make up this pattern
@@ -140,11 +145,18 @@ class Pattern {
this.#rest.#isDrive = this.#isDrive;
return this.#rest;
}
// the root is //?/UNC/host/share, the same as //host/share
#isLongUNC() {
const pl = this.#patternList;
return (pl[2] === '?' && typeof pl[3] === 'string' && /^unc$/i.test(pl[3]));
}
/**
* true if the pattern represents a //unc/path/ on windows
*/
isUNC() {
const pl = this.#patternList;
// the host and share, after //?/UNC/ in a long UNC path
const h = this.#isLongUNC() ? 4 : 2;
return this.#isUNC !== undefined ?
this.#isUNC
: (this.#isUNC =
@@ -152,10 +164,10 @@ class Pattern {
this.#index === 0 &&
pl[0] === '' &&
pl[1] === '' &&
typeof pl[2] === 'string' &&
!!pl[2] &&
typeof pl[3] === 'string' &&
!!pl[3]);
typeof pl[h] === 'string' &&
!!pl[h] &&
typeof pl[h + 1] === 'string' &&
!!pl[h + 1]);
}
// pattern like C:/...
// split = ['C:', ...]