interface

DirectUnderlyingSource

interface DirectUnderlyingSource<R = any>

  • pull: (controller: ReadableStreamDirectController) => void | PromiseLike<void>

    Write the stream's data with controller.write() (await it for backpressure) and finish with controller.close().

    A destination that takes the whole body (Bun.serve, Bun.write, .text(), ...) calls pull() once. If it returns a promise, the stream stays open while it is pending, ends when it resolves, and errors if it rejects. If it returns synchronously without closing, the stream stays open until controller.close() is called.

    A reader (getReader(), for await, pipeTo()) calls pull() again for a later read, once the previous call has settled.

  • type: 'direct'