@worker-tools/stream-response
Version:
Fetch API Response objects made from async generators. Build streaming HTML responses or SSE with JS sugar.
34 lines (33 loc) • 1.5 kB
TypeScript
import { ForAwaitable } from './iter.js';
export declare type StreamBodyInit = ForAwaitable<string> | ReadableStream<string>;
export declare type ByteStreamBodyInit = ForAwaitable<Uint8Array> | ReadableStream<Uint8Array>;
export declare class StreamResponse extends Response {
constructor(body?: StreamBodyInit | null, init?: ResponseInit);
}
export declare class ByteStreamResponse extends Response {
constructor(body?: ByteStreamBodyInit | null, init?: ResponseInit);
}
/**
* If for any reason you don't want to use streaming response bodies,
* you can use this class instead, which will buffer the entire body before releasing it to the network.
* Note that headers will still be sent immediately.
*/
export declare class BufferedStreamResponse extends Response {
constructor(body?: StreamBodyInit | null, init?: ResponseInit);
}
export declare class BufferedByteStreamResponse extends Response {
constructor(body?: ByteStreamBodyInit | null, init?: ResponseInit);
}
export { BufferedStreamResponse as BufferedResponse };
export declare type StreamRequestInit = Omit<RequestInit, 'body'> & {
body?: StreamBodyInit;
};
export declare type ByteStreamRequestInit = Omit<RequestInit, 'body'> & {
body?: ByteStreamBodyInit;
};
export declare class StreamRequest extends Request {
constructor(input: RequestInfo, init?: StreamRequestInit);
}
export declare class ByteStreamRequest extends Request {
constructor(input: RequestInfo, init?: ByteStreamRequestInit);
}