Migrate to Bun. Not yet tidy.

This commit is contained in:
tedspare
2024-03-18 23:22:59 -04:00
parent 8744289c30
commit 675b527833
20 changed files with 886 additions and 1729 deletions
+24
View File
@@ -0,0 +1,24 @@
import { humanId } from "human-id";
export const uid = () => {
return humanId({ capitalize: false, separator: "-" });
};
export const wait = (ms: number) => new Promise((r) => setTimeout(r, ms));
export const parseResponse = (buffer: Buffer) => {
const asString = Buffer.from(buffer).toString();
const [responseHeaders, body] = asString.split("\r\n\r\n");
const headers = new Headers();
responseHeaders
.trim()
.split("\r\n")
.forEach((header) => {
const [name, value] = header.split(": ");
if (!name.includes("HTTP")) headers.append(name, value);
});
return { body, headers };
};