MCPcopy Create free account
hub / github.com/Noumena-Network/code / next

Method next

src/utils/stream.ts:19–37  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17 }
18
19 next(): Promise<IteratorResult<T, unknown>> {
20 if (this.queue.length > 0) {
21 return Promise.resolve({
22 done: false,
23 value: this.queue.shift()!,
24 })
25 }
26 // Error checks before done so a late stream.error() never gets swallowed
27 if (this.hasError) {
28 return Promise.reject(this.hasError)
29 }
30 if (this.isDone) {
31 return Promise.resolve({ done: true, value: undefined })
32 }
33 return new Promise<IteratorResult<T>>((resolve, reject) => {
34 this.readResolve = resolve
35 this.readReject = reject
36 })
37 }
38
39 enqueue(value: T): void {
40 if (this.readResolve) {

Callers 15

collectQueryFunction · 0.45
collectTurnEventsFunction · 0.45
callFunction · 0.45
callFunction · 0.45
callFunction · 0.45
cachedLexerFunction · 0.45
cacheQueryStateFunction · 0.45
cachedHighlightFunction · 0.45
evictOldestFromSetFunction · 0.45
evictOldestFromMapFunction · 0.45

Calls 3

resolveMethod · 0.80
shiftMethod · 0.80
rejectMethod · 0.80

Tested by 3

collectQueryFunction · 0.36
collectTurnEventsFunction · 0.36
collectStreamFunction · 0.36