MCPcopy Create free account
hub / github.com/middleapi/orpc / constructor

Method constructor

packages/shared/src/iterator.ts:31–58  ·  view source on GitHub ↗
(next: AsyncIteratorClassNextFn<T, TReturn>, cleanup: AsyncIteratorClassCleanupFn)

Source from the content-addressed store, hash-verified

29 #next: AsyncIteratorClassNextFn<T, TReturn>
30
31 constructor(next: AsyncIteratorClassNextFn<T, TReturn>, cleanup: AsyncIteratorClassCleanupFn) {
32 this.#cleanup = cleanup
33 this.#next = sequential(async () => {
34 if (this.#isDone) {
35 return { done: true, value: undefined as any }
36 }
37
38 try {
39 const result = await next()
40
41 if (result.done) {
42 this.#isDone = true
43 }
44
45 return result
46 }
47 catch (err) {
48 this.#isDone = true
49 throw err
50 }
51 finally {
52 if (this.#isDone && !this.#isExecuteComplete) {
53 this.#isExecuteComplete = true
54 await this.#cleanup('next')
55 }
56 }
57 })
58 }
59
60 next(): Promise<IteratorResult<T, TReturn>> {
61 return this.#next()

Callers

nothing calls this directly

Calls 2

sequentialFunction · 0.90
nextFunction · 0.70

Tested by

no test coverage detected