@stacksjs/bun-router 0.1.14 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1 -1
- package/dist/index.js +11 -11
- package/dist/response/compression.d.ts +16 -3
- package/package.json +1 -1
|
@@ -100,10 +100,23 @@ export declare function compressResponse(response: Response, request: Request, o
|
|
|
100
100
|
* the prefix, which is what makes a small answer distinguishable from the
|
|
101
101
|
* beginning of a large one.
|
|
102
102
|
*/
|
|
103
|
-
export
|
|
104
|
-
|
|
103
|
+
export interface PeekedBody {
|
|
104
|
+
/**
|
|
105
|
+
* What to send.
|
|
106
|
+
*
|
|
107
|
+
* Bytes when the body ended inside the prefix, a stream when it did not.
|
|
108
|
+
* The distinction is the whole point: a body that ended was never a stream,
|
|
109
|
+
* it was a small answer that arrived whole, and rebuilding it as a stream
|
|
110
|
+
* asks Bun for a controller, a start microtask and a drain per response.
|
|
111
|
+
* Measured on a route returning seventeen bytes of JSON, that machinery was
|
|
112
|
+
* roughly three times the cost of answering the request.
|
|
113
|
+
*/
|
|
114
|
+
body: ReadableStream<Uint8Array> | Uint8Array;
|
|
105
115
|
size: number;
|
|
106
116
|
ended: boolean;
|
|
107
|
-
}
|
|
117
|
+
}
|
|
118
|
+
/** A stream again, for the branch that has to pipe what it peeked. */
|
|
119
|
+
export declare function peekedStream(peeked: PeekedBody): ReadableStream<Uint8Array>;
|
|
120
|
+
export declare function peekBody(source: ReadableStream<Uint8Array>, limit: number): Promise<PeekedBody>;
|
|
108
121
|
/** Add to `Vary` without dropping what is already there. */
|
|
109
122
|
export declare function appendVary(headers: Headers, value: string): void;
|