@ztimson/utils 0.27.12 → 0.27.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +6 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +6 -19
- package/dist/index.mjs.map +1 -1
- package/dist/path-events.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1960,22 +1960,12 @@ ${opts.message || this.desc}`;
|
|
|
1960
1960
|
}
|
|
1961
1961
|
let [p, method] = e.replaceAll(/\/{2,}/g, "/").split(":");
|
|
1962
1962
|
if (!method) method = "*";
|
|
1963
|
-
if (p === "" || p === void 0) {
|
|
1964
|
-
this.module = "";
|
|
1965
|
-
this.path = "";
|
|
1966
|
-
this.fullPath = "";
|
|
1967
|
-
this.name = "";
|
|
1968
|
-
this.methods = new ASet(["n"]);
|
|
1969
|
-
this.hasGlob = false;
|
|
1970
|
-
PathEvent.pathEventCache.set(e, this);
|
|
1971
|
-
return;
|
|
1972
|
-
}
|
|
1973
|
-
if (p === "*") {
|
|
1963
|
+
if (p === "" || p === void 0 || p === "*") {
|
|
1974
1964
|
this.module = "";
|
|
1975
1965
|
this.path = "";
|
|
1976
1966
|
this.fullPath = "**";
|
|
1977
1967
|
this.name = "";
|
|
1978
|
-
this.methods = new ASet(["*"]);
|
|
1968
|
+
this.methods = new ASet(p === "*" ? ["*"] : method.split(""));
|
|
1979
1969
|
this.hasGlob = true;
|
|
1980
1970
|
PathEvent.pathEventCache.set(e, this);
|
|
1981
1971
|
return;
|
|
@@ -2090,10 +2080,7 @@ ${opts.message || this.desc}`;
|
|
|
2090
2080
|
static filter(target, ...filter) {
|
|
2091
2081
|
const parsedTarget = makeArray(target).map((pe) => pe instanceof PathEvent ? pe : new PathEvent(pe));
|
|
2092
2082
|
const parsedFilter = makeArray(filter).map((pe) => pe instanceof PathEvent ? pe : new PathEvent(pe));
|
|
2093
|
-
return parsedTarget.filter((t) =>
|
|
2094
|
-
const combined = PathEvent.combine(t);
|
|
2095
|
-
return !!parsedFilter.find((r) => PathEvent.matches(r, combined));
|
|
2096
|
-
});
|
|
2083
|
+
return parsedTarget.filter((t) => !!parsedFilter.find((r) => PathEvent.matches(r, t)));
|
|
2097
2084
|
}
|
|
2098
2085
|
/**
|
|
2099
2086
|
* Check if a filter pattern matches a target path
|
|
@@ -2101,7 +2088,8 @@ ${opts.message || this.desc}`;
|
|
|
2101
2088
|
*/
|
|
2102
2089
|
static matches(pattern, target) {
|
|
2103
2090
|
if (pattern.fullPath === "" || target.fullPath === "") return false;
|
|
2104
|
-
if (pattern.fullPath === "
|
|
2091
|
+
if (pattern.fullPath === "**") return pattern.methods.has("*") || pattern.methods.intersection(target.methods).length > 0;
|
|
2092
|
+
if (target.fullPath === "**") return pattern.methods.has("*") || target.methods.has("*") || pattern.methods.intersection(target.methods).length > 0;
|
|
2105
2093
|
const methodsMatch = pattern.all || target.all || pattern.methods.intersection(target.methods).length > 0;
|
|
2106
2094
|
if (!methodsMatch) return false;
|
|
2107
2095
|
if (!pattern.hasGlob && !target.hasGlob) {
|
|
@@ -2122,8 +2110,7 @@ ${opts.message || this.desc}`;
|
|
|
2122
2110
|
static has(target, ...has) {
|
|
2123
2111
|
const parsedTarget = makeArray(target).map((pe) => pe instanceof PathEvent ? pe : new PathEvent(pe));
|
|
2124
2112
|
const parsedRequired = makeArray(has).map((pe) => pe instanceof PathEvent ? pe : new PathEvent(pe));
|
|
2125
|
-
|
|
2126
|
-
return !!parsedRequired.find((r) => PathEvent.matches(r, effectiveTarget));
|
|
2113
|
+
return !!parsedRequired.find((r) => !!parsedTarget.find((t) => PathEvent.matches(r, t)));
|
|
2127
2114
|
}
|
|
2128
2115
|
/**
|
|
2129
2116
|
* Squash 2 sets of paths & return true if the target has all paths
|