feathers-utils 5.0.1 → 5.0.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 CHANGED
@@ -688,6 +688,9 @@ const forEach = (actionPerItem, options) => {
688
688
  if (shouldSkip("forEach", context)) {
689
689
  return context;
690
690
  }
691
+ if (options?.skip && await options.skip(context)) {
692
+ return context;
693
+ }
691
694
  const { items } = getItemsIsArray(context, { from });
692
695
  const forAll = options?.forAll ? await options.forAll(items, context) : {};
693
696
  const promises = [];
package/dist/index.d.cts CHANGED
@@ -40,6 +40,7 @@ type HookForEachOptions<T = any, H = HookContext, R = any> = {
40
40
  wait?: "sequential" | "parallel" | false;
41
41
  items?: GetItemsIsArrayOptions["from"];
42
42
  forAll?: (items: T[], context: H) => Promisable<R>;
43
+ skip?: (context: H) => Promisable<boolean>;
43
44
  };
44
45
  type ActionPerItem<T, H, R> = (item: T, options: {
45
46
  context: H;
package/dist/index.d.mts CHANGED
@@ -40,6 +40,7 @@ type HookForEachOptions<T = any, H = HookContext, R = any> = {
40
40
  wait?: "sequential" | "parallel" | false;
41
41
  items?: GetItemsIsArrayOptions["from"];
42
42
  forAll?: (items: T[], context: H) => Promisable<R>;
43
+ skip?: (context: H) => Promisable<boolean>;
43
44
  };
44
45
  type ActionPerItem<T, H, R> = (item: T, options: {
45
46
  context: H;
package/dist/index.d.ts CHANGED
@@ -40,6 +40,7 @@ type HookForEachOptions<T = any, H = HookContext, R = any> = {
40
40
  wait?: "sequential" | "parallel" | false;
41
41
  items?: GetItemsIsArrayOptions["from"];
42
42
  forAll?: (items: T[], context: H) => Promisable<R>;
43
+ skip?: (context: H) => Promisable<boolean>;
43
44
  };
44
45
  type ActionPerItem<T, H, R> = (item: T, options: {
45
46
  context: H;
package/dist/index.mjs CHANGED
@@ -674,6 +674,9 @@ const forEach = (actionPerItem, options) => {
674
674
  if (shouldSkip("forEach", context)) {
675
675
  return context;
676
676
  }
677
+ if (options?.skip && await options.skip(context)) {
678
+ return context;
679
+ }
677
680
  const { items } = getItemsIsArray(context, { from });
678
681
  const forAll = options?.forAll ? await options.forAll(items, context) : {};
679
682
  const promises = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "feathers-utils",
3
- "version": "5.0.1",
3
+ "version": "5.0.2",
4
4
  "description": "Some utils for projects using '@feathersjs/feathers'",
5
5
  "author": "fratzinger",
6
6
  "repository": {
@@ -9,6 +9,7 @@ export type HookForEachOptions<T = any, H = HookContext, R = any> = {
9
9
  wait?: "sequential" | "parallel" | false;
10
10
  items?: GetItemsIsArrayOptions["from"];
11
11
  forAll?: (items: T[], context: H) => Promisable<R>;
12
+ skip?: (context: H) => Promisable<boolean>;
12
13
  };
13
14
 
14
15
  type ActionPerItem<T, H, R> = (
@@ -31,6 +32,10 @@ export const forEach = <H extends HookContext = HookContext, T = any, R = any>(
31
32
  return context;
32
33
  }
33
34
 
35
+ if (options?.skip && (await options.skip(context))) {
36
+ return context;
37
+ }
38
+
34
39
  const { items } = getItemsIsArray(context, { from });
35
40
 
36
41
  const forAll = options?.forAll