Skip to content

Commit

Permalink
extend IterableIterator instead of Generator (#4190)
Browse files Browse the repository at this point in the history
  • Loading branch information
IMax153 authored Dec 25, 2024
1 parent bfe8027 commit 16dd657
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/polite-crews-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"effect": patch
---

extend `IterableIterator` instead of `Generator` in `SingleShotGen`
8 changes: 4 additions & 4 deletions packages/effect/src/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export type GenKindTypeId = typeof GenKindTypeId
export interface GenKind<F extends TypeLambda, R, O, E, A> extends Variance<F, R, O, E> {
readonly value: Kind<F, R, O, E, A>

[Symbol.iterator](): Generator<GenKind<F, R, O, E, A>, A>
[Symbol.iterator](): IterableIterator<GenKind<F, R, O, E, A>, A>
}

/**
Expand Down Expand Up @@ -97,7 +97,7 @@ export class GenKindImpl<F extends TypeLambda, R, O, E, A> implements GenKind<F,
/**
* @since 2.0.0
*/
[Symbol.iterator](): Generator<GenKind<F, R, O, E, A>, A> {
[Symbol.iterator](): IterableIterator<GenKind<F, R, O, E, A>, A> {
return new SingleShotGen<GenKind<F, R, O, E, A>, A>(this as any)
}
}
Expand All @@ -106,7 +106,7 @@ export class GenKindImpl<F extends TypeLambda, R, O, E, A> implements GenKind<F,
* @category constructors
* @since 2.0.0
*/
export class SingleShotGen<T, A> implements Generator<T, A> {
export class SingleShotGen<T, A> implements IterableIterator<T, A> {
private called = false

constructor(readonly self: T) {}
Expand Down Expand Up @@ -147,7 +147,7 @@ export class SingleShotGen<T, A> implements Generator<T, A> {
/**
* @since 2.0.0
*/
[Symbol.iterator](): Generator<T, A> {
[Symbol.iterator](): IterableIterator<T, A> {
return new SingleShotGen<T, A>(this.self)
}
}
Expand Down

0 comments on commit 16dd657

Please sign in to comment.