MCPcopy Index your code
hub / github.com/Effect-TS/effect / SingleShotGen

Class SingleShotGen

packages/effect/src/internal/singleShotGen.ts:2–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1/** @internal */
2export class SingleShotGen<T, A> implements Generator<T, A> {
3 called = false
4
5 constructor(readonly self: T) {
6 }
7
8 next(a: A): IteratorResult<T, A> {
9 return this.called ?
10 ({
11 value: a,
12 done: true
13 }) :
14 (this.called = true,
15 ({
16 value: this.self,
17 done: false
18 }))
19 }
20
21 return(a: A): IteratorResult<T, A> {
22 return ({
23 value: a,
24 done: true
25 })
26 }
27
28 throw(e: unknown): IteratorResult<T, A> {
29 throw e
30 }
31
32 [Symbol.iterator](): Generator<T, A> {
33 return new SingleShotGen<T, A>(this.self)
34 }
35}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected