Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add forEach to fx #285

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/Lazy/fx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,24 @@ class FxAsyncIterable<A> {

/**
* Iterates over AsyncIterable, applying each in turn to `f`.
* It works the same way as `forEach`.
*
* see {@link https://fxts.dev/docs/each | each}
*/
async each(f: (a: A) => unknown): Promise<void> {
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<void> {
return each(f, this.asyncIterable);
}

/**
* Takes item from AsyncIterable and returns an array.
*
Expand Down Expand Up @@ -516,13 +527,24 @@ export class FxIterable<A> {

/**
* Iterates over Iterable, applying each in turn to `f`.
* It works the same way as `forEach`.
*
* see {@link https://fxts.dev/docs/each | each}
*/
each(f: (a: A) => unknown): void {
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.
*
Expand Down
Loading