@ztimson/utils 0.25.14 → 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 +9 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +9 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1173,7 +1173,7 @@ function fileText(file) {
|
|
|
1173
1173
|
}
|
|
1174
1174
|
function timestampFilename(name, date = /* @__PURE__ */ new Date()) {
|
|
1175
1175
|
if (typeof date == "number" || typeof date == "string") date = new Date(date);
|
|
1176
|
-
const timestamp = formatDate("YYYY-MM-DD_HH
|
|
1176
|
+
const timestamp = formatDate("YYYY-MM-DD_HH-mm", date);
|
|
1177
1177
|
return name ? name.replace("{{TIMESTAMP}}", timestamp) : timestamp;
|
|
1178
1178
|
}
|
|
1179
1179
|
function uploadWithProgress(options) {
|
|
@@ -1686,7 +1686,6 @@ class PathEvent {
|
|
|
1686
1686
|
__publicField(this, "name");
|
|
1687
1687
|
/** List of methods */
|
|
1688
1688
|
__publicField(this, "methods");
|
|
1689
|
-
var _a;
|
|
1690
1689
|
if (typeof e == "object") return Object.assign(this, e);
|
|
1691
1690
|
let [p, scope, method] = e.replaceAll(/\/{2,}/g, "/").split(":");
|
|
1692
1691
|
if (!method) method = scope || "*";
|
|
@@ -1695,7 +1694,7 @@ class PathEvent {
|
|
|
1695
1694
|
method = "*";
|
|
1696
1695
|
}
|
|
1697
1696
|
let temp = p.split("/").filter((p2) => !!p2);
|
|
1698
|
-
this.module =
|
|
1697
|
+
this.module = temp.splice(0, 1)[0] || "";
|
|
1699
1698
|
this.path = temp.join("/");
|
|
1700
1699
|
this.fullPath = `${this.module}${this.module && this.path ? "/" : ""}${this.path}`;
|
|
1701
1700
|
this.name = temp.pop() || "";
|
|
@@ -1775,11 +1774,8 @@ class PathEvent {
|
|
|
1775
1774
|
*/
|
|
1776
1775
|
static filter(target, ...filter) {
|
|
1777
1776
|
const parsedTarget = makeArray(target).map((pe) => new PathEvent(pe));
|
|
1778
|
-
const
|
|
1779
|
-
return parsedTarget.filter((t) =>
|
|
1780
|
-
if (!t.fullPath && t.all) return true;
|
|
1781
|
-
return !!parsedFind.find((f) => (t.fullPath.startsWith(f.fullPath) || f.fullPath.startsWith(t.fullPath)) && (f.all || t.all || t.methods.intersection(f.methods).length));
|
|
1782
|
-
});
|
|
1777
|
+
const parsedFilter = makeArray(filter).map((pe) => new PathEvent(pe));
|
|
1778
|
+
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)));
|
|
1783
1779
|
}
|
|
1784
1780
|
/**
|
|
1785
1781
|
* Squash 2 sets of paths & return true if any overlap is found
|
|
@@ -1789,15 +1785,11 @@ class PathEvent {
|
|
|
1789
1785
|
* @return {boolean} Whether there is any overlap
|
|
1790
1786
|
*/
|
|
1791
1787
|
static has(target, ...has) {
|
|
1792
|
-
const parsedRequired = makeArray(has).map((pe) => new PathEvent(pe));
|
|
1793
1788
|
const parsedTarget = makeArray(target).map((pe) => new PathEvent(pe));
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
const combined = PathEvent.combine(...filtered);
|
|
1799
|
-
return !combined.none && (combined.all || r.all) || combined.methods.intersection(r.methods).length;
|
|
1800
|
-
});
|
|
1789
|
+
const parsedRequired = makeArray(has).map((pe) => new PathEvent(pe));
|
|
1790
|
+
return !!parsedRequired.find((r) => !!parsedTarget.find(
|
|
1791
|
+
(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)
|
|
1792
|
+
));
|
|
1801
1793
|
}
|
|
1802
1794
|
/**
|
|
1803
1795
|
* Squash 2 sets of paths & return true if the target has all paths
|
|
@@ -1872,7 +1864,7 @@ class PathEventEmitter {
|
|
|
1872
1864
|
}
|
|
1873
1865
|
on(event, listener) {
|
|
1874
1866
|
makeArray(event).forEach((e) => this.listeners.push([
|
|
1875
|
-
new PathEvent(`${this.prefix}/${
|
|
1867
|
+
new PathEvent(`${this.prefix}/${e}`),
|
|
1876
1868
|
listener
|
|
1877
1869
|
]));
|
|
1878
1870
|
return () => this.off(listener);
|