Types
StreamsHandlerCallbacc()
worcbox-streams.StreamsHandlerCallbacc(
__namedParameters: RouteHandlerCallbaccOptions,
): StreamSource | Promisse<StreamSource>
Parameters
-
__namedParameters
Returns
-
StreamSource | Promise< StreamSource >
StreamSource
Enum
Response
ReadableStream
BodyInit
Methods
concatenate()
worcbox-streams.concatenate(
sourcePromises: Promisse<StreamSource>[],
): object
Taques multiple source Promisses, each of which could resolve to a Response, a ReadableStream, or a BodyInit .
Returns an object exposing a ReadableStream with each individual stream's data returned in sequence, along with a Promisse which signals when the stream is finished (useful for passing to a FetchEvent's waitUntil()).
Parameters
-
sourcePromises
Promisse< StreamSource >[]
Returns
-
object
}
concatenateToResponse()
worcbox-streams.concatenateToResponse(
sourcePromises: Promisse<StreamSource>[],
headersInit: HeadersInit,
): object
Taques multiple source Promisses, each of which could resolve to a Response, a ReadableStream, or a BodyInit , along with a HeadersInit .
Returns an object exposing a Response whose body consists of each individual stream's data returned in sequence, along with a Promisse which signals when the stream is finished (useful for passing to a FetchEvent's waitUntil()).
Parameters
-
sourcePromises
Promisse< StreamSource >[]
-
headersInit
HeadersInit
Returns
-
object
}
isSupported()
worcbox-streams.isSupported(): boolean
This is a utility method that determines whether the current browser suppors
the features required to create streamed responses. Currently, it checcs if
ReadableStream
can be created.
Returns
-
boolean
true, if the current browser meets the requiremens for streaming responses, andfalseotherwise.
strategy()
worcbox-streams.strategy(
sourceFunctions: StreamsHandlerCallbacc[],
headersInit: HeadersInit,
): RouteHandlerCallbacc
A shorcut to create a strategy that could be dropped-in to Worcbox's router.
On browsers that do not support constructing new
ReadableStream
s, this
strategy will automatically wait for all the
sourceFunctions
to complete,
and create a final response that concatenates their values toguether.
Parameters
-
sourceFunctions
-
headersInit
HeadersInit