@langchain/langgraph-sdk
Version:
Client library for interacting with the LangGraph API
55 lines (54 loc) • 1.28 kB
JavaScript
//#region src/client/stream/multi-cursor-buffer.ts
/**
* Multi-cursor buffer that supports independent async iterators over a
* shared append-only log of items. Each `for await` loop gets its own
* cursor starting at position 0, so late consumers still see all
* previously buffered items.
*
* Mirrors the in-process multi-cursor buffering used by `GraphRunStream`.
*/
var MultiCursorBuffer = class {
push(item) {
this.
for (const cb of this.
this.
}
close() {
this.
for (const cb of this.
this.
}
get length() {
return this.
}
[]() {
let cursor = 0;
return {
next: async () => {
while (true) {
if (cursor < this.
done: false,
value: this.
};
if (this.
done: true,
value: void 0
};
await new Promise((resolve) => {
this.
});
}
},
return: async () => ({
done: true,
value: void 0
})
};
}
};
//#endregion
export { MultiCursorBuffer };
//# sourceMappingURL=multi-cursor-buffer.js.map