Skip to content

Commit

Permalink
Add bytes() to NodeFastResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
bergold authored Dec 1, 2024
1 parent 916cbbe commit 3c3418c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/node-utils/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,17 @@ export const NodeFastResponse = /* @__PURE__ */ (() =>
return this.#response.blob(); // Slow path
}

bytes(): Promise<Uint8Array> {
if (this.#responseObj) {
return this.#responseObj.bytes(); // Reuse instance
}
const fastBody = this.#fastBody(Uint8Array);
if (fastBody !== false) {
return Promise.resolve(fastBody || new Uint8Array()); // Fast path
}
return this.#response.bytes(); // Slow path
}

formData(): Promise<FormData> {
if (this.#responseObj) {
return this.#responseObj.formData(); // Reuse instance
Expand Down

0 comments on commit 3c3418c

Please sign in to comment.