-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
π pomelo: fix parsing & verification
- Loading branch information
1 parent
b46c451
commit 1cdc3d1
Showing
3 changed files
with
14 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import type { Readable } from "node:stream"; | ||
|
||
export default async function buffer(readable: Readable) { | ||
const chunks = []; | ||
for await (const chunk of readable) { | ||
chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk); | ||
} | ||
return Buffer.concat(chunks); | ||
export default function buffer(request: Readable): Promise<Buffer> { | ||
return new Promise((r) => { | ||
const chunks: Buffer[] = []; | ||
request.on("data", (chunk: Buffer | string) => chunks.push(Buffer.from(chunk))); | ||
request.on("end", () => { | ||
r(Buffer.concat(chunks)); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters