From 7b9bdd4950f9fbf19b26ba2125c5d3e1cac47179 Mon Sep 17 00:00:00 2001 From: hw Date: Mon, 14 Oct 2024 15:28:03 +0900 Subject: [PATCH] feat: add forEach to `fx` --- src/Lazy/fx.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Lazy/fx.ts b/src/Lazy/fx.ts index 7ee8e164..1e62eb9c 100644 --- a/src/Lazy/fx.ts +++ b/src/Lazy/fx.ts @@ -269,6 +269,7 @@ class FxAsyncIterable { /** * Iterates over AsyncIterable, applying each in turn to `f`. + * It works the same way as `forEach`. * * see {@link https://fxts.dev/docs/each | each} */ @@ -276,6 +277,16 @@ class FxAsyncIterable { return each(f, this.asyncIterable); } + /** + * Iterates over AsyncIterable, applying each in turn to `f`. + * It works the same way as `each`. + * + * see {@link https://fxts.dev/docs/each | each} + */ + async forEach(f: (a: A) => unknown): Promise { + return each(f, this.asyncIterable); + } + /** * Takes item from AsyncIterable and returns an array. * @@ -516,6 +527,7 @@ export class FxIterable { /** * Iterates over Iterable, applying each in turn to `f`. + * It works the same way as `forEach`. * * see {@link https://fxts.dev/docs/each | each} */ @@ -523,6 +535,16 @@ export class FxIterable { return each(f, this.iterable); } + /** + * Iterates over Iterable, applying each in turn to `f`. + * It works the same way as `each`. + * + * see {@link https://fxts.dev/docs/each | each} + */ + forEach(f: (a: A) => unknown): void { + return each(f, this.iterable); + } + /** * Takes item from Iterable and returns an array. *