@ztimson/utils 0.25.15 → 0.25.16
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 +8 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +8 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1690,7 +1690,6 @@ ${opts.message || this.desc}`;
|
|
|
1690
1690
|
__publicField(this, "name");
|
|
1691
1691
|
/** List of methods */
|
|
1692
1692
|
__publicField(this, "methods");
|
|
1693
|
-
var _a;
|
|
1694
1693
|
if (typeof e == "object") return Object.assign(this, e);
|
|
1695
1694
|
let [p, scope, method] = e.replaceAll(/\/{2,}/g, "/").split(":");
|
|
1696
1695
|
if (!method) method = scope || "*";
|
|
@@ -1699,7 +1698,7 @@ ${opts.message || this.desc}`;
|
|
|
1699
1698
|
method = "*";
|
|
1700
1699
|
}
|
|
1701
1700
|
let temp = p.split("/").filter((p2) => !!p2);
|
|
1702
|
-
this.module =
|
|
1701
|
+
this.module = temp.splice(0, 1)[0] || "";
|
|
1703
1702
|
this.path = temp.join("/");
|
|
1704
1703
|
this.fullPath = `${this.module}${this.module && this.path ? "/" : ""}${this.path}`;
|
|
1705
1704
|
this.name = temp.pop() || "";
|
|
@@ -1779,11 +1778,8 @@ ${opts.message || this.desc}`;
|
|
|
1779
1778
|
*/
|
|
1780
1779
|
static filter(target, ...filter) {
|
|
1781
1780
|
const parsedTarget = makeArray(target).map((pe) => new PathEvent(pe));
|
|
1782
|
-
const
|
|
1783
|
-
return parsedTarget.filter((t) =>
|
|
1784
|
-
if (!t.fullPath && t.all) return true;
|
|
1785
|
-
return !!parsedFind.find((f) => (t.fullPath.startsWith(f.fullPath) || f.fullPath.startsWith(t.fullPath)) && (f.all || t.all || t.methods.intersection(f.methods).length));
|
|
1786
|
-
});
|
|
1781
|
+
const parsedFilter = makeArray(filter).map((pe) => new PathEvent(pe));
|
|
1782
|
+
return parsedTarget.filter((t) => !!parsedFilter.find((f) => (t.fullPath == "*" || f.fullPath == "*" || t.fullPath.startsWith(f.fullPath) || f.fullPath.startsWith(t.fullPath)) && (f.all || t.all || t.methods.intersection(f.methods).length)));
|
|
1787
1783
|
}
|
|
1788
1784
|
/**
|
|
1789
1785
|
* Squash 2 sets of paths & return true if any overlap is found
|
|
@@ -1793,15 +1789,11 @@ ${opts.message || this.desc}`;
|
|
|
1793
1789
|
* @return {boolean} Whether there is any overlap
|
|
1794
1790
|
*/
|
|
1795
1791
|
static has(target, ...has) {
|
|
1796
|
-
const parsedRequired = makeArray(has).map((pe) => new PathEvent(pe));
|
|
1797
1792
|
const parsedTarget = makeArray(target).map((pe) => new PathEvent(pe));
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
const combined = PathEvent.combine(...filtered);
|
|
1803
|
-
return !combined.none && (combined.all || r.all) || combined.methods.intersection(r.methods).length;
|
|
1804
|
-
});
|
|
1793
|
+
const parsedRequired = makeArray(has).map((pe) => new PathEvent(pe));
|
|
1794
|
+
return !!parsedRequired.find((r) => !!parsedTarget.find(
|
|
1795
|
+
(t) => (r.fullPath == "*" || t.fullPath == "*" || r.fullPath.startsWith(t.fullPath) || t.fullPath.startsWith(r.fullPath)) && (r.all || t.all || r.methods.intersection(t.methods).length)
|
|
1796
|
+
));
|
|
1805
1797
|
}
|
|
1806
1798
|
/**
|
|
1807
1799
|
* Squash 2 sets of paths & return true if the target has all paths
|
|
@@ -1876,7 +1868,7 @@ ${opts.message || this.desc}`;
|
|
|
1876
1868
|
}
|
|
1877
1869
|
on(event, listener) {
|
|
1878
1870
|
makeArray(event).forEach((e) => this.listeners.push([
|
|
1879
|
-
new PathEvent(`${this.prefix}/${
|
|
1871
|
+
new PathEvent(`${this.prefix}/${e}`),
|
|
1880
1872
|
listener
|
|
1881
1873
|
]));
|
|
1882
1874
|
return () => this.off(listener);
|