Skip to content

Commit

Permalink
feat(node): add NodeRequestProxy.bytes()
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Dec 4, 2024
1 parent c468e4f commit 07863f6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/node-utils/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@ export const NodeRequestProxy = /* @__PURE__ */ (() =>
return this.#rawBody.then((buff) => buff.buffer as ArrayBuffer);
}

bytes(): Promise<Uint8Array> {
if (!this.#rawBody) {
const _bodyStream = this.body;
return _bodyStream
? _readStream(_bodyStream)
: Promise.resolve(new Uint8Array());
}
return this.#rawBody;
}

blob(): Promise<Blob> {
if (!this.#blobBody) {
this.#blobBody = this.arrayBuffer().then((buff) => {
Expand Down

0 comments on commit 07863f6

Please sign in to comment.