@ztimson/utils 0.19.1 → 0.19.2
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.map +1 -1
- package/dist/index.mjs +10 -10
- package/dist/index.mjs.map +1 -1
- package/dist/path-events.d.ts +21 -21
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -930,10 +930,10 @@ class y {
|
|
|
930
930
|
this.module = ((o = i.splice(0, 1)[0]) == null ? void 0 : o.toLowerCase()) || "", this.fullPath = e, this.path = i.join("/"), this.name = i.pop() || "", this.methods = s.split(""), this.all = s == null ? void 0 : s.includes("*"), this.none = s == null ? void 0 : s.includes("n"), this.create = !(s != null && s.includes("n")) && ((s == null ? void 0 : s.includes("*")) || (s == null ? void 0 : s.includes("w")) || (s == null ? void 0 : s.includes("c"))), this.read = !(s != null && s.includes("n")) && ((s == null ? void 0 : s.includes("*")) || (s == null ? void 0 : s.includes("r"))), this.update = !(s != null && s.includes("n")) && ((s == null ? void 0 : s.includes("*")) || (s == null ? void 0 : s.includes("w")) || (s == null ? void 0 : s.includes("u"))), this.delete = !(s != null && s.includes("n")) && ((s == null ? void 0 : s.includes("*")) || (s == null ? void 0 : s.includes("w")) || (s == null ? void 0 : s.includes("d")));
|
|
931
931
|
}
|
|
932
932
|
/**
|
|
933
|
-
* Combine multiple
|
|
933
|
+
* Combine multiple events into one parsed object. Longest path takes precedent, but all subsequent methods are
|
|
934
934
|
* combined until a "none" is reached
|
|
935
935
|
*
|
|
936
|
-
* @param {string | PathEvent} paths
|
|
936
|
+
* @param {string | PathEvent} paths Events as strings or pre-parsed
|
|
937
937
|
* @return {PathEvent} Final combined permission
|
|
938
938
|
*/
|
|
939
939
|
static combine(t) {
|
|
@@ -947,7 +947,7 @@ class y {
|
|
|
947
947
|
/**
|
|
948
948
|
* Squash 2 sets of paths & return true if any overlap is found
|
|
949
949
|
*
|
|
950
|
-
* @param {string | PathEvent | (string | PathEvent)[]} target Array of
|
|
950
|
+
* @param {string | PathEvent | (string | PathEvent)[]} target Array of Events as strings or pre-parsed
|
|
951
951
|
* @param has Target must have at least one of these path
|
|
952
952
|
* @return {boolean} Whether there is any overlap
|
|
953
953
|
*/
|
|
@@ -964,7 +964,7 @@ class y {
|
|
|
964
964
|
/**
|
|
965
965
|
* Squash 2 sets of paths & return true if the target has all paths
|
|
966
966
|
*
|
|
967
|
-
* @param {string | PathEvent | (string | PathEvent)[]} target Array of
|
|
967
|
+
* @param {string | PathEvent | (string | PathEvent)[]} target Array of Events as strings or pre-parsed
|
|
968
968
|
* @param has Target must have all these paths
|
|
969
969
|
* @return {boolean} Whether there is any overlap
|
|
970
970
|
*/
|
|
@@ -974,7 +974,7 @@ class y {
|
|
|
974
974
|
/**
|
|
975
975
|
* Same as `has` but raises an error if there is no overlap
|
|
976
976
|
*
|
|
977
|
-
* @param {string | string[]} target Array of
|
|
977
|
+
* @param {string | string[]} target Array of Events as strings or pre-parsed
|
|
978
978
|
* @param has Target must have at least one of these path
|
|
979
979
|
*/
|
|
980
980
|
static hasFatal(t, ...e) {
|
|
@@ -983,27 +983,27 @@ class y {
|
|
|
983
983
|
/**
|
|
984
984
|
* Same as `hasAll` but raises an error if the target is missing any paths
|
|
985
985
|
*
|
|
986
|
-
* @param {string | string[]} target Array of
|
|
986
|
+
* @param {string | string[]} target Array of Events as strings or pre-parsed
|
|
987
987
|
* @param has Target must have all these paths
|
|
988
988
|
*/
|
|
989
989
|
static hasAllFatal(t, ...e) {
|
|
990
990
|
if (!y.hasAll(t, ...e)) throw new Error(`Requires all: ${b(e).join(", ")}`);
|
|
991
991
|
}
|
|
992
992
|
/**
|
|
993
|
-
* Create
|
|
993
|
+
* Create event string from its components
|
|
994
994
|
*
|
|
995
995
|
* @param {string | string[]} path Event path
|
|
996
996
|
* @param {Method} methods Event method
|
|
997
|
-
* @return {string} String representation of
|
|
997
|
+
* @return {string} String representation of Event
|
|
998
998
|
*/
|
|
999
999
|
static toString(t, e) {
|
|
1000
1000
|
let r = b(t).filter((s) => s != null).join("/");
|
|
1001
1001
|
return e != null && e.length && (r += `:${b(e).map((s) => s.toLowerCase()).join("")}`), r == null ? void 0 : r.trim().replaceAll(/\/{2,}/g, "/").replaceAll(/(^\/|\/$)/g, "");
|
|
1002
1002
|
}
|
|
1003
1003
|
/**
|
|
1004
|
-
* Create
|
|
1004
|
+
* Create event string from its components
|
|
1005
1005
|
*
|
|
1006
|
-
* @return {string} String representation of
|
|
1006
|
+
* @return {string} String representation of Event
|
|
1007
1007
|
*/
|
|
1008
1008
|
toString() {
|
|
1009
1009
|
return y.toString(this.fullPath, this.methods);
|