MCPcopy Index your code
hub / github.com/middleapi/orpc / pull

Method pull

packages/shared/src/queue.ts:57–84  ·  view source on GitHub ↗
(id: string)

Source from the content-addressed store, hash-verified

55 }
56
57 async pull(id: string): Promise<T> {
58 this.assertOpen(id)
59
60 const items = this.queues.get(id)
61
62 if (items?.length) {
63 const item = items.shift()!
64
65 if (items.length === 0) {
66 this.queues.delete(id)
67 }
68
69 return item
70 }
71
72 return new Promise<T>((resolve, reject) => {
73 const waitingPulls = this.waiters.get(id)
74
75 const pending = [resolve, reject] as const
76
77 if (waitingPulls) {
78 waitingPulls.push(pending)
79 }
80 else {
81 this.waiters.set(id, [pending])
82 }
83 })
84 }
85
86 close({ id, reason }: AsyncIdQueueCloseOptions = {}): void {
87 if (id === undefined) {

Callers 4

replicateAsyncIteratorFunction · 0.95
queue.test.tsFile · 0.80
requestMethod · 0.80
toEventIteratorFunction · 0.80

Calls 5

assertOpenMethod · 0.95
pushMethod · 0.80
setMethod · 0.80
getMethod · 0.65
deleteMethod · 0.65

Tested by

no test coverage detected