@ztimson/utils 0.21.3 → 0.21.5

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/LICENSE CHANGED
File without changes
package/README.md CHANGED
File without changes
package/dist/array.d.ts CHANGED
File without changes
package/dist/aset.d.ts CHANGED
File without changes
package/dist/cache.d.ts CHANGED
File without changes
package/dist/csv.d.ts CHANGED
File without changes
package/dist/emitter.d.ts CHANGED
File without changes
package/dist/errors.d.ts CHANGED
File without changes
package/dist/files.d.ts CHANGED
File without changes
package/dist/http.d.ts CHANGED
File without changes
package/dist/index.cjs CHANGED
@@ -1200,6 +1200,21 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1200
1200
  combined.methods = new ASet(combined.methods);
1201
1201
  return combined;
1202
1202
  }
1203
+ /**
1204
+ * Filter a set of paths based on the target
1205
+ *
1206
+ * @param {string | PathEvent | (string | PathEvent)[]} target Array of events that will filtered
1207
+ * @param filter {...PathEvent} Must container one of
1208
+ * @return {boolean} Whether there is any overlap
1209
+ */
1210
+ static filter(target, ...filter) {
1211
+ const parsedTarget = makeArray(target).map((pe) => new PathEvent(pe));
1212
+ const parsedFind = makeArray(filter).map((pe) => new PathEvent(pe));
1213
+ return parsedTarget.filter((t) => {
1214
+ if (!t.fullPath && t.all) return true;
1215
+ return !!parsedFind.find((f) => t.fullPath.startsWith(f.fullPath) && (f.all || t.all || t.methods.intersection(f.methods).length));
1216
+ });
1217
+ }
1203
1218
  /**
1204
1219
  * Squash 2 sets of paths & return true if any overlap is found
1205
1220
  *
@@ -1215,7 +1230,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1215
1230
  const filtered = parsedTarget.filter((p) => r.fullPath.startsWith(p.fullPath));
1216
1231
  if (!filtered.length) return false;
1217
1232
  const combined = PathEvent.combine(...filtered);
1218
- return !combined.none && (combined.all || new ASet(combined.methods).intersection(new ASet(r.methods)).length);
1233
+ return !combined.none && (combined.all || r.all) || combined.methods.intersection(r.methods).length;
1219
1234
  });
1220
1235
  }
1221
1236
  /**
@@ -1259,6 +1274,15 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1259
1274
  if (methods == null ? void 0 : methods.length) p += `:${makeArray(methods).map((m) => m.toLowerCase()).join("")}`;
1260
1275
  return p;
1261
1276
  }
1277
+ /**
1278
+ * Filter a set of paths based on this event
1279
+ *
1280
+ * @param {string | PathEvent | (string | PathEvent)[]} target Array of events that will filtered
1281
+ * @return {boolean} Whether there is any overlap
1282
+ */
1283
+ filter(target) {
1284
+ return PathEvent.filter(target, this);
1285
+ }
1262
1286
  /**
1263
1287
  * Create event string from its components
1264
1288
  *