aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/bun.js')
-rw-r--r--test/bun.js/abort-signal-timeout.test.js4
-rw-r--r--test/bun.js/arraybuffersink.test.ts46
-rw-r--r--test/bun.js/body-stream.test.ts167
-rw-r--r--test/bun.js/buffer.test.js569
-rw-r--r--test/bun.js/bufferlist.test.ts32
-rw-r--r--test/bun.js/bun-test/jest-hooks.test.ts10
-rw-r--r--test/bun.js/bun-test/nested-describes.test.ts46
-rw-r--r--test/bun.js/bun-write.test.js65
-rw-r--r--test/bun.js/child-process-stdio.test.js97
-rw-r--r--test/bun.js/child_process-node.test.js53
-rw-r--r--test/bun.js/child_process.test.ts92
-rw-r--r--test/bun.js/concat.test.js16
-rw-r--r--test/bun.js/console/console-iterator.test.js6
-rw-r--r--test/bun.js/console/console-log.js14
-rw-r--r--test/bun.js/console/console-log.test.ts4
-rw-r--r--test/bun.js/crypto-scrypt.test.js10
-rw-r--r--test/bun.js/crypto.test.js25
-rw-r--r--test/bun.js/decorators.test.ts24
-rw-r--r--test/bun.js/esbuild-child_process.test.ts11
-rw-r--r--test/bun.js/escapeHTML.test.js72
-rw-r--r--test/bun.js/event-emitter.test.ts26
-rw-r--r--test/bun.js/exit-code.test.ts20
-rw-r--r--test/bun.js/fetch-gzip.test.ts92
-rw-r--r--test/bun.js/fetch.test.js134
-rw-r--r--test/bun.js/ffi.test.js40
-rw-r--r--test/bun.js/fileUrl.test.js8
-rw-r--r--test/bun.js/filesink.test.ts46
-rw-r--r--test/bun.js/filesystem_router.test.ts77
-rw-r--r--test/bun.js/fixture.html1177
-rw-r--r--test/bun.js/fs-stream.js6
-rw-r--r--test/bun.js/gc.js2
-rw-r--r--test/bun.js/globals.test.js12
-rw-r--r--test/bun.js/google-fixture.html648
-rw-r--r--test/bun.js/hot-runner-imported.js4
-rw-r--r--test/bun.js/hot.test.ts8
-rw-r--r--test/bun.js/html-rewriter.test.js34
-rw-r--r--test/bun.js/import-meta.test.js22
-rw-r--r--test/bun.js/inline.macro.js2
-rw-r--r--test/bun.js/inspect.test.js60
-rw-r--r--test/bun.js/install/bad-workspace.test.ts4
-rw-r--r--test/bun.js/install/bun-link.test.ts129
-rw-r--r--test/bun.js/install/bunx.test.ts17
-rw-r--r--test/bun.js/microtask.test.js10
-rw-r--r--test/bun.js/node-crypto.test.js5
-rw-r--r--test/bun.js/node-dns.test.js28
-rw-r--r--test/bun.js/node-http.test.ts4
-rw-r--r--test/bun.js/node-stream.test.js14
-rw-r--r--test/bun.js/node-test-helpers.ts24
-rw-r--r--test/bun.js/os.test.js20
-rw-r--r--test/bun.js/path.test.js64
-rw-r--r--test/bun.js/peek.test.ts8
-rw-r--r--test/bun.js/performance.test.js4
-rw-r--r--test/bun.js/plugins.test.ts70
-rw-r--r--test/bun.js/process-args.test.js8
-rw-r--r--test/bun.js/process-nexttick.js13
-rw-r--r--test/bun.js/process-nexttick.test.js13
-rw-r--r--test/bun.js/process-stdin-echo.js4
-rw-r--r--test/bun.js/process-stdio.test.ts30
-rw-r--r--test/bun.js/process.test.js44
-rw-r--r--test/bun.js/proxy.test.js6
-rw-r--r--test/bun.js/react-dom-server.bun.cjs592
-rw-r--r--test/bun.js/react-dom.test.tsx38
-rw-r--r--test/bun.js/readline.node.test.ts209
-rw-r--r--test/bun.js/readline_promises.node.test.ts8
-rw-r--r--test/bun.js/resolve-dns.test.ts30
-rw-r--r--test/bun.js/resolve.test.js89
-rw-r--r--test/bun.js/serve.test.ts187
-rw-r--r--test/bun.js/setInterval.test.js32
-rw-r--r--test/bun.js/setTimeout.test.js28
-rw-r--r--test/bun.js/snapshots.debug.js4
-rw-r--r--test/bun.js/snapshots.js4
-rw-r--r--test/bun.js/socket/echo.js2
-rw-r--r--test/bun.js/socket/node-net.test.ts24
-rw-r--r--test/bun.js/socket/socket.test.ts6
-rw-r--r--test/bun.js/some-fs.js12
-rw-r--r--test/bun.js/spawn-streaming-stdin.test.ts6
-rw-r--r--test/bun.js/spawn.test.ts18
-rw-r--r--test/bun.js/spawned-child.js2
-rw-r--r--test/bun.js/sql-raw.test.js33
-rw-r--r--test/bun.js/sqlite.test.js120
-rw-r--r--test/bun.js/stdio-test-instance-a-lot.js6
-rw-r--r--test/bun.js/stdio-test-instance.js6
-rw-r--r--test/bun.js/streams.test.js23
-rw-r--r--test/bun.js/string-decoder.test.js92
-rw-r--r--test/bun.js/tcp-server.test.ts20
-rw-r--r--test/bun.js/test-test.test.ts87
-rw-r--r--test/bun.js/test-util-types.test.js73
-rw-r--r--test/bun.js/text-decoder.test.js48
-rw-r--r--test/bun.js/text-encoder.test.js24
-rw-r--r--test/bun.js/third-party/body-parser-test/express-body-parser-test.test.ts9
-rw-r--r--test/bun.js/third-party/napi_create_external/napi-create-external.test.ts25
-rw-r--r--test/bun.js/toml.test.js8
-rw-r--r--test/bun.js/transpiler.test.js867
-rw-r--r--test/bun.js/tsconfig.json11
-rw-r--r--test/bun.js/unsafe.test.js6
-rw-r--r--test/bun.js/url.test.ts12
-rw-r--r--test/bun.js/util/util-promisify.test.js34
-rw-r--r--test/bun.js/util/util.test.js5
-rw-r--r--test/bun.js/web-crypto.test.ts15
-rw-r--r--test/bun.js/web-globals.test.js12
-rw-r--r--test/bun.js/websocket-server.test.ts85
-rw-r--r--test/bun.js/websocket-subprocess.ts2
-rw-r--r--test/bun.js/websocket.test.js41
103 files changed, 2749 insertions, 4506 deletions
diff --git a/test/bun.js/abort-signal-timeout.test.js b/test/bun.js/abort-signal-timeout.test.js
index 65e865729..7d741b2ad 100644
--- a/test/bun.js/abort-signal-timeout.test.js
+++ b/test/bun.js/abort-signal-timeout.test.js
@@ -1,8 +1,8 @@
import { expect, test } from "bun:test";
-test.skip("AbortSignal.timeout", (done) => {
+test.skip("AbortSignal.timeout", done => {
const abort = AbortSignal.timeout(10);
- abort.addEventListener("abort", (event) => {
+ abort.addEventListener("abort", event => {
done();
});
diff --git a/test/bun.js/arraybuffersink.test.ts b/test/bun.js/arraybuffersink.test.ts
index d747ffc64..f0df03d90 100644
--- a/test/bun.js/arraybuffersink.test.ts
+++ b/test/bun.js/arraybuffersink.test.ts
@@ -11,44 +11,23 @@ describe("ArrayBufferSink", () => {
],
[
["abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"],
- new TextEncoder().encode(
- "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
- ),
+ new TextEncoder().encode("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
],
[
["😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌"],
- new TextEncoder().encode(
- "😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌",
- ),
+ new TextEncoder().encode("😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌"),
"😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌",
],
[
- [
- "abcdefghijklmnopqrstuvwxyz",
- "😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌",
- ],
- new TextEncoder().encode(
- "abcdefghijklmnopqrstuvwxyz" +
- "😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌",
- ),
- "abcdefghijklmnopqrstuvwxyz" +
- "😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌",
+ ["abcdefghijklmnopqrstuvwxyz", "😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌"],
+ new TextEncoder().encode("abcdefghijklmnopqrstuvwxyz" + "😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌"),
+ "abcdefghijklmnopqrstuvwxyz" + "😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌",
],
[
- [
- "abcdefghijklmnopqrstuvwxyz",
- "😋",
- " Get Emoji — All Emojis",
- " to ✂️ Copy and 📋 Paste 👌",
- ],
- new TextEncoder().encode(
- "abcdefghijklmnopqrstuvwxyz" +
- "😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌",
- ),
- "(rope) " +
- "abcdefghijklmnopqrstuvwxyz" +
- "😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌",
+ ["abcdefghijklmnopqrstuvwxyz", "😋", " Get Emoji — All Emojis", " to ✂️ Copy and 📋 Paste 👌"],
+ new TextEncoder().encode("abcdefghijklmnopqrstuvwxyz" + "😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌"),
+ "(rope) " + "abcdefghijklmnopqrstuvwxyz" + "😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌",
],
[
[
@@ -57,13 +36,8 @@ describe("ArrayBufferSink", () => {
" Get Emoji — All Emojis",
" to ✂️ Copy and 📋 Paste 👌",
],
- new TextEncoder().encode(
- "abcdefghijklmnopqrstuvwxyz" +
- "😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌",
- ),
- "(array) " +
- "abcdefghijklmnopqrstuvwxyz" +
- "😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌",
+ new TextEncoder().encode("abcdefghijklmnopqrstuvwxyz" + "😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌"),
+ "(array) " + "abcdefghijklmnopqrstuvwxyz" + "😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌",
],
] as const;
diff --git a/test/bun.js/body-stream.test.ts b/test/bun.js/body-stream.test.ts
index 5f505143c..9a68ad3bc 100644
--- a/test/bun.js/body-stream.test.ts
+++ b/test/bun.js/body-stream.test.ts
@@ -21,49 +21,26 @@ var port = 4021;
}`, () => {
const inputFixture = [
[JSON.stringify("Hello World"), JSON.stringify("Hello World")],
+ [JSON.stringify("Hello World 123"), Buffer.from(JSON.stringify("Hello World 123")).buffer],
+ [JSON.stringify("Hello World 456"), Buffer.from(JSON.stringify("Hello World 456"))],
[
- JSON.stringify("Hello World 123"),
- Buffer.from(JSON.stringify("Hello World 123")).buffer,
- ],
- [
- JSON.stringify("Hello World 456"),
- Buffer.from(JSON.stringify("Hello World 456")),
- ],
- [
- JSON.stringify(
- "EXTREMELY LONG VERY LONG STRING WOW SO LONG YOU WONT BELIEVE IT! ".repeat(
- 100,
- ),
- ),
+ JSON.stringify("EXTREMELY LONG VERY LONG STRING WOW SO LONG YOU WONT BELIEVE IT! ".repeat(100)),
Buffer.from(
- JSON.stringify(
- "EXTREMELY LONG VERY LONG STRING WOW SO LONG YOU WONT BELIEVE IT! ".repeat(
- 100,
- ),
- ),
+ JSON.stringify("EXTREMELY LONG VERY LONG STRING WOW SO LONG YOU WONT BELIEVE IT! ".repeat(100)),
),
],
[
- JSON.stringify(
- "EXTREMELY LONG 🔥 UTF16 🔥 VERY LONG STRING WOW SO LONG YOU WONT BELIEVE IT! ".repeat(
- 100,
- ),
- ),
+ JSON.stringify("EXTREMELY LONG 🔥 UTF16 🔥 VERY LONG STRING WOW SO LONG YOU WONT BELIEVE IT! ".repeat(100)),
Buffer.from(
JSON.stringify(
- "EXTREMELY LONG 🔥 UTF16 🔥 VERY LONG STRING WOW SO LONG YOU WONT BELIEVE IT! ".repeat(
- 100,
- ),
+ "EXTREMELY LONG 🔥 UTF16 🔥 VERY LONG STRING WOW SO LONG YOU WONT BELIEVE IT! ".repeat(100),
),
),
],
];
for (const [name, input] of inputFixture) {
- test(`${name.slice(
- 0,
- Math.min(name.length ?? name.byteLength, 64),
- )}`, async () => {
+ test(`${name.slice(0, Math.min(name.length ?? name.byteLength, 64))}`, async () => {
await runInServer(
{
async fetch(req) {
@@ -75,24 +52,18 @@ var port = 4021;
expect(result.length).toBe(name.length);
expect(result).toBe(name);
} else if (result && result instanceof Blob) {
- expect(result.size).toBe(
- new TextEncoder().encode(name).byteLength,
- );
+ expect(result.size).toBe(new TextEncoder().encode(name).byteLength);
expect(await result.text()).toBe(name);
} else {
- expect(result.byteLength).toBe(
- Buffer.from(input).byteLength,
- );
- expect(Bun.SHA1.hash(result, "base64")).toBe(
- Bun.SHA1.hash(input, "base64"),
- );
+ expect(result.byteLength).toBe(Buffer.from(input).byteLength);
+ expect(Bun.SHA1.hash(result, "base64")).toBe(Bun.SHA1.hash(input, "base64"));
}
return new Response(result, {
headers: req.headers,
});
},
},
- async (url) => {
+ async url => {
var response;
// once, then batch of 5
@@ -119,9 +90,7 @@ var port = 4021;
}
expect(response.status).toBe(200);
- expect(response.headers.get("content-length")).toBe(
- String(Buffer.from(input).byteLength),
- );
+ expect(response.headers.get("content-length")).toBe(String(Buffer.from(input).byteLength));
expect(response.headers.get("content-type")).toBe("text/plain");
expect(await response.text()).toBe(name);
@@ -155,12 +124,8 @@ var port = 4021;
for (let i = 0; i < 5; i++) {
const response = results[i];
expect(response.status).toBe(200);
- expect(response.headers.get("content-length")).toBe(
- String(Buffer.from(input).byteLength),
- );
- expect(response.headers.get("content-type")).toBe(
- "text/plain",
- );
+ expect(response.headers.get("content-length")).toBe(String(Buffer.from(input).byteLength));
+ expect(response.headers.get("content-type")).toBe("text/plain");
expect(response.headers.get("x-counter")).toBe(String(i));
expect(await response.text()).toBe(name);
}
@@ -174,10 +139,7 @@ var port = 4021;
}
var existingServer;
-async function runInServer(
- opts: ServeOptions,
- cb: (url: string) => void | Promise<void>,
-) {
+async function runInServer(opts: ServeOptions, cb: (url: string) => void | Promise<void>) {
var server;
const handler = {
...opts,
@@ -241,16 +203,7 @@ describe("reader", function () {
// - less than the InlineBlob limit
// - multiple chunks
// - backpressure
- for (let inputLength of [
- 0,
- 1,
- 2,
- 12,
- 95,
- 1024,
- 1024 * 1024,
- 1024 * 1024 * 2,
- ]) {
+ for (let inputLength of [0, 1, 2, 12, 95, 1024, 1024 * 1024, 1024 * 1024 * 2]) {
var bytes = new Uint8Array(inputLength);
{
const chunk = Math.min(bytes.length, 256);
@@ -283,10 +236,7 @@ describe("reader", function () {
new Int32Array(bytes).subarray(1),
new Int32Array(bytes).subarray(0, new Int32Array(bytes).byteLength - 1),
new Float32Array(bytes).subarray(1),
- new Float32Array(bytes).subarray(
- 0,
- new Float32Array(bytes).byteLength - 1,
- ),
+ new Float32Array(bytes).subarray(0, new Float32Array(bytes).byteLength - 1),
new Int16Array(bytes).subarray(0, 1),
new Int32Array(bytes).subarray(0, 1),
new Float32Array(bytes).subarray(0, 1),
@@ -302,13 +252,9 @@ describe("reader", function () {
const expectedHash =
huge instanceof Blob
- ? Bun.SHA1.hash(
- new Uint8Array(await huge.arrayBuffer()),
- "base64",
- )
+ ? Bun.SHA1.hash(new Uint8Array(await huge.arrayBuffer()), "base64")
: Bun.SHA1.hash(huge, "base64");
- const expectedSize =
- huge instanceof Blob ? huge.size : huge.byteLength;
+ const expectedSize = huge instanceof Blob ? huge.size : huge.byteLength;
const out = await runInServer(
{
@@ -316,16 +262,12 @@ describe("reader", function () {
try {
expect(req.headers.get("x-custom")).toBe("hello");
expect(req.headers.get("content-type")).toBe("text/plain");
- expect(req.headers.get("user-agent")).toBe(
- navigator.userAgent,
- );
+ expect(req.headers.get("user-agent")).toBe(navigator.userAgent);
gc();
expect(req.headers.get("x-custom")).toBe("hello");
expect(req.headers.get("content-type")).toBe("text/plain");
- expect(req.headers.get("user-agent")).toBe(
- navigator.userAgent,
- );
+ expect(req.headers.get("user-agent")).toBe(navigator.userAgent);
var reader = req.body.getReader();
called = true;
@@ -338,14 +280,10 @@ describe("reader", function () {
const out = new Blob(buffers);
gc();
expect(out.size).toBe(expectedSize);
- expect(Bun.SHA1.hash(await out.arrayBuffer(), "base64")).toBe(
- expectedHash,
- );
+ expect(Bun.SHA1.hash(await out.arrayBuffer(), "base64")).toBe(expectedHash);
expect(req.headers.get("x-custom")).toBe("hello");
expect(req.headers.get("content-type")).toBe("text/plain");
- expect(req.headers.get("user-agent")).toBe(
- navigator.userAgent,
- );
+ expect(req.headers.get("user-agent")).toBe(navigator.userAgent);
gc();
return new Response(out, {
headers: req.headers,
@@ -356,7 +294,7 @@ describe("reader", function () {
}
},
},
- async (url) => {
+ async url => {
gc();
const response = await fetch(url, {
body: huge,
@@ -369,9 +307,7 @@ describe("reader", function () {
});
huge = undefined;
expect(response.status).toBe(200);
- const response_body = new Uint8Array(
- await response.arrayBuffer(),
- );
+ const response_body = new Uint8Array(await response.arrayBuffer());
expect(response_body.byteLength).toBe(expectedSize);
expect(Bun.SHA1.hash(response_body, "base64")).toBe(expectedHash);
@@ -388,7 +324,7 @@ describe("reader", function () {
for (let isDirectStream of [true, false]) {
const positions = ["begin", "end"];
- const inner = (thisArray) => {
+ const inner = thisArray => {
for (let position of positions) {
it(`streaming back ${thisArray.constructor.name}(${
thisArray.byteLength ?? thisArray.size
@@ -399,13 +335,9 @@ describe("reader", function () {
const expectedHash =
huge instanceof Blob
- ? Bun.SHA1.hash(
- new Uint8Array(await huge.arrayBuffer()),
- "base64",
- )
+ ? Bun.SHA1.hash(new Uint8Array(await huge.arrayBuffer()), "base64")
: Bun.SHA1.hash(huge, "base64");
- const expectedSize =
- huge instanceof Blob ? huge.size : huge.byteLength;
+ const expectedSize = huge instanceof Blob ? huge.size : huge.byteLength;
const out = await runInServer(
{
@@ -423,21 +355,13 @@ describe("reader", function () {
}
expect(req.headers.get("x-custom")).toBe("hello");
- expect(req.headers.get("content-type")).toBe(
- "text/plain",
- );
- expect(req.headers.get("user-agent")).toBe(
- navigator.userAgent,
- );
+ expect(req.headers.get("content-type")).toBe("text/plain");
+ expect(req.headers.get("user-agent")).toBe(navigator.userAgent);
gc();
expect(req.headers.get("x-custom")).toBe("hello");
- expect(req.headers.get("content-type")).toBe(
- "text/plain",
- );
- expect(req.headers.get("user-agent")).toBe(
- navigator.userAgent,
- );
+ expect(req.headers.get("content-type")).toBe("text/plain");
+ expect(req.headers.get("user-agent")).toBe(navigator.userAgent);
const direct = {
type: "direct",
@@ -469,19 +393,16 @@ describe("reader", function () {
},
};
- return new Response(
- new ReadableStream(isDirectStream ? direct : web),
- {
- headers: req.headers,
- },
- );
+ return new Response(new ReadableStream(isDirectStream ? direct : web), {
+ headers: req.headers,
+ });
} catch (e) {
console.error(e);
throw e;
}
},
},
- async (url) => {
+ async url => {
gc();
const response = await fetch(url, {
body: huge,
@@ -494,25 +415,17 @@ describe("reader", function () {
});
huge = undefined;
expect(response.status).toBe(200);
- const response_body = new Uint8Array(
- await response.arrayBuffer(),
- );
+ const response_body = new Uint8Array(await response.arrayBuffer());
expect(response_body.byteLength).toBe(expectedSize);
- expect(Bun.SHA1.hash(response_body, "base64")).toBe(
- expectedHash,
- );
+ expect(Bun.SHA1.hash(response_body, "base64")).toBe(expectedHash);
gc();
if (!response.headers.has("content-type")) {
- console.error(
- Object.fromEntries(response.headers.entries()),
- );
+ console.error(Object.fromEntries(response.headers.entries()));
}
- expect(response.headers.get("content-type")).toBe(
- "text/plain",
- );
+ expect(response.headers.get("content-type")).toBe("text/plain");
gc();
},
);
diff --git a/test/bun.js/buffer.test.js b/test/bun.js/buffer.test.js
index d1ed5a496..d624b193c 100644
--- a/test/bun.js/buffer.test.js
+++ b/test/bun.js/buffer.test.js
@@ -80,10 +80,7 @@ it("Buffer.alloc", () => {
// Test invalid encoding for Buffer.toString
assert.throws(() => b.toString("invalid"), /Unknown encoding: invalid/);
// Invalid encoding for Buffer.write
- assert.throws(
- () => b.write("test string", 0, 5, "invalid"),
- /Unknown encoding: invalid/,
- );
+ assert.throws(() => b.write("test string", 0, 5, "invalid"), /Unknown encoding: invalid/);
// Unsupported arguments for Buffer.write
// assert.throws(() => b.write("test", "utf8", 0), {
// code: "ERR_INVALID_ARG_TYPE",
@@ -161,10 +158,7 @@ it("Buffer.alloc", () => {
const asciiString = "hello world";
const offset = 100;
- assert.strictEqual(
- asciiString.length,
- b.write(asciiString, offset, "ascii"),
- );
+ assert.strictEqual(asciiString.length, b.write(asciiString, offset, "ascii"));
const asciiSlice = b.toString("ascii", offset, offset + asciiString.length);
assert.strictEqual(asciiString, asciiSlice);
}
@@ -189,15 +183,8 @@ it("Buffer.alloc", () => {
let utf8Slice = b.toString("utf8", 0, Buffer.byteLength(utf8String));
assert.strictEqual(utf8String, utf8Slice);
- assert.strictEqual(
- Buffer.byteLength(utf8String),
- b.write(utf8String, offset, "utf8"),
- );
- utf8Slice = b.toString(
- "utf8",
- offset,
- offset + Buffer.byteLength(utf8String),
- );
+ assert.strictEqual(Buffer.byteLength(utf8String), b.write(utf8String, offset, "utf8"));
+ utf8Slice = b.toString("utf8", offset, offset + Buffer.byteLength(utf8String));
assert.strictEqual(utf8String, utf8Slice);
const sliceA = b.slice(offset, offset + Buffer.byteLength(utf8String));
@@ -276,7 +263,7 @@ it("Buffer.alloc", () => {
assert.deepStrictEqual(f, Buffer.from([252, 98, 101, 114]));
}
- ["ucs2", "ucs-2", "utf16le", "utf-16le"].forEach((encoding) => {
+ ["ucs2", "ucs-2", "utf16le", "utf-16le"].forEach(encoding => {
{
// Test for proper UTF16LE encoding, length should be 8
const f = Buffer.from("über", encoding);
@@ -286,10 +273,7 @@ it("Buffer.alloc", () => {
{
// Length should be 12
const f = Buffer.from("привет", encoding);
- assert.deepStrictEqual(
- f,
- Buffer.from([63, 4, 64, 4, 56, 4, 50, 4, 53, 4, 66, 4]),
- );
+ assert.deepStrictEqual(f, Buffer.from([63, 4, 64, 4, 56, 4, 50, 4, 53, 4, 66, 4]));
assert.strictEqual(f.toString(encoding), "привет");
}
@@ -333,47 +317,21 @@ it("Buffer.alloc", () => {
{
// Test that regular and URL-safe base64 both work both ways
const expected = [0xff, 0xff, 0xbe, 0xff, 0xef, 0xbf, 0xfb, 0xef, 0xff];
- assert.deepStrictEqual(
- Buffer.from("//++/++/++//", "base64"),
- Buffer.from(expected),
- );
- assert.deepStrictEqual(
- Buffer.from("__--_--_--__", "base64"),
- Buffer.from(expected),
- );
- assert.deepStrictEqual(
- Buffer.from("//++/++/++//", "base64url"),
- Buffer.from(expected),
- );
- assert.deepStrictEqual(
- Buffer.from("__--_--_--__", "base64url"),
- Buffer.from(expected),
- );
+ assert.deepStrictEqual(Buffer.from("//++/++/++//", "base64"), Buffer.from(expected));
+ assert.deepStrictEqual(Buffer.from("__--_--_--__", "base64"), Buffer.from(expected));
+ assert.deepStrictEqual(Buffer.from("//++/++/++//", "base64url"), Buffer.from(expected));
+ assert.deepStrictEqual(Buffer.from("__--_--_--__", "base64url"), Buffer.from(expected));
}
const base64flavors = ["base64", "base64url"];
{
// Test that regular and URL-safe base64 both work both ways with padding
- const expected = [
- 0xff, 0xff, 0xbe, 0xff, 0xef, 0xbf, 0xfb, 0xef, 0xff, 0xfb,
- ];
- assert.deepStrictEqual(
- Buffer.from("//++/++/++//+w==", "base64"),
- Buffer.from(expected),
- );
- assert.deepStrictEqual(
- Buffer.from("//++/++/++//+w==", "base64"),
- Buffer.from(expected),
- );
- assert.deepStrictEqual(
- Buffer.from("//++/++/++//+w==", "base64url"),
- Buffer.from(expected),
- );
- assert.deepStrictEqual(
- Buffer.from("//++/++/++//+w==", "base64url"),
- Buffer.from(expected),
- );
+ const expected = [0xff, 0xff, 0xbe, 0xff, 0xef, 0xbf, 0xfb, 0xef, 0xff, 0xfb];
+ assert.deepStrictEqual(Buffer.from("//++/++/++//+w==", "base64"), Buffer.from(expected));
+ assert.deepStrictEqual(Buffer.from("//++/++/++//+w==", "base64"), Buffer.from(expected));
+ assert.deepStrictEqual(Buffer.from("//++/++/++//+w==", "base64url"), Buffer.from(expected));
+ assert.deepStrictEqual(Buffer.from("//++/++/++//+w==", "base64url"), Buffer.from(expected));
}
{
@@ -398,7 +356,7 @@ it("Buffer.alloc", () => {
expected.replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", ""),
);
- base64flavors.forEach((encoding) => {
+ base64flavors.forEach(encoding => {
let b = Buffer.allocUnsafe(1024);
let bytesWritten = b.write(expected, 0, encoding);
assert.strictEqual(quote.length, bytesWritten);
@@ -442,7 +400,7 @@ it("Buffer.alloc", () => {
});
}
- base64flavors.forEach((encoding) => {
+ base64flavors.forEach(encoding => {
assert.strictEqual(Buffer.from("", encoding).toString(), "");
assert.strictEqual(Buffer.from("K", encoding).toString(), "");
@@ -450,186 +408,54 @@ it("Buffer.alloc", () => {
assert.strictEqual(Buffer.from("Kg==", encoding).toString(), "*");
assert.strictEqual(Buffer.from("Kio=", encoding).toString(), "*".repeat(2));
assert.strictEqual(Buffer.from("Kioq", encoding).toString(), "*".repeat(3));
- assert.strictEqual(
- Buffer.from("KioqKg==", encoding).toString(),
- "*".repeat(4),
- );
- assert.strictEqual(
- Buffer.from("KioqKio=", encoding).toString(),
- "*".repeat(5),
- );
- assert.strictEqual(
- Buffer.from("KioqKioq", encoding).toString(),
- "*".repeat(6),
- );
- assert.strictEqual(
- Buffer.from("KioqKioqKg==", encoding).toString(),
- "*".repeat(7),
- );
- assert.strictEqual(
- Buffer.from("KioqKioqKio=", encoding).toString(),
- "*".repeat(8),
- );
- assert.strictEqual(
- Buffer.from("KioqKioqKioq", encoding).toString(),
- "*".repeat(9),
- );
- assert.strictEqual(
- Buffer.from("KioqKioqKioqKg==", encoding).toString(),
- "*".repeat(10),
- );
- assert.strictEqual(
- Buffer.from("KioqKioqKioqKio=", encoding).toString(),
- "*".repeat(11),
- );
- assert.strictEqual(
- Buffer.from("KioqKioqKioqKioq", encoding).toString(),
- "*".repeat(12),
- );
- assert.strictEqual(
- Buffer.from("KioqKioqKioqKioqKg==", encoding).toString(),
- "*".repeat(13),
- );
- assert.strictEqual(
- Buffer.from("KioqKioqKioqKioqKio=", encoding).toString(),
- "*".repeat(14),
- );
- assert.strictEqual(
- Buffer.from("KioqKioqKioqKioqKioq", encoding).toString(),
- "*".repeat(15),
- );
- assert.strictEqual(
- Buffer.from("KioqKioqKioqKioqKioqKg==", encoding).toString(),
- "*".repeat(16),
- );
- assert.strictEqual(
- Buffer.from("KioqKioqKioqKioqKioqKio=", encoding).toString(),
- "*".repeat(17),
- );
- assert.strictEqual(
- Buffer.from("KioqKioqKioqKioqKioqKioq", encoding).toString(),
- "*".repeat(18),
- );
- assert.strictEqual(
- Buffer.from("KioqKioqKioqKioqKioqKioqKg==", encoding).toString(),
- "*".repeat(19),
- );
- assert.strictEqual(
- Buffer.from("KioqKioqKioqKioqKioqKioqKio=", encoding).toString(),
- "*".repeat(20),
- );
+ assert.strictEqual(Buffer.from("KioqKg==", encoding).toString(), "*".repeat(4));
+ assert.strictEqual(Buffer.from("KioqKio=", encoding).toString(), "*".repeat(5));
+ assert.strictEqual(Buffer.from("KioqKioq", encoding).toString(), "*".repeat(6));
+ assert.strictEqual(Buffer.from("KioqKioqKg==", encoding).toString(), "*".repeat(7));
+ assert.strictEqual(Buffer.from("KioqKioqKio=", encoding).toString(), "*".repeat(8));
+ assert.strictEqual(Buffer.from("KioqKioqKioq", encoding).toString(), "*".repeat(9));
+ assert.strictEqual(Buffer.from("KioqKioqKioqKg==", encoding).toString(), "*".repeat(10));
+ assert.strictEqual(Buffer.from("KioqKioqKioqKio=", encoding).toString(), "*".repeat(11));
+ assert.strictEqual(Buffer.from("KioqKioqKioqKioq", encoding).toString(), "*".repeat(12));
+ assert.strictEqual(Buffer.from("KioqKioqKioqKioqKg==", encoding).toString(), "*".repeat(13));
+ assert.strictEqual(Buffer.from("KioqKioqKioqKioqKio=", encoding).toString(), "*".repeat(14));
+ assert.strictEqual(Buffer.from("KioqKioqKioqKioqKioq", encoding).toString(), "*".repeat(15));
+ assert.strictEqual(Buffer.from("KioqKioqKioqKioqKioqKg==", encoding).toString(), "*".repeat(16));
+ assert.strictEqual(Buffer.from("KioqKioqKioqKioqKioqKio=", encoding).toString(), "*".repeat(17));
+ assert.strictEqual(Buffer.from("KioqKioqKioqKioqKioqKioq", encoding).toString(), "*".repeat(18));
+ assert.strictEqual(Buffer.from("KioqKioqKioqKioqKioqKioqKg==", encoding).toString(), "*".repeat(19));
+ assert.strictEqual(Buffer.from("KioqKioqKioqKioqKioqKioqKio=", encoding).toString(), "*".repeat(20));
// No padding, not a multiple of 4
assert.strictEqual(Buffer.from("Kg", encoding).toString(), "*");
assert.strictEqual(Buffer.from("Kio", encoding).toString(), "*".repeat(2));
- assert.strictEqual(
- Buffer.from("KioqKg", encoding).toString(),
- "*".repeat(4),
- );
- assert.strictEqual(
- Buffer.from("KioqKio", encoding).toString(),
- "*".repeat(5),
- );
- assert.strictEqual(
- Buffer.from("KioqKioqKg", encoding).toString(),
- "*".repeat(7),
- );
- assert.strictEqual(
- Buffer.from("KioqKioqKio", encoding).toString(),
- "*".repeat(8),
- );
- assert.strictEqual(
- Buffer.from("KioqKioqKioqKg", encoding).toString(),
- "*".repeat(10),
- );
- assert.strictEqual(
- Buffer.from("KioqKioqKioqKio", encoding).toString(),
- "*".repeat(11),
- );
- assert.strictEqual(
- Buffer.from("KioqKioqKioqKioqKg", encoding).toString(),
- "*".repeat(13),
- );
- assert.strictEqual(
- Buffer.from("KioqKioqKioqKioqKio", encoding).toString(),
- "*".repeat(14),
- );
- assert.strictEqual(
- Buffer.from("KioqKioqKioqKioqKioqKg", encoding).toString(),
- "*".repeat(16),
- );
- assert.strictEqual(
- Buffer.from("KioqKioqKioqKioqKioqKio", encoding).toString(),
- "*".repeat(17),
- );
- assert.strictEqual(
- Buffer.from("KioqKioqKioqKioqKioqKioqKg", encoding).toString(),
- "*".repeat(19),
- );
- assert.strictEqual(
- Buffer.from("KioqKioqKioqKioqKioqKioqKio", encoding).toString(),
- "*".repeat(20),
- );
+ assert.strictEqual(Buffer.from("KioqKg", encoding).toString(), "*".repeat(4));
+ assert.strictEqual(Buffer.from("KioqKio", encoding).toString(), "*".repeat(5));
+ assert.strictEqual(Buffer.from("KioqKioqKg", encoding).toString(), "*".repeat(7));
+ assert.strictEqual(Buffer.from("KioqKioqKio", encoding).toString(), "*".repeat(8));
+ assert.strictEqual(Buffer.from("KioqKioqKioqKg", encoding).toString(), "*".repeat(10));
+ assert.strictEqual(Buffer.from("KioqKioqKioqKio", encoding).toString(), "*".repeat(11));
+ assert.strictEqual(Buffer.from("KioqKioqKioqKioqKg", encoding).toString(), "*".repeat(13));
+ assert.strictEqual(Buffer.from("KioqKioqKioqKioqKio", encoding).toString(), "*".repeat(14));
+ assert.strictEqual(Buffer.from("KioqKioqKioqKioqKioqKg", encoding).toString(), "*".repeat(16));
+ assert.strictEqual(Buffer.from("KioqKioqKioqKioqKioqKio", encoding).toString(), "*".repeat(17));
+ assert.strictEqual(Buffer.from("KioqKioqKioqKioqKioqKioqKg", encoding).toString(), "*".repeat(19));
+ assert.strictEqual(Buffer.from("KioqKioqKioqKioqKioqKioqKio", encoding).toString(), "*".repeat(20));
});
// Handle padding graciously, multiple-of-4 or not
- assert.strictEqual(
- Buffer.from("72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw==", "base64")
- .length,
- 32,
- );
- assert.strictEqual(
- Buffer.from("72INjkR5fchcxk9-VgdGPFJDxUBFR5_rMFsghgxADiw==", "base64url")
- .length,
- 32,
- );
- assert.strictEqual(
- Buffer.from("72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw=", "base64")
- .length,
- 32,
- );
- assert.strictEqual(
- Buffer.from("72INjkR5fchcxk9-VgdGPFJDxUBFR5_rMFsghgxADiw=", "base64url")
- .length,
- 32,
- );
- assert.strictEqual(
- Buffer.from("72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw", "base64").length,
- 32,
- );
- assert.strictEqual(
- Buffer.from("72INjkR5fchcxk9-VgdGPFJDxUBFR5_rMFsghgxADiw", "base64url")
- .length,
- 32,
- );
- assert.strictEqual(
- Buffer.from("w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg==", "base64")
- .length,
- 31,
- );
- assert.strictEqual(
- Buffer.from("w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg==", "base64url")
- .length,
- 31,
- );
- assert.strictEqual(
- Buffer.from("w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg=", "base64").length,
- 31,
- );
- assert.strictEqual(
- Buffer.from("w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg=", "base64url")
- .length,
- 31,
- );
- assert.strictEqual(
- Buffer.from("w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg", "base64").length,
- 31,
- );
- assert.strictEqual(
- Buffer.from("w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg", "base64url")
- .length,
- 31,
- );
+ assert.strictEqual(Buffer.from("72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw==", "base64").length, 32);
+ assert.strictEqual(Buffer.from("72INjkR5fchcxk9-VgdGPFJDxUBFR5_rMFsghgxADiw==", "base64url").length, 32);
+ assert.strictEqual(Buffer.from("72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw=", "base64").length, 32);
+ assert.strictEqual(Buffer.from("72INjkR5fchcxk9-VgdGPFJDxUBFR5_rMFsghgxADiw=", "base64url").length, 32);
+ assert.strictEqual(Buffer.from("72INjkR5fchcxk9+VgdGPFJDxUBFR5/rMFsghgxADiw", "base64").length, 32);
+ assert.strictEqual(Buffer.from("72INjkR5fchcxk9-VgdGPFJDxUBFR5_rMFsghgxADiw", "base64url").length, 32);
+ assert.strictEqual(Buffer.from("w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg==", "base64").length, 31);
+ assert.strictEqual(Buffer.from("w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg==", "base64url").length, 31);
+ assert.strictEqual(Buffer.from("w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg=", "base64").length, 31);
+ assert.strictEqual(Buffer.from("w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg=", "base64url").length, 31);
+ assert.strictEqual(Buffer.from("w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg", "base64").length, 31);
+ assert.strictEqual(Buffer.from("w69jACy6BgZmaFvv96HG6MYksWytuZu3T1FvGnulPg", "base64url").length, 31);
{
// This string encodes single '.' character in UTF-16
@@ -662,10 +488,7 @@ it("Buffer.alloc", () => {
for (let i = 0; i < segments.length; ++i) {
pos += b.write(segments[i], pos, "base64");
}
- assert.strictEqual(
- b.toString("latin1", 0, pos),
- "Madness?! This is node.js!",
- );
+ assert.strictEqual(b.toString("latin1", 0, pos), "Madness?! This is node.js!");
}
{
@@ -679,26 +502,17 @@ it("Buffer.alloc", () => {
for (let i = 0; i < segments.length; ++i) {
pos += b.write(segments[i], pos, "base64url");
}
- assert.strictEqual(
- b.toString("latin1", 0, pos),
- "Madness?! This is node.js!",
- );
+ assert.strictEqual(b.toString("latin1", 0, pos), "Madness?! This is node.js!");
}
// Regression test for https://github.com/nodejs/node/issues/3496.
assert.strictEqual(Buffer.from("=bad".repeat(1e4), "base64").length, 0);
// Regression test for https://github.com/nodejs/node/issues/11987.
- assert.deepStrictEqual(
- Buffer.from("w0 ", "base64"),
- Buffer.from("w0", "base64"),
- );
+ assert.deepStrictEqual(Buffer.from("w0 ", "base64"), Buffer.from("w0", "base64"));
// Regression test for https://github.com/nodejs/node/issues/13657.
- assert.deepStrictEqual(
- Buffer.from(" YWJvcnVtLg", "base64"),
- Buffer.from("YWJvcnVtLg", "base64"),
- );
+ assert.deepStrictEqual(Buffer.from(" YWJvcnVtLg", "base64"), Buffer.from("YWJvcnVtLg", "base64"));
{
// Creating buffers larger than pool size.
@@ -820,13 +634,13 @@ it("Buffer.alloc", () => {
assert.strictEqual(z[1], 0x6f);
}
- ["ucs2", "ucs-2", "utf16le", "utf-16le"].forEach((encoding) => {
+ ["ucs2", "ucs-2", "utf16le", "utf-16le"].forEach(encoding => {
const b = Buffer.allocUnsafe(10);
b.write("あいうえお", encoding);
assert.strictEqual(b.toString(encoding), "あいうえお");
});
- ["ucs2", "ucs-2", "utf16le", "utf-16le"].forEach((encoding) => {
+ ["ucs2", "ucs-2", "utf16le", "utf-16le"].forEach(encoding => {
const b = Buffer.allocUnsafe(11);
b.write("あいうえお", 1, encoding);
assert.strictEqual(b.toString(encoding, 1), "あいうえお");
@@ -923,7 +737,7 @@ it("Buffer.alloc", () => {
assert.strictEqual(buf[2], 0xcd);
assert.strictEqual(buf[3], 0xff);
- ["ucs2", "ucs-2", "utf16le", "utf-16le"].forEach((encoding) => {
+ ["ucs2", "ucs-2", "utf16le", "utf-16le"].forEach(encoding => {
buf.fill(0xff);
assert.strictEqual(buf.write("abcd", 0, 2, encoding), 2);
assert.strictEqual(buf[0], 0x61);
@@ -993,7 +807,7 @@ it("Buffer.alloc", () => {
assert.strictEqual(Buffer.from("13.37").length, 5);
// Ensure that the length argument is respected.
- ["ascii", "utf8", "hex", "base64", "latin1", "binary"].forEach((enc) => {
+ ["ascii", "utf8", "hex", "base64", "latin1", "binary"].forEach(enc => {
assert.strictEqual(Buffer.allocUnsafe(1).write("aaaaaa", 0, 1, enc), 1);
});
@@ -1013,24 +827,12 @@ it("Buffer.alloc", () => {
assert.throws(() => Buffer.alloc(16).writeDoubleLE(0, 9), outOfRangeError);
// Attempt to overflow buffers, similar to previous bug in array buffers
- assert.throws(
- () => Buffer.allocUnsafe(8).writeFloatLE(0.0, 0xffffffff),
- outOfRangeError,
- );
- assert.throws(
- () => Buffer.allocUnsafe(8).writeFloatLE(0.0, 0xffffffff),
- outOfRangeError,
- );
+ assert.throws(() => Buffer.allocUnsafe(8).writeFloatLE(0.0, 0xffffffff), outOfRangeError);
+ assert.throws(() => Buffer.allocUnsafe(8).writeFloatLE(0.0, 0xffffffff), outOfRangeError);
// Ensure negative values can't get past offset
- assert.throws(
- () => Buffer.allocUnsafe(8).writeFloatLE(0.0, -1),
- outOfRangeError,
- );
- assert.throws(
- () => Buffer.allocUnsafe(8).writeFloatLE(0.0, -1),
- outOfRangeError,
- );
+ assert.throws(() => Buffer.allocUnsafe(8).writeFloatLE(0.0, -1), outOfRangeError);
+ assert.throws(() => Buffer.allocUnsafe(8).writeFloatLE(0.0, -1), outOfRangeError);
// Test for common write(U)IntLE/BE
{
@@ -1173,9 +975,7 @@ it("Buffer.alloc", () => {
assert.throws(() => Buffer.allocUnsafe(10).copy(), {
code: "ERR_INVALID_ARG_TYPE",
name: "TypeError",
- message:
- 'The "target" argument must be an instance of Buffer or ' +
- "Uint8Array. Received undefined",
+ message: 'The "target" argument must be an instance of Buffer or ' + "Uint8Array. Received undefined",
});
assert.throws(() => Buffer.from(), {
@@ -1201,10 +1001,7 @@ it("Buffer.alloc", () => {
// Test that large negative Buffer length inputs don't affect the pool offset.
// Use the fromArrayLike() variant here because it's more lenient
// about its input and passes the length directly to allocate().
- assert.deepStrictEqual(
- Buffer.from({ length: -Buffer.poolSize }),
- Buffer.from(""),
- );
+ assert.deepStrictEqual(Buffer.from({ length: -Buffer.poolSize }), Buffer.from(""));
assert.deepStrictEqual(Buffer.from({ length: -100 }), Buffer.from(""));
// Check pool offset after that by trying to write string into the pool.
@@ -1244,19 +1041,10 @@ it("Buffer.alloc", () => {
// Buffer.from(arrayBuf);
// Buffer.from({ buffer: arrayBuf });
- assert.throws(
- () => Buffer.alloc({ valueOf: () => 1 }),
- /"size" argument must be of type number/,
- );
- assert.throws(
- () => Buffer.alloc({ valueOf: () => -1 }),
- /"size" argument must be of type number/,
- );
+ assert.throws(() => Buffer.alloc({ valueOf: () => 1 }), /"size" argument must be of type number/);
+ assert.throws(() => Buffer.alloc({ valueOf: () => -1 }), /"size" argument must be of type number/);
- assert.strictEqual(
- Buffer.prototype.toLocaleString,
- Buffer.prototype.toString,
- );
+ assert.strictEqual(Buffer.prototype.toLocaleString, Buffer.prototype.toString);
{
const buf = Buffer.from("test");
assert.strictEqual(buf.toLocaleString(), buf.toString());
@@ -1324,9 +1112,7 @@ it("buffer", () => {
gc();
expect(buf.toString("utf8", 0, "hello world ".length)).toBe("hello world ");
gc();
- expect(buf.toString("base64url", 0, "hello world ".length)).toBe(
- btoa("hello world "),
- );
+ expect(buf.toString("base64url", 0, "hello world ".length)).toBe(btoa("hello world "));
gc();
expect(buf instanceof Uint8Array).toBe(true);
gc();
@@ -1344,12 +1130,8 @@ it("buffer", () => {
});
it("Buffer", () => {
- var inputs = [
- "hello world",
- "hello world".repeat(100),
- `😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌`,
- ];
- var good = inputs.map((a) => new TextEncoder().encode(a));
+ var inputs = ["hello world", "hello world".repeat(100), `😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌`];
+ var good = inputs.map(a => new TextEncoder().encode(a));
for (let i = 0; i < inputs.length; i++) {
var input = inputs[i];
expect(new Buffer(input).toString("utf8")).toBe(inputs[i]);
@@ -1415,12 +1197,8 @@ it("writeInt", () => {
it("Buffer.from", () => {
expect(Buffer.from("hello world").toString("utf8")).toBe("hello world");
- expect(Buffer.from("hello world", "ascii").toString("utf8")).toBe(
- "hello world",
- );
- expect(Buffer.from("hello world", "latin1").toString("utf8")).toBe(
- "hello world",
- );
+ expect(Buffer.from("hello world", "ascii").toString("utf8")).toBe("hello world");
+ expect(Buffer.from("hello world", "latin1").toString("utf8")).toBe("hello world");
gc();
expect(Buffer.from([254]).join(",")).toBe("254");
@@ -1433,17 +1211,11 @@ it("Buffer.from", () => {
expect(() => Buffer.from(123).join(",")).toThrow();
- expect(Buffer.from({ length: 124 }).join(",")).toBe(
- Uint8Array.from({ length: 124 }).join(","),
- );
+ expect(Buffer.from({ length: 124 }).join(",")).toBe(Uint8Array.from({ length: 124 }).join(","));
- expect(Buffer.from(new ArrayBuffer(1024), 0, 512).join(",")).toBe(
- new Uint8Array(512).join(","),
- );
+ expect(Buffer.from(new ArrayBuffer(1024), 0, 512).join(",")).toBe(new Uint8Array(512).join(","));
- expect(Buffer.from(new Buffer(new ArrayBuffer(1024), 0, 512)).join(",")).toBe(
- new Uint8Array(512).join(","),
- );
+ expect(Buffer.from(new Buffer(new ArrayBuffer(1024), 0, 512)).join(",")).toBe(new Uint8Array(512).join(","));
gc();
});
@@ -1532,15 +1304,10 @@ it("Buffer.compare", () => {
{
const buf = Buffer.from([
- 1, 29, 0, 0, 1, 143, 216, 162, 92, 254, 248, 63, 0, 0, 0, 18, 184, 6, 0,
- 175, 29, 0, 8, 11, 1, 0, 0,
- ]);
- const chunk1 = Buffer.from([
- 1, 29, 0, 0, 1, 143, 216, 162, 92, 254, 248, 63, 0,
- ]);
- const chunk2 = Buffer.from([
- 0, 0, 18, 184, 6, 0, 175, 29, 0, 8, 11, 1, 0, 0,
+ 1, 29, 0, 0, 1, 143, 216, 162, 92, 254, 248, 63, 0, 0, 0, 18, 184, 6, 0, 175, 29, 0, 8, 11, 1, 0, 0,
]);
+ const chunk1 = Buffer.from([1, 29, 0, 0, 1, 143, 216, 162, 92, 254, 248, 63, 0]);
+ const chunk2 = Buffer.from([0, 0, 18, 184, 6, 0, 175, 29, 0, 8, 11, 1, 0, 0]);
const middle = buf.length / 2;
expect(JSON.stringify(buf.slice(0, middle))).toBe(JSON.stringify(chunk1));
@@ -1604,12 +1371,7 @@ export function fillRepeating(dstBuffer, start, end) {
}
describe("Buffer.fill string", () => {
- for (let text of [
- "hello world",
- "1234567890",
- "\uD83D\uDE00",
- "😀😃😄😁😆😅😂🤣☺️😊😊😇",
- ]) {
+ for (let text of ["hello world", "1234567890", "\uD83D\uDE00", "😀😃😄😁😆😅😂🤣☺️😊😊😇"]) {
it(text, () => {
var input = new Buffer(1024);
input.fill(text);
@@ -1642,16 +1404,10 @@ it("Buffer.concat", () => {
var array3 = new Uint8Array(128);
array3.fill(300);
gc();
- expect(Buffer.concat([array1, array2, array3]).join("")).toBe(
- array1.join("") + array2.join("") + array3.join(""),
- );
+ expect(Buffer.concat([array1, array2, array3]).join("")).toBe(array1.join("") + array2.join("") + array3.join(""));
expect(Buffer.concat([array1, array2, array3], 222).length).toBe(222);
- expect(
- Buffer.concat([array1, array2, array3], 222).subarray(0, 128).join(""),
- ).toBe("100".repeat(128));
- expect(
- Buffer.concat([array1, array2, array3], 222).subarray(129, 222).join(""),
- ).toBe("200".repeat(222 - 129));
+ expect(Buffer.concat([array1, array2, array3], 222).subarray(0, 128).join("")).toBe("100".repeat(128));
+ expect(Buffer.concat([array1, array2, array3], 222).subarray(129, 222).join("")).toBe("200".repeat(222 - 129));
});
it("read", () => {
@@ -1751,21 +1507,11 @@ it("write long utf16 string works", () => {
expect(buf.toString("utf16le", offset, offset + 20)).toBe("😀😃😄😁😆");
expect(buf.toString("utf16le", offset, offset + 24)).toBe("😀😃😄😁😆😅");
expect(buf.toString("utf16le", offset, offset + 28)).toBe("😀😃😄😁😆😅😂");
- expect(buf.toString("utf16le", offset, offset + 32)).toBe(
- "😀😃😄😁😆😅😂🤣",
- );
- expect(buf.toString("utf16le", offset, offset + 36)).toBe(
- "😀😃😄😁😆😅😂🤣☺️",
- );
- expect(buf.toString("utf16le", offset, offset + 40)).toBe(
- "😀😃😄😁😆😅😂🤣☺️😊",
- );
- expect(buf.toString("utf16le", offset, offset + 44)).toBe(
- "😀😃😄😁😆😅😂🤣☺️😊😊",
- );
- expect(buf.toString("utf16le", offset, offset + 48)).toBe(
- "😀😃😄😁😆😅😂🤣☺️😊😊😇",
- );
+ expect(buf.toString("utf16le", offset, offset + 32)).toBe("😀😃😄😁😆😅😂🤣");
+ expect(buf.toString("utf16le", offset, offset + 36)).toBe("😀😃😄😁😆😅😂🤣☺️");
+ expect(buf.toString("utf16le", offset, offset + 40)).toBe("😀😃😄😁😆😅😂🤣☺️😊");
+ expect(buf.toString("utf16le", offset, offset + 44)).toBe("😀😃😄😁😆😅😂🤣☺️😊😊");
+ expect(buf.toString("utf16le", offset, offset + 48)).toBe("😀😃😄😁😆😅😂🤣☺️😊😊😇");
}
});
@@ -1788,21 +1534,11 @@ it("write", () => {
}
// utf8, ucs2, ascii, latin1, utf16le
- const encodings = [
- "utf8",
- "utf-8",
- "ucs2",
- "ucs-2",
- "ascii",
- "latin1",
- "binary",
- "utf16le",
- "utf-16le",
- ];
+ const encodings = ["utf8", "utf-8", "ucs2", "ucs-2", "ascii", "latin1", "binary", "utf16le", "utf-16le"];
encodings
.reduce((es, e) => es.concat(e, e.toUpperCase()), [])
- .forEach((encoding) => {
+ .forEach(encoding => {
reset();
const len = Buffer.byteLength("foo", encoding);
@@ -1814,7 +1550,7 @@ it("write", () => {
});
// base64
- ["base64", "BASE64", "base64url", "BASE64URL"].forEach((encoding) => {
+ ["base64", "BASE64", "base64url", "BASE64URL"].forEach(encoding => {
reset();
const len = Buffer.byteLength("Zm9v", encoding);
@@ -1824,7 +1560,7 @@ it("write", () => {
});
// hex
- ["hex", "HEX"].forEach((encoding) => {
+ ["hex", "HEX"].forEach(encoding => {
reset();
const len = Buffer.byteLength("666f6f", encoding);
@@ -1962,9 +1698,7 @@ it("Buffer.from(base64)", () => {
const buf = Buffer.from("aGVsbG8gd29ybGQ=", "base64");
expect(buf.toString()).toBe("hello world");
- expect(
- Buffer.from(btoa('console.log("hello world")\n'), "base64").toString(),
- ).toBe('console.log("hello world")\n');
+ expect(Buffer.from(btoa('console.log("hello world")\n'), "base64").toString()).toBe('console.log("hello world")\n');
});
it("Buffer.swap16", () => {
@@ -2050,15 +1784,11 @@ it("Buffer.toString regessions", () => {
Buffer.from([65, 0])
.toString("utf16le")
.split("")
- .map((x) => x.charCodeAt(0)),
+ .map(x => x.charCodeAt(0)),
).toEqual([65]);
expect(Buffer.from([65, 0]).toString("base64")).toBe("QQA=");
- expect(
- Buffer.from('{"alg":"RS256","typ":"JWT"}', "latin1").toString("latin1"),
- ).toBe('{"alg":"RS256","typ":"JWT"}');
- expect(
- Buffer.from('{"alg":"RS256","typ":"JWT"}', "utf8").toString("utf8"),
- ).toBe('{"alg":"RS256","typ":"JWT"}');
+ expect(Buffer.from('{"alg":"RS256","typ":"JWT"}', "latin1").toString("latin1")).toBe('{"alg":"RS256","typ":"JWT"}');
+ expect(Buffer.from('{"alg":"RS256","typ":"JWT"}', "utf8").toString("utf8")).toBe('{"alg":"RS256","typ":"JWT"}');
});
it("Buffer.toString(utf16le)", () => {
@@ -2079,9 +1809,7 @@ it("Buffer.toString(base64)", () => {
}
{
- expect(Buffer.from(`console.log("hello world")\n`).toString("base64")).toBe(
- btoa('console.log("hello world")\n'),
- );
+ expect(Buffer.from(`console.log("hello world")\n`).toString("base64")).toBe(btoa('console.log("hello world")\n'));
}
});
@@ -2177,7 +1905,7 @@ it("Buffer.from (Node.js test/test-buffer-from.js)", () => {
(one, two, three) => {},
undefined,
null,
- ].forEach((input) => {
+ ].forEach(input => {
expect(() => Buffer.from(input)).toThrow();
expect(() => Buffer.from(input, "hex")).toThrow();
});
@@ -2484,7 +2212,7 @@ it("Buffer.fill (Node.js tests)", () => {
["", -1],
["", 0, buf1.length + 1],
["", 1, -1],
- ].forEach((args) => {
+ ].forEach(args => {
expect(() => buf1.fill(...args)).toThrow();
});
@@ -2493,7 +2221,7 @@ it("Buffer.fill (Node.js tests)", () => {
[
["a", 0, 0, NaN],
["a", 0, 0, false],
- ].forEach((args) => {
+ ].forEach(args => {
expect(() => buf1.fill(...args)).toThrow();
});
@@ -2543,8 +2271,7 @@ it("Buffer.fill (Node.js tests)", () => {
offset += written;
// Safety check in case write falls into infinite loop.
if (written === 0) {
- if (wasZero)
- throw new Error("Could not write all data to Buffer at " + offset);
+ if (wasZero) throw new Error("Could not write all data to Buffer at " + offset);
else wasZero = true;
}
} while (offset < buf2.length);
@@ -2556,9 +2283,7 @@ it("Buffer.fill (Node.js tests)", () => {
bufReset();
buf1.fill.apply(buf1, arguments);
// Swap bytes on BE archs for ucs2 encoding.
- expect(buf1.fill.apply(buf1, arguments)).toStrictEqual(
- writeToFill.apply(null, arguments),
- );
+ expect(buf1.fill.apply(buf1, arguments)).toStrictEqual(writeToFill.apply(null, arguments));
}
// Make sure these throw.
@@ -2575,8 +2300,7 @@ it("Buffer.fill (Node.js tests)", () => {
buf.fill(11, 0, buf.length >> 1);
for (let i = 0; i < buf.length >> 1; i++) assertEqual(buf[i], 11);
- for (let i = (buf.length >> 1) + 1; i < buf.length; i++)
- assertEqual(buf[i], 10);
+ for (let i = (buf.length >> 1) + 1; i < buf.length; i++) assertEqual(buf[i], 10);
buf.fill("h");
for (let i = 0; i < buf.length; i++) assertEqual(buf[i], "h".charCodeAt(0));
@@ -2641,50 +2365,20 @@ it("Buffer.fill (Node.js tests)", () => {
buf.fill("");
}).toThrow();
- assertEqual(
- Buffer.allocUnsafeSlow(16).fill("ab", "utf16le"),
- Buffer.from("61006200610062006100620061006200", "hex"),
- );
+ assertEqual(Buffer.allocUnsafeSlow(16).fill("ab", "utf16le"), Buffer.from("61006200610062006100620061006200", "hex"));
- assertEqual(
- Buffer.allocUnsafeSlow(15).fill("ab", "utf16le"),
- Buffer.from("610062006100620061006200610062", "hex"),
- );
+ assertEqual(Buffer.allocUnsafeSlow(15).fill("ab", "utf16le"), Buffer.from("610062006100620061006200610062", "hex"));
- assertEqual(
- Buffer.allocUnsafeSlow(16).fill("ab", "utf16le"),
- Buffer.from("61006200610062006100620061006200", "hex"),
- );
- assertEqual(
- Buffer.allocUnsafeSlow(16).fill("a", "utf16le"),
- Buffer.from("61006100610061006100610061006100", "hex"),
- );
+ assertEqual(Buffer.allocUnsafeSlow(16).fill("ab", "utf16le"), Buffer.from("61006200610062006100620061006200", "hex"));
+ assertEqual(Buffer.allocUnsafeSlow(16).fill("a", "utf16le"), Buffer.from("61006100610061006100610061006100", "hex"));
- assertEqual(
- Buffer.allocUnsafeSlow(16).fill("a", "utf16le").toString("utf16le"),
- "a".repeat(8),
- );
- assertEqual(
- Buffer.allocUnsafeSlow(16).fill("a", "latin1").toString("latin1"),
- "a".repeat(16),
- );
- assertEqual(
- Buffer.allocUnsafeSlow(16).fill("a", "utf8").toString("utf8"),
- "a".repeat(16),
- );
+ assertEqual(Buffer.allocUnsafeSlow(16).fill("a", "utf16le").toString("utf16le"), "a".repeat(8));
+ assertEqual(Buffer.allocUnsafeSlow(16).fill("a", "latin1").toString("latin1"), "a".repeat(16));
+ assertEqual(Buffer.allocUnsafeSlow(16).fill("a", "utf8").toString("utf8"), "a".repeat(16));
- assertEqual(
- Buffer.allocUnsafeSlow(16).fill("Љ", "utf16le").toString("utf16le"),
- "Љ".repeat(8),
- );
- assertEqual(
- Buffer.allocUnsafeSlow(16).fill("Љ", "latin1").toString("latin1"),
- "\t".repeat(16),
- );
- assertEqual(
- Buffer.allocUnsafeSlow(16).fill("Љ", "utf8").toString("utf8"),
- "Љ".repeat(8),
- );
+ assertEqual(Buffer.allocUnsafeSlow(16).fill("Љ", "utf16le").toString("utf16le"), "Љ".repeat(8));
+ assertEqual(Buffer.allocUnsafeSlow(16).fill("Љ", "latin1").toString("latin1"), "\t".repeat(16));
+ assertEqual(Buffer.allocUnsafeSlow(16).fill("Љ", "utf8").toString("utf8"), "Љ".repeat(8));
expect(() => {
const buf = Buffer.from("a".repeat(1000));
@@ -2696,7 +2390,7 @@ it("Buffer.fill (Node.js tests)", () => {
test("Buffer.byteLength", () => {
const SlowBuffer = require("buffer").SlowBuffer;
- [[32, "latin1"], [NaN, "utf8"], [{}, "latin1"], []].forEach((args) => {
+ [[32, "latin1"], [NaN, "utf8"], [{}, "latin1"], []].forEach(args => {
assert.throws(() => Buffer.byteLength(...args));
});
@@ -2765,19 +2459,13 @@ test("Buffer.byteLength", () => {
assert.strictEqual(Buffer.byteLength("aGVsbG8gd29ybGQ=", "BASE64"), 11);
assert.strictEqual(Buffer.byteLength("bm9kZS5qcyByb2NrcyE=", "base64"), 14);
assert.strictEqual(Buffer.byteLength("aGkk", "base64"), 3);
- assert.strictEqual(
- Buffer.byteLength("bHNrZGZsa3NqZmtsc2xrZmFqc2RsZmtqcw==", "base64"),
- 25,
- );
+ assert.strictEqual(Buffer.byteLength("bHNrZGZsa3NqZmtsc2xrZmFqc2RsZmtqcw==", "base64"), 25);
// base64url
assert.strictEqual(Buffer.byteLength("aGVsbG8gd29ybGQ", "base64url"), 11);
assert.strictEqual(Buffer.byteLength("aGVsbG8gd29ybGQ", "BASE64URL"), 11);
assert.strictEqual(Buffer.byteLength("bm9kZS5qcyByb2NrcyE", "base64url"), 14);
assert.strictEqual(Buffer.byteLength("aGkk", "base64url"), 3);
- assert.strictEqual(
- Buffer.byteLength("bHNrZGZsa3NqZmtsc2xrZmFqc2RsZmtqcw", "base64url"),
- 25,
- );
+ assert.strictEqual(Buffer.byteLength("bHNrZGZsa3NqZmtsc2xrZmFqc2RsZmtqcw", "base64url"), 25);
// special padding
assert.strictEqual(Buffer.byteLength("aaa=", "base64"), 2);
assert.strictEqual(Buffer.byteLength("aaaa==", "base64"), 3);
@@ -2788,13 +2476,13 @@ test("Buffer.byteLength", () => {
["ascii", "latin1", "binary"]
.reduce((es, e) => es.concat(e, e.toUpperCase()), [])
- .forEach((encoding) => {
+ .forEach(encoding => {
assert.strictEqual(Buffer.byteLength("Il était tué", encoding), 12);
});
["ucs2", "ucs-2", "utf16le", "utf-16le"]
.reduce((es, e) => es.concat(e, e.toUpperCase()), [])
- .forEach((encoding) => {
+ .forEach(encoding => {
assert.strictEqual(Buffer.byteLength("Il était tué", encoding), 24);
});
@@ -2807,15 +2495,12 @@ test("Buffer.byteLength", () => {
const encoding = String(i).repeat(i);
assert.ok(!Buffer.isEncoding(encoding));
- assert.strictEqual(
- Buffer.byteLength("foo", encoding),
- Buffer.byteLength("foo", "utf8"),
- );
+ assert.strictEqual(Buffer.byteLength("foo", encoding), Buffer.byteLength("foo", "utf8"));
}
});
it("should not crash on invalid UTF-8 byte sequence", () => {
- const buf = Buffer.from([0xC0, 0xFD]).toString();
+ const buf = Buffer.from([0xc0, 0xfd]).toString();
expect(buf.length).toBe(2);
const str = buf.toString();
expect(str.length).toBe(2);
diff --git a/test/bun.js/bufferlist.test.ts b/test/bun.js/bufferlist.test.ts
index c533ae21c..b8a5443ea 100644
--- a/test/bun.js/bufferlist.test.ts
+++ b/test/bun.js/bufferlist.test.ts
@@ -2,9 +2,11 @@ import { Readable } from "stream";
import { it, expect } from "bun:test";
function makeUint8Array(str) {
- return new Uint8Array([].map.call(str, function(ch) {
- return ch.charCodeAt(0);
- }));
+ return new Uint8Array(
+ [].map.call(str, function (ch) {
+ return ch.charCodeAt(0);
+ }),
+ );
}
it("should work with .clear()", () => {
@@ -23,13 +25,10 @@ it("should work with .concat()", () => {
expect(list.length).toBe(0);
expect(list.push(makeUint8Array("foo"))).toBeUndefined();
expect(list.length).toBe(1);
- expect(list.concat(3)).toEqual(new Uint8Array([ 102, 111, 111 ]));
+ expect(list.concat(3)).toEqual(new Uint8Array([102, 111, 111]));
expect(list.push(makeUint8Array("bar"))).toBeUndefined();
expect(list.length).toBe(2);
- expect(list.concat(10)).toEqual(new Uint8Array([
- 102, 111, 111, 98, 97,
- 114, 0, 0, 0, 0,
- ]));
+ expect(list.concat(10)).toEqual(new Uint8Array([102, 111, 111, 98, 97, 114, 0, 0, 0, 0]));
});
it("should fail on .concat() with invalid items", () => {
@@ -90,10 +89,7 @@ it("should work with .consume() on buffers", () => {
expect(list.length).toBe(4);
expect(list.consume(4, false)).toEqual(makeUint8Array("rbaz"));
expect(list.length).toBe(2);
- expect(list.consume(10, false)).toEqual(new Uint8Array([
- 109, 111, 111, 109, 111,
- 122, 0, 0, 0, 0,
- ]));
+ expect(list.consume(10, false)).toEqual(new Uint8Array([109, 111, 111, 109, 111, 122, 0, 0, 0, 0]));
expect(list.length).toBe(0);
});
@@ -114,7 +110,7 @@ it("should fail on .consume() with invalid items", () => {
expect(() => {
list.consume(1, true);
}).toThrow(TypeError);
- expect(list.consume(3, false)).toEqual(new Uint8Array([ 98, 97, 114 ]));
+ expect(list.consume(3, false)).toEqual(new Uint8Array([98, 97, 114]));
});
it("should work with .first()", () => {
@@ -216,16 +212,10 @@ it("should work with partial .consume() followed by .unshift()", () => {
expect(list.push(makeUint8Array("😋😋😋"))).toBeUndefined();
expect(list.push(makeUint8Array("📋📋📋"))).toBeUndefined();
expect(list.length).toBe(2);
- expect(list.consume(7, false)).toEqual(new Uint8Array([
- 61, 11, 61, 11, 61, 11,
- 61,
- ]));
+ expect(list.consume(7, false)).toEqual(new Uint8Array([61, 11, 61, 11, 61, 11, 61]));
expect(list.length).toBe(1);
expect(list.unshift(makeUint8Array("👌👌👌"))).toBeUndefined();
expect(list.length).toBe(2);
- expect(list.consume(12, false)).toEqual(new Uint8Array([
- 61, 76, 61, 76, 61, 76,
- 203, 61, 203, 61, 203, 0,
- ]));
+ expect(list.consume(12, false)).toEqual(new Uint8Array([61, 76, 61, 76, 61, 76, 203, 61, 203, 61, 203, 0]));
expect(list.length).toBe(0);
});
diff --git a/test/bun.js/bun-test/jest-hooks.test.ts b/test/bun.js/bun-test/jest-hooks.test.ts
index 4675acb07..c99dc7759 100644
--- a/test/bun.js/bun-test/jest-hooks.test.ts
+++ b/test/bun.js/bun-test/jest-hooks.test.ts
@@ -1,12 +1,4 @@
-import {
- afterAll,
- afterEach,
- beforeAll,
- beforeEach,
- describe,
- expect,
- it,
-} from "bun:test";
+import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from "bun:test";
describe("test jest hooks in bun-test", () => {
describe("test beforeAll hook", () => {
diff --git a/test/bun.js/bun-test/nested-describes.test.ts b/test/bun.js/bun-test/nested-describes.test.ts
index de7ba194e..636714fdc 100644
--- a/test/bun.js/bun-test/nested-describes.test.ts
+++ b/test/bun.js/bun-test/nested-describes.test.ts
@@ -1,8 +1,4 @@
-import {
-describe,
-expect,
-test,
-} from "bun:test";
+import { describe, expect, test } from "bun:test";
/*
In this test we want the tests to print out the following on a success.
@@ -16,23 +12,23 @@ Each success / fail should show the path of describe and test scopes
*/
describe("outer most describe", () => {
- describe("mid describe 1", () => {
- describe("inner most describe 1", () => {
- test("first", () => {
- expect(5).toEqual(5);
- })
- })
- describe("inner most describe 2", () => {
- test("second", () => {
- expect(5).toEqual(5);
- })
- })
- })
- describe("mid describe 2", () => {
- describe("inner most describe 3", () => {
- test("third", () => {
- expect(5).toEqual(5);
- })
- })
- })
-})
+ describe("mid describe 1", () => {
+ describe("inner most describe 1", () => {
+ test("first", () => {
+ expect(5).toEqual(5);
+ });
+ });
+ describe("inner most describe 2", () => {
+ test("second", () => {
+ expect(5).toEqual(5);
+ });
+ });
+ });
+ describe("mid describe 2", () => {
+ describe("inner most describe 3", () => {
+ test("third", () => {
+ expect(5).toEqual(5);
+ });
+ });
+ });
+});
diff --git a/test/bun.js/bun-write.test.js b/test/bun.js/bun-write.test.js
index 0abc4faaf..7e1d43059 100644
--- a/test/bun.js/bun-write.test.js
+++ b/test/bun.js/bun-write.test.js
@@ -4,26 +4,17 @@ import path from "path";
import { gcTick, withoutAggressiveGC } from "./gc";
it("Bun.write blob", async () => {
- await Bun.write(
- Bun.file("/tmp/response-file.test.txt"),
- Bun.file(path.join(import.meta.dir, "fetch.js.txt")),
- );
+ await Bun.write(Bun.file("/tmp/response-file.test.txt"), Bun.file(path.join(import.meta.dir, "fetch.js.txt")));
await gcTick();
await Bun.write(Bun.file("/tmp/response-file.test.txt"), "blah blah blha");
await gcTick();
- await Bun.write(
- Bun.file("/tmp/response-file.test.txt"),
- new Uint32Array(1024),
- );
+ await Bun.write(Bun.file("/tmp/response-file.test.txt"), new Uint32Array(1024));
await gcTick();
await Bun.write("/tmp/response-file.test.txt", new Uint32Array(1024));
await gcTick();
- expect(
- await Bun.write(
- new TextEncoder().encode("/tmp/response-file.test.txt"),
- new Uint32Array(1024),
- ),
- ).toBe(new Uint32Array(1024).byteLength);
+ expect(await Bun.write(new TextEncoder().encode("/tmp/response-file.test.txt"), new Uint32Array(1024))).toBe(
+ new Uint32Array(1024).byteLength,
+ );
await gcTick();
});
@@ -31,9 +22,7 @@ describe("large file", () => {
const fixtures = [
[
`/tmp/bun-test-large-file-${Date.now()}.txt`,
- "https://www.iana.org/assignments/media-types/media-types.xhtml,".repeat(
- 10000,
- ),
+ "https://www.iana.org/assignments/media-types/media-types.xhtml,".repeat(10000),
],
];
@@ -57,11 +46,7 @@ describe("large file", () => {
var bytes = new TextEncoder().encode(content);
const written = await Bun.write(filename + ".bytes", bytes);
expect(written).toBe(bytes.byteLength);
- expect(
- new Buffer(await Bun.file(filename + ".bytes").arrayBuffer()).equals(
- bytes,
- ),
- ).toBe(true);
+ expect(new Buffer(await Bun.file(filename + ".bytes").arrayBuffer()).equals(bytes)).toBe(true);
try {
unlinkSync(filename + ".bytes");
@@ -128,23 +113,15 @@ it("Bun.file -> Bun.file", async () => {
fs.writeFileSync("/tmp/fetch.js.in", text);
await gcTick();
{
- const result = await Bun.write(
- Bun.file("/tmp/fetch.js.out"),
- Bun.file("/tmp/fetch.js.in"),
- );
+ const result = await Bun.write(Bun.file("/tmp/fetch.js.out"), Bun.file("/tmp/fetch.js.in"));
await gcTick();
expect(await Bun.file("/tmp/fetch.js.out").text()).toBe(text);
await gcTick();
}
{
- await Bun.write(
- Bun.file("/tmp/fetch.js.in").slice(0, (text.length / 2) | 0),
- Bun.file("/tmp/fetch.js.out"),
- );
- expect(await Bun.file("/tmp/fetch.js.in").text()).toBe(
- text.substring(0, (text.length / 2) | 0),
- );
+ await Bun.write(Bun.file("/tmp/fetch.js.in").slice(0, (text.length / 2) | 0), Bun.file("/tmp/fetch.js.out"));
+ expect(await Bun.file("/tmp/fetch.js.in").text()).toBe(text.substring(0, (text.length / 2) | 0));
}
{
@@ -197,7 +174,7 @@ it("Bun.file as a Blob", async () => {
expect(blob.size).toBe(fixture.length);
blob = null;
await gcTick();
- await new Promise((resolve) => setTimeout(resolve, 1));
+ await new Promise(resolve => setTimeout(resolve, 1));
var blob = Bun.file(filePath);
expect(blob.size).toBe(fixture.length);
});
@@ -262,26 +239,16 @@ it("Bun.write(Bun.stderr, 'Bun.write STDERR TEST')", async () => {
});
it("Bun.write(Bun.stdout, new TextEncoder().encode('Bun.write STDOUT TEST'))", async () => {
- expect(
- await Bun.write(
- Bun.stdout,
- new TextEncoder().encode("\nBun.write STDOUT TEST\n\n"),
- ),
- ).toBe(24);
+ expect(await Bun.write(Bun.stdout, new TextEncoder().encode("\nBun.write STDOUT TEST\n\n"))).toBe(24);
});
it("Bun.write(Bun.stderr, 'new TextEncoder().encode(Bun.write STDERR TEST'))", async () => {
- expect(
- await Bun.write(
- Bun.stderr,
- new TextEncoder().encode("\nBun.write STDERR TEST\n\n"),
- ),
- ).toBe(24);
+ expect(await Bun.write(Bun.stderr, new TextEncoder().encode("\nBun.write STDERR TEST\n\n"))).toBe(24);
});
// FLAKY TEST
// Since Bun.file is resolved lazily, this needs to specifically be checked
-it.skip("Bun.write('output.html', HTMLRewriter.transform(Bun.file)))", async (done) => {
+it.skip("Bun.write('output.html', HTMLRewriter.transform(Bun.file)))", async done => {
var rewriter = new HTMLRewriter();
rewriter.on("div", {
@@ -294,8 +261,6 @@ it.skip("Bun.write('output.html', HTMLRewriter.transform(Bun.file)))", async (do
var output = rewriter.transform(input);
const outpath = `/tmp/html-rewriter.${Date.now()}.html`;
await Bun.write(outpath, output);
- expect(await Bun.file(outpath).text()).toBe(
- "<div><blink>it worked!</blink></div>",
- );
+ expect(await Bun.file(outpath).text()).toBe("<div><blink>it worked!</blink></div>");
done();
});
diff --git a/test/bun.js/child-process-stdio.test.js b/test/bun.js/child-process-stdio.test.js
index 5e295b2ca..8542ce588 100644
--- a/test/bun.js/child-process-stdio.test.js
+++ b/test/bun.js/child-process-stdio.test.js
@@ -6,10 +6,10 @@ const CHILD_PROCESS_FILE = import.meta.dir + "/spawned-child.js";
const OUT_FILE = import.meta.dir + "/stdio-test-out.txt";
describe("process.stdout", () => {
- it("should allow us to write to it", (done) => {
+ it("should allow us to write to it", done => {
const child = spawn(bunExe(), [CHILD_PROCESS_FILE, "STDOUT"]);
child.stdout.setEncoding("utf8");
- child.stdout.on("data", (data) => {
+ child.stdout.on("data", data => {
try {
expect(data).toBe("stdout_test");
done();
@@ -21,80 +21,83 @@ describe("process.stdout", () => {
});
describe("process.stdin", () => {
- it("should allow us to read from stdin in readable mode", (done) => {
+ it("should allow us to read from stdin in readable mode", done => {
const input = "hello\n";
// Child should read from stdin and write it back
const child = spawn(bunExe(), [CHILD_PROCESS_FILE, "STDIN", "READABLE"]);
let data = "";
child.stdout.setEncoding("utf8");
- child.stdout.on("data", (chunk) => {
- data += chunk;
- }).on("end", function() {
- try {
- expect(data).toBe(`data: ${input}`);
- done();
- } catch (err) {
- done(err);
- }
- });
+ child.stdout
+ .on("data", chunk => {
+ data += chunk;
+ })
+ .on("end", function () {
+ try {
+ expect(data).toBe(`data: ${input}`);
+ done();
+ } catch (err) {
+ done(err);
+ }
+ });
child.stdin.write(input);
child.stdin.end();
});
- it("should allow us to read from stdin via flowing mode", (done) => {
+ it("should allow us to read from stdin via flowing mode", done => {
const input = "hello\n";
// Child should read from stdin and write it back
const child = spawn(bunExe(), [CHILD_PROCESS_FILE, "STDIN", "FLOWING"]);
let data = "";
child.stdout.setEncoding("utf8");
- child.stdout.on("readable", () => {
- let chunk;
- while ((chunk = child.stdout.read()) !== null) {
- data += chunk;
- }
- }).on("end", function() {
- try {
- expect(data).toBe(`data: ${input}`);
- done();
- } catch (err) {
- done(err);
- }
- });
+ child.stdout
+ .on("readable", () => {
+ let chunk;
+ while ((chunk = child.stdout.read()) !== null) {
+ data += chunk;
+ }
+ })
+ .on("end", function () {
+ try {
+ expect(data).toBe(`data: ${input}`);
+ done();
+ } catch (err) {
+ done(err);
+ }
+ });
child.stdin.write(input);
child.stdin.end();
});
- it("should allow us to read > 65kb from stdin", (done) => {
+ it("should allow us to read > 65kb from stdin", done => {
const numReps = Math.ceil((66 * 1024) / 5);
const input = "hello".repeat(numReps);
// Child should read from stdin and write it back
const child = spawn(bunExe(), [CHILD_PROCESS_FILE, "STDIN", "FLOWING"]);
let data = "";
child.stdout.setEncoding("utf8");
- child.stdout.on("readable", () => {
- let chunk;
- while ((chunk = child.stdout.read()) !== null) {
- data += chunk;
- }
- }).on("end", function() {
- try {
- expect(data).toBe(`data: ${input}`);
- done();
- } catch (err) {
- done(err);
- }
- });
+ child.stdout
+ .on("readable", () => {
+ let chunk;
+ while ((chunk = child.stdout.read()) !== null) {
+ data += chunk;
+ }
+ })
+ .on("end", function () {
+ try {
+ expect(data).toBe(`data: ${input}`);
+ done();
+ } catch (err) {
+ done(err);
+ }
+ });
child.stdin.write(input);
child.stdin.end();
});
it("should allow us to read from a file", () => {
- const result = execSync(
- `${bunExe()} ${CHILD_PROCESS_FILE} STDIN FLOWING < ${
- import.meta.dir
- }/readFileSync.txt`,
- { encoding: "utf8" },
- );
+ const result = execSync(`${bunExe()} ${CHILD_PROCESS_FILE} STDIN FLOWING < ${import.meta.dir}/readFileSync.txt`, {
+ encoding: "utf8",
+ });
expect(result).toEqual("data: File read successfully");
});
});
diff --git a/test/bun.js/child_process-node.test.js b/test/bun.js/child_process-node.test.js
index 63bb8470a..f2c18c67c 100644
--- a/test/bun.js/child_process-node.test.js
+++ b/test/bun.js/child_process-node.test.js
@@ -1,11 +1,6 @@
import { beforeAll, describe, expect, it } from "bun:test";
import { ChildProcess, spawn, exec } from "node:child_process";
-import {
- throws,
- assert,
- createCallCheckCtx,
- createDoneDotAll,
-} from "node-test-helpers";
+import { throws, assert, createCallCheckCtx, createDoneDotAll } from "node-test-helpers";
import { tmpdir } from "node:os";
import { gcTick } from "gc";
const strictEqual = (a, b) => expect(a).toStrictEqual(b);
@@ -53,7 +48,7 @@ describe("ChildProcess.spawn()", () => {
// Verify that invalid options to spawn() throw.
const child = new ChildProcess();
- [undefined, null, "foo", 0, 1, NaN, true, false].forEach((options) => {
+ [undefined, null, "foo", 0, 1, NaN, true, false].forEach(options => {
throws(
() => {
child.spawn(options);
@@ -72,7 +67,7 @@ describe("ChildProcess.spawn()", () => {
it("should throw if file is not a string", () => {
// Verify that spawn throws if file is not a string.
const child = new ChildProcess();
- [undefined, null, 0, 1, NaN, true, false, {}].forEach((file) => {
+ [undefined, null, 0, 1, NaN, true, false, {}].forEach(file => {
throws(
() => {
child.spawn({ file });
@@ -92,7 +87,7 @@ describe("ChildProcess.spawn()", () => {
// Verify that spawn throws if envPairs is not an array or undefined.
const child = new ChildProcess();
- [null, 0, 1, NaN, true, false, {}, "foo"].forEach((envPairs) => {
+ [null, 0, 1, NaN, true, false, {}, "foo"].forEach(envPairs => {
throws(
() => {
child.spawn({
@@ -115,7 +110,7 @@ describe("ChildProcess.spawn()", () => {
// Verify that spawn throws if args is not an array or undefined.
const child = new ChildProcess();
- [null, 0, 1, NaN, true, false, {}, "foo"].forEach((args) => {
+ [null, 0, 1, NaN, true, false, {}, "foo"].forEach(args => {
throws(
() => {
child.spawn({ file: "foo", args });
@@ -189,7 +184,7 @@ describe("ChildProcess spawn bad stdio", () => {
return child;
}
- it("should handle normal execution of child process", (done) => {
+ it("should handle normal execution of child process", done => {
createChild(
{},
(err, stdout, stderr) => {
@@ -201,10 +196,8 @@ describe("ChildProcess spawn bad stdio", () => {
);
});
- it("should handle error event of child process", (done) => {
- const error = new Error(
- `Command failed: bun ${import.meta.dir}/spawned-child.js ERROR`,
- );
+ it("should handle error event of child process", done => {
+ const error = new Error(`Command failed: bun ${import.meta.dir}/spawned-child.js ERROR`);
createChild(
{},
(err, stdout, stderr) => {
@@ -217,7 +210,7 @@ describe("ChildProcess spawn bad stdio", () => {
);
});
- it("should handle killed process", (done) => {
+ it("should handle killed process", done => {
createChild(
{ timeout: 1 },
(err, stdout, stderr) => {
@@ -235,11 +228,7 @@ describe("child_process cwd", () => {
// - whether the child pid is undefined or number,
// - whether the exit code equals expectCode,
// - optionally whether the trimmed stdout result matches expectData
- function testCwd(
- options,
- { expectPidType, expectCode = 0, expectData },
- done = () => {},
- ) {
+ function testCwd(options, { expectPidType, expectCode = 0, expectData }, done = () => {}) {
const createDone = createDoneDotAll(done);
const { mustCall } = createCallCheckCtx(createDone(1500));
const exitDone = createDone(5000);
@@ -252,7 +241,7 @@ describe("child_process cwd", () => {
// No need to assert callback since `data` is asserted.
let data = "";
- child.stdout.on("data", (chunk) => {
+ child.stdout.on("data", chunk => {
data += chunk;
});
@@ -318,7 +307,7 @@ describe("child_process cwd", () => {
// // }
// });
- it("should work for valid given cwd", (done) => {
+ it("should work for valid given cwd", done => {
const tmpdir = { path: platformTmpDir };
const createDone = createDoneDotAll(done);
@@ -353,7 +342,7 @@ describe("child_process cwd", () => {
);
});
- it.skip("shouldn't try to chdir to an invalid cwd", (done) => {
+ it.skip("shouldn't try to chdir to an invalid cwd", done => {
const createDone = createDoneDotAll(done);
// Spawn() shouldn't try to chdir() to invalid arg, so this should just work
testCwd({ cwd: "" }, { expectPidType: "number" }, createDone(1500));
@@ -363,14 +352,14 @@ describe("child_process cwd", () => {
});
describe("child_process default options", () => {
- it("should use process.env as default env", (done) => {
+ it("should use process.env as default env", done => {
globalThis.process.env.TMPDIR = platformTmpDir;
let child = spawn("printenv", [], {});
let response = "";
child.stdout.setEncoding("utf8");
- child.stdout.on("data", (chunk) => {
+ child.stdout.on("data", chunk => {
debug(`stdout: ${chunk}`);
response += chunk;
});
@@ -385,10 +374,10 @@ describe("child_process default options", () => {
});
describe("child_process double pipe", () => {
- it("should allow two pipes to be used at once", (done) => {
+ it("should allow two pipes to be used at once", done => {
// const { mustCallAtLeast, mustCall } = createCallCheckCtx(done);
- const mustCallAtLeast = (fn) => fn;
- const mustCall = (fn) => fn;
+ const mustCallAtLeast = fn => fn;
+ const mustCall = fn => fn;
let grep, sed, echo;
grep = spawn("grep", ["o"], { stdio: ["pipe", "pipe", "pipe"] });
sed = spawn("sed", ["s/o/O/"]);
@@ -397,7 +386,7 @@ describe("child_process double pipe", () => {
// pipe grep | sed
grep.stdout.on(
"data",
- mustCallAtLeast((data) => {
+ mustCallAtLeast(data => {
debug(`grep stdout ${data.length}`);
if (!sed.stdin.write(data)) {
grep.stdout.pause();
@@ -408,7 +397,7 @@ describe("child_process double pipe", () => {
// print sed's output
sed.stdout.on(
"data",
- mustCallAtLeast((data) => {
+ mustCallAtLeast(data => {
result += data.toString("utf8");
debug(data);
}),
@@ -416,7 +405,7 @@ describe("child_process double pipe", () => {
echo.stdout.on(
"data",
- mustCallAtLeast((data) => {
+ mustCallAtLeast(data => {
debug(`grep stdin write ${data.length}`);
if (!grep.stdin.write(data)) {
debug("echo stdout pause");
diff --git a/test/bun.js/child_process.test.ts b/test/bun.js/child_process.test.ts
index 6fe5bf996..7c1315baf 100644
--- a/test/bun.js/child_process.test.ts
+++ b/test/bun.js/child_process.test.ts
@@ -1,15 +1,6 @@
import { describe, it as it_, expect as expect_ } from "bun:test";
import { gcTick } from "gc";
-import {
- ChildProcess,
- spawn,
- execFile,
- exec,
- fork,
- spawnSync,
- execFileSync,
- execSync,
-} from "node:child_process";
+import { ChildProcess, spawn, execFile, exec, fork, spawnSync, execFileSync, execSync } from "node:child_process";
import { tmpdir } from "node:os";
const expect: typeof expect_ = (actual: unknown) => {
@@ -22,13 +13,13 @@ const expect: typeof expect_ = (actual: unknown) => {
const it: typeof it_ = (label, fn) => {
const hasDone = fn.length === 1;
if (fn.constructor.name === "AsyncFunction" && hasDone) {
- return it_(label, async (done) => {
+ return it_(label, async done => {
gcTick();
await fn(done);
gcTick();
});
} else if (hasDone) {
- return it_(label, (done) => {
+ return it_(label, done => {
gcTick();
fn(done);
gcTick();
@@ -60,7 +51,7 @@ const SEMVER_REGEX =
describe("ChildProcess.spawn()", () => {
it("should emit `spawn` on spawn", async () => {
const proc = new ChildProcess();
- const result = await new Promise((resolve) => {
+ const result = await new Promise(resolve => {
proc.on("spawn", () => {
resolve(true);
});
@@ -71,7 +62,7 @@ describe("ChildProcess.spawn()", () => {
it("should emit `exit` when killed", async () => {
const proc = new ChildProcess();
- const result = await new Promise((resolve) => {
+ const result = await new Promise(resolve => {
proc.on("exit", () => {
resolve(true);
});
@@ -104,26 +95,26 @@ describe("spawn()", () => {
it("should allow stdout to be read via Node stream.Readable `data` events", async () => {
const child = spawn("bun", ["-v"]);
- const result: string = await new Promise((resolve) => {
- child.stdout.on("error", (e) => {
+ const result: string = await new Promise(resolve => {
+ child.stdout.on("error", e => {
console.error(e);
});
- child.stdout.on("data", (data) => {
+ child.stdout.on("data", data => {
debug(`stdout: ${data}`);
resolve(data.toString());
});
- child.stderr.on("data", (data) => {
+ child.stderr.on("data", data => {
debug(`stderr: ${data}`);
});
});
expect(SEMVER_REGEX.test(result.trim())).toBe(true);
});
- it("should allow stdout to be read via .read() API", async (done) => {
+ it("should allow stdout to be read via .read() API", async done => {
const child = spawn("bun", ["-v"]);
- const result: string = await new Promise((resolve) => {
+ const result: string = await new Promise(resolve => {
let finalData = "";
- child.stdout.on("error", (e) => {
+ child.stdout.on("error", e => {
done(e);
});
child.stdout.on("readable", () => {
@@ -160,8 +151,8 @@ describe("spawn()", () => {
it("should allow us to set cwd", async () => {
const child = spawn("pwd", { cwd: platformTmpDir });
- const result: string = await new Promise((resolve) => {
- child.stdout.on("data", (data) => {
+ const result: string = await new Promise(resolve => {
+ child.stdout.on("data", data => {
resolve(data.toString());
});
});
@@ -170,9 +161,9 @@ describe("spawn()", () => {
it("should allow us to write to stdin", async () => {
const child = spawn("tee");
- const result: string = await new Promise((resolve) => {
+ const result: string = await new Promise(resolve => {
child.stdin.write("hello");
- child.stdout.on("data", (data) => {
+ child.stdout.on("data", data => {
resolve(data.toString());
});
});
@@ -183,7 +174,7 @@ describe("spawn()", () => {
const child = spawn("sleep", ["2"], { timeout: 3 });
const start = performance.now();
let end;
- await new Promise((resolve) => {
+ await new Promise(resolve => {
child.on("exit", () => {
end = performance.now();
resolve(true);
@@ -194,8 +185,8 @@ describe("spawn()", () => {
it("should allow us to set env", async () => {
const child = spawn("env", { env: { TEST: "test" } });
- const result: string = await new Promise((resolve) => {
- child.stdout.on("data", (data) => {
+ const result: string = await new Promise(resolve => {
+ child.stdout.on("data", data => {
resolve(data.toString());
});
});
@@ -204,7 +195,7 @@ describe("spawn()", () => {
it("should allow explicit setting of argv0", async () => {
var resolve;
- const promise = new Promise<string>((resolve1) => {
+ const promise = new Promise<string>(resolve1 => {
resolve = resolve1;
});
process.env.NO_COLOR = "1";
@@ -212,7 +203,7 @@ describe("spawn()", () => {
delete process.env.NO_COLOR;
let msg = "";
- child.stdout.on("data", (data) => {
+ child.stdout.on("data", data => {
msg += data.toString();
});
@@ -225,15 +216,15 @@ describe("spawn()", () => {
});
it("should allow us to spawn in a shell", async () => {
- const result1: string = await new Promise((resolve) => {
+ const result1: string = await new Promise(resolve => {
const child1 = spawn("echo", ["$0"], { shell: true });
- child1.stdout.on("data", (data) => {
+ child1.stdout.on("data", data => {
resolve(data.toString());
});
});
- const result2: string = await new Promise((resolve) => {
+ const result2: string = await new Promise(resolve => {
const child2 = spawn("echo", ["$0"], { shell: "bash" });
- child2.stdout.on("data", (data) => {
+ child2.stdout.on("data", data => {
resolve(data.toString());
});
});
@@ -249,17 +240,12 @@ describe("spawn()", () => {
describe("execFile()", () => {
it("should execute a file", async () => {
const result: Buffer = await new Promise((resolve, reject) => {
- execFile(
- "bun",
- ["-v"],
- { encoding: "buffer" },
- (error, stdout, stderr) => {
- if (error) {
- reject(error);
- }
- resolve(stdout);
- },
- );
+ execFile("bun", ["-v"], { encoding: "buffer" }, (error, stdout, stderr) => {
+ if (error) {
+ reject(error);
+ }
+ resolve(stdout);
+ });
});
expect(SEMVER_REGEX.test(result.toString().trim())).toBe(true);
});
@@ -305,14 +291,10 @@ describe("execFileSync()", () => {
});
it("should allow us to pass input to the command", () => {
- const result = execFileSync(
- "node",
- [import.meta.dir + "/spawned-child.js", "STDIN"],
- {
- input: "hello world!",
- encoding: "utf8",
- },
- );
+ const result = execFileSync("node", [import.meta.dir + "/spawned-child.js", "STDIN"], {
+ input: "hello world!",
+ encoding: "utf8",
+ });
expect(result.trim()).toBe("data: hello world!");
});
});
@@ -336,10 +318,10 @@ describe("Bun.spawn()", () => {
expect(text.trim()).toBe("hello");
}
- const result = await new Promise((resolve) => {
+ const result = await new Promise(resolve => {
const maybeExited = Bun.peek(proc.exited);
if (maybeExited === proc.exited) {
- proc.exited.then((code) => resolve(code));
+ proc.exited.then(code => resolve(code));
} else {
resolve(maybeExited);
}
diff --git a/test/bun.js/concat.test.js b/test/bun.js/concat.test.js
index 35cec4f8b..36421cab6 100644
--- a/test/bun.js/concat.test.js
+++ b/test/bun.js/concat.test.js
@@ -27,20 +27,18 @@ describe("concat", () => {
}
it("works with one element", () => {
- expect(concatToString([new Uint8Array([123])])).toBe(
- polyfillToString([new Uint8Array([123])]),
- );
+ expect(concatToString([new Uint8Array([123])])).toBe(polyfillToString([new Uint8Array([123])]));
});
it("works with two elements", () => {
- expect(
- concatToString([Uint8Array.from([123]), Uint8Array.from([456])]),
- ).toBe(polyfillToString([Uint8Array.from([123]), Uint8Array.from([456])]));
+ expect(concatToString([Uint8Array.from([123]), Uint8Array.from([456])])).toBe(
+ polyfillToString([Uint8Array.from([123]), Uint8Array.from([456])]),
+ );
});
it("works with mix of ArrayBuffer and TypedArray elements", () => {
- expect(
- concatToString([Uint8Array.from([123]).buffer, Uint8Array.from([456])]),
- ).toBe(polyfillToString([Uint8Array.from([123]), Uint8Array.from([456])]));
+ expect(concatToString([Uint8Array.from([123]).buffer, Uint8Array.from([456])])).toBe(
+ polyfillToString([Uint8Array.from([123]), Uint8Array.from([456])]),
+ );
});
});
diff --git a/test/bun.js/console/console-iterator.test.js b/test/bun.js/console/console-iterator.test.js
index 533f084e1..053e4382d 100644
--- a/test/bun.js/console/console-iterator.test.js
+++ b/test/bun.js/console/console-iterator.test.js
@@ -51,14 +51,12 @@ describe("should work for streaming input", () => {
const { stdout, stdin } = proc;
stdin.write(input.slice(0, (input.length / 2) | 0));
stdin.flush();
- await new Promise((resolve) => setTimeout(resolve, 1));
+ await new Promise(resolve => setTimeout(resolve, 1));
stdin.write(input.slice((input.length / 2) | 0));
stdin.flush();
stdin.end();
- expect(await new Response(stdout).text()).toBe(
- input.replaceAll("\n", ""),
- );
+ expect(await new Response(stdout).text()).toBe(input.replaceAll("\n", ""));
proc.kill(0);
});
}
diff --git a/test/bun.js/console/console-log.js b/test/bun.js/console/console-log.js
index c22303371..5468c1c98 100644
--- a/test/bun.js/console/console-log.js
+++ b/test/bun.js/console/console-log.js
@@ -36,20 +36,10 @@ console.log(/FooRegex/);
console.error("uh oh");
console.time("Check");
-console.log(
- "Is it a bug or a feature that formatting numbers like %d is colored",
- 123,
-);
+console.log("Is it a bug or a feature that formatting numbers like %d is colored", 123);
//console.log(globalThis);
-console.log(
- "String %s should be 2nd word, 456 == %s and percent s %s == %s",
- "123",
- "456",
- "%s",
- "What",
- "okay",
-);
+console.log("String %s should be 2nd word, 456 == %s and percent s %s == %s", "123", "456", "%s", "What", "okay");
const infinteLoop = {
foo: {
diff --git a/test/bun.js/console/console-log.test.ts b/test/bun.js/console/console-log.test.ts
index 1365e174d..7fd9c79e5 100644
--- a/test/bun.js/console/console-log.test.ts
+++ b/test/bun.js/console/console-log.test.ts
@@ -14,5 +14,7 @@ it("should log to console correctly", async () => {
});
expect(await exited).toBe(0);
expect(await new Response(stderr).text()).toBe("uh oh\n");
- expect(await new Response(stdout).text()).toBe(await new Response(file(import.meta.dir + "/console-log.expected.txt")).text());
+ expect(await new Response(stdout).text()).toBe(
+ await new Response(file(import.meta.dir + "/console-log.expected.txt")).text(),
+ );
});
diff --git a/test/bun.js/crypto-scrypt.test.js b/test/bun.js/crypto-scrypt.test.js
index 4b9f632c0..e188e9fae 100644
--- a/test/bun.js/crypto-scrypt.test.js
+++ b/test/bun.js/crypto-scrypt.test.js
@@ -185,10 +185,7 @@ it("scrypt bad", () => {
const expected = {
message: /Invalid scrypt param/,
};
- assert.throws(
- () => crypto.scryptSync("pass", "salt", 1, options),
- expected,
- );
+ assert.throws(() => crypto.scryptSync("pass", "salt", 1, options), expected);
}
});
@@ -197,10 +194,7 @@ it("scrypt toobig", () => {
const expected = {
message: /Invalid scrypt param/,
};
- assert.throws(
- () => crypto.scryptSync("pass", "salt", 1, options),
- expected,
- );
+ assert.throws(() => crypto.scryptSync("pass", "salt", 1, options), expected);
}
});
diff --git a/test/bun.js/crypto.test.js b/test/bun.js/crypto.test.js
index 8b93dab64..b5b8e9286 100644
--- a/test/bun.js/crypto.test.js
+++ b/test/bun.js/crypto.test.js
@@ -1,29 +1,8 @@
-import {
- sha,
- MD5,
- MD4,
- SHA1,
- SHA224,
- SHA256,
- SHA384,
- SHA512,
- SHA512_256,
- gc,
- CryptoHasher,
-} from "bun";
+import { sha, MD5, MD4, SHA1, SHA224, SHA256, SHA384, SHA512, SHA512_256, gc, CryptoHasher } from "bun";
import { it, expect, describe } from "bun:test";
import { readFileSync } from "fs";
-const HashClasses = [
- MD5,
- MD4,
- SHA1,
- SHA224,
- SHA256,
- SHA384,
- SHA512,
- SHA512_256,
-];
+const HashClasses = [MD5, MD4, SHA1, SHA224, SHA256, SHA384, SHA512, SHA512_256];
describe("CryptoHasher", () => {
it("CryptoHasher.algorithms", () => {
diff --git a/test/bun.js/decorators.test.ts b/test/bun.js/decorators.test.ts
index e132f3ed0..134ae73ac 100644
--- a/test/bun.js/decorators.test.ts
+++ b/test/bun.js/decorators.test.ts
@@ -260,13 +260,7 @@ test("parameter decorators", () => {
this.y = y;
}
- constructor(
- one: number,
- two: string,
- three: boolean,
- @d1 @d2 width: number,
- @d3 height: number,
- ) {
+ constructor(one: number, two: string, three: boolean, @d1 @d2 width: number, @d3 height: number) {
this.width = width;
this.height = height;
}
@@ -334,11 +328,7 @@ test("parameter decorators", () => {
}
class Maybe {
- constructor(
- @m1 private x: number,
- @m2 public y: boolean,
- @m3 protected z: string,
- ) {}
+ constructor(@m1 private x: number, @m2 public y: boolean, @m3 protected z: string) {}
}
function m1(target, propertyKey, index) {
@@ -384,7 +374,7 @@ test("decorators random", () => {
const getter = () => {
return val;
};
- const setter = (next) => {
+ const setter = next => {
val = `🍦 ${next} 🍦`;
};
@@ -545,7 +535,7 @@ test("decorators random", () => {
const getter = () => {
return val;
};
- const setter = (value) => {
+ const setter = value => {
val = `${value} ${emoji}`;
};
@@ -921,11 +911,7 @@ describe("constructor statements", () => {
class A {
l: number;
- constructor(
- protected u: string,
- @d1 l: number = 3,
- @d2 public k: number = 4,
- ) {
+ constructor(protected u: string, @d1 l: number = 3, @d2 public k: number = 4) {
this.l = l;
}
}
diff --git a/test/bun.js/esbuild-child_process.test.ts b/test/bun.js/esbuild-child_process.test.ts
index d64786602..9c0daa523 100644
--- a/test/bun.js/esbuild-child_process.test.ts
+++ b/test/bun.js/esbuild-child_process.test.ts
@@ -3,14 +3,11 @@ import { describe, it, expect, test } from "bun:test";
import { bunExe } from "bunExe";
test("esbuild", () => {
- const { exitCode, stderr, stdout } = spawnSync(
- [bunExe(), import.meta.dir + "/esbuild-test.js"],
- {
- env: {
- BUN_DEBUG_QUIET_LOGS: "1",
- },
+ const { exitCode, stderr, stdout } = spawnSync([bunExe(), import.meta.dir + "/esbuild-test.js"], {
+ env: {
+ BUN_DEBUG_QUIET_LOGS: "1",
},
- );
+ });
const out = "" + stderr?.toString() + stdout?.toString();
if (exitCode !== 0 && out?.length) {
throw new Error(out);
diff --git a/test/bun.js/escapeHTML.test.js b/test/bun.js/escapeHTML.test.js
index af119c6e3..f96849a84 100644
--- a/test/bun.js/escapeHTML.test.js
+++ b/test/bun.js/escapeHTML.test.js
@@ -13,12 +13,8 @@ describe("escapeHTML", () => {
// 7. Works when the text to escape is in the end
// 8. Returns the same string when there's no need to escape
it("works", () => {
- expect(escapeHTML("absolutely nothing to do here")).toBe(
- "absolutely nothing to do here",
- );
- expect(escapeHTML("<script>alert(1)</script>")).toBe(
- "&lt;script&gt;alert(1)&lt;/script&gt;",
- );
+ expect(escapeHTML("absolutely nothing to do here")).toBe("absolutely nothing to do here");
+ expect(escapeHTML("<script>alert(1)</script>")).toBe("&lt;script&gt;alert(1)&lt;/script&gt;");
expect(escapeHTML("<")).toBe("&lt;");
expect(escapeHTML(">")).toBe("&gt;");
expect(escapeHTML("&")).toBe("&amp;");
@@ -39,64 +35,46 @@ describe("escapeHTML", () => {
"lalala&lt;script&gt;alert(1)&lt;/script&gt;lalala",
);
- expect(escapeHTML("<script>alert(1)</script>" + "lalala")).toBe(
- "&lt;script&gt;alert(1)&lt;/script&gt;lalala",
- );
- expect(escapeHTML("lalala" + "<script>alert(1)</script>")).toBe(
- "lalala" + "&lt;script&gt;alert(1)&lt;/script&gt;",
- );
+ expect(escapeHTML("<script>alert(1)</script>" + "lalala")).toBe("&lt;script&gt;alert(1)&lt;/script&gt;lalala");
+ expect(escapeHTML("lalala" + "<script>alert(1)</script>")).toBe("lalala" + "&lt;script&gt;alert(1)&lt;/script&gt;");
expect(escapeHTML("What does 😊 mean?")).toBe("What does 😊 mean?");
const output = escapeHTML("<What does 😊");
expect(output).toBe("&lt;What does 😊");
- expect(escapeHTML("<div>What does 😊 mean in text?")).toBe(
- "&lt;div&gt;What does 😊 mean in text?",
- );
+ expect(escapeHTML("<div>What does 😊 mean in text?")).toBe("&lt;div&gt;What does 😊 mean in text?");
- expect(
- escapeHTML(
- ("lalala" + "<script>alert(1)</script>" + "lalala").repeat(900),
- ),
- ).toBe("lalala&lt;script&gt;alert(1)&lt;/script&gt;lalala".repeat(900));
- expect(
- escapeHTML(("<script>alert(1)</script>" + "lalala").repeat(900)),
- ).toBe("&lt;script&gt;alert(1)&lt;/script&gt;lalala".repeat(900));
- expect(
- escapeHTML(("lalala" + "<script>alert(1)</script>").repeat(900)),
- ).toBe(("lalala" + "&lt;script&gt;alert(1)&lt;/script&gt;").repeat(900));
+ expect(escapeHTML(("lalala" + "<script>alert(1)</script>" + "lalala").repeat(900))).toBe(
+ "lalala&lt;script&gt;alert(1)&lt;/script&gt;lalala".repeat(900),
+ );
+ expect(escapeHTML(("<script>alert(1)</script>" + "lalala").repeat(900))).toBe(
+ "&lt;script&gt;alert(1)&lt;/script&gt;lalala".repeat(900),
+ );
+ expect(escapeHTML(("lalala" + "<script>alert(1)</script>").repeat(900))).toBe(
+ ("lalala" + "&lt;script&gt;alert(1)&lt;/script&gt;").repeat(900),
+ );
// the positions of the unicode codepoint are important
// our simd code for U16 is at 8 bytes, so we need to especially check the boundaries
- expect(
- escapeHTML("😊lalala" + "<script>alert(1)</script>" + "lalala"),
- ).toBe("😊lalala&lt;script&gt;alert(1)&lt;/script&gt;lalala");
- expect(escapeHTML("<script>😊alert(1)</script>" + "lalala")).toBe(
- "&lt;script&gt;😊alert(1)&lt;/script&gt;lalala",
- );
- expect(escapeHTML("<script>alert(1)😊</script>" + "lalala")).toBe(
- "&lt;script&gt;alert(1)😊&lt;/script&gt;lalala",
- );
- expect(escapeHTML("<script>alert(1)</script>" + "😊lalala")).toBe(
- "&lt;script&gt;alert(1)&lt;/script&gt;😊lalala",
+ expect(escapeHTML("😊lalala" + "<script>alert(1)</script>" + "lalala")).toBe(
+ "😊lalala&lt;script&gt;alert(1)&lt;/script&gt;lalala",
);
- expect(escapeHTML("<script>alert(1)</script>" + "lal😊ala")).toBe(
- "&lt;script&gt;alert(1)&lt;/script&gt;lal😊ala",
+ expect(escapeHTML("<script>😊alert(1)</script>" + "lalala")).toBe("&lt;script&gt;😊alert(1)&lt;/script&gt;lalala");
+ expect(escapeHTML("<script>alert(1)😊</script>" + "lalala")).toBe("&lt;script&gt;alert(1)😊&lt;/script&gt;lalala");
+ expect(escapeHTML("<script>alert(1)</script>" + "😊lalala")).toBe("&lt;script&gt;alert(1)&lt;/script&gt;😊lalala");
+ expect(escapeHTML("<script>alert(1)</script>" + "lal😊ala")).toBe("&lt;script&gt;alert(1)&lt;/script&gt;lal😊ala");
+ expect(escapeHTML("<script>alert(1)</script>" + "lal😊ala".repeat(10))).toBe(
+ "&lt;script&gt;alert(1)&lt;/script&gt;" + "lal😊ala".repeat(10),
);
- expect(
- escapeHTML("<script>alert(1)</script>" + "lal😊ala".repeat(10)),
- ).toBe("&lt;script&gt;alert(1)&lt;/script&gt;" + "lal😊ala".repeat(10));
for (let i = 1; i < 10; i++)
expect(escapeHTML("<script>alert(1)</script>" + "la😊".repeat(i))).toBe(
"&lt;script&gt;alert(1)&lt;/script&gt;" + "la😊".repeat(i),
);
- expect(escapeHTML("la😊" + "<script>alert(1)</script>")).toBe(
- "la😊" + "&lt;script&gt;alert(1)&lt;/script&gt;",
+ expect(escapeHTML("la😊" + "<script>alert(1)</script>")).toBe("la😊" + "&lt;script&gt;alert(1)&lt;/script&gt;");
+ expect(escapeHTML(("lalala" + "<script>alert(1)</script>😊").repeat(1))).toBe(
+ ("lalala" + "&lt;script&gt;alert(1)&lt;/script&gt;😊").repeat(1),
);
- expect(
- escapeHTML(("lalala" + "<script>alert(1)</script>😊").repeat(1)),
- ).toBe(("lalala" + "&lt;script&gt;alert(1)&lt;/script&gt;😊").repeat(1));
expect(escapeHTML("😊".repeat(100))).toBe("😊".repeat(100));
expect(escapeHTML("😊<".repeat(100))).toBe("😊&lt;".repeat(100));
diff --git a/test/bun.js/event-emitter.test.ts b/test/bun.js/event-emitter.test.ts
index 4e586cea4..cd1eaeaf2 100644
--- a/test/bun.js/event-emitter.test.ts
+++ b/test/bun.js/event-emitter.test.ts
@@ -3,10 +3,7 @@ import fs from "node:fs";
// this is also testing that imports with default and named imports in the same statement work
// our transpiler transform changes this to a var with import.meta.require
-import EventEmitter, {
- getEventListeners,
- captureRejectionSymbol,
-} from "node:events";
+import EventEmitter, { getEventListeners, captureRejectionSymbol } from "node:events";
import { heapStats } from "bun:jsc";
describe("EventEmitter", () => {
@@ -42,7 +39,7 @@ describe("EventEmitter", () => {
});
// These are also tests for the done() function in the test runner.
- test("EventEmitter emit (different tick)", (done) => {
+ test("EventEmitter emit (different tick)", done => {
var emitter = new EventEmitter();
emitter.on("wow", () => done());
queueMicrotask(() => {
@@ -51,21 +48,21 @@ describe("EventEmitter", () => {
});
// Unlike Jest, bun supports async and done
- test("async EventEmitter emit (microtask)", async (done) => {
+ test("async EventEmitter emit (microtask)", async done => {
await 1;
var emitter = new EventEmitter();
emitter.on("wow", () => done());
emitter.emit("wow");
});
- test("async EventEmitter emit (microtask) after", async (done) => {
+ test("async EventEmitter emit (microtask) after", async done => {
var emitter = new EventEmitter();
emitter.on("wow", () => done());
await 1;
emitter.emit("wow");
});
- test("EventEmitter emit (same tick)", (done) => {
+ test("EventEmitter emit (same tick)", done => {
var emitter = new EventEmitter();
emitter.on("wow", () => done());
@@ -73,7 +70,7 @@ describe("EventEmitter", () => {
emitter.emit("wow");
});
- test("EventEmitter emit (setTimeout task)", (done) => {
+ test("EventEmitter emit (setTimeout task)", done => {
var emitter = new EventEmitter();
emitter.on("wow", () => done());
setTimeout(() => emitter.emit("wow"), 1);
@@ -117,11 +114,7 @@ const waysOfCreating = [
];
for (let create of waysOfCreating) {
- it(`${create
- .toString()
- .slice(10, 40)
- .replaceAll("\n", "\\n")
- .trim()} should work`, () => {
+ it(`${create.toString().slice(10, 40).replaceAll("\n", "\\n").trim()} should work`, () => {
var myEmitter = create();
var called = false;
myEmitter.once("event", function () {
@@ -161,10 +154,7 @@ test("EventEmitter GCs", () => {
EventEmitter.call(this);
}
- Object.setPrototypeOf(
- EventEmitterSubclass.prototype,
- EventEmitter.prototype,
- );
+ Object.setPrototypeOf(EventEmitterSubclass.prototype, EventEmitter.prototype);
Object.setPrototypeOf(EventEmitterSubclass, EventEmitter);
var myEmitter = new EventEmitterSubclass();
diff --git a/test/bun.js/exit-code.test.ts b/test/bun.js/exit-code.test.ts
index b7d91f8e9..5f1aab904 100644
--- a/test/bun.js/exit-code.test.ts
+++ b/test/bun.js/exit-code.test.ts
@@ -3,33 +3,21 @@ import { bunExe } from "bunExe";
import { spawnSync } from "bun";
it("process.exit(1) works", () => {
- const { exitCode } = spawnSync([
- bunExe(),
- import.meta.dir + "/exit-code-1.js",
- ]);
+ const { exitCode } = spawnSync([bunExe(), import.meta.dir + "/exit-code-1.js"]);
expect(exitCode).toBe(1);
});
it("await on a thrown value reports exit code 1", () => {
- const { exitCode } = spawnSync([
- bunExe(),
- import.meta.dir + "/exit-code-await-throw-1.js",
- ]);
+ const { exitCode } = spawnSync([bunExe(), import.meta.dir + "/exit-code-await-throw-1.js"]);
expect(exitCode).toBe(1);
});
it("unhandled promise rejection reports exit code 1", () => {
- const { exitCode } = spawnSync([
- bunExe(),
- import.meta.dir + "/exit-code-unhandled-throw.js",
- ]);
+ const { exitCode } = spawnSync([bunExe(), import.meta.dir + "/exit-code-unhandled-throw.js"]);
expect(exitCode).toBe(1);
});
it("process.exit(0) works", () => {
- const { exitCode } = spawnSync([
- bunExe(),
- import.meta.dir + "/exit-code-0.js",
- ]);
+ const { exitCode } = spawnSync([bunExe(), import.meta.dir + "/exit-code-0.js"]);
expect(exitCode).toBe(0);
});
diff --git a/test/bun.js/fetch-gzip.test.ts b/test/bun.js/fetch-gzip.test.ts
index bdfc48f53..eee841375 100644
--- a/test/bun.js/fetch-gzip.test.ts
+++ b/test/bun.js/fetch-gzip.test.ts
@@ -9,31 +9,23 @@ it("fetch() with a buffered gzip response works (one chunk)", async () => {
async fetch(req) {
gcTick(true);
- return new Response(
- require("fs").readFileSync(import.meta.dir + "/fixture.html.gz"),
- {
- headers: {
- "Content-Encoding": "gzip",
- "Content-Type": "text/html; charset=utf-8",
- },
+ return new Response(require("fs").readFileSync(import.meta.dir + "/fixture.html.gz"), {
+ headers: {
+ "Content-Encoding": "gzip",
+ "Content-Type": "text/html; charset=utf-8",
},
- );
+ });
},
});
gcTick(true);
- const res = await fetch(
- `http://${server.hostname}:${server.port}`,
- { verbose: true },
- );
+ const res = await fetch(`http://${server.hostname}:${server.port}`, { verbose: true });
gcTick(true);
const arrayBuffer = await res.arrayBuffer();
const clone = new Buffer(arrayBuffer);
gcTick(true);
await (async function () {
- const second = new Buffer(
- await Bun.file(import.meta.dir + "/fixture.html").arrayBuffer(),
- );
+ const second = new Buffer(await Bun.file(import.meta.dir + "/fixture.html").arrayBuffer());
gcTick(true);
expect(second.equals(clone)).toBe(true);
})();
@@ -47,31 +39,21 @@ it("fetch() with a redirect that returns a buffered gzip response works (one chu
async fetch(req) {
if (req.url.endsWith("/redirect"))
- return new Response(
- await Bun.file(import.meta.dir + "/fixture.html.gz").arrayBuffer(),
- {
- headers: {
- "Content-Encoding": "gzip",
- "Content-Type": "text/html; charset=utf-8",
- },
+ return new Response(await Bun.file(import.meta.dir + "/fixture.html.gz").arrayBuffer(), {
+ headers: {
+ "Content-Encoding": "gzip",
+ "Content-Type": "text/html; charset=utf-8",
},
- );
+ });
return Response.redirect("/redirect");
},
});
- const res = await fetch(
- `http://${server.hostname}:${server.port}/hey`,
- { verbose: true },
- );
+ const res = await fetch(`http://${server.hostname}:${server.port}/hey`, { verbose: true });
const arrayBuffer = await res.arrayBuffer();
expect(
- new Buffer(arrayBuffer).equals(
- new Buffer(
- await Bun.file(import.meta.dir + "/fixture.html").arrayBuffer(),
- ),
- ),
+ new Buffer(arrayBuffer).equals(new Buffer(await Bun.file(import.meta.dir + "/fixture.html").arrayBuffer())),
).toBe(true);
server.stop();
});
@@ -82,34 +64,24 @@ it("fetch() with a protocol-relative redirect that returns a buffered gzip respo
async fetch(req, server) {
if (req.url.endsWith("/redirect"))
- return new Response(
- await Bun.file(import.meta.dir + "/fixture.html.gz").arrayBuffer(),
- {
- headers: {
- "Content-Encoding": "gzip",
- "Content-Type": "text/html; charset=utf-8",
- },
+ return new Response(await Bun.file(import.meta.dir + "/fixture.html.gz").arrayBuffer(), {
+ headers: {
+ "Content-Encoding": "gzip",
+ "Content-Type": "text/html; charset=utf-8",
},
- );
+ });
return Response.redirect(`://${server.hostname}:${server.port}/redirect`);
},
});
- const res = await fetch(
- `http://${server.hostname}:${server.port}/hey`,
- { verbose: true },
- );
+ const res = await fetch(`http://${server.hostname}:${server.port}/hey`, { verbose: true });
expect(res.url).toBe(`http://${server.hostname}:${server.port}/redirect`);
expect(res.redirected).toBe(true);
expect(res.status).toBe(200);
const arrayBuffer = await res.arrayBuffer();
expect(
- new Buffer(arrayBuffer).equals(
- new Buffer(
- await Bun.file(import.meta.dir + "/fixture.html").arrayBuffer(),
- ),
- ),
+ new Buffer(arrayBuffer).equals(new Buffer(await Bun.file(import.meta.dir + "/fixture.html").arrayBuffer())),
).toBe(true);
server.stop();
@@ -126,9 +98,7 @@ it("fetch() with a gzip response works (one chunk, streamed, with a delay", asyn
async pull(controller) {
await 2;
- const buffer = await Bun.file(
- import.meta.dir + "/fixture.html.gz",
- ).arrayBuffer();
+ const buffer = await Bun.file(import.meta.dir + "/fixture.html.gz").arrayBuffer();
controller.write(buffer);
controller.close();
},
@@ -147,19 +117,13 @@ it("fetch() with a gzip response works (one chunk, streamed, with a delay", asyn
const res = await fetch(`http://${server.hostname}:${server.port}`, {});
const arrayBuffer = await res.arrayBuffer();
expect(
- new Buffer(arrayBuffer).equals(
- new Buffer(
- await Bun.file(import.meta.dir + "/fixture.html").arrayBuffer(),
- ),
- ),
+ new Buffer(arrayBuffer).equals(new Buffer(await Bun.file(import.meta.dir + "/fixture.html").arrayBuffer())),
).toBe(true);
server.stop();
});
-it("fetch() with a gzip response works (multiple chunks, TCP server", async (done) => {
- const compressed = await Bun.file(
- import.meta.dir + "/fixture.html.gz",
- ).arrayBuffer();
+it("fetch() with a gzip response works (multiple chunks, TCP server", async done => {
+ const compressed = await Bun.file(import.meta.dir + "/fixture.html.gz").arrayBuffer();
var socketToClose;
const server = Bun.listen({
port: 4024,
@@ -209,11 +173,7 @@ it("fetch() with a gzip response works (multiple chunks, TCP server", async (don
const res = await fetch(`http://${server.hostname}:${server.port}`, {});
const arrayBuffer = await res.arrayBuffer();
expect(
- new Buffer(arrayBuffer).equals(
- new Buffer(
- await Bun.file(import.meta.dir + "/fixture.html").arrayBuffer(),
- ),
- ),
+ new Buffer(arrayBuffer).equals(new Buffer(await Bun.file(import.meta.dir + "/fixture.html").arrayBuffer())),
).toBe(true);
socketToClose.end();
server.stop();
diff --git a/test/bun.js/fetch.test.js b/test/bun.js/fetch.test.js
index 28a7c109b..b41e5f129 100644
--- a/test/bun.js/fetch.test.js
+++ b/test/bun.js/fetch.test.js
@@ -4,8 +4,7 @@ import { mkfifo } from "mkfifo";
import { gc, withoutAggressiveGC } from "./gc";
const exampleFixture = fs.readFileSync(
- import.meta.path.substring(0, import.meta.path.lastIndexOf("/")) +
- "/fetch.js.txt",
+ import.meta.path.substring(0, import.meta.path.lastIndexOf("/")) + "/fetch.js.txt",
"utf8",
);
@@ -44,10 +43,7 @@ describe("Headers", () => {
["Set-Cookie", "foo2=bar2; Path=/; HttpOnly"],
]);
expect(headers.count).toBe(6);
- expect(headers.getAll("set-cookie")).toEqual([
- "foo=bar; Path=/; HttpOnly",
- "foo2=bar2; Path=/; HttpOnly",
- ]);
+ expect(headers.getAll("set-cookie")).toEqual(["foo=bar; Path=/; HttpOnly", "foo2=bar2; Path=/; HttpOnly"]);
});
it("Set-Cookies init", () => {
@@ -204,46 +200,33 @@ function testBlobInterface(blobbyConstructor, hasBlobFn) {
for (let jsonObject of [
{ hello: true },
{
- hello:
- "😀 😃 😄 😁 😆 😅 😂 🤣 🥲 ☺️ 😊 😇 🙂 🙃 😉 😌 😍 🥰 😘 😗 😙 😚 😋 😛 😝 😜 🤪 🤨 🧐 🤓 😎 🥸 🤩 🥳",
+ hello: "😀 😃 😄 😁 😆 😅 😂 🤣 🥲 ☺️ 😊 😇 🙂 🙃 😉 😌 😍 🥰 😘 😗 😙 😚 😋 😛 😝 😜 🤪 🤨 🧐 🤓 😎 🥸 🤩 🥳",
},
]) {
- it(`${jsonObject.hello === true ? "latin1" : "utf16"} json${
- withGC ? " (with gc) " : ""
- }`, async () => {
+ it(`${jsonObject.hello === true ? "latin1" : "utf16"} json${withGC ? " (with gc) " : ""}`, async () => {
if (withGC) gc();
var response = blobbyConstructor(JSON.stringify(jsonObject));
if (withGC) gc();
- expect(JSON.stringify(await response.json())).toBe(
- JSON.stringify(jsonObject),
- );
+ expect(JSON.stringify(await response.json())).toBe(JSON.stringify(jsonObject));
if (withGC) gc();
});
- it(`${
- jsonObject.hello === true ? "latin1" : "utf16"
- } arrayBuffer -> json${withGC ? " (with gc) " : ""}`, async () => {
+ it(`${jsonObject.hello === true ? "latin1" : "utf16"} arrayBuffer -> json${
+ withGC ? " (with gc) " : ""
+ }`, async () => {
if (withGC) gc();
- var response = blobbyConstructor(
- new TextEncoder().encode(JSON.stringify(jsonObject)),
- );
+ var response = blobbyConstructor(new TextEncoder().encode(JSON.stringify(jsonObject)));
if (withGC) gc();
- expect(JSON.stringify(await response.json())).toBe(
- JSON.stringify(jsonObject),
- );
+ expect(JSON.stringify(await response.json())).toBe(JSON.stringify(jsonObject));
if (withGC) gc();
});
- it(`${
- jsonObject.hello === true ? "latin1" : "utf16"
- } arrayBuffer -> invalid json${
+ it(`${jsonObject.hello === true ? "latin1" : "utf16"} arrayBuffer -> invalid json${
withGC ? " (with gc) " : ""
}`, async () => {
if (withGC) gc();
var response = blobbyConstructor(
- new TextEncoder().encode(
- JSON.stringify(jsonObject) + " NOW WE ARE INVALID JSON",
- ),
+ new TextEncoder().encode(JSON.stringify(jsonObject) + " NOW WE ARE INVALID JSON"),
);
if (withGC) gc();
var failed = false;
@@ -256,9 +239,7 @@ function testBlobInterface(blobbyConstructor, hasBlobFn) {
if (withGC) gc();
});
- it(`${jsonObject.hello === true ? "latin1" : "utf16"} text${
- withGC ? " (with gc) " : ""
- }`, async () => {
+ it(`${jsonObject.hello === true ? "latin1" : "utf16"} text${withGC ? " (with gc) " : ""}`, async () => {
if (withGC) gc();
var response = blobbyConstructor(JSON.stringify(jsonObject));
if (withGC) gc();
@@ -266,21 +247,17 @@ function testBlobInterface(blobbyConstructor, hasBlobFn) {
if (withGC) gc();
});
- it(`${
- jsonObject.hello === true ? "latin1" : "utf16"
- } arrayBuffer -> text${withGC ? " (with gc) " : ""}`, async () => {
+ it(`${jsonObject.hello === true ? "latin1" : "utf16"} arrayBuffer -> text${
+ withGC ? " (with gc) " : ""
+ }`, async () => {
if (withGC) gc();
- var response = blobbyConstructor(
- new TextEncoder().encode(JSON.stringify(jsonObject)),
- );
+ var response = blobbyConstructor(new TextEncoder().encode(JSON.stringify(jsonObject)));
if (withGC) gc();
expect(await response.text()).toBe(JSON.stringify(jsonObject));
if (withGC) gc();
});
- it(`${jsonObject.hello === true ? "latin1" : "utf16"} arrayBuffer${
- withGC ? " (with gc) " : ""
- }`, async () => {
+ it(`${jsonObject.hello === true ? "latin1" : "utf16"} arrayBuffer${withGC ? " (with gc) " : ""}`, async () => {
if (withGC) gc();
var response = blobbyConstructor(JSON.stringify(jsonObject));
@@ -303,14 +280,12 @@ function testBlobInterface(blobbyConstructor, hasBlobFn) {
if (withGC) gc();
});
- it(`${
- jsonObject.hello === true ? "latin1" : "utf16"
- } arrayBuffer -> arrayBuffer${withGC ? " (with gc) " : ""}`, async () => {
+ it(`${jsonObject.hello === true ? "latin1" : "utf16"} arrayBuffer -> arrayBuffer${
+ withGC ? " (with gc) " : ""
+ }`, async () => {
if (withGC) gc();
- var response = blobbyConstructor(
- new TextEncoder().encode(JSON.stringify(jsonObject)),
- );
+ var response = blobbyConstructor(new TextEncoder().encode(JSON.stringify(jsonObject)));
if (withGC) gc();
const bytes = new TextEncoder().encode(JSON.stringify(jsonObject));
@@ -331,9 +306,7 @@ function testBlobInterface(blobbyConstructor, hasBlobFn) {
});
hasBlobFn &&
- it(`${jsonObject.hello === true ? "latin1" : "utf16"} blob${
- withGC ? " (with gc) " : ""
- }`, async () => {
+ it(`${jsonObject.hello === true ? "latin1" : "utf16"} blob${withGC ? " (with gc) " : ""}`, async () => {
if (withGC) gc();
const text = JSON.stringify(jsonObject);
var response = blobbyConstructor(text);
@@ -357,7 +330,7 @@ function testBlobInterface(blobbyConstructor, hasBlobFn) {
const out = await blobed.text();
expect(out).toBe(text);
if (withGC) gc();
- await new Promise((resolve) => setTimeout(resolve, 1));
+ await new Promise(resolve => setTimeout(resolve, 1));
if (withGC) gc();
expect(out).toBe(text);
const first = await blobed.arrayBuffer();
@@ -374,7 +347,7 @@ function testBlobInterface(blobbyConstructor, hasBlobFn) {
describe("Bun.file", () => {
const tempdir = require("os").tmpdir();
var callCount = 0;
- testBlobInterface((data) => {
+ testBlobInterface(data => {
const blob = new Blob([data]);
const buffer = Bun.peek(blob.arrayBuffer());
const path = tempdir + "-" + callCount++ + ".bytes";
@@ -415,7 +388,7 @@ describe("Bun.file", () => {
} catch {}
});
- forEachMethod((m) => () => {
+ forEachMethod(m => () => {
const file = Bun.file("/tmp/my-new-file");
expect(async () => await file[m]()).toThrow("Permission denied");
});
@@ -428,7 +401,7 @@ describe("Bun.file", () => {
} catch {}
});
- forEachMethod((m) => async () => {
+ forEachMethod(m => async () => {
const file = Bun.file("/tmp/does-not-exist");
expect(async () => await file[m]()).toThrow("No such file or directory");
});
@@ -436,7 +409,7 @@ describe("Bun.file", () => {
});
describe("Blob", () => {
- testBlobInterface((data) => new Blob([data]));
+ testBlobInterface(data => new Blob([data]));
var blobConstructorValues = [
["123", "456"],
@@ -480,11 +453,9 @@ describe("Blob", () => {
const res = await response.text();
if (res !== expected[i]) {
throw new Error(
- `Failed: ${expected[i]
+ `Failed: ${expected[i].split("").map(a => a.charCodeAt(0))}, received: ${res
.split("")
- .map((a) => a.charCodeAt(0))}, received: ${res
- .split("")
- .map((a) => a.charCodeAt(0))}`,
+ .map(a => a.charCodeAt(0))}`,
);
}
@@ -502,21 +473,13 @@ describe("Blob", () => {
if (withGC) gc();
for (let part of parts) {
if (withGC) gc();
- expect(
- await combined
- .slice(str.indexOf(part), str.indexOf(part) + part.length)
- .text(),
- ).toBe(part);
+ expect(await combined.slice(str.indexOf(part), str.indexOf(part) + part.length).text()).toBe(part);
if (withGC) gc();
}
if (withGC) gc();
for (let part of parts) {
if (withGC) gc();
- expect(
- await combined
- .slice(str.indexOf(part), str.indexOf(part) + part.length)
- .text(),
- ).toBe(part);
+ expect(await combined.slice(str.indexOf(part), str.indexOf(part) + part.length).text()).toBe(part);
if (withGC) gc();
}
});
@@ -541,17 +504,10 @@ describe("Blob", () => {
for (let withGC of [false, true]) {
for (let TypedArray of typedArrays) {
for (let Constructor of Constructors) {
- it(`${Constructor.name} arrayBuffer() with ${TypedArray.name}${
- withGC ? " with gc" : ""
- }`, async () => {
+ it(`${Constructor.name} arrayBuffer() with ${TypedArray.name}${withGC ? " with gc" : ""}`, async () => {
const data = new TypedArray(sample);
if (withGC) gc();
- const input =
- Constructor === Blob
- ? [data]
- : Constructor === Request
- ? { body: data }
- : data;
+ const input = Constructor === Blob ? [data] : Constructor === Request ? { body: data } : data;
if (withGC) gc();
const blob = new Constructor(input);
if (withGC) gc();
@@ -570,12 +526,7 @@ describe("Blob", () => {
describe("Response", () => {
describe("Response.json", () => {
it("works", async () => {
- const inputs = [
- "hellooo",
- [[123], 456, 789],
- { hello: "world" },
- { ok: "😉 😌 😍 🥰 😘 " },
- ];
+ const inputs = ["hellooo", [[123], 456, 789], { hello: "world" }, { ok: "😉 😌 😍 🥰 😘 " }];
for (let input of inputs) {
const output = JSON.stringify(input);
expect(await Response.json(input).text()).toBe(output);
@@ -588,17 +539,13 @@ describe("Response", () => {
it("sets the content-type header", () => {
let response = Response.json("hello");
expect(response.type).toBe("basic");
- expect(response.headers.get("content-type")).toBe(
- "application/json;charset=utf-8",
- );
+ expect(response.headers.get("content-type")).toBe("application/json;charset=utf-8");
expect(response.status).toBe(200);
});
it("supports number status code", () => {
let response = Response.json("hello", 407);
expect(response.type).toBe("basic");
- expect(response.headers.get("content-type")).toBe(
- "application/json;charset=utf-8",
- );
+ expect(response.headers.get("content-type")).toBe("application/json;charset=utf-8");
expect(response.status).toBe(407);
});
@@ -687,7 +634,7 @@ describe("Response", () => {
}
});
- testBlobInterface((data) => new Response(data), true);
+ testBlobInterface(data => new Response(data), true);
});
describe("Request", () => {
@@ -714,10 +661,7 @@ describe("Request", () => {
gc();
});
- testBlobInterface(
- (data) => new Request("https://hello.com", { body: data }),
- true,
- );
+ testBlobInterface(data => new Request("https://hello.com", { body: data }), true);
});
describe("Headers", () => {
diff --git a/test/bun.js/ffi.test.js b/test/bun.js/ffi.test.js
index 4adf67990..102737782 100644
--- a/test/bun.js/ffi.test.js
+++ b/test/bun.js/ffi.test.js
@@ -384,9 +384,7 @@ function ffiRunner(fast) {
if (fast) expect(returns_42_uint64_t().valueOf()).toBe(42);
else expect(returns_42_uint64_t().valueOf()).toBe(42n);
Bun.gc(true);
- expect(Math.fround(returns_42_float())).toBe(
- Math.fround(42.41999804973602),
- );
+ expect(Math.fround(returns_42_float())).toBe(Math.fround(42.41999804973602));
expect(returns_42_double()).toBe(42.42);
expect(returns_42_uint8_t()).toBe(42);
expect(returns_neg_42_int8_t()).toBe(-42);
@@ -425,19 +423,13 @@ function ffiRunner(fast) {
new Uint8Array(bigArray.buffer).fill(255);
var bigIntArray = new BigInt64Array(bigArray.buffer);
expect(identity_uint64_t(bigArray[0])).toBe(bigArray[0]);
- expect(identity_uint64_t(bigArray[0] - BigInt(1))).toBe(
- bigArray[0] - BigInt(1),
- );
+ expect(identity_uint64_t(bigArray[0] - BigInt(1))).toBe(bigArray[0] - BigInt(1));
if (fast) {
expect(add_uint64_t(BigInt(-1) * bigArray[0], bigArray[0])).toBe(0);
- expect(
- add_uint64_t(BigInt(-1) * bigArray[0] + BigInt(10), bigArray[0]),
- ).toBe(10);
+ expect(add_uint64_t(BigInt(-1) * bigArray[0] + BigInt(10), bigArray[0])).toBe(10);
} else {
expect(add_uint64_t(BigInt(-1) * bigArray[0], bigArray[0])).toBe(0n);
- expect(
- add_uint64_t(BigInt(-1) * bigArray[0] + BigInt(10), bigArray[0]),
- ).toBe(10n);
+ expect(add_uint64_t(BigInt(-1) * bigArray[0] + BigInt(10), bigArray[0])).toBe(10n);
}
if (fast) {
expect(identity_uint64_t(0)).toBe(0);
@@ -452,9 +444,7 @@ function ffiRunner(fast) {
expect(identity_uint64_t(BigInt(100))).toBe(100n);
expect(identity_int64_t(bigIntArray[0])).toBe(bigIntArray[0]);
- expect(identity_int64_t(bigIntArray[0] - BigInt(1))).toBe(
- bigIntArray[0] - BigInt(1),
- );
+ expect(identity_int64_t(bigIntArray[0] - BigInt(1))).toBe(bigIntArray[0] - BigInt(1));
}
Bun.gc(true);
expect(add_char.native(1, 1)).toBe(2);
@@ -477,9 +467,7 @@ function ffiRunner(fast) {
expect(does_pointer_equal_42_as_int32_t(cptr)).toBe(true);
const buffer = toBuffer(cptr, 0, 4);
expect(buffer.readInt32(0)).toBe(42);
- expect(
- new DataView(toArrayBuffer(cptr, 0, 4), 0, 4).getInt32(0, true),
- ).toBe(42);
+ expect(new DataView(toArrayBuffer(cptr, 0, 4), 0, 4).getInt32(0, true)).toBe(42);
expect(ptr(buffer)).toBe(cptr);
expect(new CString(cptr, 0, 1).toString()).toBe("*");
expect(identity_ptr(cptr)).toBe(cptr);
@@ -512,7 +500,7 @@ function ffiRunner(fast) {
it("JSCallback", () => {
var toClose = new JSCallback(
- (input) => {
+ input => {
return input;
},
{
@@ -531,7 +519,7 @@ function ffiRunner(fast) {
it("fn(" + returnName + ") " + returnName, () => {
var roundtripFunction = new CFunction({
ptr: new JSCallback(
- (input) => {
+ input => {
return input;
},
{
@@ -559,12 +547,12 @@ function ffiRunner(fast) {
}
});
- describe("threadsafe callback", (done) => {
+ describe("threadsafe callback", done => {
// 1 arg, threadsafe
for (let [name, value] of Object.entries(typeMap)) {
it("fn(" + name + ") " + name, async () => {
const cb = new JSCallback(
- (arg1) => {
+ arg1 => {
expect(arg1).toBe(value);
},
{
@@ -596,12 +584,8 @@ it("read", () => {
for (let i = 0; i < buffer.length; i++) {
buffer[i] = BigInt(i);
- expect(read.intptr(addr, i * 8)).toBe(
- Number(dataView.getBigInt64(i * 8, true)),
- );
- expect(read.ptr(addr, i * 8)).toBe(
- Number(dataView.getBigUint64(i * 8, true)),
- );
+ expect(read.intptr(addr, i * 8)).toBe(Number(dataView.getBigInt64(i * 8, true)));
+ expect(read.ptr(addr, i * 8)).toBe(Number(dataView.getBigUint64(i * 8, true)));
expect(read.f64(addr, i + 8)).toBe(dataView.getFloat64(i + 8, true));
expect(read.i64(addr, i * 8)).toBe(dataView.getBigInt64(i * 8, true));
expect(read.u64(addr, i * 8)).toBe(dataView.getBigUint64(i * 8, true));
diff --git a/test/bun.js/fileUrl.test.js b/test/bun.js/fileUrl.test.js
index 7efa8f235..ebae570f8 100644
--- a/test/bun.js/fileUrl.test.js
+++ b/test/bun.js/fileUrl.test.js
@@ -2,9 +2,7 @@ import { expect, it, describe } from "bun:test";
import { pathToFileURL, fileURLToPath } from "bun";
describe("pathToFileURL", () => {
it("should convert a path to a file url", () => {
- expect(pathToFileURL("/path/to/file.js").href).toBe(
- "file:///path/to/file.js",
- );
+ expect(pathToFileURL("/path/to/file.js").href).toBe("file:///path/to/file.js");
});
});
@@ -13,8 +11,6 @@ describe("fileURLToPath", () => {
expect(fileURLToPath("file:///path/to/file.js")).toBe("/path/to/file.js");
});
it("should convert a URL to a path", () => {
- expect(fileURLToPath(new URL("file:///path/to/file.js"))).toBe(
- "/path/to/file.js",
- );
+ expect(fileURLToPath(new URL("file:///path/to/file.js"))).toBe("/path/to/file.js");
});
});
diff --git a/test/bun.js/filesink.test.ts b/test/bun.js/filesink.test.ts
index 2e6174ba7..31fd70e54 100644
--- a/test/bun.js/filesink.test.ts
+++ b/test/bun.js/filesink.test.ts
@@ -11,44 +11,23 @@ describe("FileSink", () => {
],
[
["abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"],
- new TextEncoder().encode(
- "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
- ),
+ new TextEncoder().encode("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
],
[
["😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌"],
- new TextEncoder().encode(
- "😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌",
- ),
+ new TextEncoder().encode("😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌"),
"😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌",
],
[
- [
- "abcdefghijklmnopqrstuvwxyz",
- "😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌",
- ],
- new TextEncoder().encode(
- "abcdefghijklmnopqrstuvwxyz" +
- "😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌",
- ),
- "abcdefghijklmnopqrstuvwxyz" +
- "😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌",
+ ["abcdefghijklmnopqrstuvwxyz", "😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌"],
+ new TextEncoder().encode("abcdefghijklmnopqrstuvwxyz" + "😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌"),
+ "abcdefghijklmnopqrstuvwxyz" + "😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌",
],
[
- [
- "abcdefghijklmnopqrstuvwxyz",
- "😋",
- " Get Emoji — All Emojis",
- " to ✂️ Copy and 📋 Paste 👌",
- ],
- new TextEncoder().encode(
- "abcdefghijklmnopqrstuvwxyz" +
- "😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌",
- ),
- "(rope) " +
- "abcdefghijklmnopqrstuvwxyz" +
- "😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌",
+ ["abcdefghijklmnopqrstuvwxyz", "😋", " Get Emoji — All Emojis", " to ✂️ Copy and 📋 Paste 👌"],
+ new TextEncoder().encode("abcdefghijklmnopqrstuvwxyz" + "😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌"),
+ "(rope) " + "abcdefghijklmnopqrstuvwxyz" + "😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌",
],
[
[
@@ -57,13 +36,8 @@ describe("FileSink", () => {
" Get Emoji — All Emojis",
" to ✂️ Copy and 📋 Paste 👌",
],
- new TextEncoder().encode(
- "abcdefghijklmnopqrstuvwxyz" +
- "😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌",
- ),
- "(array) " +
- "abcdefghijklmnopqrstuvwxyz" +
- "😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌",
+ new TextEncoder().encode("abcdefghijklmnopqrstuvwxyz" + "😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌"),
+ "(array) " + "abcdefghijklmnopqrstuvwxyz" + "😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌",
],
] as const;
diff --git a/test/bun.js/filesystem_router.test.ts b/test/bun.js/filesystem_router.test.ts
index a73e98c2d..b55e716c0 100644
--- a/test/bun.js/filesystem_router.test.ts
+++ b/test/bun.js/filesystem_router.test.ts
@@ -134,12 +134,7 @@ it(".params works on dynamic routes", () => {
it("should support static routes", () => {
// set up the test
- const { dir } = make([
- "index.tsx",
- "posts/[id].tsx",
- "posts.tsx",
- "posts/hey.tsx",
- ]);
+ const { dir } = make(["index.tsx", "posts/[id].tsx", "posts.tsx", "posts/hey.tsx"]);
const router = new Bun.FileSystemRouter({
dir,
@@ -154,35 +149,18 @@ it("should support static routes", () => {
it("should support optional catch-all routes", () => {
// set up the test
- const { dir } = make([
- "index.tsx",
- "posts/[id].tsx",
- "posts.tsx",
- "posts/hey.tsx",
- "posts/[[...id]].tsx",
- ]);
+ const { dir } = make(["index.tsx", "posts/[id].tsx", "posts.tsx", "posts/hey.tsx", "posts/[[...id]].tsx"]);
const router = new Bun.FileSystemRouter({
dir,
style: "nextjs",
});
- for (let fixture of [
- "/posts/123",
- "/posts/hey",
- "/posts/zorp",
- "/posts",
- "/index",
- "/posts/",
- ]) {
+ for (let fixture of ["/posts/123", "/posts/hey", "/posts/zorp", "/posts", "/index", "/posts/"]) {
expect(router.match(fixture)?.name).not.toBe("/posts/[[...id]]");
}
- for (let fixture of [
- "/posts/hey/there",
- "/posts/hey/there/you",
- "/posts/zorp/123",
- ]) {
+ for (let fixture of ["/posts/hey/there", "/posts/hey/there/you", "/posts/zorp/123"]) {
const { name, params, filePath } = router.match(fixture);
expect(name).toBe("/posts/[[...id]]");
@@ -207,23 +185,11 @@ it("should support catch-all routes", () => {
style: "nextjs",
});
- for (let fixture of [
- "/posts/123",
- "/posts/hey",
- "/posts/zorp",
- "/posts",
- "/index",
- "/posts/",
- ]) {
+ for (let fixture of ["/posts/123", "/posts/hey", "/posts/zorp", "/posts", "/index", "/posts/"]) {
expect(router.match(fixture)?.name).not.toBe("/posts/[...id]");
}
- for (let fixture of [
- "/posts/hey/there",
- "/posts/hey/there/you",
- "/posts/zorp/123",
- "/posts/wow/hey/there",
- ]) {
+ for (let fixture of ["/posts/hey/there", "/posts/hey/there/you", "/posts/zorp/123", "/posts/wow/hey/there"]) {
const { name, params, filePath } = router.match(fixture);
expect(name).toBe("/posts/[...id]");
@@ -234,12 +200,7 @@ it("should support catch-all routes", () => {
it("should support index routes", () => {
// set up the test
- const { dir } = make([
- "index.tsx",
- "posts/[id].tsx",
- "posts.tsx",
- "posts/hey.tsx",
- ]);
+ const { dir } = make(["index.tsx", "posts/[id].tsx", "posts.tsx", "posts/hey.tsx"]);
const router = new Bun.FileSystemRouter({
dir,
@@ -327,18 +288,14 @@ it(".query works", () => {
for (let [current, object] of [
[new URL("https://example.com/posts?hello=world").href, { hello: "world" }],
- [
- new URL("https://example.com/posts?hello=world&second=2").href,
- { hello: "world", second: "2" },
- ],
+ [new URL("https://example.com/posts?hello=world&second=2").href, { hello: "world", second: "2" }],
[
new URL("https://example.com/posts?hello=world&second=2&third=3").href,
{ hello: "world", second: "2", third: "3" },
],
[new URL("https://example.com/posts").href, {}],
]) {
- const { name, src, filePath, checkThisDoesntCrash, query } =
- router.match(current);
+ const { name, src, filePath, checkThisDoesntCrash, query } = router.match(current);
expect(name).toBe("/posts");
// check nothing is weird on the MatchedRoute object
@@ -377,23 +334,15 @@ it(".query works with dynamic routes, including params", () => {
});
for (let [current, object] of [
+ [new URL("https://example.com/posts/123?hello=world").href, { id: "123", hello: "world" }],
+ [new URL("https://example.com/posts/123?hello=world&second=2").href, { id: "123", hello: "world", second: "2" }],
[
- new URL("https://example.com/posts/123?hello=world").href,
- { id: "123", hello: "world" },
- ],
- [
- new URL("https://example.com/posts/123?hello=world&second=2").href,
- { id: "123", hello: "world", second: "2" },
- ],
- [
- new URL("https://example.com/posts/123?hello=world&second=2&third=3")
- .href,
+ new URL("https://example.com/posts/123?hello=world&second=2&third=3").href,
{ id: "123", hello: "world", second: "2", third: "3" },
],
[new URL("https://example.com/posts/123").href, { id: "123" }],
]) {
- const { name, src, filePath, checkThisDoesntCrash, query } =
- router.match(current);
+ const { name, src, filePath, checkThisDoesntCrash, query } = router.match(current);
expect(name).toBe("/posts/[id]");
// check nothing is weird on the MatchedRoute object
diff --git a/test/bun.js/fixture.html b/test/bun.js/fixture.html
index 929b73ce4..081040506 100644
--- a/test/bun.js/fixture.html
+++ b/test/bun.js/fixture.html
@@ -1,38 +1,42 @@
<!DOCTYPE html>
<html>
-<head>
-<meta charset="UTF-8" />
-<meta name="viewport" content="width=device-width, initial-scale=1" />
-<meta property="og:title" content="Bun is a fast all-in-one JavaScript runtime" />
-<title>Bun is a fast all-in-one JavaScript runtime</title>
-<meta property="og:description" content="Bundle, transpile, install and run JavaScript &amp; TypeScript
+ <head>
+ <meta charset="UTF-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <meta property="og:title" content="Bun is a fast all-in-one JavaScript runtime" />
+ <title>Bun is a fast all-in-one JavaScript runtime</title>
+ <meta
+ property="og:description"
+ content="Bundle, transpile, install and run JavaScript &amp; TypeScript
projects – all in Bun. Bun is a new JavaScript runtime with
- a native bundler, transpiler, task runner and npm client built-in." />
-<meta name="og:locale" content="en_US" />
-<meta name="twitter:site" content="@jarredsumner" />
-<meta name="twitter:card" content="summary_large_image" />
-<meta property="og:image" content="https://bun.sh/share.png" />
-<meta name="description" content="Bundle, transpile, install and run JavaScript &amp; TypeScript
+ a native bundler, transpiler, task runner and npm client built-in."
+ />
+ <meta name="og:locale" content="en_US" />
+ <meta name="twitter:site" content="@jarredsumner" />
+ <meta name="twitter:card" content="summary_large_image" />
+ <meta property="og:image" content="https://bun.sh/share.png" />
+ <meta
+ name="description"
+ content="Bundle, transpile, install and run JavaScript &amp; TypeScript
projects – all in Bun. Bun is a new JavaScript runtime with
- a native bundler, transpiler, task runner and npm client built-in." />
-<meta name="theme-color" content="#fbf0df" />
-<link rel="manifest" href="manifest.json" />
-<link rel="icon" type="image/png" sizes="256x256" href="/logo-square.png" />
-<link rel="icon" type="image/png" sizes="32x32" href="/logo-square@32px.png" />
-<link rel="icon" type="image/png" sizes="16x16" href="/logo-square@16px.png" />
-<style>
+ a native bundler, transpiler, task runner and npm client built-in."
+ />
+ <meta name="theme-color" content="#fbf0df" />
+ <link rel="manifest" href="manifest.json" />
+ <link rel="icon" type="image/png" sizes="256x256" href="/logo-square.png" />
+ <link rel="icon" type="image/png" sizes="32x32" href="/logo-square@32px.png" />
+ <link rel="icon" type="image/png" sizes="16x16" href="/logo-square@16px.png" />
+ <style>
:root {
--black: #0b0a08;
--blue: #00a6e1;
--orange: #f89b4b;
--orange-light: #d4d3d2;
- --monospace-font: "Fira Code", "Hack", "Source Code Pro", "SF Mono",
- "Inconsolata", monospace;
+ --monospace-font: "Fira Code", "Hack", "Source Code Pro", "SF Mono", "Inconsolata", monospace;
--dark-border: rgba(200, 200, 25, 0.2);
--max-width: 1152px;
- --system-font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
- Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue",
- sans-serif;
+ --system-font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell,
+ "Open Sans", "Helvetica Neue", sans-serif;
--horizontal-padding: 3rem;
--vertical-padding: 4rem;
--line-height: 1.4;
@@ -172,11 +176,7 @@
color: var(--orange-light);
}
#usecases-section {
- background: linear-gradient(
- 12deg,
- rgba(0, 0, 0, 0.7),
- rgba(0, 0, 0, 0.2)
- ),
+ background: linear-gradient(12deg, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.2)),
conic-gradient(
from 6.27deg at 46.95% 50.05%,
#ff8181 0deg,
@@ -204,12 +204,7 @@
padding-bottom: 1rem;
}
#usecases-section h1 {
- background: linear-gradient(
- 90deg,
- #ff0000 0%,
- #faff00 50.52%,
- #0500ff 100%
- );
+ background: linear-gradient(90deg, #ff0000 0%, #faff00 50.52%, #0500ff 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
@@ -692,9 +687,7 @@
.CodeBlock .shiki {
padding: 24px 16px;
margin: calc(-1 * var(--horizontal-padding));
- width: calc(
- 100vw - var(--horizontal-padding) - var(--horizontal-padding) -2px
- );
+ width: calc(100vw - var(--horizontal-padding) - var(--horizontal-padding) -2px);
white-space: pre-wrap;
box-sizing: border-box;
border-radius: 0;
@@ -797,562 +790,604 @@
width: 1px;
}
</style>
-</head>
-<body>
-<div id="header-wrap">
-<header>
-<a href="/" id="logo-link" aria-label="home"><img height="61px" src="data:image/svg+xml;base64, PHN2ZyBpZD0iQnVuIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA4MCA3MCI+PHRpdGxlPkJ1biBMb2dvPC90aXRsZT48cGF0aCBpZD0iU2hhZG93IiBkPSJNNzEuMDksMjAuNzRjLS4xNi0uMTctLjMzLS4zNC0uNS0uNXMtLjMzLS4zNC0uNS0uNS0uMzMtLjM0LS41LS41LS4zMy0uMzQtLjUtLjUtLjMzLS4zNC0uNS0uNS0uMzMtLjM0LS41LS41LS4zMy0uMzQtLjUtLjVBMjYuNDYsMjYuNDYsMCwwLDEsNzUuNSwzNS43YzAsMTYuNTctMTYuODIsMzAuMDUtMzcuNSwzMC4wNS0xMS41OCwwLTIxLjk0LTQuMjMtMjguODMtMTAuODZsLjUuNS41LjUuNS41LjUuNS41LjUuNS41LjUuNUMxOS41NSw2NS4zLDMwLjE0LDY5Ljc1LDQyLDY5Ljc1YzIwLjY4LDAsMzcuNS0xMy40OCwzNy41LTMwQzc5LjUsMzIuNjksNzYuNDYsMjYsNzEuMDksMjAuNzRaIi8+PGcgaWQ9IkJvZHkiPjxwYXRoIGlkPSJCYWNrZ3JvdW5kIiBkPSJNNzMsMzUuN2MwLDE1LjIxLTE1LjY3LDI3LjU0LTM1LDI3LjU0UzMsNTAuOTEsMywzNS43QzMsMjYuMjcsOSwxNy45NCwxOC4yMiwxM1MzMy4xOCwzLDM4LDNzOC45NCw0LjEzLDE5Ljc4LDEwQzY3LDE3Ljk0LDczLDI2LjI3LDczLDM1LjdaIiBzdHlsZT0iZmlsbDojZmJmMGRmIi8+PHBhdGggaWQ9IkJvdHRvbV9TaGFkb3ciIGRhdGEtbmFtZT0iQm90dG9tIFNoYWRvdyIgZD0iTTczLDM1LjdhMjEuNjcsMjEuNjcsMCwwLDAtLjgtNS43OGMtMi43MywzMy4zLTQzLjM1LDM0LjktNTkuMzIsMjQuOTRBNDAsNDAsMCwwLDAsMzgsNjMuMjRDNTcuMyw2My4yNCw3Myw1MC44OSw3MywzNS43WiIgc3R5bGU9ImZpbGw6I2Y2ZGVjZSIvPjxwYXRoIGlkPSJMaWdodF9TaGluZSIgZGF0YS1uYW1lPSJMaWdodCBTaGluZSIgZD0iTTI0LjUzLDExLjE3QzI5LDguNDksMzQuOTQsMy40Niw0MC43OCwzLjQ1QTkuMjksOS4yOSwwLDAsMCwzOCwzYy0yLjQyLDAtNSwxLjI1LTguMjUsMy4xMy0xLjEzLjY2LTIuMywxLjM5LTMuNTQsMi4xNS0yLjMzLDEuNDQtNSwzLjA3LTgsNC43QzguNjksMTguMTMsMywyNi42MiwzLDM1LjdjMCwuNCwwLC44LDAsMS4xOUM5LjA2LDE1LjQ4LDIwLjA3LDEzLjg1LDI0LjUzLDExLjE3WiIgc3R5bGU9ImZpbGw6I2ZmZmVmYyIvPjxwYXRoIGlkPSJUb3AiIGQ9Ik0zNS4xMiw1LjUzQTE2LjQxLDE2LjQxLDAsMCwxLDI5LjQ5LDE4Yy0uMjguMjUtLjA2LjczLjMuNTksMy4zNy0xLjMxLDcuOTItNS4yMyw2LTEzLjE0QzM1LjcxLDUsMzUuMTIsNS4xMiwzNS4xMiw1LjUzWm0yLjI3LDBBMTYuMjQsMTYuMjQsMCwwLDEsMzksMTljLS4xMi4zNS4zMS42NS41NS4zNkM0MS43NCwxNi41Niw0My42NSwxMSwzNy45Myw1LDM3LjY0LDQuNzQsMzcuMTksNS4xNCwzNy4zOSw1LjQ5Wm0yLjc2LS4xN0ExNi40MiwxNi40MiwwLDAsMSw0NywxNy4xMmEuMzMuMzMsMCwwLDAsLjY1LjExYy45Mi0zLjQ5LjQtOS40NC03LjE3LTEyLjUzQzQwLjA4LDQuNTQsMzkuODIsNS4wOCw0MC4xNSw1LjMyWk0yMS42OSwxNS43NmExNi45NCwxNi45NCwwLDAsMCwxMC40Ny05Yy4xOC0uMzYuNzUtLjIyLjY2LjE4LTEuNzMsOC03LjUyLDkuNjctMTEuMTIsOS40NUMyMS4zMiwxNi40LDIxLjMzLDE1Ljg3LDIxLjY5LDE1Ljc2WiIgc3R5bGU9ImZpbGw6I2NjYmVhNztmaWxsLXJ1bGU6ZXZlbm9kZCIvPjxwYXRoIGlkPSJPdXRsaW5lIiBkPSJNMzgsNjUuNzVDMTcuMzIsNjUuNzUuNSw1Mi4yNy41LDM1LjdjMC0xMCw2LjE4LTE5LjMzLDE2LjUzLTI0LjkyLDMtMS42LDUuNTctMy4yMSw3Ljg2LTQuNjIsMS4yNi0uNzgsMi40NS0xLjUxLDMuNi0yLjE5QzMyLDEuODksMzUsLjUsMzgsLjVzNS42MiwxLjIsOC45LDMuMTRjMSwuNTcsMiwxLjE5LDMuMDcsMS44NywyLjQ5LDEuNTQsNS4zLDMuMjgsOSw1LjI3QzY5LjMyLDE2LjM3LDc1LjUsMjUuNjksNzUuNSwzNS43LDc1LjUsNTIuMjcsNTguNjgsNjUuNzUsMzgsNjUuNzVaTTM4LDNjLTIuNDIsMC01LDEuMjUtOC4yNSwzLjEzLTEuMTMuNjYtMi4zLDEuMzktMy41NCwyLjE1LTIuMzMsMS40NC01LDMuMDctOCw0LjdDOC42OSwxOC4xMywzLDI2LjYyLDMsMzUuNywzLDUwLjg5LDE4LjcsNjMuMjUsMzgsNjMuMjVTNzMsNTAuODksNzMsMzUuN0M3MywyNi42Miw2Ny4zMSwxOC4xMyw1Ny43OCwxMyw1NCwxMSw1MS4wNSw5LjEyLDQ4LjY2LDcuNjRjLTEuMDktLjY3LTIuMDktMS4yOS0zLTEuODRDNDIuNjMsNCw0MC40MiwzLDM4LDNaIi8+PC9nPjxnIGlkPSJNb3V0aCI+PGcgaWQ9IkJhY2tncm91bmQtMiIgZGF0YS1uYW1lPSJCYWNrZ3JvdW5kIj48cGF0aCBkPSJNNDUuMDUsNDNhOC45Myw4LjkzLDAsMCwxLTIuOTIsNC43MSw2LjgxLDYuODEsMCwwLDEtNCwxLjg4QTYuODQsNi44NCwwLDAsMSwzNCw0Ny43MSw4LjkzLDguOTMsMCwwLDEsMzEuMTIsNDNhLjcyLjcyLDAsMCwxLC44LS44MUg0NC4yNkEuNzIuNzIsMCwwLDEsNDUuMDUsNDNaIiBzdHlsZT0iZmlsbDojYjcxNDIyIi8+PC9nPjxnIGlkPSJUb25ndWUiPjxwYXRoIGlkPSJCYWNrZ3JvdW5kLTMiIGRhdGEtbmFtZT0iQmFja2dyb3VuZCIgZD0iTTM0LDQ3Ljc5YTYuOTEsNi45MSwwLDAsMCw0LjEyLDEuOSw2LjkxLDYuOTEsMCwwLDAsNC4xMS0xLjksMTAuNjMsMTAuNjMsMCwwLDAsMS0xLjA3LDYuODMsNi44MywwLDAsMC00LjktMi4zMSw2LjE1LDYuMTUsMCwwLDAtNSwyLjc4QzMzLjU2LDQ3LjQsMzMuNzYsNDcuNiwzNCw0Ny43OVoiIHN0eWxlPSJmaWxsOiNmZjYxNjQiLz48cGF0aCBpZD0iT3V0bGluZS0yIiBkYXRhLW5hbWU9Ik91dGxpbmUiIGQ9Ik0zNC4xNiw0N2E1LjM2LDUuMzYsMCwwLDEsNC4xOS0yLjA4LDYsNiwwLDAsMSw0LDEuNjljLjIzLS4yNS40NS0uNTEuNjYtLjc3YTcsNywwLDAsMC00LjcxLTEuOTMsNi4zNiw2LjM2LDAsMCwwLTQuODksMi4zNkE5LjUzLDkuNTMsMCwwLDAsMzQuMTYsNDdaIi8+PC9nPjxwYXRoIGlkPSJPdXRsaW5lLTMiIGRhdGEtbmFtZT0iT3V0bGluZSIgZD0iTTM4LjA5LDUwLjE5YTcuNDIsNy40MiwwLDAsMS00LjQ1LTIsOS41Miw5LjUyLDAsMCwxLTMuMTEtNS4wNSwxLjIsMS4yLDAsMCwxLC4yNi0xLDEuNDEsMS40MSwwLDAsMSwxLjEzLS41MUg0NC4yNmExLjQ0LDEuNDQsMCwwLDEsMS4xMy41MSwxLjE5LDEuMTksMCwwLDEsLjI1LDFoMGE5LjUyLDkuNTIsMCwwLDEtMy4xMSw1LjA1QTcuNDIsNy40MiwwLDAsMSwzOC4wOSw1MC4xOVptLTYuMTctNy40Yy0uMTYsMC0uMi4wNy0uMjEuMDlhOC4yOSw4LjI5LDAsMCwwLDIuNzMsNC4zN0E2LjIzLDYuMjMsMCwwLDAsMzguMDksNDlhNi4yOCw2LjI4LDAsMCwwLDMuNjUtMS43Myw4LjMsOC4zLDAsMCwwLDIuNzItNC4zNy4yMS4yMSwwLDAsMC0uMi0uMDlaIi8+PC9nPjxnIGlkPSJGYWNlIj48ZWxsaXBzZSBpZD0iUmlnaHRfQmx1c2giIGRhdGEtbmFtZT0iUmlnaHQgQmx1c2giIGN4PSI1My4yMiIgY3k9IjQwLjE4IiByeD0iNS44NSIgcnk9IjMuNDQiIHN0eWxlPSJmaWxsOiNmZWJiZDAiLz48ZWxsaXBzZSBpZD0iTGVmdF9CbHVjaCIgZGF0YS1uYW1lPSJMZWZ0IEJsdWNoIiBjeD0iMjIuOTUiIGN5PSI0MC4xOCIgcng9IjUuODUiIHJ5PSIzLjQ0IiBzdHlsZT0iZmlsbDojZmViYmQwIi8+PHBhdGggaWQ9IkV5ZXMiIGQ9Ik0yNS43LDM4LjhhNS41MSw1LjUxLDAsMSwwLTUuNS01LjUxQTUuNTEsNS41MSwwLDAsMCwyNS43LDM4LjhabTI0Ljc3LDBBNS41MSw1LjUxLDAsMSwwLDQ1LDMzLjI5LDUuNSw1LjUsMCwwLDAsNTAuNDcsMzguOFoiIHN0eWxlPSJmaWxsLXJ1bGU6ZXZlbm9kZCIvPjxwYXRoIGlkPSJJcmlzIiBkPSJNMjQsMzMuNjRhMi4wNywyLjA3LDAsMSwwLTIuMDYtMi4wN0EyLjA3LDIuMDcsMCwwLDAsMjQsMzMuNjRabTI0Ljc3LDBhMi4wNywyLjA3LDAsMSwwLTIuMDYtMi4wN0EyLjA3LDIuMDcsMCwwLDAsNDguNzUsMzMuNjRaIiBzdHlsZT0iZmlsbDojZmZmO2ZpbGwtcnVsZTpldmVub2RkIi8+PC9nPjwvc3ZnPg==" alt="Bun logo" id="logo" /><img alt="Bun" id="logo-text" height="31.65px" src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAALkAAAA9CAYAAADxjMiSAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAi1SURBVHgB7Z3vddpIEMBnBPhdPgUqiLgUYFJBSAXxVRC7gjgVxK4gdgVxKohdQUgFRxo4SAXgT753Ejs3s5JsQiQQsCsJaX/v+R+SkZBmZ2fnnxAKgGYTf/W1AKCL/JW2fxtgGv86x15/Dg7HHmDeHVlQRSC7IYBP/AWxkKKHL/R2osfX9N/RPqZOcsrvN0XEqVL0g/8e80AYuwHgyMMvQi6CHETCOfBADQi9F7zDgCLB7UL1GCOp7wTebafXH4HDkcKjkAfzyTf+MYBqCvNGRNvzt1FLwSVr+Ck4HDHLQk5QExDhxgm7I8GDGkIEpwuEb//NJqfgaDxayONFZa2QhS9r9M/B/eQjOBqNFvJ/D9QOzwXBRXg/+QyOxlJLc2UVMV9Yo38CRyNphJBrCM6D2WQIjsbRhgYhNjr/6IOjckhUnGM0Q/61yzEaH7zW88dtin6SRL93DAJqF6LWcOyNgCZA8GZT4Ii9MhIv0DGD5IJzRDcJiKWmI9ByKgLifOXGTHd1Z2aciy/bMCWqnHEeU4kjbPrcImgLPpaKPqO/Es1ORaLQoBb3CrypF0Wm53kDc+LwCD14j2xObhkhH7EJ+qXDP/Nc18YJOd+Um/Zz/yxr+wPf6DbCBEwek29Gu9t/AzsQzKd8X2gIBmBhOmv3+jdg+VibjqOPJV4vNiFhX6cHwkVbwfU67d4cmzyGtdIJOFJByNbY26EGWVtEiQSzf8bi9QITXj1+H46J/J2WBJhg3SaPwu04SqZNHlVzmdKSTMMkG1G+FNCJh/jaZHJXCl25IC4aao8FeH7a62KeSJCOAH0wiMhLyIIeziYyg9yubrcl5HM+8jW/+c2WwqRPUCKVHsJHW8Ie1DkuUAFaCMdprwdAVwjogx26hPCVZefVUa8/Xt5gx1xhAefFx8Wu2pJP8ibgBSL/OgYLYEOFXBX0uUU5rUbRRXHxeugdWAZlplgxXSprkz/jARIS/AUyKxiG1rxnq8YDYNPgNjlzBivvJTMzFEM3jFzFT8eWb5Zt4J0RQeeV+hcwTOfJzfYbTdXypvEit6dGtHjBMjZcDvwdgndlBGZxFUWF8ORhYRPiPRTN0sxReSFXa7TuLrBdaMXOd/xK4mF5iOzjARTPozavvJCbNh9aii7BYZ3Ew8JrnNLiEghKH7vyQm60IJqjnU32jydh+iKQ+yaalE0V6x6VzHNATx+78glasb/cCE6LZ/OwJmK4M+WninRloFVakwf3P40FhIjgg4tyNg+Wn0ElNXmcnfYRSJ2DCUhdHvVeXoGjbMSrNeWop/ZuEZD17hAs5MNKCblEqli434WSnUaGPjwLeKf38iLv7rLQrU3bgoqAUWrsZVoKbjibnPAOn2z50WUBbEfI2S8aziepCw7KcAlK/rJ05wJzEjYXE4U1+M02/xTnUjsMoDufRWm3o6x94oSqWxb2K7LgT5fBY0uTdyl7GvIh/WSMIV4UWWQ6G7w8RMBbBG/y3gMW9vNgPj02lTu/TK3yyWValMofKYpwAl4uinZo7kR2vF+1EnJF6q5tOEJaPnS4bfu2JLLZcQSGqZcmR+9TiDAJ5pOZ9HbUiUE2/L8F0rSEMST6AYaxZJPjLRHdZWzM7EvOYdguR6lew/65DvL+Em0bLlijBPeTm87zvgsEHQBKEujALHaEnEfj0YZC1nVI9K0FdGEiyZ4ij80Fe3tO8yyE4vI8R0mgBXOzkuaK5JEf9f48ZeE0pn1F2BcpVSMp+7k03BIJmyLkCVJCx2aPsaKJJUF3hREN4gAWnmg0HK8ru73sUiwbmoRctVGpVF7I48prsyYEwXnB2twHR2kchAsRLdjJIaQnfz2zE0Tqxu3eHCVwEEJuZbqPXJXpmyyYLEmViqN4Ki/ksQa0YVoMszZY8bCg935bE0kS/qvaSeGQOABNTmZyytPeOcOdSATGo24Q9QP5mnfnuAlr7v0d2Xjxt0r6hkWLF9F1KQVbFf3DYD5Z25xSP0tVnooRlY45r4wBdMTT9PSMHuxdMFumJov7bNtiEOfX3PKM8R2ern0XEd6GYka5kKtRrIT15Rk9HEYXIR2Rgi/bPB0gskPpFAqo8s4K8bcARiFY54SF2i1GC8Ba+VucMyLCeioCw5pL+7vlyQTSxnl53zgxS7T/EHQCVyG1OZkmiQxIHqRTt+irB0XWeGo/MYfpYVWGqYT1L5L6vnYHgjsoo71ZDF8iyeTsA+IxGGJVuSzzByugAmavUmjckyYSWuCtTReguFd6WbQIPpDhlIZ11Lk/ZNLVtlGZd5jjgUpxZXlZ12Ucn58tL0+j0EK+aJiQs5Y8y7UjwTWUAMXH7dSulK8cmmeukMpdYMsLFjEXClcAnbhdtZgQ6AR9b5ol5EQ/tmo0xEJGBgs3ch1zpSkpGax5bGpBSGOEXDRiG3AIW3LU61/ZqCDPYrUpKbtTp2CITZHtus4ajRByWWiyHf5qVw9CSHRWiACkmFLKLT73Rgv5sxo34mF/+LU8DXkfF5lcH2XpIV0JMhAzTCkn5HtSW02uNa900+q9NJLFKBVKocwGNjQ6292taBD9hkkPCzV0EVtHIdeNPll79ztrGk3ugmh0eb6oyeJqPdPwWiFrpinSw1LXheljWJ+1VL+lc0doiFEo+aDKteI+iNdpj502SWzanT7MJhf79IZJ2hnzTDPauLM8QMDDt/zT5z/8LXJq5lHpII6BFj85yjtdexi+fh7iW+JjQHSMrVJ9o8HIC2WUZp80hR2Q9IIFD3zA1jFFLfJ82CHlGKNMUsmVym5WpBvhs6BLp34PlC8H3fIC20Zu4Jht5btO9HjzUrSQfl68Vg5quOYaRc3n+YIrxW5MA+cbVxnpm588Rr2zpIlNNTyV3Pcgo+uZCFF8zLnt65/k4IcZ8rfUA/O3c9kp3U8XM0TtmX3UX6rLN1iyCLsy+pJtYIjlUSlCIsK9Tfquo9lYz2ld1TiYc+pJRqZrwezYl/8BpjOlthQ26tQAAAAASUVORK5CYII=" /></a>
-<nav class="Navigation">
-<ul>
-<li>
-<a class="NavText" href="https://github.com/oven-sh/bun#Reference">Docs</a
- >
-</li>
-<li>
-<a class="NavText" href="https://bun.sh/discord">Discord</a>
-</li>
-<li>
-<a class="NavText" href="https://github.com/oven-sh/bun">GitHub</a
- >
-</li>
-</ul>
-</nav>
-</header>
-</div>
-<div id="pitch">
-<main>
-<div id="pitch-content">
-<h1 class="tagline">Bun is a fast all-in-one JavaScript runtime</h1>
-<p class="subtitle">
-Bundle, transpile, install and run JavaScript &amp; TypeScript
-projects — all in Bun. Bun is a new JavaScript runtime with a native
-bundler, transpiler, task runner and npm client built-in.
-</p>
-<div class="InstallBox InstallBox--desktop">
-<div class="InstallBox-label">
-<div class="InstallBox-label-heading">
-Install Bun CLI
-<!-- -->0.2.1<!-- -->
-(beta)
-</div>
-<div class="InstallBox-label-subtitle">
-macOS x64 &amp; Silicon, Linux x64, Windows Subsystem for Linux
-</div>
-</div>
-<div class="InstallBox-code-box">
-<div class="InstallBox-curl">
-curl https://bun.sh/install | bash
-</div>
-<button class="InstallBox-copy" aria-label="Copy installation script">
-copy
-</button>
-</div>
-<a class="InstallBox-view-source-link" target="_blank" href="https://bun.sh/install">Show script source</a
+ </head>
+ <body>
+ <div id="header-wrap">
+ <header>
+ <a href="/" id="logo-link" aria-label="home"
+ ><img
+ height="61px"
+ src="data:image/svg+xml;base64, PHN2ZyBpZD0iQnVuIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA4MCA3MCI+PHRpdGxlPkJ1biBMb2dvPC90aXRsZT48cGF0aCBpZD0iU2hhZG93IiBkPSJNNzEuMDksMjAuNzRjLS4xNi0uMTctLjMzLS4zNC0uNS0uNXMtLjMzLS4zNC0uNS0uNS0uMzMtLjM0LS41LS41LS4zMy0uMzQtLjUtLjUtLjMzLS4zNC0uNS0uNS0uMzMtLjM0LS41LS41LS4zMy0uMzQtLjUtLjVBMjYuNDYsMjYuNDYsMCwwLDEsNzUuNSwzNS43YzAsMTYuNTctMTYuODIsMzAuMDUtMzcuNSwzMC4wNS0xMS41OCwwLTIxLjk0LTQuMjMtMjguODMtMTAuODZsLjUuNS41LjUuNS41LjUuNS41LjUuNS41LjUuNUMxOS41NSw2NS4zLDMwLjE0LDY5Ljc1LDQyLDY5Ljc1YzIwLjY4LDAsMzcuNS0xMy40OCwzNy41LTMwQzc5LjUsMzIuNjksNzYuNDYsMjYsNzEuMDksMjAuNzRaIi8+PGcgaWQ9IkJvZHkiPjxwYXRoIGlkPSJCYWNrZ3JvdW5kIiBkPSJNNzMsMzUuN2MwLDE1LjIxLTE1LjY3LDI3LjU0LTM1LDI3LjU0UzMsNTAuOTEsMywzNS43QzMsMjYuMjcsOSwxNy45NCwxOC4yMiwxM1MzMy4xOCwzLDM4LDNzOC45NCw0LjEzLDE5Ljc4LDEwQzY3LDE3Ljk0LDczLDI2LjI3LDczLDM1LjdaIiBzdHlsZT0iZmlsbDojZmJmMGRmIi8+PHBhdGggaWQ9IkJvdHRvbV9TaGFkb3ciIGRhdGEtbmFtZT0iQm90dG9tIFNoYWRvdyIgZD0iTTczLDM1LjdhMjEuNjcsMjEuNjcsMCwwLDAtLjgtNS43OGMtMi43MywzMy4zLTQzLjM1LDM0LjktNTkuMzIsMjQuOTRBNDAsNDAsMCwwLDAsMzgsNjMuMjRDNTcuMyw2My4yNCw3Myw1MC44OSw3MywzNS43WiIgc3R5bGU9ImZpbGw6I2Y2ZGVjZSIvPjxwYXRoIGlkPSJMaWdodF9TaGluZSIgZGF0YS1uYW1lPSJMaWdodCBTaGluZSIgZD0iTTI0LjUzLDExLjE3QzI5LDguNDksMzQuOTQsMy40Niw0MC43OCwzLjQ1QTkuMjksOS4yOSwwLDAsMCwzOCwzYy0yLjQyLDAtNSwxLjI1LTguMjUsMy4xMy0xLjEzLjY2LTIuMywxLjM5LTMuNTQsMi4xNS0yLjMzLDEuNDQtNSwzLjA3LTgsNC43QzguNjksMTguMTMsMywyNi42MiwzLDM1LjdjMCwuNCwwLC44LDAsMS4xOUM5LjA2LDE1LjQ4LDIwLjA3LDEzLjg1LDI0LjUzLDExLjE3WiIgc3R5bGU9ImZpbGw6I2ZmZmVmYyIvPjxwYXRoIGlkPSJUb3AiIGQ9Ik0zNS4xMiw1LjUzQTE2LjQxLDE2LjQxLDAsMCwxLDI5LjQ5LDE4Yy0uMjguMjUtLjA2LjczLjMuNTksMy4zNy0xLjMxLDcuOTItNS4yMyw2LTEzLjE0QzM1LjcxLDUsMzUuMTIsNS4xMiwzNS4xMiw1LjUzWm0yLjI3LDBBMTYuMjQsMTYuMjQsMCwwLDEsMzksMTljLS4xMi4zNS4zMS42NS41NS4zNkM0MS43NCwxNi41Niw0My42NSwxMSwzNy45Myw1LDM3LjY0LDQuNzQsMzcuMTksNS4xNCwzNy4zOSw1LjQ5Wm0yLjc2LS4xN0ExNi40MiwxNi40MiwwLDAsMSw0NywxNy4xMmEuMzMuMzMsMCwwLDAsLjY1LjExYy45Mi0zLjQ5LjQtOS40NC03LjE3LTEyLjUzQzQwLjA4LDQuNTQsMzkuODIsNS4wOCw0MC4xNSw1LjMyWk0yMS42OSwxNS43NmExNi45NCwxNi45NCwwLDAsMCwxMC40Ny05Yy4xOC0uMzYuNzUtLjIyLjY2LjE4LTEuNzMsOC03LjUyLDkuNjctMTEuMTIsOS40NUMyMS4zMiwxNi40LDIxLjMzLDE1Ljg3LDIxLjY5LDE1Ljc2WiIgc3R5bGU9ImZpbGw6I2NjYmVhNztmaWxsLXJ1bGU6ZXZlbm9kZCIvPjxwYXRoIGlkPSJPdXRsaW5lIiBkPSJNMzgsNjUuNzVDMTcuMzIsNjUuNzUuNSw1Mi4yNy41LDM1LjdjMC0xMCw2LjE4LTE5LjMzLDE2LjUzLTI0LjkyLDMtMS42LDUuNTctMy4yMSw3Ljg2LTQuNjIsMS4yNi0uNzgsMi40NS0xLjUxLDMuNi0yLjE5QzMyLDEuODksMzUsLjUsMzgsLjVzNS42MiwxLjIsOC45LDMuMTRjMSwuNTcsMiwxLjE5LDMuMDcsMS44NywyLjQ5LDEuNTQsNS4zLDMuMjgsOSw1LjI3QzY5LjMyLDE2LjM3LDc1LjUsMjUuNjksNzUuNSwzNS43LDc1LjUsNTIuMjcsNTguNjgsNjUuNzUsMzgsNjUuNzVaTTM4LDNjLTIuNDIsMC01LDEuMjUtOC4yNSwzLjEzLTEuMTMuNjYtMi4zLDEuMzktMy41NCwyLjE1LTIuMzMsMS40NC01LDMuMDctOCw0LjdDOC42OSwxOC4xMywzLDI2LjYyLDMsMzUuNywzLDUwLjg5LDE4LjcsNjMuMjUsMzgsNjMuMjVTNzMsNTAuODksNzMsMzUuN0M3MywyNi42Miw2Ny4zMSwxOC4xMyw1Ny43OCwxMyw1NCwxMSw1MS4wNSw5LjEyLDQ4LjY2LDcuNjRjLTEuMDktLjY3LTIuMDktMS4yOS0zLTEuODRDNDIuNjMsNCw0MC40MiwzLDM4LDNaIi8+PC9nPjxnIGlkPSJNb3V0aCI+PGcgaWQ9IkJhY2tncm91bmQtMiIgZGF0YS1uYW1lPSJCYWNrZ3JvdW5kIj48cGF0aCBkPSJNNDUuMDUsNDNhOC45Myw4LjkzLDAsMCwxLTIuOTIsNC43MSw2LjgxLDYuODEsMCwwLDEtNCwxLjg4QTYuODQsNi44NCwwLDAsMSwzNCw0Ny43MSw4LjkzLDguOTMsMCwwLDEsMzEuMTIsNDNhLjcyLjcyLDAsMCwxLC44LS44MUg0NC4yNkEuNzIuNzIsMCwwLDEsNDUuMDUsNDNaIiBzdHlsZT0iZmlsbDojYjcxNDIyIi8+PC9nPjxnIGlkPSJUb25ndWUiPjxwYXRoIGlkPSJCYWNrZ3JvdW5kLTMiIGRhdGEtbmFtZT0iQmFja2dyb3VuZCIgZD0iTTM0LDQ3Ljc5YTYuOTEsNi45MSwwLDAsMCw0LjEyLDEuOSw2LjkxLDYuOTEsMCwwLDAsNC4xMS0xLjksMTAuNjMsMTAuNjMsMCwwLDAsMS0xLjA3LDYuODMsNi44MywwLDAsMC00LjktMi4zMSw2LjE1LDYuMTUsMCwwLDAtNSwyLjc4QzMzLjU2LDQ3LjQsMzMuNzYsNDcuNiwzNCw0Ny43OVoiIHN0eWxlPSJmaWxsOiNmZjYxNjQiLz48cGF0aCBpZD0iT3V0bGluZS0yIiBkYXRhLW5hbWU9Ik91dGxpbmUiIGQ9Ik0zNC4xNiw0N2E1LjM2LDUuMzYsMCwwLDEsNC4xOS0yLjA4LDYsNiwwLDAsMSw0LDEuNjljLjIzLS4yNS40NS0uNTEuNjYtLjc3YTcsNywwLDAsMC00LjcxLTEuOTMsNi4zNiw2LjM2LDAsMCwwLTQuODksMi4zNkE5LjUzLDkuNTMsMCwwLDAsMzQuMTYsNDdaIi8+PC9nPjxwYXRoIGlkPSJPdXRsaW5lLTMiIGRhdGEtbmFtZT0iT3V0bGluZSIgZD0iTTM4LjA5LDUwLjE5YTcuNDIsNy40MiwwLDAsMS00LjQ1LTIsOS41Miw5LjUyLDAsMCwxLTMuMTEtNS4wNSwxLjIsMS4yLDAsMCwxLC4yNi0xLDEuNDEsMS40MSwwLDAsMSwxLjEzLS41MUg0NC4yNmExLjQ0LDEuNDQsMCwwLDEsMS4xMy41MSwxLjE5LDEuMTksMCwwLDEsLjI1LDFoMGE5LjUyLDkuNTIsMCwwLDEtMy4xMSw1LjA1QTcuNDIsNy40MiwwLDAsMSwzOC4wOSw1MC4xOVptLTYuMTctNy40Yy0uMTYsMC0uMi4wNy0uMjEuMDlhOC4yOSw4LjI5LDAsMCwwLDIuNzMsNC4zN0E2LjIzLDYuMjMsMCwwLDAsMzguMDksNDlhNi4yOCw2LjI4LDAsMCwwLDMuNjUtMS43Myw4LjMsOC4zLDAsMCwwLDIuNzItNC4zNy4yMS4yMSwwLDAsMC0uMi0uMDlaIi8+PC9nPjxnIGlkPSJGYWNlIj48ZWxsaXBzZSBpZD0iUmlnaHRfQmx1c2giIGRhdGEtbmFtZT0iUmlnaHQgQmx1c2giIGN4PSI1My4yMiIgY3k9IjQwLjE4IiByeD0iNS44NSIgcnk9IjMuNDQiIHN0eWxlPSJmaWxsOiNmZWJiZDAiLz48ZWxsaXBzZSBpZD0iTGVmdF9CbHVjaCIgZGF0YS1uYW1lPSJMZWZ0IEJsdWNoIiBjeD0iMjIuOTUiIGN5PSI0MC4xOCIgcng9IjUuODUiIHJ5PSIzLjQ0IiBzdHlsZT0iZmlsbDojZmViYmQwIi8+PHBhdGggaWQ9IkV5ZXMiIGQ9Ik0yNS43LDM4LjhhNS41MSw1LjUxLDAsMSwwLTUuNS01LjUxQTUuNTEsNS41MSwwLDAsMCwyNS43LDM4LjhabTI0Ljc3LDBBNS41MSw1LjUxLDAsMSwwLDQ1LDMzLjI5LDUuNSw1LjUsMCwwLDAsNTAuNDcsMzguOFoiIHN0eWxlPSJmaWxsLXJ1bGU6ZXZlbm9kZCIvPjxwYXRoIGlkPSJJcmlzIiBkPSJNMjQsMzMuNjRhMi4wNywyLjA3LDAsMSwwLTIuMDYtMi4wN0EyLjA3LDIuMDcsMCwwLDAsMjQsMzMuNjRabTI0Ljc3LDBhMi4wNywyLjA3LDAsMSwwLTIuMDYtMi4wN0EyLjA3LDIuMDcsMCwwLDAsNDguNzUsMzMuNjRaIiBzdHlsZT0iZmlsbDojZmZmO2ZpbGwtcnVsZTpldmVub2RkIi8+PC9nPjwvc3ZnPg=="
+ alt="Bun logo"
+ id="logo" /><img
+ alt="Bun"
+ id="logo-text"
+ height="31.65px"
+ src="data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAALkAAAA9CAYAAADxjMiSAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAi1SURBVHgB7Z3vddpIEMBnBPhdPgUqiLgUYFJBSAXxVRC7gjgVxK4gdgVxKohdQUgFRxo4SAXgT753Ejs3s5JsQiQQsCsJaX/v+R+SkZBmZ2fnnxAKgGYTf/W1AKCL/JW2fxtgGv86x15/Dg7HHmDeHVlQRSC7IYBP/AWxkKKHL/R2osfX9N/RPqZOcsrvN0XEqVL0g/8e80AYuwHgyMMvQi6CHETCOfBADQi9F7zDgCLB7UL1GCOp7wTebafXH4HDkcKjkAfzyTf+MYBqCvNGRNvzt1FLwSVr+Ck4HDHLQk5QExDhxgm7I8GDGkIEpwuEb//NJqfgaDxayONFZa2QhS9r9M/B/eQjOBqNFvJ/D9QOzwXBRXg/+QyOxlJLc2UVMV9Yo38CRyNphJBrCM6D2WQIjsbRhgYhNjr/6IOjckhUnGM0Q/61yzEaH7zW88dtin6SRL93DAJqF6LWcOyNgCZA8GZT4Ii9MhIv0DGD5IJzRDcJiKWmI9ByKgLifOXGTHd1Z2aciy/bMCWqnHEeU4kjbPrcImgLPpaKPqO/Es1ORaLQoBb3CrypF0Wm53kDc+LwCD14j2xObhkhH7EJ+qXDP/Nc18YJOd+Um/Zz/yxr+wPf6DbCBEwek29Gu9t/AzsQzKd8X2gIBmBhOmv3+jdg+VibjqOPJV4vNiFhX6cHwkVbwfU67d4cmzyGtdIJOFJByNbY26EGWVtEiQSzf8bi9QITXj1+H46J/J2WBJhg3SaPwu04SqZNHlVzmdKSTMMkG1G+FNCJh/jaZHJXCl25IC4aao8FeH7a62KeSJCOAH0wiMhLyIIeziYyg9yubrcl5HM+8jW/+c2WwqRPUCKVHsJHW8Ie1DkuUAFaCMdprwdAVwjogx26hPCVZefVUa8/Xt5gx1xhAefFx8Wu2pJP8ibgBSL/OgYLYEOFXBX0uUU5rUbRRXHxeugdWAZlplgxXSprkz/jARIS/AUyKxiG1rxnq8YDYNPgNjlzBivvJTMzFEM3jFzFT8eWb5Zt4J0RQeeV+hcwTOfJzfYbTdXypvEit6dGtHjBMjZcDvwdgndlBGZxFUWF8ORhYRPiPRTN0sxReSFXa7TuLrBdaMXOd/xK4mF5iOzjARTPozavvJCbNh9aii7BYZ3Ew8JrnNLiEghKH7vyQm60IJqjnU32jydh+iKQ+yaalE0V6x6VzHNATx+78glasb/cCE6LZ/OwJmK4M+WninRloFVakwf3P40FhIjgg4tyNg+Wn0ElNXmcnfYRSJ2DCUhdHvVeXoGjbMSrNeWop/ZuEZD17hAs5MNKCblEqli434WSnUaGPjwLeKf38iLv7rLQrU3bgoqAUWrsZVoKbjibnPAOn2z50WUBbEfI2S8aziepCw7KcAlK/rJ05wJzEjYXE4U1+M02/xTnUjsMoDufRWm3o6x94oSqWxb2K7LgT5fBY0uTdyl7GvIh/WSMIV4UWWQ6G7w8RMBbBG/y3gMW9vNgPj02lTu/TK3yyWValMofKYpwAl4uinZo7kR2vF+1EnJF6q5tOEJaPnS4bfu2JLLZcQSGqZcmR+9TiDAJ5pOZ9HbUiUE2/L8F0rSEMST6AYaxZJPjLRHdZWzM7EvOYdguR6lew/65DvL+Em0bLlijBPeTm87zvgsEHQBKEujALHaEnEfj0YZC1nVI9K0FdGEiyZ4ij80Fe3tO8yyE4vI8R0mgBXOzkuaK5JEf9f48ZeE0pn1F2BcpVSMp+7k03BIJmyLkCVJCx2aPsaKJJUF3hREN4gAWnmg0HK8ru73sUiwbmoRctVGpVF7I48prsyYEwXnB2twHR2kchAsRLdjJIaQnfz2zE0Tqxu3eHCVwEEJuZbqPXJXpmyyYLEmViqN4Ki/ksQa0YVoMszZY8bCg935bE0kS/qvaSeGQOABNTmZyytPeOcOdSATGo24Q9QP5mnfnuAlr7v0d2Xjxt0r6hkWLF9F1KQVbFf3DYD5Z25xSP0tVnooRlY45r4wBdMTT9PSMHuxdMFumJov7bNtiEOfX3PKM8R2ern0XEd6GYka5kKtRrIT15Rk9HEYXIR2Rgi/bPB0gskPpFAqo8s4K8bcARiFY54SF2i1GC8Ba+VucMyLCeioCw5pL+7vlyQTSxnl53zgxS7T/EHQCVyG1OZkmiQxIHqRTt+irB0XWeGo/MYfpYVWGqYT1L5L6vnYHgjsoo71ZDF8iyeTsA+IxGGJVuSzzByugAmavUmjckyYSWuCtTReguFd6WbQIPpDhlIZ11Lk/ZNLVtlGZd5jjgUpxZXlZ12Ucn58tL0+j0EK+aJiQs5Y8y7UjwTWUAMXH7dSulK8cmmeukMpdYMsLFjEXClcAnbhdtZgQ6AR9b5ol5EQ/tmo0xEJGBgs3ch1zpSkpGax5bGpBSGOEXDRiG3AIW3LU61/ZqCDPYrUpKbtTp2CITZHtus4ajRByWWiyHf5qVw9CSHRWiACkmFLKLT73Rgv5sxo34mF/+LU8DXkfF5lcH2XpIV0JMhAzTCkn5HtSW02uNa900+q9NJLFKBVKocwGNjQ6292taBD9hkkPCzV0EVtHIdeNPll79ztrGk3ugmh0eb6oyeJqPdPwWiFrpinSw1LXheljWJ+1VL+lc0doiFEo+aDKteI+iNdpj502SWzanT7MJhf79IZJ2hnzTDPauLM8QMDDt/zT5z/8LXJq5lHpII6BFj85yjtdexi+fh7iW+JjQHSMrVJ9o8HIC2WUZp80hR2Q9IIFD3zA1jFFLfJ82CHlGKNMUsmVym5WpBvhs6BLp34PlC8H3fIC20Zu4Jht5btO9HjzUrSQfl68Vg5quOYaRc3n+YIrxW5MA+cbVxnpm588Rr2zpIlNNTyV3Pcgo+uZCFF8zLnt65/k4IcZ8rfUA/O3c9kp3U8XM0TtmX3UX6rLN1iyCLsy+pJtYIjlUSlCIsK9Tfquo9lYz2ld1TiYc+pJRqZrwezYl/8BpjOlthQ26tQAAAAASUVORK5CYII="
+ /></a>
+ <nav class="Navigation">
+ <ul>
+ <li>
+ <a class="NavText" href="https://github.com/oven-sh/bun#Reference">Docs</a>
+ </li>
+ <li>
+ <a class="NavText" href="https://bun.sh/discord">Discord</a>
+ </li>
+ <li>
+ <a class="NavText" href="https://github.com/oven-sh/bun">GitHub</a>
+ </li>
+ </ul>
+ </nav>
+ </header>
+ </div>
+ <div id="pitch">
+ <main>
+ <div id="pitch-content">
+ <h1 class="tagline">Bun is a fast all-in-one JavaScript runtime</h1>
+ <p class="subtitle">
+ Bundle, transpile, install and run JavaScript &amp; TypeScript projects — all in Bun. Bun is a new
+ JavaScript runtime with a native bundler, transpiler, task runner and npm client built-in.
+ </p>
+ <div class="InstallBox InstallBox--desktop">
+ <div class="InstallBox-label">
+ <div class="InstallBox-label-heading">
+ Install Bun CLI
+ <!-- -->0.2.1<!-- -->
+ (beta)
+ </div>
+ <div class="InstallBox-label-subtitle">
+ macOS x64 &amp; Silicon, Linux x64, Windows Subsystem for Linux
+ </div>
+ </div>
+ <div class="InstallBox-code-box">
+ <div class="InstallBox-curl">curl https://bun.sh/install | bash</div>
+ <button class="InstallBox-copy" aria-label="Copy installation script">copy</button>
+ </div>
+ <a class="InstallBox-view-source-link" target="_blank" href="https://bun.sh/install">Show script source</a>
+ </div>
+ </div>
+ <div class="Graphs Graphs--active-react">
+ <div class="Tabs" role="tablist">
+ <button
+ data-tab="react"
+ id="tab-react"
+ aria-controls="react-tab-content"
+ class="Tab"
+ role="tab"
+ aria-selected="true"
+ tabindex="0"
+ >
+ Bun.serve</button
+ ><button
+ data-tab="websocket"
+ id="tab-websocket"
+ aria-controls="websocket-tab-content"
+ class="Tab"
+ role="tab"
+ tabindex="-1"
+ >
+ WebSocket</button
+ ><button
+ data-tab="sqlite"
+ id="tab-sqlite"
+ aria-controls="sqlite-tab-content"
+ class="Tab"
+ role="tab"
+ tabindex="-1"
>
-</div>
-</div>
-<div class="Graphs Graphs--active-react">
-<div class="Tabs" role="tablist">
-<button data-tab="react" id="tab-react" aria-controls="react-tab-content" class="Tab" role="tab" aria-selected="true" tabindex="0">
-Bun.serve</button
- ><button data-tab="websocket" id="tab-websocket" aria-controls="websocket-tab-content" class="Tab" role="tab" tabindex="-1">
-WebSocket</button
- ><button data-tab="sqlite" id="tab-sqlite" aria-controls="sqlite-tab-content" class="Tab" role="tab" tabindex="-1">
-bun:sqlite
-</button>
-</div>
-<div id="active-tab" class="ActiveTab">
-<div role="tabpanel" tabindex="0" id="react-tab-content" aria-labelledby="tab-react" class="BarGraph BarGraph--react BarGraph--horizontal BarGraph--dark">
-<h2 class="BarGraph-heading">Server-side rendering React</h2>
-<p class="BarGraph-subheading">
-HTTP requests per second (Linux x64)
-</p>
-<ul style="--count: 3" class="BarGraphList">
-<li class="BarGraphItem BarGraphItem--bun" style="--amount: 69845; --max: 87306.25">
-<div class="visually-hidden">
-bun: 69,845 requests per second
-</div>
-<div style="--amount: 69845; --max: 87306.25" class="BarGraphBar" aria-hidden="true">
-<div style="--amount: 69845; --max: 87306.25" class="BarGraphBar-label">
-69,845
-</div>
-</div>
-</li>
-<li class="BarGraphItem BarGraphItem--node" style="--amount: 16288; --max: 87306.25">
-<div class="visually-hidden">
-node: 16,288 requests per second
-</div>
-<div style="--amount: 16288; --max: 87306.25" class="BarGraphBar" aria-hidden="true">
-<div style="--amount: 16288; --max: 87306.25" class="BarGraphBar-label">
-16,288
-</div>
-</div>
-</li>
-<li class="BarGraphItem BarGraphItem--deno" style="--amount: 12926; --max: 87306.25">
-<div class="visually-hidden">
-deno: 12,926 requests per second
-</div>
-<div style="--amount: 12926; --max: 87306.25" class="BarGraphBar" aria-hidden="true">
-<div style="--amount: 12926; --max: 87306.25" class="BarGraphBar-label">
-12,926
-</div>
-</div>
-</li>
-</ul>
-<div style="--count: 3" class="BarGraphKey">
-<a href="https://github.com/oven-sh/bun/blob/b0a7f8df926e91d3b2f0b3b8833ddaf55073f30e/bench/react-hello-world/react-hello-world.jsx#L27" target="_blank" class="BarGraphKeyItem" aria-label="bun benchmark source"><div class="BarGraphKeyItem-label">bun</div>
-<div class="BarGraphKeyItem-value">v0.2.0</div>
-<div class="BarGraphKeyItem-viewSource">View source</div></a
- ><a href="https://github.com/oven-sh/bun/blob/e55d6eed2bf9a5db30250fdd8b9be063dc949054/bench/react-hello-world/react-hello-world.node.jsx" target="_blank" class="BarGraphKeyItem" aria-label="node benchmark source"><div class="BarGraphKeyItem-label">node</div>
-<div class="BarGraphKeyItem-value">v18.1.0</div>
-<div class="BarGraphKeyItem-viewSource">View source</div></a
- ><a href="https://github.com/oven-sh/bun/blob/af033c02c5fbaade201abfe332f376879d9e6885/bench/react-hello-world/react-hello-world.deno.jsx" target="_blank" class="BarGraphKeyItem" aria-label="Deno.serve() benchmark source"><div class="BarGraphKeyItem-label">Deno.serve()</div>
-<div class="BarGraphKeyItem-value">v1.26.0</div>
-<div class="BarGraphKeyItem-viewSource">View source</div></a
+ bun:sqlite
+ </button>
+ </div>
+ <div id="active-tab" class="ActiveTab">
+ <div
+ role="tabpanel"
+ tabindex="0"
+ id="react-tab-content"
+ aria-labelledby="tab-react"
+ class="BarGraph BarGraph--react BarGraph--horizontal BarGraph--dark"
+ >
+ <h2 class="BarGraph-heading">Server-side rendering React</h2>
+ <p class="BarGraph-subheading">HTTP requests per second (Linux x64)</p>
+ <ul style="--count: 3" class="BarGraphList">
+ <li class="BarGraphItem BarGraphItem--bun" style="--amount: 69845; --max: 87306.25">
+ <div class="visually-hidden">bun: 69,845 requests per second</div>
+ <div style="--amount: 69845; --max: 87306.25" class="BarGraphBar" aria-hidden="true">
+ <div style="--amount: 69845; --max: 87306.25" class="BarGraphBar-label">69,845</div>
+ </div>
+ </li>
+ <li class="BarGraphItem BarGraphItem--node" style="--amount: 16288; --max: 87306.25">
+ <div class="visually-hidden">node: 16,288 requests per second</div>
+ <div style="--amount: 16288; --max: 87306.25" class="BarGraphBar" aria-hidden="true">
+ <div style="--amount: 16288; --max: 87306.25" class="BarGraphBar-label">16,288</div>
+ </div>
+ </li>
+ <li class="BarGraphItem BarGraphItem--deno" style="--amount: 12926; --max: 87306.25">
+ <div class="visually-hidden">deno: 12,926 requests per second</div>
+ <div style="--amount: 12926; --max: 87306.25" class="BarGraphBar" aria-hidden="true">
+ <div style="--amount: 12926; --max: 87306.25" class="BarGraphBar-label">12,926</div>
+ </div>
+ </li>
+ </ul>
+ <div style="--count: 3" class="BarGraphKey">
+ <a
+ href="https://github.com/oven-sh/bun/blob/b0a7f8df926e91d3b2f0b3b8833ddaf55073f30e/bench/react-hello-world/react-hello-world.jsx#L27"
+ target="_blank"
+ class="BarGraphKeyItem"
+ aria-label="bun benchmark source"
+ ><div class="BarGraphKeyItem-label">bun</div>
+ <div class="BarGraphKeyItem-value">v0.2.0</div>
+ <div class="BarGraphKeyItem-viewSource">View source</div></a
+ ><a
+ href="https://github.com/oven-sh/bun/blob/e55d6eed2bf9a5db30250fdd8b9be063dc949054/bench/react-hello-world/react-hello-world.node.jsx"
+ target="_blank"
+ class="BarGraphKeyItem"
+ aria-label="node benchmark source"
+ ><div class="BarGraphKeyItem-label">node</div>
+ <div class="BarGraphKeyItem-value">v18.1.0</div>
+ <div class="BarGraphKeyItem-viewSource">View source</div></a
+ ><a
+ href="https://github.com/oven-sh/bun/blob/af033c02c5fbaade201abfe332f376879d9e6885/bench/react-hello-world/react-hello-world.deno.jsx"
+ target="_blank"
+ class="BarGraphKeyItem"
+ aria-label="Deno.serve() benchmark source"
+ ><div class="BarGraphKeyItem-label">Deno.serve()</div>
+ <div class="BarGraphKeyItem-value">v1.26.0</div>
+ <div class="BarGraphKeyItem-viewSource">View source</div></a
>
-</div>
-</div>
-<div role="tabpanel" tabindex="-1" id="websocket-tab-content" aria-labelledby="tab-websocket" class="BarGraph BarGraph--websocket BarGraph--horizontal BarGraph--dark">
-<h2 class="BarGraph-heading">WebSocket server chat</h2>
-<p class="BarGraph-subheading">
-Messages sent per second (Linux x64, 16 clients)
-</p>
-<ul style="--count: 3" class="BarGraphList">
-<li class="BarGraphItem BarGraphItem--bun" style="--amount: 737280; --max: 921600">
-<div class="visually-hidden">
-bun: 737,280 messages sent per second
-</div>
-<div style="--amount: 737280; --max: 921600" class="BarGraphBar" aria-hidden="true">
-<div style="--amount: 737280; --max: 921600" class="BarGraphBar-label">
-737,280
-</div>
-</div>
-</li>
-<li class="BarGraphItem BarGraphItem--node" style="--amount: 107457; --max: 921600">
-<div class="visually-hidden">
-node: 107,457 messages sent per second
-</div>
-<div style="--amount: 107457; --max: 921600" class="BarGraphBar" aria-hidden="true">
-<div style="--amount: 107457; --max: 921600" class="BarGraphBar-label">
-107,457
-</div>
-</div>
-</li>
-<li class="BarGraphItem BarGraphItem--deno" style="--amount: 82097; --max: 921600">
-<div class="visually-hidden">
-deno: 82,097 messages sent per second
-</div>
-<div style="--amount: 82097; --max: 921600" class="BarGraphBar" aria-hidden="true">
-<div style="--amount: 82097; --max: 921600" class="BarGraphBar-label">
-82,097
-</div>
-</div>
-</li>
-</ul>
-<div style="--count: 3" class="BarGraphKey">
-<a href="https://github.com/oven-sh/bun/blob/9c7eb75a9ac845d92bfdfd6cc574dc8f39bde293/bench/websocket-server/chat-server.bun.js#L1" target="_blank" class="BarGraphKeyItem" aria-label="Bun.serve() benchmark source"><div class="BarGraphKeyItem-label">Bun.serve()</div>
-<div class="BarGraphKeyItem-value">v0.2.1</div>
-<div class="BarGraphKeyItem-viewSource">View source</div></a
- ><a href="https://github.com/oven-sh/bun/blob/9c7eb75a9ac845d92bfdfd6cc574dc8f39bde293/bench/websocket-server/chat-server.node.mjs#L1" target="_blank" class="BarGraphKeyItem" aria-label="ws (Node.js) benchmark source"><div class="BarGraphKeyItem-label">ws (Node.js)</div>
-<div class="BarGraphKeyItem-value">node v18.10.0</div>
-<div class="BarGraphKeyItem-viewSource">View source</div></a
- ><a href="https://github.com/oven-sh/bun/blob/9c7eb75a9ac845d92bfdfd6cc574dc8f39bde293/bench/websocket-server/chat-server.deno.mjs#L1" target="_blank" class="BarGraphKeyItem" aria-label="Deno.serve() benchmark source"><div class="BarGraphKeyItem-label">Deno.serve()</div>
-<div class="BarGraphKeyItem-value">v1.26.2</div>
-<div class="BarGraphKeyItem-viewSource">View source</div></a
+ </div>
+ </div>
+ <div
+ role="tabpanel"
+ tabindex="-1"
+ id="websocket-tab-content"
+ aria-labelledby="tab-websocket"
+ class="BarGraph BarGraph--websocket BarGraph--horizontal BarGraph--dark"
+ >
+ <h2 class="BarGraph-heading">WebSocket server chat</h2>
+ <p class="BarGraph-subheading">Messages sent per second (Linux x64, 16 clients)</p>
+ <ul style="--count: 3" class="BarGraphList">
+ <li class="BarGraphItem BarGraphItem--bun" style="--amount: 737280; --max: 921600">
+ <div class="visually-hidden">bun: 737,280 messages sent per second</div>
+ <div style="--amount: 737280; --max: 921600" class="BarGraphBar" aria-hidden="true">
+ <div style="--amount: 737280; --max: 921600" class="BarGraphBar-label">737,280</div>
+ </div>
+ </li>
+ <li class="BarGraphItem BarGraphItem--node" style="--amount: 107457; --max: 921600">
+ <div class="visually-hidden">node: 107,457 messages sent per second</div>
+ <div style="--amount: 107457; --max: 921600" class="BarGraphBar" aria-hidden="true">
+ <div style="--amount: 107457; --max: 921600" class="BarGraphBar-label">107,457</div>
+ </div>
+ </li>
+ <li class="BarGraphItem BarGraphItem--deno" style="--amount: 82097; --max: 921600">
+ <div class="visually-hidden">deno: 82,097 messages sent per second</div>
+ <div style="--amount: 82097; --max: 921600" class="BarGraphBar" aria-hidden="true">
+ <div style="--amount: 82097; --max: 921600" class="BarGraphBar-label">82,097</div>
+ </div>
+ </li>
+ </ul>
+ <div style="--count: 3" class="BarGraphKey">
+ <a
+ href="https://github.com/oven-sh/bun/blob/9c7eb75a9ac845d92bfdfd6cc574dc8f39bde293/bench/websocket-server/chat-server.bun.js#L1"
+ target="_blank"
+ class="BarGraphKeyItem"
+ aria-label="Bun.serve() benchmark source"
+ ><div class="BarGraphKeyItem-label">Bun.serve()</div>
+ <div class="BarGraphKeyItem-value">v0.2.1</div>
+ <div class="BarGraphKeyItem-viewSource">View source</div></a
+ ><a
+ href="https://github.com/oven-sh/bun/blob/9c7eb75a9ac845d92bfdfd6cc574dc8f39bde293/bench/websocket-server/chat-server.node.mjs#L1"
+ target="_blank"
+ class="BarGraphKeyItem"
+ aria-label="ws (Node.js) benchmark source"
+ ><div class="BarGraphKeyItem-label">ws (Node.js)</div>
+ <div class="BarGraphKeyItem-value">node v18.10.0</div>
+ <div class="BarGraphKeyItem-viewSource">View source</div></a
+ ><a
+ href="https://github.com/oven-sh/bun/blob/9c7eb75a9ac845d92bfdfd6cc574dc8f39bde293/bench/websocket-server/chat-server.deno.mjs#L1"
+ target="_blank"
+ class="BarGraphKeyItem"
+ aria-label="Deno.serve() benchmark source"
+ ><div class="BarGraphKeyItem-label">Deno.serve()</div>
+ <div class="BarGraphKeyItem-value">v1.26.2</div>
+ <div class="BarGraphKeyItem-viewSource">View source</div></a
>
-</div>
-</div>
-<div role="tabpanel" tabindex="-1" id="sqlite-tab-content" aria-labelledby="tab-sqlite" class="BarGraph--sqlite BarGraph BarGraph--horizontal BarGraph--dark">
-<h2 class="BarGraph-heading">Load a huge table</h2>
-<p class="BarGraph-subheading">Average queries per second</p>
-<ul style="--count: 3" class="BarGraphList">
-<li class="BarGraphItem BarGraphItem--bun" style="--amount: 70.32; --max: 88">
-<div class="visually-hidden">
-bun: 70.32 queries per second
-</div>
-<div style="--amount: 70.32; --max: 88" class="BarGraphBar" aria-hidden="true">
-<div style="--amount: 70.32; --max: 88" class="BarGraphBar-label">
-70.32
-</div>
-</div>
-</li>
-<li class="BarGraphItem BarGraphItem--deno" style="--amount: 36.54; --max: 88">
-<div class="visually-hidden">
-deno: 36.54 queries per second
-</div>
-<div style="--amount: 36.54; --max: 88" class="BarGraphBar" aria-hidden="true">
-<div style="--amount: 36.54; --max: 88" class="BarGraphBar-label">
-36.54
-</div>
-</div>
-</li>
-<li class="BarGraphItem BarGraphItem--better-sqlite3" style="--amount: 23.28; --max: 88">
-<div class="visually-hidden">
-better-sqlite3: 23.28 queries per second
-</div>
-<div style="--amount: 23.28; --max: 88" class="BarGraphBar" aria-hidden="true">
-<div style="--amount: 23.28; --max: 88" class="BarGraphBar-label">
- 23.28
-</div>
-</div>
-</li>
-</ul>
-<div style="--count: 3" class="BarGraphKey">
-<a href="https://github.com/oven-sh/bun/blob/b0a7f8df926e91d3b2f0b3b8833ddaf55073f30e/bench/sqlite/bun.js#L9" target="_blank" class="BarGraphKeyItem" aria-label="bun:sqlite benchmark source"><div class="BarGraphKeyItem-label">bun:sqlite</div>
-<div class="BarGraphKeyItem-value">v0.2.0</div>
-<div class="BarGraphKeyItem-viewSource">View source</div></a
- ><a href="https://github.com/oven-sh/bun/blob/6223030360c121e272aad98c7d1c14a009c5fc1c/bench/sqlite/deno.js#L9" target="_blank" class="BarGraphKeyItem" aria-label="deno (x/sqlite3) benchmark source"><div class="BarGraphKeyItem-label">deno (x/sqlite3)</div>
-<div class="BarGraphKeyItem-value">v1.26.1</div>
-<div class="BarGraphKeyItem-viewSource">View source</div></a
- ><a href="https://github.com/oven-sh/bun/blob/e55d6eed2bf9a5db30250fdd8b9be063dc949054/bench/sqlite/node.mjs" target="_blank" class="BarGraphKeyItem" aria-label="better-sqlite3 benchmark source"><div class="BarGraphKeyItem-label">better-sqlite3</div>
-<div class="BarGraphKeyItem-value">node v18.2.0</div>
-<div class="BarGraphKeyItem-viewSource">View source</div></a
+ </div>
+ </div>
+ <div
+ role="tabpanel"
+ tabindex="-1"
+ id="sqlite-tab-content"
+ aria-labelledby="tab-sqlite"
+ class="BarGraph--sqlite BarGraph BarGraph--horizontal BarGraph--dark"
+ >
+ <h2 class="BarGraph-heading">Load a huge table</h2>
+ <p class="BarGraph-subheading">Average queries per second</p>
+ <ul style="--count: 3" class="BarGraphList">
+ <li class="BarGraphItem BarGraphItem--bun" style="--amount: 70.32; --max: 88">
+ <div class="visually-hidden">bun: 70.32 queries per second</div>
+ <div style="--amount: 70.32; --max: 88" class="BarGraphBar" aria-hidden="true">
+ <div style="--amount: 70.32; --max: 88" class="BarGraphBar-label">70.32</div>
+ </div>
+ </li>
+ <li class="BarGraphItem BarGraphItem--deno" style="--amount: 36.54; --max: 88">
+ <div class="visually-hidden">deno: 36.54 queries per second</div>
+ <div style="--amount: 36.54; --max: 88" class="BarGraphBar" aria-hidden="true">
+ <div style="--amount: 36.54; --max: 88" class="BarGraphBar-label">36.54</div>
+ </div>
+ </li>
+ <li class="BarGraphItem BarGraphItem--better-sqlite3" style="--amount: 23.28; --max: 88">
+ <div class="visually-hidden">better-sqlite3: 23.28 queries per second</div>
+ <div style="--amount: 23.28; --max: 88" class="BarGraphBar" aria-hidden="true">
+ <div style="--amount: 23.28; --max: 88" class="BarGraphBar-label">23.28</div>
+ </div>
+ </li>
+ </ul>
+ <div style="--count: 3" class="BarGraphKey">
+ <a
+ href="https://github.com/oven-sh/bun/blob/b0a7f8df926e91d3b2f0b3b8833ddaf55073f30e/bench/sqlite/bun.js#L9"
+ target="_blank"
+ class="BarGraphKeyItem"
+ aria-label="bun:sqlite benchmark source"
+ ><div class="BarGraphKeyItem-label">bun:sqlite</div>
+ <div class="BarGraphKeyItem-value">v0.2.0</div>
+ <div class="BarGraphKeyItem-viewSource">View source</div></a
+ ><a
+ href="https://github.com/oven-sh/bun/blob/6223030360c121e272aad98c7d1c14a009c5fc1c/bench/sqlite/deno.js#L9"
+ target="_blank"
+ class="BarGraphKeyItem"
+ aria-label="deno (x/sqlite3) benchmark source"
+ ><div class="BarGraphKeyItem-label">deno (x/sqlite3)</div>
+ <div class="BarGraphKeyItem-value">v1.26.1</div>
+ <div class="BarGraphKeyItem-viewSource">View source</div></a
+ ><a
+ href="https://github.com/oven-sh/bun/blob/e55d6eed2bf9a5db30250fdd8b9be063dc949054/bench/sqlite/node.mjs"
+ target="_blank"
+ class="BarGraphKeyItem"
+ aria-label="better-sqlite3 benchmark source"
+ ><div class="BarGraphKeyItem-label">better-sqlite3</div>
+ <div class="BarGraphKeyItem-value">node v18.2.0</div>
+ <div class="BarGraphKeyItem-viewSource">View source</div></a
>
-</div>
-</div>
-</div>
-</div>
-<div class="InstallBox InstallBox--mobile">
-<div class="InstallBox-label">
-<div class="InstallBox-label-heading">
-Install Bun CLI
-<!-- -->0.2.1<!-- -->
-(beta)
-</div>
-<div class="InstallBox-label-subtitle">
-macOS x64 &amp; Silicon, Linux x64, Windows Subsystem for Linux
-</div>
-</div>
-<div class="InstallBox-code-box">
-<div class="InstallBox-curl">
-curl https://bun.sh/install | bash
-</div>
-<button class="InstallBox-copy" aria-label="Copy installation script">
-copy
-</button>
-</div>
-<a class="InstallBox-view-source-link" target="_blank" href="https://bun.sh/install">Show script source</a
- >
-</div>
-</main>
-</div>
-<section id="explain-section">
-<div id="explain">
-<h2>Tell me more about Bun</h2>
-<p>
-Bun is a modern JavaScript runtime like Node or Deno. It was built
-from scratch to focus on three main things:
-</p>
-<ul>
-<li>Start fast (it has the edge in mind).</li>
-<li>
-New levels of performance (extending JavaScriptCore, the engine).
-</li>
-<li>
-Being a great and complete tool (bundler, transpiler, package
-manager).
-</li>
-</ul>
-<p>
-Bun is designed as a drop-in replacement for your current JavaScript
-&amp; TypeScript apps or scripts — on your local computer, server or
-on the edge. Bun natively implements hundreds of Node.js and Web APIs,
-including ~90% of<!-- -->
-<a href="https://nodejs.org/api/n-api.html" target="_blank">Node-API</a
- >
-<!-- -->functions (native modules), fs, path, Buffer and more.
-</p>
-<p>
-The goal of Bun is to run most of the world&#x27;s JavaScript outside
-of browsers, bringing performance and complexity enhancements to your
-future infrastructure, as well as developer productivity through
-better, simpler tooling.
- </p>
-<h2>Batteries included</h2>
-<ul id="batteries">
-<li>
-Web APIs like<!-- -->
-<a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/API/fetch" class="Tag Tag--WebAPI">fetch</a
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="InstallBox InstallBox--mobile">
+ <div class="InstallBox-label">
+ <div class="InstallBox-label-heading">
+ Install Bun CLI
+ <!-- -->0.2.1<!-- -->
+ (beta)
+ </div>
+ <div class="InstallBox-label-subtitle">macOS x64 &amp; Silicon, Linux x64, Windows Subsystem for Linux</div>
+ </div>
+ <div class="InstallBox-code-box">
+ <div class="InstallBox-curl">curl https://bun.sh/install | bash</div>
+ <button class="InstallBox-copy" aria-label="Copy installation script">copy</button>
+ </div>
+ <a class="InstallBox-view-source-link" target="_blank" href="https://bun.sh/install">Show script source</a>
+ </div>
+ </main>
+ </div>
+ <section id="explain-section">
+ <div id="explain">
+ <h2>Tell me more about Bun</h2>
+ <p>
+ Bun is a modern JavaScript runtime like Node or Deno. It was built from scratch to focus on three main things:
+ </p>
+ <ul>
+ <li>Start fast (it has the edge in mind).</li>
+ <li>New levels of performance (extending JavaScriptCore, the engine).</li>
+ <li>Being a great and complete tool (bundler, transpiler, package manager).</li>
+ </ul>
+ <p>
+ Bun is designed as a drop-in replacement for your current JavaScript &amp; TypeScript apps or scripts — on
+ your local computer, server or on the edge. Bun natively implements hundreds of Node.js and Web APIs,
+ including ~90% of<!-- -->
+ <a href="https://nodejs.org/api/n-api.html" target="_blank">Node-API</a>
+ <!-- -->functions (native modules), fs, path, Buffer and more.
+ </p>
+ <p>
+ The goal of Bun is to run most of the world&#x27;s JavaScript outside of browsers, bringing performance and
+ complexity enhancements to your future infrastructure, as well as developer productivity through better,
+ simpler tooling.
+ </p>
+ <h2>Batteries included</h2>
+ <ul id="batteries">
+ <li>
+ Web APIs like<!-- -->
+ <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/API/fetch" class="Tag Tag--WebAPI"
+ >fetch</a
>,<!-- -->
-<a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/API/WebSocket" class="Tag Tag--WebAPI">WebSocket</a
+ <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/API/WebSocket" class="Tag Tag--WebAPI"
+ >WebSocket</a
>, and<!-- -->
-<a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream" class="Tag Tag--WebAPI">ReadableStream</a
- >
-<!-- -->are built-in
-</li>
-<li>
-<span target="_blank" class="Tag Tag--NodeJS">node_modules</span>
-bun implements Node.js&#x27; module resolution algorithm, so you can
-use npm packages in Bun. ESM and CommonJS are supported, but Bun
-internally uses ESM
-</li>
-<li>
-In Bun, every file is transpiled.<!-- -->
-<span target="_blank" class="Tag Tag--TypeScript">TypeScript</span>
-&amp; <span target="_blank" class="Tag Tag--React">JSX</span> just
-work
-</li>
-<li>
-Bun supports <code>&quot;paths&quot;</code>,
-<code>&quot;jsxImportSource&quot;</code>and more from
-<span target="_blank" class="Tag Tag--TypeScript">tsconfig.json</span
- >
-files
-</li>
-<li>
-<span target="_blank" class="Tag Tag--Bun">Bun.Transpiler</span>
-Bun&#x27;s JSX &amp; TypeScript transpiler is available as an API in
-Bun
-</li>
-<li>
-use the fastest system calls available with
-<span target="_blank" class="Tag Tag--Bun">Bun.write</span>
-<!-- -->to write, copy, pipe, send and clone files
-</li>
-<li>
-Bun automatically loads environment variables from
-<span target="_blank" class="Tag Tag--Bun">.env</span>
-<!-- -->files. No more<!-- -->
-<code class="mono">require(&quot;dotenv&quot;).config()</code>
-</li>
-<li>
-Bun ships with a fast SQLite3 client built-in<!-- -->
-<span target="_blank" class="Tag Tag--Bun">bun:sqlite</span>
-</li>
-<li>
-<a target="_blank" href="https://github.com/oven-sh/bun/issues/158" class="Tag Tag--NodeJS">Node-API</a
+ <a
+ target="_blank"
+ href="https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream"
+ class="Tag Tag--WebAPI"
+ >ReadableStream</a
>
-<!-- -->Bun implements most of<!-- -->
-<a href="https://nodejs.org/api/n-api.html#node-api" target="_blank">Node-API (N-API)</a
- >. Many Node.js native modules just work
-</li>
-<li>
-<span target="_blank" class="Tag Tag--Bun">bun:ffi</span> call
-native code from JavaScript with Bun&#x27;s low-overhead foreign
-function interface
-</li>
-<li>
-<span target="_blank" class="Tag Tag--NodeJS">node:fs</span>
-<span target="_blank" class="Tag Tag--NodeJS">node:path</span> Bun
-natively supports a growing list of Node.js core modules along with
-globals like Buffer and process
-</li>
-</ul>
-<h2>How does Bun work?</h2>
-<p>
-Bun uses the<!-- -->
-<a href="https://github.com/WebKit/WebKit/tree/main/Source/JavaScriptCore">JavaScriptCore</a
- >
-<!-- -->engine, which tends<!-- -->
-<a target="blank" href="https://twitter.com/jarredsumner/status/1499225725492076544">to start</a
- >
-<!-- -->and perform a little faster than more traditional choices like
-V8. Bun is written in<!-- -->
-<a href="https://ziglang.org/"><svg xmlns="http://www.w3.org/2000/svg" height="1.2rem" class="Zig" viewBox="0 0 400 140">
-<title>Zig</title>
-<g fill="#F7A41D">
-<g>
-<polygon points="46,22 28,44 19,30"></polygon>
-<polygon points="46,22 33,33 28,44 22,44 22,95 31,95 20,100 12,117 0,117 0,22" shape-rendering="crispEdges"></polygon>
-<polygon points="31,95 12,117 4,106"></polygon>
-</g>
-<g>
-<polygon points="56,22 62,36 37,44"></polygon>
-<polygon points="56,22 111,22 111,44 37,44 56,32" shape-rendering="crispEdges"></polygon>
-<polygon points="116,95 97,117 90,104"></polygon>
-<polygon points="116,95 100,104 97,117 42,117 42,95" shape-rendering="crispEdges"></polygon>
-<polygon points="150,0 52,117 3,140 101,22"></polygon>
-</g>
-<g>
-<polygon points="141,22 140,40 122,45"></polygon>
-<polygon points="153,22 153,117 106,117 120,105 125,95 131,95 131,45 122,45 132,36 141,22" shape-rendering="crispEdges"></polygon>
-<polygon points="125,95 130,110 106,117"></polygon>
-</g>
-</g>
-<g fill="#121212">
-<g>
-<polygon points="260,22 260,37 229,40 177,40 177,22" shape-rendering="crispEdges"></polygon>
-<polygon points="260,37 207,99 207,103 176,103 229,40 229,37"></polygon>
-<polygon points="261,99 261,117 176,117 176,103 206,99" shape-rendering="crispEdges"></polygon>
-</g>
-<rect x="272" y="22" shape-rendering="crispEdges" width="22" height="95"></rect>
-<g>
-<polygon points="394,67 394,106 376,106 376,81 360,70 346,67" shape-rendering="crispEdges"></polygon>
-<polygon points="360,68 376,81 346,67"></polygon>
-<path d="M394,106c-10.2,7.3-24,12-37.7,12c-29,0-51.1-20.8-51.1-48.3c0-27.3,22.5-48.1,52-48.1
+ <!-- -->are built-in
+ </li>
+ <li>
+ <span target="_blank" class="Tag Tag--NodeJS">node_modules</span>
+ bun implements Node.js&#x27; module resolution algorithm, so you can use npm packages in Bun. ESM and
+ CommonJS are supported, but Bun internally uses ESM
+ </li>
+ <li>
+ In Bun, every file is transpiled.<!-- -->
+ <span target="_blank" class="Tag Tag--TypeScript">TypeScript</span>
+ &amp; <span target="_blank" class="Tag Tag--React">JSX</span> just work
+ </li>
+ <li>
+ Bun supports <code>&quot;paths&quot;</code>, <code>&quot;jsxImportSource&quot;</code>and more from
+ <span target="_blank" class="Tag Tag--TypeScript">tsconfig.json</span>
+ files
+ </li>
+ <li>
+ <span target="_blank" class="Tag Tag--Bun">Bun.Transpiler</span>
+ Bun&#x27;s JSX &amp; TypeScript transpiler is available as an API in Bun
+ </li>
+ <li>
+ use the fastest system calls available with
+ <span target="_blank" class="Tag Tag--Bun">Bun.write</span>
+ <!-- -->to write, copy, pipe, send and clone files
+ </li>
+ <li>
+ Bun automatically loads environment variables from
+ <span target="_blank" class="Tag Tag--Bun">.env</span>
+ <!-- -->files. No more<!-- -->
+ <code class="mono">require(&quot;dotenv&quot;).config()</code>
+ </li>
+ <li>
+ Bun ships with a fast SQLite3 client built-in<!-- -->
+ <span target="_blank" class="Tag Tag--Bun">bun:sqlite</span>
+ </li>
+ <li>
+ <a target="_blank" href="https://github.com/oven-sh/bun/issues/158" class="Tag Tag--NodeJS">Node-API</a>
+ <!-- -->Bun implements most of<!-- -->
+ <a href="https://nodejs.org/api/n-api.html#node-api" target="_blank">Node-API (N-API)</a>. Many Node.js
+ native modules just work
+ </li>
+ <li>
+ <span target="_blank" class="Tag Tag--Bun">bun:ffi</span> call native code from JavaScript with Bun&#x27;s
+ low-overhead foreign function interface
+ </li>
+ <li>
+ <span target="_blank" class="Tag Tag--NodeJS">node:fs</span>
+ <span target="_blank" class="Tag Tag--NodeJS">node:path</span> Bun natively supports a growing list of
+ Node.js core modules along with globals like Buffer and process
+ </li>
+ </ul>
+ <h2>How does Bun work?</h2>
+ <p>
+ Bun uses the<!-- -->
+ <a href="https://github.com/WebKit/WebKit/tree/main/Source/JavaScriptCore">JavaScriptCore</a>
+ <!-- -->engine, which tends<!-- -->
+ <a target="blank" href="https://twitter.com/jarredsumner/status/1499225725492076544">to start</a>
+ <!-- -->and perform a little faster than more traditional choices like V8. Bun is written in<!-- -->
+ <a href="https://ziglang.org/"
+ ><svg xmlns="http://www.w3.org/2000/svg" height="1.2rem" class="Zig" viewBox="0 0 400 140">
+ <title>Zig</title>
+ <g fill="#F7A41D">
+ <g>
+ <polygon points="46,22 28,44 19,30"></polygon>
+ <polygon
+ points="46,22 33,33 28,44 22,44 22,95 31,95 20,100 12,117 0,117 0,22"
+ shape-rendering="crispEdges"
+ ></polygon>
+ <polygon points="31,95 12,117 4,106"></polygon>
+ </g>
+ <g>
+ <polygon points="56,22 62,36 37,44"></polygon>
+ <polygon points="56,22 111,22 111,44 37,44 56,32" shape-rendering="crispEdges"></polygon>
+ <polygon points="116,95 97,117 90,104"></polygon>
+ <polygon points="116,95 100,104 97,117 42,117 42,95" shape-rendering="crispEdges"></polygon>
+ <polygon points="150,0 52,117 3,140 101,22"></polygon>
+ </g>
+ <g>
+ <polygon points="141,22 140,40 122,45"></polygon>
+ <polygon
+ points="153,22 153,117 106,117 120,105 125,95 131,95 131,45 122,45 132,36 141,22"
+ shape-rendering="crispEdges"
+ ></polygon>
+ <polygon points="125,95 130,110 106,117"></polygon>
+ </g>
+ </g>
+ <g fill="#121212">
+ <g>
+ <polygon points="260,22 260,37 229,40 177,40 177,22" shape-rendering="crispEdges"></polygon>
+ <polygon points="260,37 207,99 207,103 176,103 229,40 229,37"></polygon>
+ <polygon points="261,99 261,117 176,117 176,103 206,99" shape-rendering="crispEdges"></polygon>
+ </g>
+ <rect x="272" y="22" shape-rendering="crispEdges" width="22" height="95"></rect>
+ <g>
+ <polygon points="394,67 394,106 376,106 376,81 360,70 346,67" shape-rendering="crispEdges"></polygon>
+ <polygon points="360,68 376,81 346,67"></polygon>
+ <path
+ d="M394,106c-10.2,7.3-24,12-37.7,12c-29,0-51.1-20.8-51.1-48.3c0-27.3,22.5-48.1,52-48.1
c14.3,0,29.2,5.5,38.9,14l-13,15c-7.1-6.3-16.8-10-25.9-10c-17,0-30.2,12.9-30.2,29.5c0,16.8,13.3,29.6,30.3,29.6
- c5.7,0,12.8-2.3,19-5.5L394,106z"></path>
-</g>
-</g></svg></a
- >, a low-level programming language with manual memory management.<br /><br />Most
-of Bun is written from scratch including the JSX/TypeScript
-transpiler, npm client, bundler, SQLite client, HTTP client, WebSocket
-client and more.
-</p>
-<h2>Why is Bun fast?</h2>
-<p>
-An enormous amount of time spent profiling, benchmarking and
-optimizing things. The answer is different for every part of Bun, but
-one general theme:<!-- -->
-<a href="https://ziglang.org/"><svg xmlns="http://www.w3.org/2000/svg" height="1.2rem" class="Zig" viewBox="0 0 400 140">
-<title>Zig</title>
-<g fill="#F7A41D">
-<g>
-<polygon points="46,22 28,44 19,30"></polygon>
-<polygon points="46,22 33,33 28,44 22,44 22,95 31,95 20,100 12,117 0,117 0,22" shape-rendering="crispEdges"></polygon>
-<polygon points="31,95 12,117 4,106"></polygon>
-</g>
-<g>
-<polygon points="56,22 62,36 37,44"></polygon>
-<polygon points="56,22 111,22 111,44 37,44 56,32" shape-rendering="crispEdges"></polygon>
-<polygon points="116,95 97,117 90,104"></polygon>
-<polygon points="116,95 100,104 97,117 42,117 42,95" shape-rendering="crispEdges"></polygon>
-<polygon points="150,0 52,117 3,140 101,22"></polygon>
-</g>
-<g>
-<polygon points="141,22 140,40 122,45"></polygon>
-<polygon points="153,22 153,117 106,117 120,105 125,95 131,95 131,45 122,45 132,36 141,22" shape-rendering="crispEdges"></polygon>
-<polygon points="125,95 130,110 106,117"></polygon>
-</g>
-</g>
-<g fill="#121212">
-<g>
-<polygon points="260,22 260,37 229,40 177,40 177,22" shape-rendering="crispEdges"></polygon>
-<polygon points="260,37 207,99 207,103 176,103 229,40 229,37"></polygon>
-<polygon points="261,99 261,117 176,117 176,103 206,99" shape-rendering="crispEdges"></polygon>
-</g>
-<rect x="272" y="22" shape-rendering="crispEdges" width="22" height="95"></rect>
-<g>
-<polygon points="394,67 394,106 376,106 376,81 360,70 346,67" shape-rendering="crispEdges"></polygon>
-<polygon points="360,68 376,81 346,67"></polygon>
-<path d="M394,106c-10.2,7.3-24,12-37.7,12c-29,0-51.1-20.8-51.1-48.3c0-27.3,22.5-48.1,52-48.1
+ c5.7,0,12.8-2.3,19-5.5L394,106z"
+ ></path>
+ </g>
+ </g></svg></a
+ >, a low-level programming language with manual memory management.<br /><br />Most of Bun is written from
+ scratch including the JSX/TypeScript transpiler, npm client, bundler, SQLite client, HTTP client, WebSocket
+ client and more.
+ </p>
+ <h2>Why is Bun fast?</h2>
+ <p>
+ An enormous amount of time spent profiling, benchmarking and optimizing things. The answer is different for
+ every part of Bun, but one general theme:<!-- -->
+ <a href="https://ziglang.org/"
+ ><svg xmlns="http://www.w3.org/2000/svg" height="1.2rem" class="Zig" viewBox="0 0 400 140">
+ <title>Zig</title>
+ <g fill="#F7A41D">
+ <g>
+ <polygon points="46,22 28,44 19,30"></polygon>
+ <polygon
+ points="46,22 33,33 28,44 22,44 22,95 31,95 20,100 12,117 0,117 0,22"
+ shape-rendering="crispEdges"
+ ></polygon>
+ <polygon points="31,95 12,117 4,106"></polygon>
+ </g>
+ <g>
+ <polygon points="56,22 62,36 37,44"></polygon>
+ <polygon points="56,22 111,22 111,44 37,44 56,32" shape-rendering="crispEdges"></polygon>
+ <polygon points="116,95 97,117 90,104"></polygon>
+ <polygon points="116,95 100,104 97,117 42,117 42,95" shape-rendering="crispEdges"></polygon>
+ <polygon points="150,0 52,117 3,140 101,22"></polygon>
+ </g>
+ <g>
+ <polygon points="141,22 140,40 122,45"></polygon>
+ <polygon
+ points="153,22 153,117 106,117 120,105 125,95 131,95 131,45 122,45 132,36 141,22"
+ shape-rendering="crispEdges"
+ ></polygon>
+ <polygon points="125,95 130,110 106,117"></polygon>
+ </g>
+ </g>
+ <g fill="#121212">
+ <g>
+ <polygon points="260,22 260,37 229,40 177,40 177,22" shape-rendering="crispEdges"></polygon>
+ <polygon points="260,37 207,99 207,103 176,103 229,40 229,37"></polygon>
+ <polygon points="261,99 261,117 176,117 176,103 206,99" shape-rendering="crispEdges"></polygon>
+ </g>
+ <rect x="272" y="22" shape-rendering="crispEdges" width="22" height="95"></rect>
+ <g>
+ <polygon points="394,67 394,106 376,106 376,81 360,70 346,67" shape-rendering="crispEdges"></polygon>
+ <polygon points="360,68 376,81 346,67"></polygon>
+ <path
+ d="M394,106c-10.2,7.3-24,12-37.7,12c-29,0-51.1-20.8-51.1-48.3c0-27.3,22.5-48.1,52-48.1
c14.3,0,29.2,5.5,38.9,14l-13,15c-7.1-6.3-16.8-10-25.9-10c-17,0-30.2,12.9-30.2,29.5c0,16.8,13.3,29.6,30.3,29.6
- c5.7,0,12.8-2.3,19-5.5L394,106z"></path>
-</g>
-</g></svg></a
- >&#x27;s low-level control over memory and lack of hidden control flow
-makes it much simpler to write fast software.<!-- -->
-<a href="https://github.com/sponsors/ziglang">Sponsor the Zig Software Foundation</a
- >.
-</p>
-<h2>Getting started</h2>
-<p>
-To install Bun, run this<!-- -->
-<a target="_blank" href="https://bun.sh/install">install script</a>
-<!-- -->in your terminal. It downloads Bun from GitHub.
-</p>
-<div class="CodeBlock">
-<pre class="shiki" style="background-color: #282a36"><code><span class="line"><span style="color: #F8F8F2">curl https://bun.sh/install </span><span style="color: #FF79C6">|</span><span style="color: #F8F8F2"> bash</span></span></code></pre>
-</div>
-<p>
-<!-- -->Bun&#x27;s HTTP server is built on web standards like<!-- -->
-<a class="Identifier" href="https://developer.mozilla.org/en-US/docs/Web/API/Request">Request</a
- >
-<!-- -->and<!-- -->
-<a class="Identifier" href="https://developer.mozilla.org/en-US/docs/Web/API/Response">Response</a
- >
-</p>
-<div class="CodeBlock">
-<pre class="shiki" style="background-color: #282a36"><code><span class="line"><span style="color: #6272A4">// http.js</span></span>
+ c5.7,0,12.8-2.3,19-5.5L394,106z"
+ ></path>
+ </g>
+ </g></svg></a
+ >&#x27;s low-level control over memory and lack of hidden control flow makes it much simpler to write fast
+ software.<!-- -->
+ <a href="https://github.com/sponsors/ziglang">Sponsor the Zig Software Foundation</a>.
+ </p>
+ <h2>Getting started</h2>
+ <p>
+ To install Bun, run this<!-- -->
+ <a target="_blank" href="https://bun.sh/install">install script</a>
+ <!-- -->in your terminal. It downloads Bun from GitHub.
+ </p>
+ <div class="CodeBlock">
+ <pre
+ class="shiki"
+ style="background-color: #282a36"
+ ><code><span class="line"><span style="color: #F8F8F2">curl https://bun.sh/install </span><span style="color: #FF79C6">|</span><span style="color: #F8F8F2"> bash</span></span></code></pre>
+ </div>
+ <p>
+ <!-- -->Bun&#x27;s HTTP server is built on web standards like<!-- -->
+ <a class="Identifier" href="https://developer.mozilla.org/en-US/docs/Web/API/Request">Request</a>
+ <!-- -->and<!-- -->
+ <a class="Identifier" href="https://developer.mozilla.org/en-US/docs/Web/API/Response">Response</a>
+ </p>
+ <div class="CodeBlock">
+ <pre
+ class="shiki"
+ style="background-color: #282a36"
+ ><code><span class="line"><span style="color: #6272A4">// http.js</span></span>
<span class="line"><span style="color: #FF79C6">export</span><span style="color: #F8F8F2"> </span><span style="color: #FF79C6">default</span><span style="color: #F8F8F2"> {</span></span>
<span class="line"><span style="color: #F8F8F2"> port</span><span style="color: #FF79C6">:</span><span style="color: #F8F8F2"> </span><span style="color: #BD93F9">3000</span><span style="color: #F8F8F2">,</span></span>
<span class="line"><span style="color: #F8F8F2"> </span><span style="color: #50FA7B">fetch</span><span style="color: #F8F8F2">(</span><span style="color: #FFB86C; font-style: italic">request</span><span style="color: #F8F8F2">) {</span></span>
<span class="line"><span style="color: #F8F8F2"> </span><span style="color: #FF79C6">return</span><span style="color: #F8F8F2"> </span><span style="color: #FF79C6; font-weight: bold">new</span><span style="color: #F8F8F2"> </span><span style="color: #50FA7B">Response</span><span style="color: #F8F8F2">(</span><span style="color: #E9F284">&quot;</span><span style="color: #F1FA8C">Welcome to Bun!</span><span style="color: #E9F284">&quot;</span><span style="color: #F8F8F2">);</span></span>
<span class="line"><span style="color: #F8F8F2"> },</span></span>
<span class="line"><span style="color: #F8F8F2">};</span></span></code></pre>
-</div>
-<p>Run it with Bun:</p>
-<div class="CodeBlock">
-<pre class="shiki" style="background-color: #282a36"><code><span class="line"><span style="color: #F8F8F2">bun run http.js</span></span></code></pre>
-</div>
-<p>
-Then open<!-- -->
-<a target="_blank" href="http://localhost:3000">http://localhost:3000</a
- >
-<!-- -->in your browser.<br /><br />See<!-- -->
-<a href="https://github.com/oven-sh/bun/tree/main/examples">more examples</a
- >
-<!-- -->and check out<!-- -->
-<a href="https://github.com/oven-sh/bun#Reference">the docs</a>. If
-you have any questions or want help, join<!-- -->
-<a href="https://bun.sh/discord">Bun&#x27;s Discord</a>.
-</p>
-<h2>Bun CLI</h2>
-<div class="Group">
-<span target="_blank" class="Tag Tag--Command">bun run</span>
-<p>
-The same command for running JavaScript &amp; TypeScript files with
-bun&#x27;s JavaScript runtime also runs package.json<!-- -->
-<code class="mono">&quot;scripts&quot;</code>.
-</p>
-<strong>Replace <code class="mono">npm run</code> with<!-- -->
-<code class="mono">bun run</code> and save 160ms on every
-run.</strong
+ </div>
+ <p>Run it with Bun:</p>
+ <div class="CodeBlock">
+ <pre
+ class="shiki"
+ style="background-color: #282a36"
+ ><code><span class="line"><span style="color: #F8F8F2">bun run http.js</span></span></code></pre>
+ </div>
+ <p>
+ Then open<!-- -->
+ <a target="_blank" href="http://localhost:3000">http://localhost:3000</a>
+ <!-- -->in your browser.<br /><br />See<!-- -->
+ <a href="https://github.com/oven-sh/bun/tree/main/examples">more examples</a>
+ <!-- -->and check out<!-- -->
+ <a href="https://github.com/oven-sh/bun#Reference">the docs</a>. If you have any questions or want help, join<!-- -->
+ <a href="https://bun.sh/discord">Bun&#x27;s Discord</a>.
+ </p>
+ <h2>Bun CLI</h2>
+ <div class="Group">
+ <span target="_blank" class="Tag Tag--Command">bun run</span>
+ <p>
+ The same command for running JavaScript &amp; TypeScript files with bun&#x27;s JavaScript runtime also runs
+ package.json<!-- -->
+ <code class="mono">&quot;scripts&quot;</code>.
+ </p>
+ <strong
+ >Replace <code class="mono">npm run</code> with<!-- -->
+ <code class="mono">bun run</code> and save 160ms on every run.</strong
><br />
-<div>
-Bun runs package.json scripts<!-- -->
-<a href="https://twitter.com/jarredsumner/status/1454218996983623685" target="_blank" class="PerformanceClaim">30x faster than <code class="mono">npm run</code></a
+ <div>
+ Bun runs package.json scripts<!-- -->
+ <a
+ href="https://twitter.com/jarredsumner/status/1454218996983623685"
+ target="_blank"
+ class="PerformanceClaim"
+ >30x faster than <code class="mono">npm run</code></a
>
-</div>
-</div>
-<div class="Group">
-<span target="_blank" class="Tag Tag--Command">bun install</span>
-<p>
-<code classsName="mono">bun install</code> is an npm-compatible
-package manager. You probably will be surprised by how much faster
-copying files can get.
-</p>
-<strong>Replace <code class="mono">yarn</code> with<!-- -->
-<code class="mono">bun install</code> and get 20x faster package
-installs.</strong
+ </div>
+ </div>
+ <div class="Group">
+ <span target="_blank" class="Tag Tag--Command">bun install</span>
+ <p>
+ <code classsName="mono">bun install</code> is an npm-compatible package manager. You probably will be
+ surprised by how much faster copying files can get.
+ </p>
+ <strong
+ >Replace <code class="mono">yarn</code> with<!-- -->
+ <code class="mono">bun install</code> and get 20x faster package installs.</strong
><br />
-<div>
-<code class="mono">bun install</code> uses the fastest system calls
-available to copy files.
-</div>
-</div>
-<div class="Group">
-<span target="_blank" class="Tag Tag--Command">bun wiptest</span>
-<p>
-A Jest-like test runner for JavaScript &amp; TypeScript projects
-built-in to Bun.
-</p>
-<div class="Label">
-<a href="https://twitter.com/jarredsumner/status/1542824445810642946" target="_blank" class="PerformanceClaim">You&#x27;ve never seen a JavaScript test runner this fast</a
+ <div><code class="mono">bun install</code> uses the fastest system calls available to copy files.</div>
+ </div>
+ <div class="Group">
+ <span target="_blank" class="Tag Tag--Command">bun wiptest</span>
+ <p>A Jest-like test runner for JavaScript &amp; TypeScript projects built-in to Bun.</p>
+ <div class="Label">
+ <a
+ href="https://twitter.com/jarredsumner/status/1542824445810642946"
+ target="_blank"
+ class="PerformanceClaim"
+ >You&#x27;ve never seen a JavaScript test runner this fast</a
>
-<!-- -->(or incomplete).
-</div>
-</div>
-<h2>What is the license?</h2>
-<p>MIT License, excluding dependencies which have various licenses.</p>
-<h2>How do I see the source code?</h2>
-<p>Bun is on <a href="https://github.com/oven-sh/bun">GitHub</a>.</p>
-</div>
-</section>
-<section id="explain-section"><div id="explain"></div></section>
-<script>
- [...document.querySelectorAll(".Tab")].map((el) => {
+ <!-- -->(or incomplete).
+ </div>
+ </div>
+ <h2>What is the license?</h2>
+ <p>MIT License, excluding dependencies which have various licenses.</p>
+ <h2>How do I see the source code?</h2>
+ <p>Bun is on <a href="https://github.com/oven-sh/bun">GitHub</a>.</p>
+ </div>
+ </section>
+ <section id="explain-section"><div id="explain"></div></section>
+ <script>
+ [...document.querySelectorAll(".Tab")].map(el => {
el.addEventListener("click", function (e) {
var tab = e.srcElement.getAttribute("data-tab");
- [...document.querySelectorAll(".Tab")].map((el) => {
+ [...document.querySelectorAll(".Tab")].map(el => {
var active = el.getAttribute("data-tab") === tab;
el.setAttribute("tabindex", active ? 0 : -1);
el.setAttribute("aria-selected", active);
});
- [...document.querySelectorAll(".BarGraph")].map((el) => {
+ [...document.querySelectorAll(".BarGraph")].map(el => {
var active = el.id === tab + "-tab-content";
el.setAttribute("tabindex", active ? 0 : -1);
});
- document
- .querySelector(".Graphs")
- .setAttribute("class", "Graphs Graphs--active-" + tab);
+ document.querySelector(".Graphs").setAttribute("class", "Graphs Graphs--active-" + tab);
});
- el.addEventListener("keydown", (e) => {
+ el.addEventListener("keydown", e => {
var tabs = [...document.querySelectorAll(".Tab")];
- var activeTabEl = document.querySelector(
- ".Tab[aria-selected='true']"
- );
+ var activeTabEl = document.querySelector(".Tab[aria-selected='true']");
var activeTabIndex = tabs.indexOf(activeTabEl);
if (e.key === "ArrowRight" || e.key === "ArrowDown") {
e.preventDefault();
@@ -1380,16 +1415,14 @@ built-in to Bun.
});
for (const el of document.querySelectorAll(".InstallBox-copy")) {
- el.addEventListener("click", async (e) => {
- await navigator.clipboard.writeText(
- "curl https://bun.sh/install | bash"
- );
+ el.addEventListener("click", async e => {
+ await navigator.clipboard.writeText("curl https://bun.sh/install | bash");
});
}
</script>
-<div class="Built">
-Built with Bun
-<!-- -->0.2.1
-</div>
-</body>
+ <div class="Built">
+ Built with Bun
+ <!-- -->0.2.1
+ </div>
+ </body>
</html>
diff --git a/test/bun.js/fs-stream.js b/test/bun.js/fs-stream.js
index 1ef3ee71c..db56fdfaa 100644
--- a/test/bun.js/fs-stream.js
+++ b/test/bun.js/fs-stream.js
@@ -3,15 +3,13 @@ import { createReadStream, createWriteStream, readFileSync } from "fs";
await new Promise((resolve, reject) => {
createReadStream("fs-stream.js")
.pipe(createWriteStream("/tmp/fs-stream.copy.js"))
- .once("error", (err) => reject(err))
+ .once("error", err => reject(err))
.once("finish", () => {
try {
const copied = readFileSync("/tmp/fs-stream.copy.js", "utf8");
const real = readFileSync("/tmp/fs-stream.js", "utf8");
if (copied !== real) {
- reject(
- new Error("fs-stream.js is not the same as fs-stream.copy.js"),
- );
+ reject(new Error("fs-stream.js is not the same as fs-stream.copy.js"));
return;
}
diff --git a/test/bun.js/gc.js b/test/bun.js/gc.js
index 523c5c1e4..3f9678f92 100644
--- a/test/bun.js/gc.js
+++ b/test/bun.js/gc.js
@@ -8,7 +8,7 @@ export function gcTick(trace = false) {
trace && console.trace("");
// console.trace("hello");
gc();
- return new Promise((resolve) => {
+ return new Promise(resolve => {
setTimeout(resolve, 0);
});
}
diff --git a/test/bun.js/globals.test.js b/test/bun.js/globals.test.js
index a94c1a4b9..5d491cde7 100644
--- a/test/bun.js/globals.test.js
+++ b/test/bun.js/globals.test.js
@@ -1,17 +1,7 @@
import { it, describe, expect } from "bun:test";
it("extendable", () => {
- const classes = [
- Blob,
- TextDecoder,
- TextEncoder,
- Request,
- Response,
- Headers,
- HTMLRewriter,
- Bun.Transpiler,
- Buffer,
- ];
+ const classes = [Blob, TextDecoder, TextEncoder, Request, Response, Headers, HTMLRewriter, Bun.Transpiler, Buffer];
// None of these should error
for (let Class of classes) {
var Foo = class extends Class {};
diff --git a/test/bun.js/google-fixture.html b/test/bun.js/google-fixture.html
index cb8ca91c9..a5042789e 100644
--- a/test/bun.js/google-fixture.html
+++ b/test/bun.js/google-fixture.html
@@ -1,16 +1,632 @@
-<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en"><head><meta content="Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for." name="description"><meta content="noodp" name="robots"><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"><meta content="/images/branding/googleg/1x/googleg_standard_color_128dp.png" itemprop="image"><title>Google</title><script nonce="GkiuApJ39JY6FCXsWXwc0g">(function(){window.google={kEI:'8kuEY6zVJKHhkPIPl6yFkAs',kEXPI:'0,1359409,6059,206,2414,2390,2316,383,246,5,5367,1123753,1197711,380780,16114,28684,22430,1362,12316,2818,14765,4998,13228,3847,10622,22741,5081,1593,1279,2742,149,1103,840,1983,4314,3514,606,2023,2297,14670,3227,2847,6,33769,1850,15325,432,3,346,1244,1,5445,148,11323,2652,4,1528,2304,7039,22023,5708,7355,11444,2216,2980,1457,15351,1435,5815,2542,4094,4052,3,3541,1,27183,14971,2,14022,2373,342,23024,5679,1020,2381,12485,16256,4568,6256,23421,1252,5835,14968,4332,2204,5280,445,2,2,1,10956,6356,9320,8155,7381,2,3,1475,14490,873,6577,3048,10008,9,1352,568,5784,3995,20640,1139,14375,15759,10745,8880,11256,14,82,950,2940,751,2070,641,7153,2009,2271,735,3,683,109,112,718,683,899,879,1856,1996,1119,6,1539,42,2204,1053,3401,670,79,244,458,5201,1742,813,1224,10,2626,84,600,817,2,563,402,337,252,64,933,394,151,553,171,96,83,90,554,368,450,473,110,36,6,291,1092,2300,443,483,402,407,481,120,20,3,784,3,80,2261,283,141,57,651,7,2,3,67,761,274,246,64,34,334,1,57,727,57,1275,13,90,890,57,1,856,301,262,665,91,8,13,114,310,34,1436,55,149,66,168,42,29,3,253,246,1214,461,771,92,1345,174,198,96,969,67,2,560,278,497,672,264,196,19,248,359,262,5,363,78,365,3,147,613,522,180,332,209,21,17,102,830,36,42,1,403,1265,313,2,389,326,9,81,1288,11289133,2803332,3311,141,795,19735,1,1,346,1903,856,41,169,1,23947515,486,25,19,15,4041597,1964,3094,13579,3405,5595,11,5758,1469,1135,14,1029',kBL:'-1VY'};google.sn='webhp';google.kHL='en';})();(function(){
- var f=this||self;var h,k=[];function l(a){for(var b;a&&(!a.getAttribute||!(b=a.getAttribute("eid")));)a=a.parentNode;return b||h}function m(a){for(var b=null;a&&(!a.getAttribute||!(b=a.getAttribute("leid")));)a=a.parentNode;return b}
- function n(a,b,c,d,g){var e="";c||-1!==b.search("&ei=")||(e="&ei="+l(d),-1===b.search("&lei=")&&(d=m(d))&&(e+="&lei="+d));d="";!c&&f._cshid&&-1===b.search("&cshid=")&&"slh"!==a&&(d="&cshid="+f._cshid);c=c||"/"+(g||"gen_204")+"?atyp=i&ct="+a+"&cad="+b+e+"&zx="+Date.now()+d;/^http:/i.test(c)&&"https:"===window.location.protocol&&(google.ml&&google.ml(Error("a"),!1,{src:c,glmm:1}),c="");return c};h=google.kEI;google.getEI=l;google.getLEI=m;google.ml=function(){return null};google.log=function(a,b,c,d,g){if(c=n(a,b,c,d,g)){a=new Image;var e=k.length;k[e]=a;a.onerror=a.onload=a.onabort=function(){delete k[e]};a.src=c}};google.logUrl=n;}).call(this);(function(){google.y={};google.sy=[];google.x=function(a,b){if(a)var c=a.id;else{do c=Math.random();while(google.y[c])}google.y[c]=[a,b];return!1};google.sx=function(a){google.sy.push(a)};google.lm=[];google.plm=function(a){google.lm.push.apply(google.lm,a)};google.lq=[];google.load=function(a,b,c){google.lq.push([[a],b,c])};google.loadAll=function(a,b){google.lq.push([a,b])};google.bx=!1;google.lx=function(){};}).call(this);google.f={};(function(){
- document.documentElement.addEventListener("submit",function(b){var a;if(a=b.target){var c=a.getAttribute("data-submitfalse");a="1"===c||"q"===c&&!a.elements.q.value?!0:!1}else a=!1;a&&(b.preventDefault(),b.stopPropagation())},!0);document.documentElement.addEventListener("click",function(b){var a;a:{for(a=b.target;a&&a!==document.documentElement;a=a.parentElement)if("A"===a.tagName){a="1"===a.getAttribute("data-nohref");break a}a=!1}a&&b.preventDefault()},!0);}).call(this);</script><style>#gbar,#guser{font-size:13px;padding-top:1px !important;}#gbar{height:22px}#guser{padding-bottom:7px !important;text-align:right}.gbh,.gbd{border-top:1px solid #c9d7f1;font-size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}@media all{.gb1{height:22px;margin-right:.5em;vertical-align:top}#gbar{float:left}}a.gb1,a.gb4{text-decoration:underline !important}a.gb1,a.gb4{color:#00c !important}.gbi .gb4{color:#dd8e27 !important}.gbf .gb4{color:#900 !important}
- </style><style>body,td,a,p,.h{font-family:arial,sans-serif}body{margin:0;overflow-y:scroll}#gog{padding:3px 8px 0}td{line-height:.8em}.gac_m td{line-height:17px}form{margin-bottom:20px}.h{color:#1558d6}em{font-weight:bold;font-style:normal}.lst{height:25px;width:496px}.gsfi,.lst{font:18px arial,sans-serif}.gsfs{font:17px arial,sans-serif}.ds{display:inline-box;display:inline-block;margin:3px 0 4px;margin-left:4px}input{font-family:inherit}body{background:#fff;color:#000}a{color:#4b11a8;text-decoration:none}a:hover,a:active{text-decoration:underline}.fl a{color:#1558d6}a:visited{color:#4b11a8}.sblc{padding-top:5px}.sblc a{display:block;margin:2px 0;margin-left:13px;font-size:11px}.lsbb{background:#f8f9fa;border:solid 1px;border-color:#dadce0 #70757a #70757a #dadce0;height:30px}.lsbb{display:block}#WqQANb a{display:inline-block;margin:0 12px}.lsb{background:url(/images/nav_logo229.png) 0 -261px repeat-x;border:none;color:#000;cursor:pointer;height:30px;margin:0;outline:0;font:15px arial,sans-serif;vertical-align:top}.lsb:active{background:#dadce0}.lst:focus{outline:none}</style><script nonce="GkiuApJ39JY6FCXsWXwc0g">(function(){window.google.erd={jsr:1,bv:1693,de:true};
- var h=this||self;var k,l=null!=(k=h.mei)?k:1,n,p=null!=(n=h.sdo)?n:!0,q=0,r,t=google.erd,v=t.jsr;google.ml=function(a,b,d,m,e){e=void 0===e?2:e;b&&(r=a&&a.message);if(google.dl)return google.dl(a,e,d),null;if(0>v){window.console&&console.error(a,d);if(-2===v)throw a;b=!1}else b=!a||!a.message||"Error loading script"===a.message||q>=l&&!m?!1:!0;if(!b)return null;q++;d=d||{};b=encodeURIComponent;var c="/gen_204?atyp=i&ei="+b(google.kEI);google.kEXPI&&(c+="&jexpid="+b(google.kEXPI));c+="&srcpg="+b(google.sn)+"&jsr="+b(t.jsr)+"&bver="+b(t.bv);var f=a.lineNumber;void 0!==f&&(c+="&line="+f);var g=
- a.fileName;g&&(0<g.indexOf("-extension:/")&&(e=3),c+="&script="+b(g),f&&g===window.location.href&&(f=document.documentElement.outerHTML.split("\n")[f],c+="&cad="+b(f?f.substring(0,300):"No script found.")));c+="&jsel="+e;for(var u in d)c+="&",c+=b(u),c+="=",c+=b(d[u]);c=c+"&emsg="+b(a.name+": "+a.message);c=c+"&jsst="+b(a.stack||"N/A");12288<=c.length&&(c=c.substr(0,12288));a=c;m||google.log(0,"",a);return a};window.onerror=function(a,b,d,m,e){r!==a&&(a=e instanceof Error?e:Error(a),void 0===d||"lineNumber"in a||(a.lineNumber=d),void 0===b||"fileName"in a||(a.fileName=b),google.ml(a,!1,void 0,!1,"SyntaxError"===a.name||"SyntaxError"===a.message.substring(0,11)||-1!==a.message.indexOf("Script error")?3:0));r=null;p&&q>=l&&(window.onerror=null)};})();</script></head><body bgcolor="#fff"><script nonce="GkiuApJ39JY6FCXsWXwc0g">(function(){var src='/images/nav_logo229.png';var iesg=false;document.body.onload = function(){window.n && window.n();if (document.images){new Image().src=src;}
- if (!iesg){document.f&&document.f.q.focus();document.gbqf&&document.gbqf.q.focus();}
- }
- })();</script><div id="mngb"><div id=gbar><nobr><b class=gb1>Search</b> <a class=gb1 href="https://www.google.com/imghp?hl=en&tab=wi">Images</a> <a class=gb1 href="https://maps.google.com/maps?hl=en&tab=wl">Maps</a> <a class=gb1 href="https://play.google.com/?hl=en&tab=w8">Play</a> <a class=gb1 href="https://www.youtube.com/?tab=w1">YouTube</a> <a class=gb1 href="https://news.google.com/?tab=wn">News</a> <a class=gb1 href="https://mail.google.com/mail/?tab=wm">Gmail</a> <a class=gb1 href="https://drive.google.com/?tab=wo">Drive</a> <a class=gb1 style="text-decoration:none" href="https://www.google.com/intl/en/about/products?tab=wh"><u>More</u> &raquo;</a></nobr></div><div id=guser width=100%><nobr><span id=gbn class=gbi></span><span id=gbf class=gbf></span><span id=gbe></span><a href="http://www.google.com/history/optout?hl=en" class=gb4>Web History</a> | <a href="/preferences?hl=en" class=gb4>Settings</a> | <a target=_top id=gb_70 href="https://accounts.google.com/ServiceLogin?hl=en&passive=true&continue=https://www.google.com/&ec=GAZAAQ" class=gb4>Sign in</a></nobr></div><div class=gbh style=left:0></div><div class=gbh style=right:0></div></div><center><br clear="all" id="lgpd"><div id="lga"><img alt="Google" height="92" src="/images/branding/googlelogo/1x/googlelogo_white_background_color_272x92dp.png" style="padding:28px 0 14px" width="272" id="hplogo"><br><br></div><form action="/search" name="f"><table cellpadding="0" cellspacing="0"><tr valign="top"><td width="25%">&nbsp;</td><td align="center" nowrap=""><input name="ie" value="ISO-8859-1" type="hidden"><input value="en" name="hl" type="hidden"><input name="source" type="hidden" value="hp"><input name="biw" type="hidden"><input name="bih" type="hidden"><div class="ds" style="height:32px;margin:4px 0"><input class="lst" style="margin:0;padding:5px 8px 0 6px;vertical-align:top;color:#000" autocomplete="off" value="" title="Google Search" maxlength="2048" name="q" size="57"></div><br style="line-height:0"><span class="ds"><span class="lsbb"><input class="lsb" value="Google Search" name="btnG" type="submit"></span></span><span class="ds"><span class="lsbb"><input class="lsb" id="tsuid_1" value="I'm Feeling Lucky" name="btnI" type="submit"><script nonce="GkiuApJ39JY6FCXsWXwc0g">(function(){var id='tsuid_1';document.getElementById(id).onclick = function(){if (this.form.q.value){this.checked = 1;if (this.form.iflsig)this.form.iflsig.disabled = false;}
- else top.location='/doodles/';};})();</script><input value="AJiK0e8AAAAAY4RaAr_DYhOW5v1e7hnMw1PppyhHzD0h" name="iflsig" type="hidden"></span></span></td><td class="fl sblc" align="left" nowrap="" width="25%"><a href="/advanced_search?hl=en&amp;authuser=0">Advanced search</a></td></tr></table><input id="gbv" name="gbv" type="hidden" value="1"><script nonce="GkiuApJ39JY6FCXsWXwc0g">(function(){var a,b="1";if(document&&document.getElementById)if("undefined"!=typeof XMLHttpRequest)b="2";else if("undefined"!=typeof ActiveXObject){var c,d,e=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"];for(c=0;d=e[c++];)try{new ActiveXObject(d),b="2"}catch(h){}}a=b;if("2"==a&&-1==location.search.indexOf("&gbv=2")){var f=google.gbvu,g=document.getElementById("gbv");g&&(g.value=a);f&&window.setTimeout(function(){location.href=f},0)};}).call(this);</script></form><div id="gac_scont"></div><div style="font-size:83%;min-height:3.5em"><br></div><span id="footer"><div style="font-size:10pt"><div style="margin:19px auto;text-align:center" id="WqQANb"><a href="/intl/en/ads/">Advertising†Programs</a><a href="/services/">Business Solutions</a><a href="/intl/en/about.html">About Google</a></div></div><p style="font-size:8pt;color:#70757a">&copy; 2022 - <a href="/intl/en/policies/privacy/">Privacy</a> - <a href="/intl/en/policies/terms/">Terms</a></p></span></center><script nonce="GkiuApJ39JY6FCXsWXwc0g">(function(){window.google.cdo={height:757,width:1440};(function(){var a=window.innerWidth,b=window.innerHeight;if(!a||!b){var c=window.document,d="CSS1Compat"==c.compatMode?c.documentElement:c.body;a=d.clientWidth;b=d.clientHeight}a&&b&&(a!=google.cdo.width||b!=google.cdo.height)&&google.log("","","/client_204?&atyp=i&biw="+a+"&bih="+b+"&ei="+google.kEI);}).call(this);})();</script> <script nonce="GkiuApJ39JY6FCXsWXwc0g">(function(){google.xjs={ck:'xjs.hp.o5AfvK7BgaM.L.X.O',cs:'ACT90oHyGC850G6IwjNxf19ZOa0R6EWAQw',excm:[]};})();</script> <script nonce="GkiuApJ39JY6FCXsWXwc0g">(function(){var u='/xjs/_/js/k\x3dxjs.hp.en_US.dE-FG74hDaY.O/am\x3dAADoBABQAGAB/d\x3d1/ed\x3d1/rs\x3dACT90oFXGhsDPcVbgIE3ddPch07JJa-91Q/m\x3dsb_he,d';var amd=0;
- var d=this||self,e=function(a){return a};var g;var l=function(a,b){this.g=b===h?a:""};l.prototype.toString=function(){return this.g+""};var h={};
- function m(){var a=u;google.lx=function(){p(a);google.lx=function(){}};google.bx||google.lx()}
- function p(a){google.timers&&google.timers.load&&google.tick&&google.tick("load","xjsls");var b=document;var c="SCRIPT";"application/xhtml+xml"===b.contentType&&(c=c.toLowerCase());c=b.createElement(c);if(void 0===g){b=null;var k=d.trustedTypes;if(k&&k.createPolicy){try{b=k.createPolicy("goog#html",{createHTML:e,createScript:e,createScriptURL:e})}catch(q){d.console&&d.console.error(q.message)}g=b}else g=b}a=(b=g)?b.createScriptURL(a):a;a=new l(a,h);c.src=a instanceof l&&a.constructor===l?a.g:"type_error:TrustedResourceUrl";var f,n;(f=(a=null==(n=(f=(c.ownerDocument&&c.ownerDocument.defaultView||window).document).querySelector)?void 0:n.call(f,"script[nonce]"))?a.nonce||a.getAttribute("nonce")||"":"")&&c.setAttribute("nonce",f);document.body.appendChild(c);google.psa=!0};google.xjsu=u;setTimeout(function(){0<amd?google.caft(function(){return m()},amd):m()},0);})();function _DumpException(e){throw e;}
- function _F_installCss(c){}
- (function(){google.jl={blt:'none',chnk:0,dw:false,dwu:true,emtn:0,end:0,ico:false,ikb:0,ine:false,injs:'none',injt:0,injth:0,injv2:false,lls:'default',pdt:0,rep:0,snet:true,strt:0,ubm:false,uwp:true};})();(function(){var pmc='{\x22d\x22:{},\x22sb_he\x22:{\x22agen\x22:true,\x22cgen\x22:true,\x22client\x22:\x22heirloom-hp\x22,\x22dh\x22:true,\x22ds\x22:\x22\x22,\x22fl\x22:true,\x22host\x22:\x22google.com\x22,\x22jsonp\x22:true,\x22msgs\x22:{\x22cibl\x22:\x22Clear Search\x22,\x22dym\x22:\x22Did you mean:\x22,\x22lcky\x22:\x22I\\u0026#39;m Feeling Lucky\x22,\x22lml\x22:\x22Learn more\x22,\x22psrc\x22:\x22This search was removed from your \\u003Ca href\x3d\\\x22/history\\\x22\\u003EWeb History\\u003C/a\\u003E\x22,\x22psrl\x22:\x22Remove\x22,\x22sbit\x22:\x22Search by image\x22,\x22srch\x22:\x22Google Search\x22},\x22ovr\x22:{},\x22pq\x22:\x22\x22,\x22rfs\x22:[],\x22sbas\x22:\x220 3px 8px 0 rgba(0,0,0,0.2),0 0 0 1px rgba(0,0,0,0.08)\x22,\x22stok\x22:\x22sL4-RrhdjZ3aIiP5pD7muEeZ3T8\x22}}';google.pmc=JSON.parse(pmc);})();</script> </body></html> \ No newline at end of file
+<!DOCTYPE html>
+<html itemscope="" itemtype="http://schema.org/WebPage" lang="en">
+ <head>
+ <meta
+ content="Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for."
+ name="description"
+ />
+ <meta content="noodp" name="robots" />
+ <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
+ <meta content="/images/branding/googleg/1x/googleg_standard_color_128dp.png" itemprop="image" />
+ <title>Google</title>
+ <script nonce="GkiuApJ39JY6FCXsWXwc0g">
+ (function () {
+ window.google = {
+ kEI: "8kuEY6zVJKHhkPIPl6yFkAs",
+ kEXPI:
+ "0,1359409,6059,206,2414,2390,2316,383,246,5,5367,1123753,1197711,380780,16114,28684,22430,1362,12316,2818,14765,4998,13228,3847,10622,22741,5081,1593,1279,2742,149,1103,840,1983,4314,3514,606,2023,2297,14670,3227,2847,6,33769,1850,15325,432,3,346,1244,1,5445,148,11323,2652,4,1528,2304,7039,22023,5708,7355,11444,2216,2980,1457,15351,1435,5815,2542,4094,4052,3,3541,1,27183,14971,2,14022,2373,342,23024,5679,1020,2381,12485,16256,4568,6256,23421,1252,5835,14968,4332,2204,5280,445,2,2,1,10956,6356,9320,8155,7381,2,3,1475,14490,873,6577,3048,10008,9,1352,568,5784,3995,20640,1139,14375,15759,10745,8880,11256,14,82,950,2940,751,2070,641,7153,2009,2271,735,3,683,109,112,718,683,899,879,1856,1996,1119,6,1539,42,2204,1053,3401,670,79,244,458,5201,1742,813,1224,10,2626,84,600,817,2,563,402,337,252,64,933,394,151,553,171,96,83,90,554,368,450,473,110,36,6,291,1092,2300,443,483,402,407,481,120,20,3,784,3,80,2261,283,141,57,651,7,2,3,67,761,274,246,64,34,334,1,57,727,57,1275,13,90,890,57,1,856,301,262,665,91,8,13,114,310,34,1436,55,149,66,168,42,29,3,253,246,1214,461,771,92,1345,174,198,96,969,67,2,560,278,497,672,264,196,19,248,359,262,5,363,78,365,3,147,613,522,180,332,209,21,17,102,830,36,42,1,403,1265,313,2,389,326,9,81,1288,11289133,2803332,3311,141,795,19735,1,1,346,1903,856,41,169,1,23947515,486,25,19,15,4041597,1964,3094,13579,3405,5595,11,5758,1469,1135,14,1029",
+ kBL: "-1VY",
+ };
+ google.sn = "webhp";
+ google.kHL = "en";
+ })();
+ (function () {
+ var f = this || self;
+ var h,
+ k = [];
+ function l(a) {
+ for (var b; a && (!a.getAttribute || !(b = a.getAttribute("eid"))); ) a = a.parentNode;
+ return b || h;
+ }
+ function m(a) {
+ for (var b = null; a && (!a.getAttribute || !(b = a.getAttribute("leid"))); ) a = a.parentNode;
+ return b;
+ }
+ function n(a, b, c, d, g) {
+ var e = "";
+ c ||
+ -1 !== b.search("&ei=") ||
+ ((e = "&ei=" + l(d)), -1 === b.search("&lei=") && (d = m(d)) && (e += "&lei=" + d));
+ d = "";
+ !c && f._cshid && -1 === b.search("&cshid=") && "slh" !== a && (d = "&cshid=" + f._cshid);
+ c = c || "/" + (g || "gen_204") + "?atyp=i&ct=" + a + "&cad=" + b + e + "&zx=" + Date.now() + d;
+ /^http:/i.test(c) &&
+ "https:" === window.location.protocol &&
+ (google.ml && google.ml(Error("a"), !1, { src: c, glmm: 1 }), (c = ""));
+ return c;
+ }
+ h = google.kEI;
+ google.getEI = l;
+ google.getLEI = m;
+ google.ml = function () {
+ return null;
+ };
+ google.log = function (a, b, c, d, g) {
+ if ((c = n(a, b, c, d, g))) {
+ a = new Image();
+ var e = k.length;
+ k[e] = a;
+ a.onerror =
+ a.onload =
+ a.onabort =
+ function () {
+ delete k[e];
+ };
+ a.src = c;
+ }
+ };
+ google.logUrl = n;
+ }).call(this);
+ (function () {
+ google.y = {};
+ google.sy = [];
+ google.x = function (a, b) {
+ if (a) var c = a.id;
+ else {
+ do c = Math.random();
+ while (google.y[c]);
+ }
+ google.y[c] = [a, b];
+ return !1;
+ };
+ google.sx = function (a) {
+ google.sy.push(a);
+ };
+ google.lm = [];
+ google.plm = function (a) {
+ google.lm.push.apply(google.lm, a);
+ };
+ google.lq = [];
+ google.load = function (a, b, c) {
+ google.lq.push([[a], b, c]);
+ };
+ google.loadAll = function (a, b) {
+ google.lq.push([a, b]);
+ };
+ google.bx = !1;
+ google.lx = function () {};
+ }).call(this);
+ google.f = {};
+ (function () {
+ document.documentElement.addEventListener(
+ "submit",
+ function (b) {
+ var a;
+ if ((a = b.target)) {
+ var c = a.getAttribute("data-submitfalse");
+ a = "1" === c || ("q" === c && !a.elements.q.value) ? !0 : !1;
+ } else a = !1;
+ a && (b.preventDefault(), b.stopPropagation());
+ },
+ !0,
+ );
+ document.documentElement.addEventListener(
+ "click",
+ function (b) {
+ var a;
+ a: {
+ for (a = b.target; a && a !== document.documentElement; a = a.parentElement)
+ if ("A" === a.tagName) {
+ a = "1" === a.getAttribute("data-nohref");
+ break a;
+ }
+ a = !1;
+ }
+ a && b.preventDefault();
+ },
+ !0,
+ );
+ }).call(this);
+ </script>
+ <style>
+ #gbar,
+ #guser {
+ font-size: 13px;
+ padding-top: 1px !important;
+ }
+ #gbar {
+ height: 22px;
+ }
+ #guser {
+ padding-bottom: 7px !important;
+ text-align: right;
+ }
+ .gbh,
+ .gbd {
+ border-top: 1px solid #c9d7f1;
+ font-size: 1px;
+ }
+ .gbh {
+ height: 0;
+ position: absolute;
+ top: 24px;
+ width: 100%;
+ }
+ @media all {
+ .gb1 {
+ height: 22px;
+ margin-right: 0.5em;
+ vertical-align: top;
+ }
+ #gbar {
+ float: left;
+ }
+ }
+ a.gb1,
+ a.gb4 {
+ text-decoration: underline !important;
+ }
+ a.gb1,
+ a.gb4 {
+ color: #00c !important;
+ }
+ .gbi .gb4 {
+ color: #dd8e27 !important;
+ }
+ .gbf .gb4 {
+ color: #900 !important;
+ }
+ </style>
+ <style>
+ body,
+ td,
+ a,
+ p,
+ .h {
+ font-family: arial, sans-serif;
+ }
+ body {
+ margin: 0;
+ overflow-y: scroll;
+ }
+ #gog {
+ padding: 3px 8px 0;
+ }
+ td {
+ line-height: 0.8em;
+ }
+ .gac_m td {
+ line-height: 17px;
+ }
+ form {
+ margin-bottom: 20px;
+ }
+ .h {
+ color: #1558d6;
+ }
+ em {
+ font-weight: bold;
+ font-style: normal;
+ }
+ .lst {
+ height: 25px;
+ width: 496px;
+ }
+ .gsfi,
+ .lst {
+ font: 18px arial, sans-serif;
+ }
+ .gsfs {
+ font: 17px arial, sans-serif;
+ }
+ .ds {
+ display: inline-box;
+ display: inline-block;
+ margin: 3px 0 4px;
+ margin-left: 4px;
+ }
+ input {
+ font-family: inherit;
+ }
+ body {
+ background: #fff;
+ color: #000;
+ }
+ a {
+ color: #4b11a8;
+ text-decoration: none;
+ }
+ a:hover,
+ a:active {
+ text-decoration: underline;
+ }
+ .fl a {
+ color: #1558d6;
+ }
+ a:visited {
+ color: #4b11a8;
+ }
+ .sblc {
+ padding-top: 5px;
+ }
+ .sblc a {
+ display: block;
+ margin: 2px 0;
+ margin-left: 13px;
+ font-size: 11px;
+ }
+ .lsbb {
+ background: #f8f9fa;
+ border: solid 1px;
+ border-color: #dadce0 #70757a #70757a #dadce0;
+ height: 30px;
+ }
+ .lsbb {
+ display: block;
+ }
+ #WqQANb a {
+ display: inline-block;
+ margin: 0 12px;
+ }
+ .lsb {
+ background: url(/images/nav_logo229.png) 0 -261px repeat-x;
+ border: none;
+ color: #000;
+ cursor: pointer;
+ height: 30px;
+ margin: 0;
+ outline: 0;
+ font: 15px arial, sans-serif;
+ vertical-align: top;
+ }
+ .lsb:active {
+ background: #dadce0;
+ }
+ .lst:focus {
+ outline: none;
+ }
+ </style>
+ <script nonce="GkiuApJ39JY6FCXsWXwc0g">
+ (function () {
+ window.google.erd = { jsr: 1, bv: 1693, de: true };
+ var h = this || self;
+ var k,
+ l = null != (k = h.mei) ? k : 1,
+ n,
+ p = null != (n = h.sdo) ? n : !0,
+ q = 0,
+ r,
+ t = google.erd,
+ v = t.jsr;
+ google.ml = function (a, b, d, m, e) {
+ e = void 0 === e ? 2 : e;
+ b && (r = a && a.message);
+ if (google.dl) return google.dl(a, e, d), null;
+ if (0 > v) {
+ window.console && console.error(a, d);
+ if (-2 === v) throw a;
+ b = !1;
+ } else b = !a || !a.message || "Error loading script" === a.message || (q >= l && !m) ? !1 : !0;
+ if (!b) return null;
+ q++;
+ d = d || {};
+ b = encodeURIComponent;
+ var c = "/gen_204?atyp=i&ei=" + b(google.kEI);
+ google.kEXPI && (c += "&jexpid=" + b(google.kEXPI));
+ c += "&srcpg=" + b(google.sn) + "&jsr=" + b(t.jsr) + "&bver=" + b(t.bv);
+ var f = a.lineNumber;
+ void 0 !== f && (c += "&line=" + f);
+ var g = a.fileName;
+ g &&
+ (0 < g.indexOf("-extension:/") && (e = 3),
+ (c += "&script=" + b(g)),
+ f &&
+ g === window.location.href &&
+ ((f = document.documentElement.outerHTML.split("\n")[f]),
+ (c += "&cad=" + b(f ? f.substring(0, 300) : "No script found."))));
+ c += "&jsel=" + e;
+ for (var u in d) (c += "&"), (c += b(u)), (c += "="), (c += b(d[u]));
+ c = c + "&emsg=" + b(a.name + ": " + a.message);
+ c = c + "&jsst=" + b(a.stack || "N/A");
+ 12288 <= c.length && (c = c.substr(0, 12288));
+ a = c;
+ m || google.log(0, "", a);
+ return a;
+ };
+ window.onerror = function (a, b, d, m, e) {
+ r !== a &&
+ ((a = e instanceof Error ? e : Error(a)),
+ void 0 === d || "lineNumber" in a || (a.lineNumber = d),
+ void 0 === b || "fileName" in a || (a.fileName = b),
+ google.ml(
+ a,
+ !1,
+ void 0,
+ !1,
+ "SyntaxError" === a.name ||
+ "SyntaxError" === a.message.substring(0, 11) ||
+ -1 !== a.message.indexOf("Script error")
+ ? 3
+ : 0,
+ ));
+ r = null;
+ p && q >= l && (window.onerror = null);
+ };
+ })();
+ </script>
+ </head>
+ <body bgcolor="#fff">
+ <script nonce="GkiuApJ39JY6FCXsWXwc0g">
+ (function () {
+ var src = "/images/nav_logo229.png";
+ var iesg = false;
+ document.body.onload = function () {
+ window.n && window.n();
+ if (document.images) {
+ new Image().src = src;
+ }
+ if (!iesg) {
+ document.f && document.f.q.focus();
+ document.gbqf && document.gbqf.q.focus();
+ }
+ };
+ })();
+ </script>
+ <div id="mngb">
+ <div id="gbar">
+ <nobr
+ ><b class="gb1">Search</b> <a class="gb1" href="https://www.google.com/imghp?hl=en&tab=wi">Images</a>
+ <a class="gb1" href="https://maps.google.com/maps?hl=en&tab=wl">Maps</a>
+ <a class="gb1" href="https://play.google.com/?hl=en&tab=w8">Play</a>
+ <a class="gb1" href="https://www.youtube.com/?tab=w1">YouTube</a>
+ <a class="gb1" href="https://news.google.com/?tab=wn">News</a>
+ <a class="gb1" href="https://mail.google.com/mail/?tab=wm">Gmail</a>
+ <a class="gb1" href="https://drive.google.com/?tab=wo">Drive</a>
+ <a class="gb1" style="text-decoration: none" href="https://www.google.com/intl/en/about/products?tab=wh"
+ ><u>More</u> &raquo;</a
+ ></nobr
+ >
+ </div>
+ <div id="guser" width="100%">
+ <nobr
+ ><span id="gbn" class="gbi"></span><span id="gbf" class="gbf"></span><span id="gbe"></span
+ ><a href="http://www.google.com/history/optout?hl=en" class="gb4">Web History</a> |
+ <a href="/preferences?hl=en" class="gb4">Settings</a> |
+ <a
+ target="_top"
+ id="gb_70"
+ href="https://accounts.google.com/ServiceLogin?hl=en&passive=true&continue=https://www.google.com/&ec=GAZAAQ"
+ class="gb4"
+ >Sign in</a
+ ></nobr
+ >
+ </div>
+ <div class="gbh" style="left: 0"></div>
+ <div class="gbh" style="right: 0"></div>
+ </div>
+ <center>
+ <br clear="all" id="lgpd" />
+ <div id="lga">
+ <img
+ alt="Google"
+ height="92"
+ src="/images/branding/googlelogo/1x/googlelogo_white_background_color_272x92dp.png"
+ style="padding: 28px 0 14px"
+ width="272"
+ id="hplogo"
+ /><br /><br />
+ </div>
+ <form action="/search" name="f">
+ <table cellpadding="0" cellspacing="0">
+ <tr valign="top">
+ <td width="25%">&nbsp;</td>
+ <td align="center" nowrap="">
+ <input name="ie" value="ISO-8859-1" type="hidden" /><input value="en" name="hl" type="hidden" /><input
+ name="source"
+ type="hidden"
+ value="hp"
+ /><input name="biw" type="hidden" /><input name="bih" type="hidden" />
+ <div class="ds" style="height: 32px; margin: 4px 0">
+ <input
+ class="lst"
+ style="margin: 0; padding: 5px 8px 0 6px; vertical-align: top; color: #000"
+ autocomplete="off"
+ value=""
+ title="Google Search"
+ maxlength="2048"
+ name="q"
+ size="57"
+ />
+ </div>
+ <br style="line-height: 0" /><span class="ds"
+ ><span class="lsbb"><input class="lsb" value="Google Search" name="btnG" type="submit" /></span></span
+ ><span class="ds"
+ ><span class="lsbb"
+ ><input class="lsb" id="tsuid_1" value="I'm Feeling Lucky" name="btnI" type="submit" />
+ <script nonce="GkiuApJ39JY6FCXsWXwc0g">
+ (function () {
+ var id = "tsuid_1";
+ document.getElementById(id).onclick = function () {
+ if (this.form.q.value) {
+ this.checked = 1;
+ if (this.form.iflsig) this.form.iflsig.disabled = false;
+ } else top.location = "/doodles/";
+ };
+ })();
+ </script>
+ <input value="AJiK0e8AAAAAY4RaAr_DYhOW5v1e7hnMw1PppyhHzD0h" name="iflsig" type="hidden" /></span
+ ></span>
+ </td>
+ <td class="fl sblc" align="left" nowrap="" width="25%">
+ <a href="/advanced_search?hl=en&amp;authuser=0">Advanced search</a>
+ </td>
+ </tr>
+ </table>
+ <input id="gbv" name="gbv" type="hidden" value="1" />
+ <script nonce="GkiuApJ39JY6FCXsWXwc0g">
+ (function () {
+ var a,
+ b = "1";
+ if (document && document.getElementById)
+ if ("undefined" != typeof XMLHttpRequest) b = "2";
+ else if ("undefined" != typeof ActiveXObject) {
+ var c,
+ d,
+ e = ["MSXML2.XMLHTTP.6.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"];
+ for (c = 0; (d = e[c++]); )
+ try {
+ new ActiveXObject(d), (b = "2");
+ } catch (h) {}
+ }
+ a = b;
+ if ("2" == a && -1 == location.search.indexOf("&gbv=2")) {
+ var f = google.gbvu,
+ g = document.getElementById("gbv");
+ g && (g.value = a);
+ f &&
+ window.setTimeout(function () {
+ location.href = f;
+ }, 0);
+ }
+ }).call(this);
+ </script>
+ </form>
+ <div id="gac_scont"></div>
+ <div style="font-size: 83%; min-height: 3.5em"><br /></div>
+ <span id="footer"
+ ><div style="font-size: 10pt">
+ <div style="margin: 19px auto; text-align: center" id="WqQANb">
+ <a href="/intl/en/ads/">Advertising†Programs</a><a href="/services/">Business Solutions</a
+ ><a href="/intl/en/about.html">About Google</a>
+ </div>
+ </div>
+ <p style="font-size: 8pt; color: #70757a">
+ &copy; 2022 - <a href="/intl/en/policies/privacy/">Privacy</a> - <a href="/intl/en/policies/terms/">Terms</a>
+ </p></span
+ >
+ </center>
+ <script nonce="GkiuApJ39JY6FCXsWXwc0g">
+ (function () {
+ window.google.cdo = { height: 757, width: 1440 };
+ (function () {
+ var a = window.innerWidth,
+ b = window.innerHeight;
+ if (!a || !b) {
+ var c = window.document,
+ d = "CSS1Compat" == c.compatMode ? c.documentElement : c.body;
+ a = d.clientWidth;
+ b = d.clientHeight;
+ }
+ a &&
+ b &&
+ (a != google.cdo.width || b != google.cdo.height) &&
+ google.log("", "", "/client_204?&atyp=i&biw=" + a + "&bih=" + b + "&ei=" + google.kEI);
+ }).call(this);
+ })();
+ </script>
+ <script nonce="GkiuApJ39JY6FCXsWXwc0g">
+ (function () {
+ google.xjs = { ck: "xjs.hp.o5AfvK7BgaM.L.X.O", cs: "ACT90oHyGC850G6IwjNxf19ZOa0R6EWAQw", excm: [] };
+ })();
+ </script>
+ <script nonce="GkiuApJ39JY6FCXsWXwc0g">
+ (function () {
+ var u =
+ "/xjs/_/js/k\x3dxjs.hp.en_US.dE-FG74hDaY.O/am\x3dAADoBABQAGAB/d\x3d1/ed\x3d1/rs\x3dACT90oFXGhsDPcVbgIE3ddPch07JJa-91Q/m\x3dsb_he,d";
+ var amd = 0;
+ var d = this || self,
+ e = function (a) {
+ return a;
+ };
+ var g;
+ var l = function (a, b) {
+ this.g = b === h ? a : "";
+ };
+ l.prototype.toString = function () {
+ return this.g + "";
+ };
+ var h = {};
+ function m() {
+ var a = u;
+ google.lx = function () {
+ p(a);
+ google.lx = function () {};
+ };
+ google.bx || google.lx();
+ }
+ function p(a) {
+ google.timers && google.timers.load && google.tick && google.tick("load", "xjsls");
+ var b = document;
+ var c = "SCRIPT";
+ "application/xhtml+xml" === b.contentType && (c = c.toLowerCase());
+ c = b.createElement(c);
+ if (void 0 === g) {
+ b = null;
+ var k = d.trustedTypes;
+ if (k && k.createPolicy) {
+ try {
+ b = k.createPolicy("goog#html", { createHTML: e, createScript: e, createScriptURL: e });
+ } catch (q) {
+ d.console && d.console.error(q.message);
+ }
+ g = b;
+ } else g = b;
+ }
+ a = (b = g) ? b.createScriptURL(a) : a;
+ a = new l(a, h);
+ c.src = a instanceof l && a.constructor === l ? a.g : "type_error:TrustedResourceUrl";
+ var f, n;
+ (f = (a =
+ null == (n = (f = ((c.ownerDocument && c.ownerDocument.defaultView) || window).document).querySelector)
+ ? void 0
+ : n.call(f, "script[nonce]"))
+ ? a.nonce || a.getAttribute("nonce") || ""
+ : "") && c.setAttribute("nonce", f);
+ document.body.appendChild(c);
+ google.psa = !0;
+ }
+ google.xjsu = u;
+ setTimeout(function () {
+ 0 < amd
+ ? google.caft(function () {
+ return m();
+ }, amd)
+ : m();
+ }, 0);
+ })();
+ function _DumpException(e) {
+ throw e;
+ }
+ function _F_installCss(c) {}
+ (function () {
+ google.jl = {
+ blt: "none",
+ chnk: 0,
+ dw: false,
+ dwu: true,
+ emtn: 0,
+ end: 0,
+ ico: false,
+ ikb: 0,
+ ine: false,
+ injs: "none",
+ injt: 0,
+ injth: 0,
+ injv2: false,
+ lls: "default",
+ pdt: 0,
+ rep: 0,
+ snet: true,
+ strt: 0,
+ ubm: false,
+ uwp: true,
+ };
+ })();
+ (function () {
+ var pmc =
+ "{\x22d\x22:{},\x22sb_he\x22:{\x22agen\x22:true,\x22cgen\x22:true,\x22client\x22:\x22heirloom-hp\x22,\x22dh\x22:true,\x22ds\x22:\x22\x22,\x22fl\x22:true,\x22host\x22:\x22google.com\x22,\x22jsonp\x22:true,\x22msgs\x22:{\x22cibl\x22:\x22Clear Search\x22,\x22dym\x22:\x22Did you mean:\x22,\x22lcky\x22:\x22I\\u0026#39;m Feeling Lucky\x22,\x22lml\x22:\x22Learn more\x22,\x22psrc\x22:\x22This search was removed from your \\u003Ca href\x3d\\\x22/history\\\x22\\u003EWeb History\\u003C/a\\u003E\x22,\x22psrl\x22:\x22Remove\x22,\x22sbit\x22:\x22Search by image\x22,\x22srch\x22:\x22Google Search\x22},\x22ovr\x22:{},\x22pq\x22:\x22\x22,\x22rfs\x22:[],\x22sbas\x22:\x220 3px 8px 0 rgba(0,0,0,0.2),0 0 0 1px rgba(0,0,0,0.08)\x22,\x22stok\x22:\x22sL4-RrhdjZ3aIiP5pD7muEeZ3T8\x22}}";
+ google.pmc = JSON.parse(pmc);
+ })();
+ </script>
+ </body>
+</html>
diff --git a/test/bun.js/hot-runner-imported.js b/test/bun.js/hot-runner-imported.js
index bfa94ec4f..a763a17d6 100644
--- a/test/bun.js/hot-runner-imported.js
+++ b/test/bun.js/hot-runner-imported.js
@@ -1,5 +1,3 @@
globalThis.importedCounter ??= 0;
-console.log(
- `[${Date.now()}] [#!imported] Reloaded: ${++globalThis.importedCounter}`,
-);
+console.log(`[${Date.now()}] [#!imported] Reloaded: ${++globalThis.importedCounter}`);
diff --git a/test/bun.js/hot.test.ts b/test/bun.js/hot.test.ts
index 97dff6d91..174515507 100644
--- a/test/bun.js/hot.test.ts
+++ b/test/bun.js/hot.test.ts
@@ -2,13 +2,7 @@ import { spawn } from "bun";
import { expect, it } from "bun:test";
import { bunEnv } from "bunEnv";
import { bunExe } from "bunExe";
-import {
- readFileSync,
- renameSync,
- rmSync,
- unlinkSync,
- writeFileSync,
-} from "fs";
+import { readFileSync, renameSync, rmSync, unlinkSync, writeFileSync } from "fs";
it("should hot reload when file is overwritten", async () => {
const root = import.meta.dir + "/hot-runner.js";
diff --git a/test/bun.js/html-rewriter.test.js b/test/bun.js/html-rewriter.test.js
index 008ced791..660c6e4f6 100644
--- a/test/bun.js/html-rewriter.test.js
+++ b/test/bun.js/html-rewriter.test.js
@@ -73,13 +73,9 @@ describe("HTMLRewriter", () => {
}
},
});
- var input = new Response(
- '<div first second="alrihgt" third="123" fourth=5 fifth=helloooo>hello</div>',
- );
+ var input = new Response('<div first second="alrihgt" third="123" fourth=5 fifth=helloooo>hello</div>');
var output = rewriter.transform(input);
- expect(await output.text()).toBe(
- '<div first second="alrihgt" third="123" fourth=5 fifth=helloooo>hello</div>',
- );
+ expect(await output.text()).toBe('<div first second="alrihgt" third="123" fourth=5 fifth=helloooo>hello</div>');
expect(expected.length).toBe(0);
});
@@ -147,9 +143,7 @@ describe("HTMLRewriter", () => {
element.setInnerContent(this.content);
}
}
- const res = new HTMLRewriter()
- .on("p", new Handler("new"))
- .transform(new Response("<p>test</p>"));
+ const res = new HTMLRewriter().on("p", new Handler("new")).transform(new Response("<p>test</p>"));
expect(await res.text()).toBe("<p>new</p>");
});
@@ -169,8 +163,8 @@ describe("HTMLRewriter", () => {
remove: "<p></p>",
};
- const commentPropertiesMacro = async (func) => {
- const res = func(new HTMLRewriter(), (comment) => {
+ const commentPropertiesMacro = async func => {
+ const res = func(new HTMLRewriter(), comment => {
expect(comment.removed).toBe(false);
expect(comment.text).toBe("test");
comment.text = "new";
@@ -224,21 +218,9 @@ describe("HTMLRewriter", () => {
"<div><p>1</p><p>2</p><p>3</p></div>",
"<div><p>1</p><p>new</p><p>new</p></div>",
);
- await checkSelector(
- "p.red",
- '<p class="red">1</p><p>2</p>',
- '<p class="red">new</p><p>2</p>',
- );
- await checkSelector(
- "h1#header",
- '<h1 id="header">1</h1><h1>2</h1>',
- '<h1 id="header">new</h1><h1>2</h1>',
- );
- await checkSelector(
- "p[data-test]",
- "<p data-test>1</p><p>2</p>",
- "<p data-test>new</p><p>2</p>",
- );
+ await checkSelector("p.red", '<p class="red">1</p><p>2</p>', '<p class="red">new</p><p>2</p>');
+ await checkSelector("h1#header", '<h1 id="header">1</h1><h1>2</h1>', '<h1 id="header">new</h1><h1>2</h1>');
+ await checkSelector("p[data-test]", "<p data-test>1</p><p>2</p>", "<p data-test>new</p><p>2</p>");
await checkSelector(
'p[data-test="one"]',
'<p data-test="one">1</p><p data-test="two">2</p>',
diff --git a/test/bun.js/import-meta.test.js b/test/bun.js/import-meta.test.js
index 21d2c41a8..3f89c09f0 100644
--- a/test/bun.js/import-meta.test.js
+++ b/test/bun.js/import-meta.test.js
@@ -10,17 +10,13 @@ it("primordials are not here!", () => {
});
it("import.meta.resolveSync", () => {
- expect(
- import.meta.resolveSync("./" + import.meta.file, import.meta.path),
- ).toBe(path);
+ expect(import.meta.resolveSync("./" + import.meta.file, import.meta.path)).toBe(path);
const require = Module.createRequire(import.meta.path);
expect(require.resolve(import.meta.path)).toBe(path);
expect(require.resolve("./" + import.meta.file)).toBe(path);
// check it works with URL objects
- expect(
- Module.createRequire(new URL(import.meta.url)).resolve(import.meta.path),
- ).toBe(import.meta.path);
+ expect(Module.createRequire(new URL(import.meta.url)).resolve(import.meta.path)).toBe(import.meta.path);
});
it("require with a query string works on dynamically created content", () => {
@@ -29,9 +25,7 @@ it("require with a query string works on dynamically created content", () => {
force: true,
});
try {
- const require = Module.createRequire(
- "/tmp/bun-test-import-meta-dynamic-dir/foo.js",
- );
+ const require = Module.createRequire("/tmp/bun-test-import-meta-dynamic-dir/foo.js");
try {
require("./bar.js?query=123");
} catch (e) {
@@ -40,11 +34,7 @@ it("require with a query string works on dynamically created content", () => {
mkdirSync("/tmp/bun-test-import-meta-dynamic-dir", { recursive: true });
- writeFileSync(
- "/tmp/bun-test-import-meta-dynamic-dir/bar.js",
- "export default 'hello';",
- "utf8",
- );
+ writeFileSync("/tmp/bun-test-import-meta-dynamic-dir/bar.js", "export default 'hello';", "utf8");
expect(require("./bar.js?query=123").default).toBe("hello");
} catch (e) {
@@ -132,9 +122,7 @@ it("import.meta.require (javascript, live bindings)", () => {
var ReExport = require("./import.live.rexport.js");
// dynamic require (string interpolation that way forces it to be dynamic)
- var ReExportDynamic = require(`./import.live.${"rexport"
- .split("")
- .join("")}.js`);
+ var ReExportDynamic = require(`./import.live.${"rexport".split("").join("")}.js`);
expect(Source.foo).toBe(1);
Source.setFoo(Source.foo + 1);
diff --git a/test/bun.js/inline.macro.js b/test/bun.js/inline.macro.js
index 082dbeaf4..8b157aa38 100644
--- a/test/bun.js/inline.macro.js
+++ b/test/bun.js/inline.macro.js
@@ -13,7 +13,7 @@ export function promiseReturningFunction(expr, ctx) {
export function promiseReturningCtx(expr, ctx) {
return new Promise((resolve, reject) => {
setTimeout(
- (ctx) => {
+ ctx => {
resolve(ctx);
},
1,
diff --git a/test/bun.js/inspect.test.js b/test/bun.js/inspect.test.js
index d0f4f026a..229f80548 100644
--- a/test/bun.js/inspect.test.js
+++ b/test/bun.js/inspect.test.js
@@ -12,8 +12,7 @@ it("when prototype defines the same property, don't print the same property twic
it("Blob inspect", () => {
expect(Bun.inspect(new Blob(["123"]))).toBe(`Blob (3 bytes)`);
expect(Bun.inspect(new Blob(["123".repeat(900)]))).toBe(`Blob (2.70 KB)`);
- expect(Bun.inspect(Bun.file("/tmp/file.txt")))
- .toBe(`FileRef ("/tmp/file.txt") {
+ expect(Bun.inspect(Bun.file("/tmp/file.txt"))).toBe(`FileRef ("/tmp/file.txt") {
type: "text/plain;charset=utf-8"
}`);
expect(Bun.inspect(Bun.file(123))).toBe(`FileRef (fd: 123) {
@@ -103,14 +102,10 @@ it("TypedArray prints", () => {
const buffer = new TypedArray([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
const input = Bun.inspect(buffer);
- expect(input).toBe(
- `${TypedArray.name}(${buffer.length}) [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]`,
- );
+ expect(input).toBe(`${TypedArray.name}(${buffer.length}) [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]`);
for (let i = 1; i < buffer.length + 1; i++) {
expect(Bun.inspect(buffer.subarray(i))).toBe(
- `${TypedArray.name}(${buffer.length - i}) [ ` +
- [...buffer.subarray(i)].join(", ") +
- " ]",
+ `${TypedArray.name}(${buffer.length - i}) [ ` + [...buffer.subarray(i)].join(", ") + " ]",
);
}
}
@@ -121,13 +116,11 @@ it("BigIntArray", () => {
const buffer = new TypedArray([1n, 2n, 3n, 4n, 5n, 6n, 7n, 8n, 9n, 10n]);
const input = Bun.inspect(buffer);
- expect(input).toBe(
- `${TypedArray.name}(${buffer.length}) [ 1n, 2n, 3n, 4n, 5n, 6n, 7n, 8n, 9n, 10n ]`,
- );
+ expect(input).toBe(`${TypedArray.name}(${buffer.length}) [ 1n, 2n, 3n, 4n, 5n, 6n, 7n, 8n, 9n, 10n ]`);
for (let i = 1; i < buffer.length + 1; i++) {
expect(Bun.inspect(buffer.subarray(i))).toBe(
`${TypedArray.name}(${buffer.length - i}) [ ` +
- [...buffer.subarray(i)].map((a) => a.toString(10) + "n").join(", ") +
+ [...buffer.subarray(i)].map(a => a.toString(10) + "n").join(", ") +
" ]",
);
}
@@ -139,16 +132,10 @@ it("FloatArray", () => {
const buffer = new TypedArray([Math.fround(42.68)]);
const input = Bun.inspect(buffer);
- expect(input).toBe(
- `${TypedArray.name}(${buffer.length}) [ ${[Math.fround(42.68)].join(
- ", ",
- )} ]`,
- );
+ expect(input).toBe(`${TypedArray.name}(${buffer.length}) [ ${[Math.fround(42.68)].join(", ")} ]`);
for (let i = 1; i < buffer.length + 1; i++) {
expect(Bun.inspect(buffer.subarray(i))).toBe(
- `${TypedArray.name}(${buffer.length - i}) [ ` +
- [...buffer.subarray(i)].join(", ") +
- " ]",
+ `${TypedArray.name}(${buffer.length - i}) [ ` + [...buffer.subarray(i)].join(", ") + " ]",
);
}
}
@@ -189,9 +176,7 @@ it("jsx with fragment", () => {
});
it("inspect", () => {
- expect(Bun.inspect(new TypeError("what")).includes("TypeError: what")).toBe(
- true,
- );
+ expect(Bun.inspect(new TypeError("what")).includes("TypeError: what")).toBe(true);
expect("hi").toBe("hi");
expect(Bun.inspect(1)).toBe("1");
expect(Bun.inspect(NaN)).toBe("NaN");
@@ -201,15 +186,9 @@ it("inspect", () => {
expect(Bun.inspect([])).toBe("[]");
expect(Bun.inspect({})).toBe("{}");
expect(Bun.inspect({ hello: 1 })).toBe("{\n hello: 1\n}");
- expect(Bun.inspect({ hello: 1, there: 2 })).toBe(
- "{\n hello: 1,\n there: 2\n}",
- );
- expect(Bun.inspect({ hello: "1", there: 2 })).toBe(
- '{\n hello: "1",\n there: 2\n}',
- );
- expect(Bun.inspect({ 'hello-"there': "1", there: 2 })).toBe(
- '{\n "hello-\\"there": "1",\n there: 2\n}',
- );
+ expect(Bun.inspect({ hello: 1, there: 2 })).toBe("{\n hello: 1,\n there: 2\n}");
+ expect(Bun.inspect({ hello: "1", there: 2 })).toBe('{\n hello: "1",\n there: 2\n}');
+ expect(Bun.inspect({ 'hello-"there': "1", there: 2 })).toBe('{\n "hello-\\"there": "1",\n there: 2\n}');
var str = "123";
while (str.length < 4096) {
str += "123";
@@ -226,19 +205,13 @@ it("inspect", () => {
// ).toBe('{"hi":"ok"}');
expect(Bun.inspect(new Set())).toBe("Set {}");
expect(Bun.inspect(new Map())).toBe("Map {}");
- expect(Bun.inspect(new Map([["foo", "bar"]]))).toBe(
- 'Map(1) {\n "foo": "bar",\n}',
- );
+ expect(Bun.inspect(new Map([["foo", "bar"]]))).toBe('Map(1) {\n "foo": "bar",\n}');
expect(Bun.inspect(new Set(["bar"]))).toBe('Set(1) {\n "bar",\n}');
expect(Bun.inspect(<div>foo</div>)).toBe("<div>foo</div>");
expect(Bun.inspect(<div hello>foo</div>)).toBe("<div hello=true>foo</div>");
expect(Bun.inspect(<div hello={1}>foo</div>)).toBe("<div hello=1>foo</div>");
- expect(Bun.inspect(<div hello={123}>hi</div>)).toBe(
- "<div hello=123>hi</div>",
- );
- expect(Bun.inspect(<div hello="quoted">quoted</div>)).toBe(
- '<div hello="quoted">quoted</div>',
- );
+ expect(Bun.inspect(<div hello={123}>hi</div>)).toBe("<div hello=123>hi</div>");
+ expect(Bun.inspect(<div hello="quoted">quoted</div>)).toBe('<div hello="quoted">quoted</div>');
expect(
Bun.inspect(
<div hello="quoted">
@@ -318,10 +291,7 @@ const fixture = [
describe("crash testing", () => {
for (let input of fixture) {
- it(`inspecting "${input
- .toString()
- .slice(0, 20)
- .replaceAll("\n", "\\n")}" doesn't crash`, async () => {
+ it(`inspecting "${input.toString().slice(0, 20).replaceAll("\n", "\\n")}" doesn't crash`, async () => {
try {
Bun.inspect(await input());
} catch (e) {
diff --git a/test/bun.js/install/bad-workspace.test.ts b/test/bun.js/install/bad-workspace.test.ts
index 5fdd54ed3..bb3f03a86 100644
--- a/test/bun.js/install/bad-workspace.test.ts
+++ b/test/bun.js/install/bad-workspace.test.ts
@@ -29,9 +29,7 @@ test("bad workspace path", () => {
const text = stderr!.toString();
expect(text).toContain('Workspace not found "i-dont-exist"');
- expect(text).toContain(
- 'Workspace not found "*/i-have-a-star-and-i-dont-exist"',
- );
+ expect(text).toContain('Workspace not found "*/i-have-a-star-and-i-dont-exist"');
expect(exitCode).toBe(1);
rmSync(cwd, { recursive: true, force: true });
});
diff --git a/test/bun.js/install/bun-link.test.ts b/test/bun.js/install/bun-link.test.ts
index a3ef9eeb7..5e80216bd 100644
--- a/test/bun.js/install/bun-link.test.ts
+++ b/test/bun.js/install/bun-link.test.ts
@@ -1,10 +1,5 @@
import { spawn } from "bun";
-import {
- afterEach,
- beforeEach,
- expect,
- it,
-} from "bun:test";
+import { afterEach, beforeEach, expect, it } from "bun:test";
import { bunExe } from "bunExe";
import { bunEnv as env } from "bunEnv";
import { mkdtemp, rm, writeFile } from "fs/promises";
@@ -24,16 +19,26 @@ afterEach(async () => {
it("should link package", async () => {
var link_name = basename(link_dir).slice("bun-link.".length);
- await writeFile(join(link_dir, "package.json"), JSON.stringify({
- name: link_name,
- version: "0.0.1",
- }));
- await writeFile(join(package_dir, "package.json"), JSON.stringify({
- name: "foo",
- version: "0.0.2",
- }));
+ await writeFile(
+ join(link_dir, "package.json"),
+ JSON.stringify({
+ name: link_name,
+ version: "0.0.1",
+ }),
+ );
+ await writeFile(
+ join(package_dir, "package.json"),
+ JSON.stringify({
+ name: "foo",
+ version: "0.0.2",
+ }),
+ );
- const { stdout: stdout1, stderr: stderr1, exited: exited1 } = spawn({
+ const {
+ stdout: stdout1,
+ stderr: stderr1,
+ exited: exited1,
+ } = spawn({
cmd: [bunExe(), "link"],
cwd: link_dir,
stdout: null,
@@ -43,15 +48,16 @@ it("should link package", async () => {
});
expect(stderr1).toBeDefined();
const err1 = await new Response(stderr1).text();
- expect(err1.replace(/^(.*?) v[^\n]+/, "$1").split(/\r?\n/)).toEqual([
- "bun link",
- "",
- ]);
+ expect(err1.replace(/^(.*?) v[^\n]+/, "$1").split(/\r?\n/)).toEqual(["bun link", ""]);
expect(stdout1).toBeDefined();
expect(await new Response(stdout1).text()).toContain(`Success! Registered "${link_name}"`);
expect(await exited1).toBe(0);
- const { stdout: stdout2, stderr: stderr2, exited: exited2 } = spawn({
+ const {
+ stdout: stdout2,
+ stderr: stderr2,
+ exited: exited2,
+ } = spawn({
cmd: [bunExe(), "link", link_name],
cwd: package_dir,
stdout: null,
@@ -61,10 +67,7 @@ it("should link package", async () => {
});
expect(stderr2).toBeDefined();
const err2 = await new Response(stderr2).text();
- expect(err2.replace(/^(.*?) v[^\n]+/, "$1").split(/\r?\n/)).toEqual([
- "bun link",
- "",
- ]);
+ expect(err2.replace(/^(.*?) v[^\n]+/, "$1").split(/\r?\n/)).toEqual(["bun link", ""]);
expect(stdout2).toBeDefined();
const out2 = await new Response(stdout2).text();
expect(out2.replace(/\s*\[[0-9\.]+ms\]\s*$/, "").split(/\r?\n/)).toEqual([
@@ -76,7 +79,11 @@ it("should link package", async () => {
]);
expect(await exited2).toBe(0);
- const { stdout: stdout3, stderr: stderr3, exited: exited3 } = spawn({
+ const {
+ stdout: stdout3,
+ stderr: stderr3,
+ exited: exited3,
+ } = spawn({
cmd: [bunExe(), "unlink"],
cwd: link_dir,
stdout: null,
@@ -86,15 +93,16 @@ it("should link package", async () => {
});
expect(stderr3).toBeDefined();
const err3 = await new Response(stderr3).text();
- expect(err3.replace(/^(.*?) v[^\n]+/, "$1").split(/\r?\n/)).toEqual([
- "bun unlink",
- "",
- ]);
+ expect(err3.replace(/^(.*?) v[^\n]+/, "$1").split(/\r?\n/)).toEqual(["bun unlink", ""]);
expect(stdout3).toBeDefined();
expect(await new Response(stdout3).text()).toContain(`success: unlinked package "${link_name}"`);
expect(await exited3).toBe(0);
- const { stdout: stdout4, stderr: stderr4, exited: exited4 } = spawn({
+ const {
+ stdout: stdout4,
+ stderr: stderr4,
+ exited: exited4,
+ } = spawn({
cmd: [bunExe(), "link", link_name],
cwd: package_dir,
stdout: null,
@@ -113,16 +121,26 @@ it("should link package", async () => {
it("should link scoped package", async () => {
var link_name = `@${basename(link_dir).slice("bun-link.".length)}/foo`;
- await writeFile(join(link_dir, "package.json"), JSON.stringify({
- name: link_name,
- version: "0.0.1",
- }));
- await writeFile(join(package_dir, "package.json"), JSON.stringify({
- name: "bar",
- version: "0.0.2",
- }));
+ await writeFile(
+ join(link_dir, "package.json"),
+ JSON.stringify({
+ name: link_name,
+ version: "0.0.1",
+ }),
+ );
+ await writeFile(
+ join(package_dir, "package.json"),
+ JSON.stringify({
+ name: "bar",
+ version: "0.0.2",
+ }),
+ );
- const { stdout: stdout1, stderr: stderr1, exited: exited1 } = spawn({
+ const {
+ stdout: stdout1,
+ stderr: stderr1,
+ exited: exited1,
+ } = spawn({
cmd: [bunExe(), "link"],
cwd: link_dir,
stdout: null,
@@ -132,15 +150,16 @@ it("should link scoped package", async () => {
});
expect(stderr1).toBeDefined();
const err1 = await new Response(stderr1).text();
- expect(err1.replace(/^(.*?) v[^\n]+/, "$1").split(/\r?\n/)).toEqual([
- "bun link",
- "",
- ]);
+ expect(err1.replace(/^(.*?) v[^\n]+/, "$1").split(/\r?\n/)).toEqual(["bun link", ""]);
expect(stdout1).toBeDefined();
expect(await new Response(stdout1).text()).toContain(`Success! Registered "${link_name}"`);
expect(await exited1).toBe(0);
- const { stdout: stdout2, stderr: stderr2, exited: exited2 } = spawn({
+ const {
+ stdout: stdout2,
+ stderr: stderr2,
+ exited: exited2,
+ } = spawn({
cmd: [bunExe(), "link", link_name],
cwd: package_dir,
stdout: null,
@@ -150,10 +169,7 @@ it("should link scoped package", async () => {
});
expect(stderr2).toBeDefined();
const err2 = await new Response(stderr2).text();
- expect(err2.replace(/^(.*?) v[^\n]+/, "$1").split(/\r?\n/)).toEqual([
- "bun link",
- "",
- ]);
+ expect(err2.replace(/^(.*?) v[^\n]+/, "$1").split(/\r?\n/)).toEqual(["bun link", ""]);
expect(stdout2).toBeDefined();
const out2 = await new Response(stdout2).text();
expect(out2.replace(/\s*\[[0-9\.]+ms\]\s*$/, "").split(/\r?\n/)).toEqual([
@@ -165,7 +181,11 @@ it("should link scoped package", async () => {
]);
expect(await exited2).toBe(0);
- const { stdout: stdout3, stderr: stderr3, exited: exited3 } = spawn({
+ const {
+ stdout: stdout3,
+ stderr: stderr3,
+ exited: exited3,
+ } = spawn({
cmd: [bunExe(), "unlink"],
cwd: link_dir,
stdout: null,
@@ -175,15 +195,16 @@ it("should link scoped package", async () => {
});
expect(stderr3).toBeDefined();
const err3 = await new Response(stderr3).text();
- expect(err3.replace(/^(.*?) v[^\n]+/, "$1").split(/\r?\n/)).toEqual([
- "bun unlink",
- "",
- ]);
+ expect(err3.replace(/^(.*?) v[^\n]+/, "$1").split(/\r?\n/)).toEqual(["bun unlink", ""]);
expect(stdout3).toBeDefined();
expect(await new Response(stdout3).text()).toContain(`success: unlinked package "${link_name}"`);
expect(await exited3).toBe(0);
- const { stdout: stdout4, stderr: stderr4, exited: exited4 } = spawn({
+ const {
+ stdout: stdout4,
+ stderr: stderr4,
+ exited: exited4,
+ } = spawn({
cmd: [bunExe(), "link", link_name],
cwd: package_dir,
stdout: null,
diff --git a/test/bun.js/install/bunx.test.ts b/test/bun.js/install/bunx.test.ts
index 95fe3b2b9..b754ca0c6 100644
--- a/test/bun.js/install/bunx.test.ts
+++ b/test/bun.js/install/bunx.test.ts
@@ -1,10 +1,5 @@
import { spawn } from "bun";
-import {
- afterEach,
- beforeEach,
- expect,
- it,
-} from "bun:test";
+import { afterEach, beforeEach, expect, it } from "bun:test";
import { bunExe } from "bunExe";
import { bunEnv as env } from "bunEnv";
import { realpathSync } from "fs";
@@ -35,10 +30,7 @@ it("should install and run default (latest) version", async () => {
expect(err).not.toContain("error");
expect(stdout).toBeDefined();
const out = await new Response(stdout).text();
- expect(out.split(/\r?\n/)).toEqual([
- "console.log(42);",
- "",
- ]);
+ expect(out.split(/\r?\n/)).toEqual(["console.log(42);", ""]);
expect(await exited).toBe(0);
});
@@ -56,9 +48,6 @@ it("should install and run specified version", async () => {
expect(err).not.toContain("error");
expect(stdout).toBeDefined();
const out = await new Response(stdout).text();
- expect(out.split(/\r?\n/)).toEqual([
- "uglify-js 3.14.1",
- "",
- ]);
+ expect(out.split(/\r?\n/)).toEqual(["uglify-js 3.14.1", ""]);
expect(await exited).toBe(0);
});
diff --git a/test/bun.js/microtask.test.js b/test/bun.js/microtask.test.js
index dba84f36c..f41159cfa 100644
--- a/test/bun.js/microtask.test.js
+++ b/test/bun.js/microtask.test.js
@@ -58,10 +58,7 @@ it("queueMicrotask", async () => {
passed = exception instanceof TypeError;
}
- if (!passed)
- throw new Error(
- "queueMicrotask should throw a TypeError if the argument is not a function",
- );
+ if (!passed) throw new Error("queueMicrotask should throw a TypeError if the argument is not a function");
}
{
@@ -72,9 +69,6 @@ it("queueMicrotask", async () => {
passed = exception instanceof TypeError;
}
- if (!passed)
- throw new Error(
- "queueMicrotask should throw a TypeError if the argument is empty",
- );
+ if (!passed) throw new Error("queueMicrotask should throw a TypeError if the argument is empty");
}
});
diff --git a/test/bun.js/node-crypto.test.js b/test/bun.js/node-crypto.test.js
index 151a06198..5d9d6a77d 100644
--- a/test/bun.js/node-crypto.test.js
+++ b/test/bun.js/node-crypto.test.js
@@ -17,10 +17,7 @@ it("crypto.createHash ", () => {
});
it("crypto.createHmac", () => {
- const result = crypto
- .createHmac("sha256", "key")
- .update("message")
- .digest("base64");
+ const result = crypto.createHmac("sha256", "key").update("message").digest("base64");
expect(result).toBe("bp7ym3X//Ft6uuUn1Y/a2y/kLnIZARl2kXNDBl9Y7Uo=");
});
diff --git a/test/bun.js/node-dns.test.js b/test/bun.js/node-dns.test.js
index b84b8c9ba..a2780374f 100644
--- a/test/bun.js/node-dns.test.js
+++ b/test/bun.js/node-dns.test.js
@@ -21,13 +21,11 @@ test("it exists", () => {
});
// //TODO: use a bun.sh SRV for testing
-test("dns.resolveSrv (_test._tcp.test.socketify.dev)", (done) => {
+test("dns.resolveSrv (_test._tcp.test.socketify.dev)", done => {
dns.resolveSrv("_test._tcp.test.socketify.dev", (err, results) => {
expect(err).toBeNull();
expect(results instanceof Array).toBe(true);
- expect(results[0].name).toBe(
- "_dc-srv.130c90ab9de1._test._tcp.test.socketify.dev",
- );
+ expect(results[0].name).toBe("_dc-srv.130c90ab9de1._test._tcp.test.socketify.dev");
expect(results[0].priority).toBe(50);
expect(results[0].weight).toBe(50);
expect(results[0].port).toBe(80);
@@ -35,7 +33,7 @@ test("dns.resolveSrv (_test._tcp.test.socketify.dev)", (done) => {
});
});
-test("dns.resolveSrv (_test._tcp.invalid.localhost)", (done) => {
+test("dns.resolveSrv (_test._tcp.invalid.localhost)", done => {
dns.resolveSrv("_test._tcp.invalid.localhost", (err, results) => {
expect(err).toBeTruthy();
expect(results).toBeUndefined(true);
@@ -43,7 +41,7 @@ test("dns.resolveSrv (_test._tcp.invalid.localhost)", (done) => {
});
});
-test("dns.resolveTxt (txt.socketify.dev)", (done) => {
+test("dns.resolveTxt (txt.socketify.dev)", done => {
dns.resolveTxt("txt.socketify.dev", (err, results) => {
expect(err).toBeNull();
expect(results instanceof Array).toBe(true);
@@ -52,7 +50,7 @@ test("dns.resolveTxt (txt.socketify.dev)", (done) => {
});
});
-test("dns.resolveSoa (bun.sh)", (done) => {
+test("dns.resolveSoa (bun.sh)", done => {
dns.resolveSoa("bun.sh", (err, result) => {
expect(err).toBeNull();
expect(result.serial).toBe(2295878541);
@@ -66,7 +64,7 @@ test("dns.resolveSoa (bun.sh)", (done) => {
});
});
-test("dns.resolveNaptr (naptr.socketify.dev)", (done) => {
+test("dns.resolveNaptr (naptr.socketify.dev)", done => {
dns.resolveNaptr("naptr.socketify.dev", (err, results) => {
expect(err).toBeNull();
expect(results instanceof Array).toBe(true);
@@ -80,7 +78,7 @@ test("dns.resolveNaptr (naptr.socketify.dev)", (done) => {
});
});
-test("dns.resolveCaa (caa.socketify.dev)", (done) => {
+test("dns.resolveCaa (caa.socketify.dev)", done => {
dns.resolveCaa("caa.socketify.dev", (err, results) => {
expect(err).toBeNull();
expect(results instanceof Array).toBe(true);
@@ -90,7 +88,7 @@ test("dns.resolveCaa (caa.socketify.dev)", (done) => {
});
});
-test("dns.resolveMx (bun.sh)", (done) => {
+test("dns.resolveMx (bun.sh)", done => {
dns.resolveMx("bun.sh", (err, results) => {
expect(err).toBeNull();
expect(results instanceof Array).toBe(true);
@@ -101,7 +99,7 @@ test("dns.resolveMx (bun.sh)", (done) => {
});
});
-test("dns.resolveNs (bun.sh) ", (done) => {
+test("dns.resolveNs (bun.sh) ", done => {
dns.resolveNs("bun.sh", (err, results) => {
expect(err).toBeNull();
expect(results instanceof Array).toBe(true);
@@ -110,7 +108,7 @@ test("dns.resolveNs (bun.sh) ", (done) => {
});
});
-test("dns.resolvePtr (ptr.socketify.dev)", (done) => {
+test("dns.resolvePtr (ptr.socketify.dev)", done => {
dns.resolvePtr("ptr.socketify.dev", (err, results) => {
expect(err).toBeNull();
expect(results instanceof Array).toBe(true);
@@ -119,7 +117,7 @@ test("dns.resolvePtr (ptr.socketify.dev)", (done) => {
});
});
-test("dns.resolveCname (cname.socketify.dev)", (done) => {
+test("dns.resolveCname (cname.socketify.dev)", done => {
dns.resolveCname("cname.socketify.dev", (err, results) => {
expect(err).toBeNull();
expect(results instanceof Array).toBe(true);
@@ -128,7 +126,7 @@ test("dns.resolveCname (cname.socketify.dev)", (done) => {
});
});
-test("dns.lookup (example.com)", (done) => {
+test("dns.lookup (example.com)", done => {
dns.lookup("example.com", (err, address, family) => {
expect(err).toBeNull();
expect(typeof address).toBe("string");
@@ -136,7 +134,7 @@ test("dns.lookup (example.com)", (done) => {
});
});
-test("dns.lookup (localhost)", (done) => {
+test("dns.lookup (localhost)", done => {
dns.lookup("localhost", (err, address, family) => {
expect(err).toBeNull();
if (family === 6) {
diff --git a/test/bun.js/node-http.test.ts b/test/bun.js/node-http.test.ts
index 24b3f1c85..cdb0d4758 100644
--- a/test/bun.js/node-http.test.ts
+++ b/test/bun.js/node-http.test.ts
@@ -22,7 +22,7 @@ describe("node:http", () => {
const server = createServer((req, res) => {
res.writeHead(200, { "Content-Type": "text/plain" });
- req.on("data", (chunk) => {
+ req.on("data", chunk => {
res.write(chunk);
});
@@ -49,7 +49,7 @@ describe("node:http", () => {
const server = createServer((req, res) => {
res.writeHead(200, { "Content-Type": "text/plain" });
- req.on("data", (chunk) => {
+ req.on("data", chunk => {
res.write(chunk);
});
diff --git a/test/bun.js/node-stream.test.js b/test/bun.js/node-stream.test.js
index afa1867b6..6bff28b94 100644
--- a/test/bun.js/node-stream.test.js
+++ b/test/bun.js/node-stream.test.js
@@ -1,14 +1,8 @@
import { expect, describe, it } from "bun:test";
-import {
- Readable,
- Writable,
- Duplex,
- Transform,
- PassThrough,
-} from "node:stream";
+import { Readable, Writable, Duplex, Transform, PassThrough } from "node:stream";
describe("Readable", () => {
- it("should be able to be created without _construct method defined", (done) => {
+ it("should be able to be created without _construct method defined", done => {
const readable = new Readable({
read() {
this.push("Hello World!\n");
@@ -17,7 +11,7 @@ describe("Readable", () => {
});
expect(readable instanceof Readable).toBe(true);
let data = "";
- readable.on("data", (chunk) => {
+ readable.on("data", chunk => {
data += chunk.toString();
});
readable.on("end", () => {
@@ -26,7 +20,7 @@ describe("Readable", () => {
});
});
- it("should be able to be piped via .pipe", (done) => {
+ it("should be able to be piped via .pipe", done => {
const readable = new Readable({
read() {
this.push("Hello World!");
diff --git a/test/bun.js/node-test-helpers.ts b/test/bun.js/node-test-helpers.ts
index fbad2a3bf..34147c194 100644
--- a/test/bun.js/node-test-helpers.ts
+++ b/test/bun.js/node-test-helpers.ts
@@ -6,7 +6,7 @@ import assertNode from "node:assert";
type DoneCb = (err?: Error) => any;
function noop() {}
-const expect = (actual) => {
+const expect = actual => {
gcTick();
const ret = expect_(actual);
gcTick();
@@ -14,23 +14,17 @@ const expect = (actual) => {
};
// Assert
-export const strictEqual = (
- ...args: Parameters<typeof assertNode.strictEqual>
-) => {
+export const strictEqual = (...args: Parameters<typeof assertNode.strictEqual>) => {
assertNode.strictEqual.apply(this, args);
expect(true).toBe(true);
};
-export const notStrictEqual = (
- ...args: Parameters<typeof assertNode.notStrictEqual>
-) => {
+export const notStrictEqual = (...args: Parameters<typeof assertNode.notStrictEqual>) => {
assertNode.notStrictEqual.apply(this, args);
expect(true).toBe(true);
};
-export const deepStrictEqual = (
- ...args: Parameters<typeof assertNode.deepStrictEqual>
-) => {
+export const deepStrictEqual = (...args: Parameters<typeof assertNode.deepStrictEqual>) => {
assertNode.deepStrictEqual.apply(this, args);
expect(true).toBe(true);
};
@@ -92,9 +86,7 @@ export const createCallCheckCtx = (done: DoneCb) => {
return mustCallAtLeast(fn, exact);
}
- function mustNotCall(
- reason: string = "function should not have been called",
- ) {
+ function mustNotCall(reason: string = "function should not have been called") {
const localDone = createDone();
setTimeout(() => localDone(), 200);
return () => {
@@ -115,8 +107,7 @@ export const createCallCheckCtx = (done: DoneCb) => {
}
function _mustCallInner(fn, criteria = 1, field) {
- if (process._exiting)
- throw new Error("Cannot use common.mustCall*() in process exit handler");
+ if (process._exiting) throw new Error("Cannot use common.mustCall*() in process exit handler");
if (typeof fn === "number") {
criteria = fn;
fn = noop;
@@ -124,8 +115,7 @@ export const createCallCheckCtx = (done: DoneCb) => {
fn = noop;
}
- if (typeof criteria !== "number")
- throw new TypeError(`Invalid ${field} value: ${criteria}`);
+ if (typeof criteria !== "number") throw new TypeError(`Invalid ${field} value: ${criteria}`);
let actual = 0;
let expected = criteria;
diff --git a/test/bun.js/os.test.js b/test/bun.js/os.test.js
index f48354216..c907e74ef 100644
--- a/test/bun.js/os.test.js
+++ b/test/bun.js/os.test.js
@@ -2,7 +2,7 @@ import { it, expect } from "bun:test";
import * as os from "node:os";
it("arch", () => {
- expect(["x64", "x86", "arm64"].some((arch) => os.arch() === arch)).toBe(true);
+ expect(["x64", "x86", "arm64"].some(arch => os.arch() === arch)).toBe(true);
});
it("endianness", () => {
@@ -40,13 +40,9 @@ it("homedir", () => {
it("tmpdir", () => {
if (process.platform === "win32") {
expect(os.tmpdir()).toBe(process.env.TEMP || process.env.TMP);
- expect(os.tmpdir()).toBe(
- `${process.env.SystemRoot || process.env.windir}\\temp`,
- );
+ expect(os.tmpdir()).toBe(`${process.env.SystemRoot || process.env.windir}\\temp`);
} else {
- expect(os.tmpdir()).toBe(
- process.env.TMPDIR || process.env.TMP || process.env.TEMP || "/tmp",
- );
+ expect(os.tmpdir()).toBe(process.env.TMPDIR || process.env.TMP || process.env.TEMP || "/tmp");
}
});
@@ -55,11 +51,7 @@ it("hostname", () => {
});
it("platform", () => {
- expect(
- ["win32", "darwin", "linux", "wasm"].some(
- (platform) => os.platform() === platform,
- ),
- ).toBe(true);
+ expect(["win32", "darwin", "linux", "wasm"].some(platform => os.platform() === platform)).toBe(true);
});
it("release", () => {
@@ -67,9 +59,7 @@ it("release", () => {
});
it("type", () => {
- expect(
- ["Windows_NT", "Darwin", "Linux"].some((type) => os.type() === type),
- ).toBe(true);
+ expect(["Windows_NT", "Darwin", "Linux"].some(type => os.type() === type)).toBe(true);
});
it("uptime", () => {
diff --git a/test/bun.js/path.test.js b/test/bun.js/path.test.js
index 97132512c..176d98c8e 100644
--- a/test/bun.js/path.test.js
+++ b/test/bun.js/path.test.js
@@ -64,10 +64,7 @@ it("path.basename", () => {
strictEqual(path.win32.basename("a", "a"), "");
// On unix a backslash is just treated as any other character.
- strictEqual(
- path.posix.basename("\\dir\\basename.ext"),
- "\\dir\\basename.ext",
- );
+ strictEqual(path.posix.basename("\\dir\\basename.ext"), "\\dir\\basename.ext");
strictEqual(path.posix.basename("\\basename.ext"), "\\basename.ext");
strictEqual(path.posix.basename("basename.ext"), "basename.ext");
strictEqual(path.posix.basename("basename.ext\\"), "basename.ext\\");
@@ -77,10 +74,7 @@ it("path.basename", () => {
// POSIX filenames may include control characters
// c.f. http://www.dwheeler.com/essays/fixing-unix-linux-filenames.html
const controlCharFilename = `Icon${String.fromCharCode(13)}`;
- strictEqual(
- path.posix.basename(`/a/b/${controlCharFilename}`),
- controlCharFilename,
- );
+ strictEqual(path.posix.basename(`/a/b/${controlCharFilename}`), controlCharFilename);
});
it("path.join", () => {
@@ -195,10 +189,10 @@ it("path.join", () => {
// [["c:", "file"], "c:\\file"],
// ]),
// ]);
- joinTests.forEach((test) => {
+ joinTests.forEach(test => {
if (!Array.isArray(test[0])) test[0] = [test[0]];
- test[0].forEach((join) => {
- test[1].forEach((test) => {
+ test[0].forEach(join => {
+ test[1].forEach(test => {
const actual = join.apply(null, test[0]);
const expected = test[1];
// For non-Windows specific tests with the Windows join(), we need to try
@@ -284,9 +278,9 @@ it("path.relative", () => {
],
];
- relativeTests.forEach((test) => {
+ relativeTests.forEach(test => {
const relative = test[0];
- test[1].forEach((test) => {
+ test[1].forEach(test => {
const actual = relative(test[0], test[1]);
const expected = test[2];
if (actual !== expected) {
@@ -294,9 +288,7 @@ it("path.relative", () => {
const message = `path.${os}.relative(${test
.slice(0, 2)
.map(JSON.stringify)
- .join(",")})\n expect=${JSON.stringify(
- expected,
- )}\n actual=${JSON.stringify(actual)}`;
+ .join(",")})\n expect=${JSON.stringify(expected)}\n actual=${JSON.stringify(actual)}`;
failures.push(`\n${message}`);
}
});
@@ -353,10 +345,7 @@ it("path.normalize", () => {
// );
// strictEqual(path.win32.normalize("foo/bar\\baz"), "foo\\bar\\baz");
- strictEqual(
- path.posix.normalize("./fixtures///b/../b/c.js"),
- "fixtures/b/c.js",
- );
+ strictEqual(path.posix.normalize("./fixtures///b/../b/c.js"), "fixtures/b/c.js");
strictEqual(path.posix.normalize("/foo/../../../bar"), "/bar");
strictEqual(path.posix.normalize("a//b//../b"), "a/b");
strictEqual(path.posix.normalize("a//b//./c"), "a/b/c");
@@ -370,22 +359,10 @@ it("path.normalize", () => {
strictEqual(path.posix.normalize("bar/foo.."), "bar/foo..");
strictEqual(path.posix.normalize("../foo../../../bar"), "../../bar");
strictEqual(path.posix.normalize("../.../.././.../../../bar"), "../../bar");
- strictEqual(
- path.posix.normalize("../../../foo/../../../bar"),
- "../../../../../bar",
- );
- strictEqual(
- path.posix.normalize("../../../foo/../../../bar/../../"),
- "../../../../../../",
- );
- strictEqual(
- path.posix.normalize("../foobar/barfoo/foo/../../../bar/../../"),
- "../../",
- );
- strictEqual(
- path.posix.normalize("../.../../foobar/../../../bar/../../baz"),
- "../../../../baz",
- );
+ strictEqual(path.posix.normalize("../../../foo/../../../bar"), "../../../../../bar");
+ strictEqual(path.posix.normalize("../../../foo/../../../bar/../../"), "../../../../../../");
+ strictEqual(path.posix.normalize("../foobar/barfoo/foo/../../../bar/../../"), "../../");
+ strictEqual(path.posix.normalize("../.../../foobar/../../../bar/../../baz"), "../../../../baz");
strictEqual(path.posix.normalize("foo/bar\\baz"), "foo/bar\\baz");
});
@@ -425,10 +402,7 @@ it("path.resolve", () => {
[["a/b/c/", "../../.."], process.cwd()],
[["."], process.cwd()],
[["/some/dir", ".", "/absolute/"], "/absolute"],
- [
- ["/foo/tmp.3/", "../tmp.3/cycles/root.js"],
- "/foo/tmp.3/cycles/root.js",
- ],
+ [["/foo/tmp.3/", "../tmp.3/cycles/root.js"], "/foo/tmp.3/cycles/root.js"],
],
],
];
@@ -438,14 +412,10 @@ it("path.resolve", () => {
const actual = resolve.apply(null, test);
let actualAlt;
const os = resolve === path.win32.resolve ? "win32" : "posix";
- if (resolve === path.win32.resolve && !isWindows)
- actualAlt = actual.replace(backslashRE, "/");
- else if (resolve !== path.win32.resolve && isWindows)
- actualAlt = actual.replace(slashRE, "\\");
+ if (resolve === path.win32.resolve && !isWindows) actualAlt = actual.replace(backslashRE, "/");
+ else if (resolve !== path.win32.resolve && isWindows) actualAlt = actual.replace(slashRE, "\\");
- const message = `path.${os}.resolve(${test
- .map(JSON.stringify)
- .join(",")})\n expect=${JSON.stringify(
+ const message = `path.${os}.resolve(${test.map(JSON.stringify).join(",")})\n expect=${JSON.stringify(
expected,
)}\n actual=${JSON.stringify(actual)}`;
if (actual !== expected && actualAlt !== expected) failures.push(message);
diff --git a/test/bun.js/peek.test.ts b/test/bun.js/peek.test.ts
index 0c2614d75..421c306d8 100644
--- a/test/bun.js/peek.test.ts
+++ b/test/bun.js/peek.test.ts
@@ -22,14 +22,10 @@ test("peek", () => {
// If we peek a rejected promise, it:
// - returns the error
// - does not mark the promise as handled
- const rejected = Promise.reject<Error>(
- new Error("Succesfully tested promise rejection"),
- );
+ const rejected = Promise.reject<Error>(new Error("Succesfully tested promise rejection"));
const peeked = peek(rejected);
expect(peeked instanceof Error).toBe(true);
- expect((peeked as Error).message).toBe(
- "Succesfully tested promise rejection",
- );
+ expect((peeked as Error).message).toBe("Succesfully tested promise rejection");
rejected.catch(() => {});
});
diff --git a/test/bun.js/performance.test.js b/test/bun.js/performance.test.js
index 51479209c..dd50c4dc6 100644
--- a/test/bun.js/performance.test.js
+++ b/test/bun.js/performance.test.js
@@ -18,7 +18,5 @@ it("performance.now() should be monotonic", () => {
});
it("performance.timeOrigin + performance.now() should be similar to Date.now()", () => {
- expect(
- Math.abs(performance.timeOrigin + performance.now() - Date.now()) < 1000,
- ).toBe(true);
+ expect(Math.abs(performance.timeOrigin + performance.now() - Date.now()) < 1000).toBe(true);
});
diff --git a/test/bun.js/plugins.test.ts b/test/bun.js/plugins.test.ts
index 1d0b0821a..e533cef06 100644
--- a/test/bun.js/plugins.test.ts
+++ b/test/bun.js/plugins.test.ts
@@ -44,10 +44,7 @@ plugin({
path,
namespace: "fail",
}));
- builder.onLoad(
- { filter: /.*/, namespace: "fail" },
- () => globalThis.failingObject,
- );
+ builder.onLoad({ filter: /.*/, namespace: "fail" }, () => globalThis.failingObject);
},
});
@@ -95,20 +92,17 @@ plugin({
path,
}));
globalThis.asyncObject = {};
- builder.onLoad(
- { filter: /.*/, namespace: "async-obj" },
- async ({ path }) => {
- await Promise.resolve(1);
- return new Promise((resolve, reject) => {
- setTimeout(() => {
- resolve({
- exports: (globalThis.asyncObject ||= {}),
- loader: "object",
- });
- }, 1);
- });
- },
- );
+ builder.onLoad({ filter: /.*/, namespace: "async-obj" }, async ({ path }) => {
+ await Promise.resolve(1);
+ return new Promise((resolve, reject) => {
+ setTimeout(() => {
+ resolve({
+ exports: (globalThis.asyncObject ||= {}),
+ loader: "object",
+ });
+ }, 1);
+ });
+ });
builder.onResolve({ filter: /.*/, namespace: "asyncfail" }, ({ path }) => ({
namespace: "asyncfail",
@@ -116,14 +110,11 @@ plugin({
}));
globalThis.asyncfail = false;
- builder.onLoad(
- { filter: /.*/, namespace: "asyncfail" },
- async ({ path }) => {
- await Promise.resolve(1);
- await 1;
- throw globalThis.asyncfail;
- },
- );
+ builder.onLoad({ filter: /.*/, namespace: "asyncfail" }, async ({ path }) => {
+ await Promise.resolve(1);
+ await 1;
+ throw globalThis.asyncfail;
+ });
builder.onResolve({ filter: /.*/, namespace: "asyncret" }, ({ path }) => ({
namespace: "asyncret",
@@ -131,14 +122,11 @@ plugin({
}));
globalThis.asyncret = 123;
- builder.onLoad(
- { filter: /.*/, namespace: "asyncret" },
- async ({ path }) => {
- await 100;
- await Promise.resolve(10);
- return await globalThis.asyncret;
- },
- );
+ builder.onLoad({ filter: /.*/, namespace: "asyncret" }, async ({ path }) => {
+ await 100;
+ await Promise.resolve(10);
+ return await globalThis.asyncret;
+ });
},
});
@@ -213,12 +201,7 @@ export default Hello;
describe("errors", () => {
it("valid loaders work", () => {
const validLoaders = ["js", "jsx", "ts", "tsx"];
- const inputs = [
- "export default 'hi';",
- "export default 'hi';",
- "export default 'hi';",
- "export default 'hi';",
- ];
+ const inputs = ["export default 'hi';", "export default 'hi';", "export default 'hi';", "export default 'hi';"];
for (let i = 0; i < validLoaders.length; i++) {
const loader = validLoaders[i];
const input = inputs[i];
@@ -229,12 +212,7 @@ describe("errors", () => {
it("invalid loaders throw", () => {
const invalidLoaders = ["blah", "blah2", "blah3", "blah4"];
- const inputs = [
- "body { background: red; }",
- "<h1>hi</h1>",
- '{"hi": "there"}',
- "hi",
- ];
+ const inputs = ["body { background: red; }", "<h1>hi</h1>", '{"hi": "there"}', "hi"];
for (let i = 0; i < invalidLoaders.length; i++) {
const loader = invalidLoaders[i];
const input = inputs[i];
diff --git a/test/bun.js/process-args.test.js b/test/bun.js/process-args.test.js
index 3b5749239..96017266b 100644
--- a/test/bun.js/process-args.test.js
+++ b/test/bun.js/process-args.test.js
@@ -27,10 +27,10 @@ test("args exclude run", async () => {
const t3 = JSON.parse(await new Response(s3).text());
expect(t3[0]).toBe(arg0);
expect(t3[1]).toBe(arg1);
- const { stdout: s4 } = spawn(
- [exe, "run", "print-process-args.js", "arg1", "arg2"],
- { cwd: import.meta.dir, env: { BUN_DEBUG_QUIET_LOGS: "1" } },
- );
+ const { stdout: s4 } = spawn([exe, "run", "print-process-args.js", "arg1", "arg2"], {
+ cwd: import.meta.dir,
+ env: { BUN_DEBUG_QUIET_LOGS: "1" },
+ });
const t4 = JSON.parse(await new Response(s4).text());
expect(t4[0]).toBe(arg0);
expect(t4[1]).toBe(arg1);
diff --git a/test/bun.js/process-nexttick.js b/test/bun.js/process-nexttick.js
index ea9d0581e..c6b24ba14 100644
--- a/test/bun.js/process-nexttick.js
+++ b/test/bun.js/process-nexttick.js
@@ -57,10 +57,7 @@ await new Promise((resolve, reject) => {
passed = exception instanceof TypeError;
}
- if (!passed)
- throw new Error(
- "queueMicrotask should throw a TypeError if the argument is not a function",
- );
+ if (!passed) throw new Error("queueMicrotask should throw a TypeError if the argument is not a function");
}
{
@@ -71,18 +68,14 @@ await new Promise((resolve, reject) => {
passed = exception instanceof TypeError;
}
- if (!passed)
- throw new Error(
- "queueMicrotask should throw a TypeError if the argument is empty",
- );
+ if (!passed) throw new Error("queueMicrotask should throw a TypeError if the argument is empty");
}
await new Promise((resolve, reject) => {
process.nextTick(
(first, second) => {
console.log(first, second);
- if (first !== 12345 || second !== "hello")
- reject(new Error("process.nextTick called with wrong arguments"));
+ if (first !== 12345 || second !== "hello") reject(new Error("process.nextTick called with wrong arguments"));
resolve(true);
},
12345,
diff --git a/test/bun.js/process-nexttick.test.js b/test/bun.js/process-nexttick.test.js
index a1b1b84b0..becf3c236 100644
--- a/test/bun.js/process-nexttick.test.js
+++ b/test/bun.js/process-nexttick.test.js
@@ -59,10 +59,7 @@ it("process.nextTick", async () => {
passed = exception instanceof TypeError;
}
- if (!passed)
- throw new Error(
- "queueMicrotask should throw a TypeError if the argument is not a function",
- );
+ if (!passed) throw new Error("queueMicrotask should throw a TypeError if the argument is not a function");
}
{
@@ -73,10 +70,7 @@ it("process.nextTick", async () => {
passed = exception instanceof TypeError;
}
- if (!passed)
- throw new Error(
- "queueMicrotask should throw a TypeError if the argument is empty",
- );
+ if (!passed) throw new Error("queueMicrotask should throw a TypeError if the argument is empty");
}
});
@@ -84,8 +78,7 @@ it("process.nextTick 2 args", async () => {
await new Promise((resolve, reject) => {
process.nextTick(
(first, second) => {
- if (first !== 12345 || second !== "hello")
- reject(new Error("process.nextTick called with wrong arguments"));
+ if (first !== 12345 || second !== "hello") reject(new Error("process.nextTick called with wrong arguments"));
resolve(true);
},
12345,
diff --git a/test/bun.js/process-stdin-echo.js b/test/bun.js/process-stdin-echo.js
index 63133d654..e265cc76d 100644
--- a/test/bun.js/process-stdin-echo.js
+++ b/test/bun.js/process-stdin-echo.js
@@ -1,9 +1,9 @@
process.stdin.setEncoding("utf8");
-process.stdin.on("data", (data) => {
+process.stdin.on("data", data => {
process.stdout.write(data);
});
process.stdin.once("end", () => {
- process.stdout.write("ENDED");
+ process.stdout.write("ENDED");
});
if (process.argv[2] == "resume") {
process.stdout.write("RESUMED");
diff --git a/test/bun.js/process-stdio.test.ts b/test/bun.js/process-stdio.test.ts
index df82f5791..6054eeeeb 100644
--- a/test/bun.js/process-stdio.test.ts
+++ b/test/bun.js/process-stdio.test.ts
@@ -6,8 +6,8 @@ import { isatty } from "tty";
test("process.stdin", () => {
expect(process.stdin).toBeDefined();
expect(process.stdout.isTTY).toBe(isatty(0));
- expect(process.stdin.on("close", function() {})).toBe(process.stdin);
- expect(process.stdin.once("end", function() {})).toBe(process.stdin);
+ expect(process.stdin.on("close", function () {})).toBe(process.stdin);
+ expect(process.stdin.once("end", function () {})).toBe(process.stdin);
});
test("process.stdin - read", async () => {
@@ -23,12 +23,7 @@ test("process.stdin - read", async () => {
});
expect(stdin).toBeDefined();
expect(stdout).toBeDefined();
- var lines = [
- "Get Emoji",
- "— All Emojis to ✂️ Copy and 📋 Paste",
- "👌",
- "",
- ];
+ var lines = ["Get Emoji", "— All Emojis to ✂️ Copy and 📋 Paste", "👌", ""];
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
setTimeout(() => {
@@ -57,12 +52,7 @@ test("process.stdin - resume", async () => {
});
expect(stdin).toBeDefined();
expect(stdout).toBeDefined();
- var lines = [
- "Get Emoji",
- "— All Emojis to ✂️ Copy and 📋 Paste",
- "👌",
- "",
- ];
+ var lines = ["Get Emoji", "— All Emojis to ✂️ Copy and 📋 Paste", "👌", ""];
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
setTimeout(() => {
@@ -100,9 +90,7 @@ test("process.stdout - write", () => {
},
});
- expect(stdout?.toString()).toBe(
- `hello worldhello again|😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌`,
- );
+ expect(stdout?.toString()).toBe(`hello worldhello again|😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌`);
});
test("process.stdout - write a lot (string)", () => {
@@ -119,9 +107,7 @@ test("process.stdout - write a lot (string)", () => {
});
expect(stdout?.toString()).toBe(
- `hello worldhello again|😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌`.repeat(
- 9999,
- ),
+ `hello worldhello again|😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌`.repeat(9999),
);
});
@@ -137,8 +123,6 @@ test("process.stdout - write a lot (bytes)", () => {
},
});
expect(stdout?.toString()).toBe(
- `hello worldhello again|😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌`.repeat(
- 9999,
- ),
+ `hello worldhello again|😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌`.repeat(9999),
);
});
diff --git a/test/bun.js/process.test.js b/test/bun.js/process.test.js
index 57b07ef53..e5517e7f6 100644
--- a/test/bun.js/process.test.js
+++ b/test/bun.js/process.test.js
@@ -7,17 +7,13 @@ it("process", () => {
// this property isn't implemented yet but it should at least return a string
const isNode = !process.isBun;
- if (!isNode && process.title !== "bun")
- throw new Error("process.title is not 'bun'");
+ if (!isNode && process.title !== "bun") throw new Error("process.title is not 'bun'");
- if (typeof process.env.USER !== "string")
- throw new Error("process.env is not an object");
+ if (typeof process.env.USER !== "string") throw new Error("process.env is not an object");
- if (process.env.USER.length === 0)
- throw new Error("process.env is missing a USER property");
+ if (process.env.USER.length === 0) throw new Error("process.env is missing a USER property");
- if (process.platform !== "darwin" && process.platform !== "linux")
- throw new Error("process.platform is invalid");
+ if (process.platform !== "darwin" && process.platform !== "linux") throw new Error("process.platform is invalid");
if (isNode) throw new Error("process.isBun is invalid");
@@ -41,9 +37,7 @@ it("process", () => {
}
if (typeof JSON.parse(JSON.stringify(process.env)).toJSON !== "undefined") {
- throw new Error(
- "process.env should call toJSON to hide its internal state",
- );
+ throw new Error("process.env should call toJSON to hide its internal state");
}
var { env, ...proces } = process;
@@ -71,9 +65,9 @@ it("process.hrtime.bigint()", () => {
it("process.release", () => {
expect(process.release.name).toBe("bun");
expect(process.release.sourceUrl).toBe(
- `https://github.com/oven-sh/bun/release/bun-v${process.versions.bun}/bun-${
- process.platform
- }-${{ arm64: "aarch64", x64: "x64" }[process.arch] || process.arch}.zip`,
+ `https://github.com/oven-sh/bun/release/bun-v${process.versions.bun}/bun-${process.platform}-${
+ { arm64: "aarch64", x64: "x64" }[process.arch] || process.arch
+ }.zip`,
);
});
@@ -95,7 +89,7 @@ it("process.env is spreadable and editable", () => {
expect(lol).toBe("😂");
delete process.env["LOL SMILE UTF16 😂"];
expect(rest).toEqual(process.env);
- const orig = ((getter) => process.env[getter])("USER");
+ const orig = (getter => process.env[getter])("USER");
expect(process.env).toEqual(process.env);
eval(`globalThis.process.env.USER = 'bun';`);
expect(eval(`globalThis.process.env.USER`)).toBe("bun");
@@ -117,9 +111,7 @@ it("process.execPath", () => {
it("process.uptime()", () => {
expect(process.uptime()).toBeGreaterThan(0);
- expect(Math.floor(process.uptime())).toBe(
- Math.floor(performance.now() / 1000),
- );
+ expect(Math.floor(process.uptime())).toBe(Math.floor(performance.now() / 1000));
});
it("process.umask()", () => {
@@ -143,18 +135,10 @@ it("process.versions", () => {
// pub const c_ares = "0e7a5dee0fbb04080750cf6eabbe89d8bae87faa";
// pub const usockets = "fafc241e8664243fc0c51d69684d5d02b9805134";
const versions = Object.fromEntries(
- readFileSync(
- import.meta.dir + "/../../src/generated_versions_list.zig",
- "utf8",
- )
+ readFileSync(import.meta.dir + "/../../src/generated_versions_list.zig", "utf8")
.split("\n")
- .filter(
- (line) =>
- line.startsWith("pub const") &&
- !line.includes("zig") &&
- line.includes(' = "'),
- )
- .map((line) => line.split(" = "))
+ .filter(line => line.startsWith("pub const") && !line.includes("zig") && line.includes(' = "'))
+ .map(line => line.split(" = "))
.map(([name, hash]) => [name.slice(9).trim(), hash.slice(1, -2)]),
);
versions.uwebsockets = versions.uws;
@@ -180,7 +164,7 @@ it("process.config", () => {
it("process.emitWarning", () => {
process.emitWarning("-- Testing process.emitWarning --");
var called = 0;
- process.on("warning", (err) => {
+ process.on("warning", err => {
called++;
expect(err.message).toBe("-- Testing process.on('warning') --");
});
diff --git a/test/bun.js/proxy.test.js b/test/bun.js/proxy.test.js
index 5f4be2338..c903efab3 100644
--- a/test/bun.js/proxy.test.js
+++ b/test/bun.js/proxy.test.js
@@ -45,11 +45,7 @@ afterAll(() => {
describe("proxy", () => {
const requests = [
- [
- new Request("http://localhost:54322"),
- "fetch() GET with non-TLS Proxy",
- "http://localhost:54312",
- ],
+ [new Request("http://localhost:54322"), "fetch() GET with non-TLS Proxy", "http://localhost:54312"],
[
new Request("http://localhost:54322", {
method: "POST",
diff --git a/test/bun.js/react-dom-server.bun.cjs b/test/bun.js/react-dom-server.bun.cjs
index 6367ee8aa..f67e54a8c 100644
--- a/test/bun.js/react-dom-server.bun.cjs
+++ b/test/bun.js/react-dom-server.bun.cjs
@@ -42,7 +42,7 @@ function t(a, b, c, d, e, f, g) {
var v = {},
ja =
"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(
- " "
+ " ",
);
ja.push("innerText", "textContent");
ja.forEach(function (a) {
@@ -60,12 +60,7 @@ ja.forEach(function (a) {
["contentEditable", "draggable", "spellCheck", "value"].forEach(function (a) {
v[a] = new t(a, 2, !1, a.toLowerCase(), null, !1, !1);
});
-[
- "autoReverse",
- "externalResourcesRequired",
- "focusable",
- "preserveAlpha",
-].forEach(function (a) {
+["autoReverse", "externalResourcesRequired", "focusable", "preserveAlpha"].forEach(function (a) {
v[a] = new t(a, 2, !1, a, null, !1, !1);
});
"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope"
@@ -95,12 +90,10 @@ function la(a) {
var b = a.replace(ka, la);
v[b] = new t(b, 1, !1, a, null, !1, !1);
});
-"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type"
- .split(" ")
- .forEach(function (a) {
- var b = a.replace(ka, la);
- v[b] = new t(b, 1, !1, a, "http://www.w3.org/1999/xlink", !1, !1);
- });
+"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function (a) {
+ var b = a.replace(ka, la);
+ v[b] = new t(b, 1, !1, a, "http://www.w3.org/1999/xlink", !1, !1);
+});
["xml:base", "xml:lang", "xml:space"].forEach(function (a) {
var b = a.replace(ka, la);
v[b] = new t(b, 1, !1, a, "http://www.w3.org/XML/1998/namespace", !1, !1);
@@ -108,15 +101,7 @@ function la(a) {
["tabIndex", "crossOrigin"].forEach(function (a) {
v[a] = new t(a, 1, !1, a.toLowerCase(), null, !1, !1);
});
-v.xlinkHref = new t(
- "xlinkHref",
- 1,
- !1,
- "xlink:href",
- "http://www.w3.org/1999/xlink",
- !0,
- !1
-);
+v.xlinkHref = new t("xlinkHref", 1, !1, "xlink:href", "http://www.w3.org/1999/xlink", !0, !1);
["src", "href", "action", "formAction"].forEach(function (a) {
v[a] = new t(a, 1, !1, a.toLowerCase(), null, !0, !0);
});
@@ -312,9 +297,7 @@ function wa(a, b, c, d) {
null == d.crossOrigin && (d.crossOrigin = a.crossOrigin),
null == d.referrerPolicy && (d.referrerPolicy = a.referrerPolicy),
null == d.title && (d.title = a.title))
- : ((f = ya(b, d)),
- (f = z(a, b, "style", f)),
- a.explicitStylePreloads.add(f));
+ : ((f = ya(b, d)), (f = z(a, b, "style", f)), a.explicitStylePreloads.add(f));
c = {
type: "style",
href: b,
@@ -336,18 +319,13 @@ function xa(a, b, c) {
null == c.crossOrigin && (c.crossOrigin = a.crossOrigin),
null == c.referrerPolicy && (c.referrerPolicy = a.referrerPolicy),
null == c.integrity && (c.integrity = a.integrity))
- : ((e = za(b, c)),
- (e = z(a, b, "script", e)),
- a.explicitScriptPreloads.add(e));
+ : ((e = za(b, c)), (e = z(a, b, "script", e)), a.explicitScriptPreloads.add(e));
c = { type: "script", src: b, flushed: !1, props: c, hint: e };
d.set(b, c);
return c;
}
function Aa(a, b) {
- if (!y)
- throw Error(
- '"currentResources" was expected to exist. This is a bug in React.'
- );
+ if (!y) throw Error('"currentResources" was expected to exist. This is a bug in React.');
var c = y;
switch (a) {
case "title":
@@ -367,11 +345,9 @@ function Aa(a, b) {
case "meta":
if ("string" === typeof b.charSet) e = "charSet";
else if ("string" === typeof b.content)
- if (((a = "::" + b.content), "string" === typeof b.httpEquiv))
- e = "httpEquiv::" + b.httpEquiv + a;
+ if (((a = "::" + b.content), "string" === typeof b.httpEquiv)) e = "httpEquiv::" + b.httpEquiv + a;
else if ("string" === typeof b.name) e = "name::" + b.name + a;
- else if ("string" === typeof b.itemProp)
- e = "itemProp::" + b.itemProp + a;
+ else if ("string" === typeof b.itemProp) e = "itemProp::" + b.itemProp + a;
else if ("string" === typeof b.property) {
var f = b.property;
e = "property::" + f + a;
@@ -383,9 +359,7 @@ function Aa(a, b) {
!c.headsMap.has(e) &&
((b = { type: "meta", key: e, props: x({}, b), flushed: !1 }),
c.headsMap.set(e, b),
- "charSet" === e
- ? (c.charset = b)
- : (d && c.structuredMetaKeys.set(d, b), c.headResources.add(b)));
+ "charSet" === e ? (c.charset = b) : (d && c.structuredMetaKeys.set(d, b), c.headResources.add(b)));
return !0;
case "base":
return (
@@ -396,19 +370,14 @@ function Aa(a, b) {
("string" === typeof d ? '[href="' + d + '"]' : ":not([href])") +
("string" === typeof e ? '[target="' + e + '"]' : ":not([target])")),
c.headsMap.has(e) ||
- ((b = { type: "base", props: x({}, b), flushed: !1 }),
- c.headsMap.set(e, b),
- c.bases.add(b)),
+ ((b = { type: "base", props: x({}, b), flushed: !1 }), c.headsMap.set(e, b), c.bases.add(b)),
!0
);
}
return !1;
}
function Ba(a) {
- if (!y)
- throw Error(
- '"currentResources" was expected to exist. This is a bug in React.'
- );
+ if (!y) throw Error('"currentResources" was expected to exist. This is a bug in React.');
var b = y,
c = a.rel,
d = a.href;
@@ -420,11 +389,7 @@ function Ba(a) {
c = a.precedence;
var g = a.disabled;
if ("string" !== typeof c || e || f || null != g)
- return (
- (c = b.preloadsMap.get(d)),
- c || ((c = z(b, d, "style", ya(d, a))), b.usedStylePreloads.add(c)),
- !1
- );
+ return (c = b.preloadsMap.get(d)), c || ((c = z(b, d, "style", ya(d, a))), b.usedStylePreloads.add(c)), !1;
e = b.stylesMap.get(d);
e ||
((a = x({}, a)),
@@ -476,11 +441,7 @@ function Ba(a) {
("string" === typeof a.media ? a.media : "");
e = b.headsMap.get(d);
if (!e)
- switch (
- ((e = { type: "link", props: x({}, a), flushed: !1 }),
- b.headsMap.set(d, e),
- c)
- ) {
+ switch (((e = { type: "link", props: x({}, a), flushed: !1 }), b.headsMap.set(d, e), c)) {
case "preconnect":
case "dns-prefetch":
b.preconnects.add(e);
@@ -526,10 +487,7 @@ function Ha(a, b, c, d, e) {
for (d = 0; d < e.length; d++)
(c = e[d]),
(g = "string" === typeof c ? void 0 : c.integrity),
- f.push(
- '<script type="module" src="',
- w("string" === typeof c ? c : c.src)
- ),
+ f.push('<script type="module" src="', w("string" === typeof c ? c : c.src)),
g && f.push('" integrity="', w(g)),
f.push('" async="">\x3c/script>');
return {
@@ -550,26 +508,14 @@ function A(a, b, c) {
return { insertionMode: a, selectedValue: b, noscriptTagInScope: c };
}
function Ia(a) {
- return A(
- "http://www.w3.org/2000/svg" === a
- ? 2
- : "http://www.w3.org/1998/Math/MathML" === a
- ? 3
- : 0,
- null,
- !1
- );
+ return A("http://www.w3.org/2000/svg" === a ? 2 : "http://www.w3.org/1998/Math/MathML" === a ? 3 : 0, null, !1);
}
function Ja(a, b, c) {
switch (b) {
case "noscript":
return A(1, null, !0);
case "select":
- return A(
- 1,
- null != c.value ? c.value : c.defaultValue,
- a.noscriptTagInScope
- );
+ return A(1, null != c.value ? c.value : c.defaultValue, a.noscriptTagInScope);
case "svg":
return A(2, null, a.noscriptTagInScope);
case "math":
@@ -587,9 +533,7 @@ function Ja(a, b, c) {
case "tr":
return A(6, null, a.noscriptTagInScope);
}
- return 4 <= a.insertionMode || 0 === a.insertionMode
- ? A(1, null, a.noscriptTagInScope)
- : a;
+ return 4 <= a.insertionMode || 0 === a.insertionMode ? A(1, null, a.noscriptTagInScope) : a;
}
function Ka(a, b, c, d) {
if ("" === b) return d;
@@ -601,7 +545,7 @@ var La = new Map();
function Ma(a, b, c) {
if ("object" !== typeof c)
throw Error(
- "The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + 'em'}} when using JSX."
+ "The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + 'em'}} when using JSX.",
);
b = !0;
for (var d in c)
@@ -616,15 +560,8 @@ function Ma(a, b, c) {
var g = La.get(f);
void 0 !== g
? (f = g)
- : ((g = w(f.replace(pa, "-$1").toLowerCase().replace(qa, "-ms-"))),
- La.set(f, g),
- (f = g));
- e =
- "number" === typeof e
- ? 0 === e || r.call(ma, d)
- ? "" + e
- : e + "px"
- : w(("" + e).trim());
+ : ((g = w(f.replace(pa, "-$1").toLowerCase().replace(qa, "-ms-"))), La.set(f, g), (f = g));
+ e = "number" === typeof e ? (0 === e || r.call(ma, d) ? "" + e : e + "px") : w(("" + e).trim());
}
b ? ((b = !1), a.push(' style="', f, ":", e)) : a.push(";", f, ":", e);
}
@@ -643,11 +580,7 @@ function C(a, b, c, d) {
case "suppressHydrationWarning":
return;
}
- if (
- !(2 < c.length) ||
- ("o" !== c[0] && "O" !== c[0]) ||
- ("n" !== c[1] && "N" !== c[1])
- )
+ if (!(2 < c.length) || ("o" !== c[0] && "O" !== c[0]) || ("n" !== c[1] && "N" !== c[1]))
if (((b = v.hasOwnProperty(c) ? v[c] : null), null !== b)) {
switch (typeof d) {
case "function":
@@ -662,9 +595,7 @@ function C(a, b, c, d) {
d && a.push(" ", c, '=""');
break;
case 4:
- !0 === d
- ? a.push(" ", c, '=""')
- : !1 !== d && a.push(" ", c, '="', w(d), '"');
+ !0 === d ? a.push(" ", c, '=""') : !1 !== d && a.push(" ", c, '="', w(d), '"');
break;
case 5:
isNaN(d) || a.push(" ", c, '="', w(d), '"');
@@ -681,23 +612,17 @@ function C(a, b, c, d) {
case "symbol":
return;
case "boolean":
- if (
- ((b = c.toLowerCase().slice(0, 5)), "data-" !== b && "aria-" !== b)
- )
- return;
+ if (((b = c.toLowerCase().slice(0, 5)), "data-" !== b && "aria-" !== b)) return;
}
a.push(" ", c, '="', w(d), '"');
}
}
function D(a, b, c) {
if (null != b) {
- if (null != c)
- throw Error(
- "Can only set one of `children` or `props.dangerouslySetInnerHTML`."
- );
+ if (null != c) throw Error("Can only set one of `children` or `props.dangerouslySetInnerHTML`.");
if ("object" !== typeof b || !("__html" in b))
throw Error(
- "`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://reactjs.org/link/dangerously-set-inner-html for more information."
+ "`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://reactjs.org/link/dangerously-set-inner-html for more information.",
);
b = b.__html;
null !== b && void 0 !== b && a.push("" + b);
@@ -721,7 +646,7 @@ function F(a, b, c) {
case "children":
case "dangerouslySetInnerHTML":
throw Error(
- "link is a self-closing tag and must neither have `children` nor use `dangerouslySetInnerHTML`."
+ "link is a self-closing tag and must neither have `children` nor use `dangerouslySetInnerHTML`.",
);
case "precedence":
if (d) continue;
@@ -742,8 +667,7 @@ function I(a, b, c, d) {
case "children":
case "dangerouslySetInnerHTML":
throw Error(
- c +
- " is a self-closing tag and must neither have `children` nor use `dangerouslySetInnerHTML`."
+ c + " is a self-closing tag and must neither have `children` nor use `dangerouslySetInnerHTML`.",
);
default:
C(a, d, e, f);
@@ -765,9 +689,7 @@ function Oa(a, b, c) {
d = f;
break;
case "dangerouslySetInnerHTML":
- throw Error(
- "`dangerouslySetInnerHTML` does not make sense on <title>."
- );
+ throw Error("`dangerouslySetInnerHTML` does not make sense on <title>.");
default:
C(a, c, e, f);
}
@@ -919,21 +841,15 @@ function Sa(a, b, c, d, e, f, g) {
h = m;
break;
case "dangerouslySetInnerHTML":
- throw Error(
- "`dangerouslySetInnerHTML` does not make sense on <textarea>."
- );
+ throw Error("`dangerouslySetInnerHTML` does not make sense on <textarea>.");
default:
C(a, e, n, m);
}
null === g && null !== h && (g = h);
a.push(">");
if (null != k) {
- if (null != g)
- throw Error(
- "If you supply `defaultValue` on a <textarea>, do not pass children."
- );
- if (ra(k) && 1 < k.length)
- throw Error("<textarea> can only have at most one child.");
+ if (null != g) throw Error("If you supply `defaultValue` on a <textarea>, do not pass children.");
+ if (ra(k) && 1 < k.length) throw Error("<textarea> can only have at most one child.");
g = "" + k;
}
"string" === typeof g && "\n" === g[0] && a.push("\n");
@@ -948,7 +864,7 @@ function Sa(a, b, c, d, e, f, g) {
case "children":
case "dangerouslySetInnerHTML":
throw Error(
- "input is a self-closing tag and must neither have `children` nor use `dangerouslySetInnerHTML`."
+ "input is a self-closing tag and must neither have `children` nor use `dangerouslySetInnerHTML`.",
);
case "defaultChecked":
m = p;
@@ -976,35 +892,19 @@ function Sa(a, b, c, d, e, f, g) {
switch (u) {
case "children":
case "dangerouslySetInnerHTML":
- throw Error(
- "menuitems cannot have `children` nor `dangerouslySetInnerHTML`."
- );
+ throw Error("menuitems cannot have `children` nor `dangerouslySetInnerHTML`.");
default:
C(a, e, u, g);
}
a.push(">");
return null;
case "title":
- return (
- (a =
- 2 !== f.insertionMode && !f.noscriptTagInScope && Aa("title", d)
- ? null
- : Oa(a, d, e)),
- a
- );
+ return (a = 2 !== f.insertionMode && !f.noscriptTagInScope && Aa("title", d) ? null : Oa(a, d, e)), a;
case "link":
- return (
- !f.noscriptTagInScope && Ba(d)
- ? (g && a.push("\x3c!-- --\x3e"), (a = null))
- : (a = F(a, d, e)),
- a
- );
+ return !f.noscriptTagInScope && Ba(d) ? (g && a.push("\x3c!-- --\x3e"), (a = null)) : (a = F(a, d, e)), a;
case "script":
if ((h = !f.noscriptTagInScope)) {
- if (!y)
- throw Error(
- '"currentResources" was expected to exist. This is a bug in React.'
- );
+ if (!y) throw Error('"currentResources" was expected to exist. This is a bug in React.');
h = y;
k = d.src;
n = d.onLoad;
@@ -1012,16 +912,8 @@ function Sa(a, b, c, d, e, f, g) {
k && "string" === typeof k
? d.async
? (n || m
- ? ((n = h.preloadsMap.get(k)),
- n ||
- ((n = z(h, k, "script", za(k, d))),
- h.usedScriptPreloads.add(n)))
- : ((n = h.scriptsMap.get(k)),
- n ||
- ((n = x({}, d)),
- (n.src = k),
- (n = xa(h, k, n)),
- h.scripts.add(n))),
+ ? ((n = h.preloadsMap.get(k)), n || ((n = z(h, k, "script", za(k, d))), h.usedScriptPreloads.add(n)))
+ : ((n = h.scriptsMap.get(k)), n || ((n = x({}, d)), (n.src = k), (n = xa(h, k, n)), h.scripts.add(n))),
(h = !0))
: (h = !1)
: (h = !1);
@@ -1030,16 +922,12 @@ function Sa(a, b, c, d, e, f, g) {
return a;
case "meta":
return (
- !f.noscriptTagInScope && Aa("meta", d)
- ? (g && a.push("\x3c!-- --\x3e"), (a = null))
- : (a = I(a, d, "meta", e)),
+ !f.noscriptTagInScope && Aa("meta", d) ? (g && a.push("\x3c!-- --\x3e"), (a = null)) : (a = I(a, d, "meta", e)),
a
);
case "base":
return (
- !f.noscriptTagInScope && Aa("base", d)
- ? (g && a.push("\x3c!-- --\x3e"), (a = null))
- : (a = I(a, d, "base", e)),
+ !f.noscriptTagInScope && Aa("base", d) ? (g && a.push("\x3c!-- --\x3e"), (a = null)) : (a = I(a, d, "base", e)),
a
);
case "listing":
@@ -1060,20 +948,15 @@ function Sa(a, b, c, d, e, f, g) {
}
a.push(">");
if (null != h) {
- if (null != g)
- throw Error(
- "Can only set one of `children` or `props.dangerouslySetInnerHTML`."
- );
+ if (null != g) throw Error("Can only set one of `children` or `props.dangerouslySetInnerHTML`.");
if ("object" !== typeof h || !("__html" in h))
throw Error(
- "`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://reactjs.org/link/dangerously-set-inner-html for more information."
+ "`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://reactjs.org/link/dangerously-set-inner-html for more information.",
);
d = h.__html;
null !== d &&
void 0 !== d &&
- ("string" === typeof d && 0 < d.length && "\n" === d[0]
- ? a.push("\n", d)
- : a.push("" + d));
+ ("string" === typeof d && 0 < d.length && "\n" === d[0] ? a.push("\n", d) : a.push("" + d));
}
"string" === typeof g && "\n" === g[0] && a.push("\n");
return g;
@@ -1103,22 +986,12 @@ function Sa(a, b, c, d, e, f, g) {
case "html":
return 0 === f.insertionMode && b.push("<!DOCTYPE html>"), J(b, d, c, e);
default:
- if (-1 === c.indexOf("-") && "string" !== typeof d.is)
- return J(a, d, c, e);
+ if (-1 === c.indexOf("-") && "string" !== typeof d.is) return J(a, d, c, e);
a.push(G(c));
h = g = null;
for (q in d)
- if (
- r.call(d, q) &&
- ((k = d[q]),
- null != k &&
- "function" !== typeof k &&
- "object" !== typeof k &&
- !1 !== k)
- )
- switch (
- (!0 === k && (k = ""), "className" === q && (q = "class"), q)
- ) {
+ if (r.call(d, q) && ((k = d[q]), null != k && "function" !== typeof k && "object" !== typeof k && !1 !== k))
+ switch ((!0 === k && (k = ""), "className" === q && (q = "class"), q)) {
case "children":
g = k;
break;
@@ -1132,10 +1005,7 @@ function Sa(a, b, c, d, e, f, g) {
case "suppressHydrationWarning":
break;
default:
- ia(q) &&
- "function" !== typeof k &&
- "symbol" !== typeof k &&
- a.push(" ", q, '="', w(k), '"');
+ ia(q) && "function" !== typeof k && "symbol" !== typeof k && a.push(" ", q, '="', w(k), '"');
}
a.push(">");
D(a, h, g);
@@ -1173,10 +1043,7 @@ function Ta(a, b, c) {
}
function Ua(a, b, c) {
l(a, '\x3c!--$?--\x3e<template id="');
- if (null === c)
- throw Error(
- "An ID must have been assigned before we can complete the boundary."
- );
+ if (null === c) throw Error("An ID must have been assigned before we can complete the boundary.");
l(a, c);
return !!a.write('"></template>');
}
@@ -1184,12 +1051,7 @@ function Va(a, b, c, d) {
switch (c.insertionMode) {
case 0:
case 1:
- return (
- l(a, '<div hidden id="'),
- l(a, b.segmentPrefix),
- l(a, d.toString(16)),
- !!a.write('">')
- );
+ return l(a, '<div hidden id="'), l(a, b.segmentPrefix), l(a, d.toString(16)), !!a.write('">');
case 2:
return (
l(a, '<svg aria-hidden="true" style="display:none" id="'),
@@ -1205,33 +1067,13 @@ function Va(a, b, c, d) {
!!a.write('">')
);
case 4:
- return (
- l(a, '<table hidden id="'),
- l(a, b.segmentPrefix),
- l(a, d.toString(16)),
- !!a.write('">')
- );
+ return l(a, '<table hidden id="'), l(a, b.segmentPrefix), l(a, d.toString(16)), !!a.write('">');
case 5:
- return (
- l(a, '<table hidden><tbody id="'),
- l(a, b.segmentPrefix),
- l(a, d.toString(16)),
- !!a.write('">')
- );
+ return l(a, '<table hidden><tbody id="'), l(a, b.segmentPrefix), l(a, d.toString(16)), !!a.write('">');
case 6:
- return (
- l(a, '<table hidden><tr id="'),
- l(a, b.segmentPrefix),
- l(a, d.toString(16)),
- !!a.write('">')
- );
+ return l(a, '<table hidden><tr id="'), l(a, b.segmentPrefix), l(a, d.toString(16)), !!a.write('">');
case 7:
- return (
- l(a, '<table hidden><colgroup id="'),
- l(a, b.segmentPrefix),
- l(a, d.toString(16)),
- !!a.write('">')
- );
+ return l(a, '<table hidden><colgroup id="'), l(a, b.segmentPrefix), l(a, d.toString(16)), !!a.write('">');
default:
throw Error("Unknown insertion mode. This is a bug in React.");
}
@@ -1269,7 +1111,7 @@ function Ya(a) {
return "\\u2029";
default:
throw Error(
- "escapeJSStringsForInstructionScripts encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React"
+ "escapeJSStringsForInstructionScripts encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React",
);
}
});
@@ -1290,7 +1132,7 @@ function K(a) {
return "\\u2029";
default:
throw Error(
- "escapeJSObjectForInstructionScripts encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React"
+ "escapeJSObjectForInstructionScripts encountered a match it does not know how to replace. this means the match regex and the replacement characters are no longer in sync. This is a bug in React",
);
}
});
@@ -1457,7 +1299,7 @@ function bb(a, b) {
case "children":
case "dangerouslySetInnerHTML":
throw Error(
- "link is a self-closing tag and must neither have `children` nor use `dangerouslySetInnerHTML`."
+ "link is a self-closing tag and must neither have `children` nor use `dangerouslySetInnerHTML`.",
);
default:
a: {
@@ -1488,16 +1330,8 @@ function bb(a, b) {
default:
if (!ia(m)) break a;
}
- if (
- !(2 < m.length) ||
- ("o" !== m[0] && "O" !== m[0]) ||
- ("n" !== m[1] && "N" !== m[1])
- )
- (h = "" + h),
- l(d, ","),
- l(d, K(k)),
- l(d, ","),
- l(d, K(h));
+ if (!(2 < m.length) || ("o" !== m[0] && "O" !== m[0]) || ("n" !== m[1] && "N" !== m[1]))
+ (h = "" + h), l(d, ","), l(d, K(k)), l(d, ","), l(d, K(h));
}
}
}
@@ -1559,14 +1393,10 @@ function xb(a) {
case kb:
var b = a.render;
a = a.displayName;
- a ||
- ((a = b.displayName || b.name || ""),
- (a = "" !== a ? "ForwardRef(" + a + ")" : "ForwardRef"));
+ a || ((a = b.displayName || b.name || ""), (a = "" !== a ? "ForwardRef(" + a + ")" : "ForwardRef"));
return a;
case nb:
- return (
- (b = a.displayName || null), null !== b ? b : xb(a.type) || "Memo"
- );
+ return (b = a.displayName || null), null !== b ? b : xb(a.type) || "Memo";
case ob:
b = a._payload;
a = a._init;
@@ -1597,15 +1427,9 @@ function Bb(a, b) {
a = a.parent;
var c = b.parent;
if (null === a) {
- if (null !== c)
- throw Error(
- "The stacks must reach the root at the same time. This is a bug in React."
- );
+ if (null !== c) throw Error("The stacks must reach the root at the same time. This is a bug in React.");
} else {
- if (null === c)
- throw Error(
- "The stacks must reach the root at the same time. This is a bug in React."
- );
+ if (null === c) throw Error("The stacks must reach the root at the same time. This is a bug in React.");
Bb(a, c);
}
b.context._currentValue = b.value;
@@ -1625,32 +1449,20 @@ function Eb(a, b) {
a.context._currentValue = a.parentValue;
a = a.parent;
if (null === a)
- throw Error(
- "The depth must equal at least at zero before reaching the root. This is a bug in React."
- );
+ throw Error("The depth must equal at least at zero before reaching the root. This is a bug in React.");
a.depth === b.depth ? Bb(a, b) : Eb(a, b);
}
function Fb(a, b) {
var c = b.parent;
if (null === c)
- throw Error(
- "The depth must equal at least at zero before reaching the root. This is a bug in React."
- );
+ throw Error("The depth must equal at least at zero before reaching the root. This is a bug in React.");
a.depth === c.depth ? Bb(a, c) : Fb(a, c);
b.context._currentValue = b.value;
}
function Gb(a) {
var b = L;
b !== a &&
- (null === b
- ? Db(a)
- : null === a
- ? Cb(b)
- : b.depth === a.depth
- ? Bb(b, a)
- : b.depth > a.depth
- ? Eb(b, a)
- : Fb(b, a),
+ (null === b ? Db(a) : null === a ? Cb(b) : b.depth === a.depth ? Bb(b, a) : b.depth > a.depth ? Eb(b, a) : Fb(b, a),
(L = a));
}
var Hb = {
@@ -1678,32 +1490,20 @@ function Ib(a, b, c, d) {
var g = b.contextType;
a.context = "object" === typeof g && null !== g ? g._currentValue : d;
g = b.getDerivedStateFromProps;
- "function" === typeof g &&
- ((g = g(c, e)),
- (e = null === g || void 0 === g ? e : x({}, e, g)),
- (a.state = e));
+ "function" === typeof g && ((g = g(c, e)), (e = null === g || void 0 === g ? e : x({}, e, g)), (a.state = e));
if (
"function" !== typeof b.getDerivedStateFromProps &&
"function" !== typeof a.getSnapshotBeforeUpdate &&
- ("function" === typeof a.UNSAFE_componentWillMount ||
- "function" === typeof a.componentWillMount)
+ ("function" === typeof a.UNSAFE_componentWillMount || "function" === typeof a.componentWillMount)
)
if (
((b = a.state),
"function" === typeof a.componentWillMount && a.componentWillMount(),
- "function" === typeof a.UNSAFE_componentWillMount &&
- a.UNSAFE_componentWillMount(),
+ "function" === typeof a.UNSAFE_componentWillMount && a.UNSAFE_componentWillMount(),
b !== a.state && Hb.enqueueReplaceState(a, a.state, null),
null !== f.queue && 0 < f.queue.length)
)
- if (
- ((b = f.queue),
- (g = f.replace),
- (f.queue = null),
- (f.replace = !1),
- g && 1 === b.length)
- )
- a.state = b[0];
+ if (((b = f.queue), (g = f.replace), (f.queue = null), (f.replace = !1), g && 1 === b.length)) a.state = b[0];
else {
f = g ? b[0] : a.state;
e = !0;
@@ -1741,7 +1541,7 @@ function Mb(a) {
return 0 === a ? 32 : (31 - ((Nb(a) / Ob) | 0)) | 0;
}
var Pb = Error(
- "Suspense Exception: This is not a real error! It's an implementation detail of `use` to interrupt the current render. You must either rethrow it immediately, or move the `use` call outside of the `try/catch` block. Capturing without rethrowing will lead to unexpected behavior.\n\nTo handle async errors, wrap your component in an error boundary, or call the promise's `.catch` method and pass the result to `use`"
+ "Suspense Exception: This is not a real error! It's an implementation detail of `use` to interrupt the current render. You must either rethrow it immediately, or move the `use` call outside of the `try/catch` block. Capturing without rethrowing will lead to unexpected behavior.\n\nTo handle async errors, wrap your component in an error boundary, or call the promise's `.catch` method and pass the result to `use`",
);
function Qb() {}
function Rb(a, b, c) {
@@ -1771,7 +1571,7 @@ function Rb(a, b, c) {
c.status = "rejected";
c.reason = a;
}
- }
+ },
),
b.status)
) {
@@ -1786,10 +1586,7 @@ function Rb(a, b, c) {
}
var Sb = null;
function Tb() {
- if (null === Sb)
- throw Error(
- "Expected a suspended thenable. This is a bug in React. Please file an issue."
- );
+ if (null === Sb) throw Error("Expected a suspended thenable. This is a bug in React. Please file an issue.");
var a = Sb;
Sb = null;
return a;
@@ -1812,13 +1609,12 @@ var Vb = "function" === typeof Object.is ? Object.is : Ub,
function U() {
if (null === M)
throw Error(
- "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem."
+ "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.",
);
return M;
}
function $b() {
- if (0 < Zb)
- throw Error("Rendered more hooks than during the previous render");
+ if (0 < Zb) throw Error("Rendered more hooks than during the previous render");
return { memoizedState: null, queue: null, next: null };
}
function ac() {
@@ -1898,18 +1694,9 @@ function hc(a, b) {
return a;
}
function gc(a, b, c) {
- if (25 <= Zb)
- throw Error(
- "Too many re-renders. React limits the number of renders to prevent an infinite loop."
- );
+ if (25 <= Zb) throw Error("Too many re-renders. React limits the number of renders to prevent an infinite loop.");
if (a === M)
- if (
- ((Yb = !0),
- (a = { action: c, next: null }),
- null === T && (T = new Map()),
- (c = T.get(b)),
- void 0 === c)
- )
+ if (((Yb = !0), (a = { action: c, next: null }), null === T && (T = new Map()), (c = T.get(b)), void 0 === c))
T.set(b, a);
else {
for (b = c; null !== b.next; ) b = b.next;
@@ -1917,9 +1704,7 @@ function gc(a, b, c) {
}
}
function ic() {
- throw Error(
- "A function wrapped in useEvent can't be called during rendering."
- );
+ throw Error("A function wrapped in useEvent can't be called during rendering.");
}
function jc() {
throw Error("startTransition cannot be called during server rendering.");
@@ -1972,9 +1757,7 @@ var nc = {
a = (a & ~(1 << (32 - Lb(a) - 1))).toString(32) + b;
var c = mc;
if (null === c)
- throw Error(
- "Invalid hook call. Hooks can only be called inside of the body of a function component."
- );
+ throw Error("Invalid hook call. Hooks can only be called inside of the body of a function component.");
b = Q++;
a = ":" + c.idPrefix + "R" + a;
0 < b && (a += "H" + b.toString(32));
@@ -1987,7 +1770,7 @@ var nc = {
useSyncExternalStore: function (a, b, c) {
if (void 0 === c)
throw Error(
- "Missing getServerSnapshot, which is required for server-rendered content. Will revert to client rendering."
+ "Missing getServerSnapshot, which is required for server-rendered content. Will revert to client rendering.",
);
return c();
},
@@ -2123,7 +1906,7 @@ function X(a, b) {
throw Error(
'onError returned something with a type other than "string". onError should return a string and may return null or undefined but must not return anything else. It received something of type "' +
typeof a +
- '" instead'
+ '" instead',
);
return a;
}
@@ -2132,9 +1915,7 @@ function Y(a, b) {
c(b);
c = a.onFatalError;
c(b);
- null !== a.destination
- ? ((a.status = 2), da(a.destination, b))
- : ((a.status = 1), (a.fatalError = b));
+ null !== a.destination ? ((a.status = 2), da(a.destination, b)) : ((a.status = 1), (a.fatalError = b));
}
function wc(a, b, c, d) {
var e = c.render(),
@@ -2147,10 +1928,7 @@ function wc(a, b, c, d) {
for (var h in c)
if (!(h in f))
throw Error(
- (xb(d) || "Unknown") +
- '.getChildContext(): key "' +
- h +
- '" is not defined in childContextTypes.'
+ (xb(d) || "Unknown") + '.getChildContext(): key "' + h + '" is not defined in childContextTypes.',
);
d = x({}, g, c);
}
@@ -2173,10 +1951,7 @@ function yc(a, b, c, d, e, f) {
if (d.prototype && d.prototype.isReactComponent)
(c = Ab(d, b.legacyContext)),
(f = d.contextType),
- (f = new d(
- e,
- "object" === typeof f && null !== f ? f._currentValue : c
- )),
+ (f = new d(e, "object" === typeof f && null !== f ? f._currentValue : c)),
Ib(f, d, e, c),
wc(a, b, f, d);
else {
@@ -2188,12 +1963,7 @@ function yc(a, b, c, d, e, f) {
c = d(e, f);
c = bc(d, e, c, f);
var g = 0 !== Q;
- if (
- "object" === typeof c &&
- null !== c &&
- "function" === typeof c.render &&
- void 0 === c.$$typeof
- )
+ if ("object" === typeof c && null !== c && "function" === typeof c.render && void 0 === c.$$typeof)
Ib(c, d, e, f), wc(a, b, c, d);
else if (g) {
e = b.treeContext;
@@ -2207,15 +1977,7 @@ function yc(a, b, c, d, e, f) {
}
else if ("string" === typeof d)
(c = b.blockedSegment),
- (f = Sa(
- c.chunks,
- a.preamble,
- d,
- e,
- a.responseState,
- c.formatContext,
- c.lastPushedText
- )),
+ (f = Sa(c.chunks, a.preamble, d, e, a.responseState, c.formatContext, c.lastPushedText)),
(c.lastPushedText = !1),
(g = c.formatContext),
(c.formatContext = Ja(g, d, e)),
@@ -2270,9 +2032,7 @@ function yc(a, b, c, d, e, f) {
try {
if (
(zc(a, b, e),
- k.lastPushedText &&
- k.textEmbedded &&
- k.chunks.push("\x3c!-- --\x3e"),
+ k.lastPushedText && k.textEmbedded && k.chunks.push("\x3c!-- --\x3e"),
(k.status = 1),
0 === h.pendingTasks &&
(null !== a.completedRootSegment || 0 < a.pendingRootTasks) &&
@@ -2282,25 +2042,11 @@ function yc(a, b, c, d, e, f) {
)
break a;
} catch (p) {
- (k.status = 4),
- (h.forceClientRender = !0),
- (h.errorDigest = X(a, p));
+ (k.status = 4), (h.forceClientRender = !0), (h.errorDigest = X(a, p));
} finally {
- (a.resources.boundaryResources = d ? d.resources : null),
- (b.blockedBoundary = d),
- (b.blockedSegment = c);
+ (a.resources.boundaryResources = d ? d.resources : null), (b.blockedBoundary = d), (b.blockedSegment = c);
}
- b = uc(
- a,
- null,
- f,
- d,
- m,
- g,
- b.legacyContext,
- b.context,
- b.treeContext
- );
+ b = uc(a, null, f, d, m, g, b.legacyContext, b.context, b.treeContext);
a.pingedTasks.push(b);
}
return;
@@ -2347,10 +2093,7 @@ function yc(a, b, c, d, e, f) {
b.context = e;
Z(a, b, null, c);
a = L;
- if (null === a)
- throw Error(
- "Tried to pop a Context at the root of the app. This is a bug in React."
- );
+ if (null === a) throw Error("Tried to pop a Context at the root of the app. This is a bug in React.");
e = a.parentValue;
a.context._currentValue = e === ub ? a.context._defaultValue : e;
a = L = a.parent;
@@ -2370,7 +2113,7 @@ function yc(a, b, c, d, e, f) {
}
throw Error(
"Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " +
- ((null == d ? d : typeof d) + ".")
+ ((null == d ? d : typeof d) + "."),
);
}
}
@@ -2383,7 +2126,7 @@ function Z(a, b, c, d) {
return;
case db:
throw Error(
- "Portals are not currently supported by the server renderer. Render them conditionally so that they only appear on the client render."
+ "Portals are not currently supported by the server renderer. Render them conditionally so that they only appear on the client render.",
);
case ob:
c = d._init;
@@ -2397,8 +2140,7 @@ function Z(a, b, c, d) {
}
null === d || "object" !== typeof d
? (c = null)
- : ((c = (wb && d[wb]) || d["@@iterator"]),
- (c = "function" === typeof c ? c : null));
+ : ((c = (wb && d[wb]) || d["@@iterator"]), (c = "function" === typeof c ? c : null));
if (c && (c = c.call(d))) {
d = c.next();
if (!d.done) {
@@ -2412,28 +2154,15 @@ function Z(a, b, c, d) {
a = Object.prototype.toString.call(d);
throw Error(
"Objects are not valid as a React child (found: " +
- ("[object Object]" === a
- ? "object with keys {" + Object.keys(d).join(", ") + "}"
- : a) +
- "). If you meant to render a collection of children, use an array instead."
+ ("[object Object]" === a ? "object with keys {" + Object.keys(d).join(", ") + "}" : a) +
+ "). If you meant to render a collection of children, use an array instead.",
);
}
"string" === typeof d
- ? ((c = b.blockedSegment),
- (c.lastPushedText = Ka(
- b.blockedSegment.chunks,
- d,
- a.responseState,
- c.lastPushedText
- )))
+ ? ((c = b.blockedSegment), (c.lastPushedText = Ka(b.blockedSegment.chunks, d, a.responseState, c.lastPushedText)))
: "number" === typeof d &&
((c = b.blockedSegment),
- (c.lastPushedText = Ka(
- b.blockedSegment.chunks,
- "" + d,
- a.responseState,
- c.lastPushedText
- )));
+ (c.lastPushedText = Ka(b.blockedSegment.chunks, "" + d, a.responseState, c.lastPushedText)));
}
function Bc(a, b, c) {
for (var d = c.length, e = 0; e < d; e++) {
@@ -2453,40 +2182,19 @@ function zc(a, b, c) {
try {
return Z(a, b, null, c);
} catch (k) {
- if (
- (cc(),
- (c = k === Pb ? Tb() : k),
- "object" === typeof c && null !== c && "function" === typeof c.then)
- ) {
+ if ((cc(), (c = k === Pb ? Tb() : k), "object" === typeof c && null !== c && "function" === typeof c.then)) {
var g = dc(),
h = b.blockedSegment,
m = tc(a, h.chunks.length, null, h.formatContext, h.lastPushedText, !0);
h.children.push(m);
h.lastPushedText = !1;
- a = uc(
- a,
- g,
- b.node,
- b.blockedBoundary,
- m,
- b.abortSet,
- b.legacyContext,
- b.context,
- b.treeContext
- ).ping;
+ a = uc(a, g, b.node, b.blockedBoundary, m, b.abortSet, b.legacyContext, b.context, b.treeContext).ping;
c.then(a, a);
b.blockedSegment.formatContext = d;
b.legacyContext = e;
b.context = f;
Gb(f);
- } else
- throw (
- ((b.blockedSegment.formatContext = d),
- (b.legacyContext = e),
- (b.context = f),
- Gb(f),
- c)
- );
+ } else throw ((b.blockedSegment.formatContext = d), (b.legacyContext = e), (b.context = f), Gb(f), c);
}
}
function Cc(a) {
@@ -2499,8 +2207,7 @@ function Ec(a, b, c) {
var d = a.blockedBoundary;
a.blockedSegment.status = 3;
null === d
- ? (b.allPendingTasks--,
- 1 !== b.status && 2 !== b.status && (X(b, c), Y(b, c)))
+ ? (b.allPendingTasks--, 1 !== b.status && 2 !== b.status && (X(b, c), Y(b, c)))
: (d.pendingTasks--,
d.forceClientRender ||
((d.forceClientRender = !0),
@@ -2514,11 +2221,7 @@ function Ec(a, b, c) {
0 === b.allPendingTasks && ((a = b.onAllReady), a()));
}
function Ac(a, b) {
- if (
- 0 === b.chunks.length &&
- 1 === b.children.length &&
- null === b.children[0].boundary
- ) {
+ if (0 === b.chunks.length && 1 === b.children.length && null === b.children[0].boundary) {
var c = b.children[0];
c.id = b.id;
c.parentFlushed = !0;
@@ -2528,31 +2231,23 @@ function Ac(a, b) {
function Dc(a, b, c) {
if (null === b) {
if (c.parentFlushed) {
- if (null !== a.completedRootSegment)
- throw Error(
- "There can only be one root segment. This is a bug in React."
- );
+ if (null !== a.completedRootSegment) throw Error("There can only be one root segment. This is a bug in React.");
a.completedRootSegment = c;
}
a.pendingRootTasks--;
- 0 === a.pendingRootTasks &&
- ((a.onShellError = W), (b = a.onShellReady), b());
+ 0 === a.pendingRootTasks && ((a.onShellError = W), (b = a.onShellReady), b());
} else
b.pendingTasks--,
b.forceClientRender ||
(0 === b.pendingTasks
? (c.parentFlushed && 1 === c.status && Ac(b, c),
- (null !== a.completedRootSegment || 0 < a.pendingRootTasks) &&
- Da(a.resources, b.resources),
+ (null !== a.completedRootSegment || 0 < a.pendingRootTasks) && Da(a.resources, b.resources),
b.parentFlushed && a.completedBoundaries.push(b),
b.fallbackAbortableTasks.forEach(Cc, a),
b.fallbackAbortableTasks.clear())
: c.parentFlushed &&
1 === c.status &&
- (Ac(b, c),
- 1 === b.completedSegments.length &&
- b.parentFlushed &&
- a.partialBoundaries.push(b)));
+ (Ac(b, c), 1 === b.completedSegments.length && b.parentFlushed && a.partialBoundaries.push(b)));
a.allPendingTasks--;
0 === a.allPendingTasks && ((a = a.onAllReady), a());
}
@@ -2585,20 +2280,14 @@ function vc(a) {
var q = m.thenableState;
m.thenableState = null;
Z(k, m, q, m.node);
- n.lastPushedText &&
- n.textEmbedded &&
- n.chunks.push("\x3c!-- --\x3e");
+ n.lastPushedText && n.textEmbedded && n.chunks.push("\x3c!-- --\x3e");
m.abortSet.delete(m);
n.status = 1;
Dc(k, m.blockedBoundary, n);
} catch (aa) {
cc();
var u = aa === Pb ? Tb() : aa;
- if (
- "object" === typeof u &&
- null !== u &&
- "function" === typeof u.then
- ) {
+ if ("object" === typeof u && null !== u && "function" === typeof u.then) {
var H = m.ping;
u.then(H, H);
m.thenableState = dc();
@@ -2632,12 +2321,7 @@ function vc(a) {
} catch (aa) {
X(a, aa), Y(a, aa);
} finally {
- (mc = f),
- (pc.current = c),
- (qc.current = d),
- (y = sa.pop()),
- (Ea.current = e),
- c === nc && Gb(b);
+ (mc = f), (pc.current = c), (qc.current = d), (y = sa.pop()), (Ea.current = e), c === nc && Gb(b);
}
}
}
@@ -2669,7 +2353,7 @@ function Gc(a, b, c) {
return e;
default:
throw Error(
- "Aborted, errored or already flushed boundaries should not be flushed again. This is a bug in React."
+ "Aborted, errored or already flushed boundaries should not be flushed again. This is a bug in React.",
);
}
}
@@ -2694,18 +2378,13 @@ function Hc(a, b, c) {
Ua(b, a.responseState, d);
Gc(a, b, c);
} else if (d.byteSize > a.progressiveChunkSize)
- (d.rootSegmentID = a.nextSegmentId++),
- a.completedBoundaries.push(d),
- Ua(b, a.responseState, d.id),
- Gc(a, b, c);
+ (d.rootSegmentID = a.nextSegmentId++), a.completedBoundaries.push(d), Ua(b, a.responseState, d.id), Gc(a, b, c);
else {
Ca(a.resources, d.resources);
b.write("\x3c!--$--\x3e");
c = d.completedSegments;
if (1 !== c.length)
- throw Error(
- "A previously unvisited boundary must have exactly one root segment. This is a bug in React."
- );
+ throw Error("A previously unvisited boundary must have exactly one root segment. This is a bug in React.");
Hc(a, b, c[0]);
}
return !!b.write("\x3c!--/$--\x3e");
@@ -2743,25 +2422,22 @@ function Jc(a, b, c) {
: ((a.sentStyleInsertionFunction = !0),
l(
b,
- '$RM=new Map;\n$RR=function(p,q,v){function r(l){this.s=l}for(var t=$RC,u=$RM,m=new Map,n=document,g,e,f=n.querySelectorAll("link[data-precedence],style[data-precedence]"),d=0;e=f[d++];)m.set(e.dataset.precedence,g=e);e=0;f=[];for(var c,h,b,a;c=v[e++];){var k=0;h=c[k++];if(b=u.get(h))"l"!==b.s&&f.push(b);else{a=n.createElement("link");a.href=h;a.rel="stylesheet";for(a.dataset.precedence=d=c[k++];b=c[k++];)a.setAttribute(b,c[k++]);b=a._p=new Promise(function(l,w){a.onload=l;a.onerror=w});b.then(r.bind(b,\n"l"),r.bind(b,"e"));u.set(h,b);f.push(b);c=m.get(d)||g;c===g&&(g=a);m.set(d,a);c?c.parentNode.insertBefore(a,c.nextSibling):(d=n.head,d.insertBefore(a,d.firstChild))}}Promise.all(f).then(t.bind(null,p,q,""),t.bind(null,p,q,"Resource failed to load"))};;$RR("'
+ '$RM=new Map;\n$RR=function(p,q,v){function r(l){this.s=l}for(var t=$RC,u=$RM,m=new Map,n=document,g,e,f=n.querySelectorAll("link[data-precedence],style[data-precedence]"),d=0;e=f[d++];)m.set(e.dataset.precedence,g=e);e=0;f=[];for(var c,h,b,a;c=v[e++];){var k=0;h=c[k++];if(b=u.get(h))"l"!==b.s&&f.push(b);else{a=n.createElement("link");a.href=h;a.rel="stylesheet";for(a.dataset.precedence=d=c[k++];b=c[k++];)a.setAttribute(b,c[k++]);b=a._p=new Promise(function(l,w){a.onload=l;a.onerror=w});b.then(r.bind(b,\n"l"),r.bind(b,"e"));u.set(h,b);f.push(b);c=m.get(d)||g;c===g&&(g=a);m.set(d,a);c?c.parentNode.insertBefore(a,c.nextSibling):(d=n.head,d.insertBefore(a,d.firstChild))}}Promise.all(f).then(t.bind(null,p,q,""),t.bind(null,p,q,"Resource failed to load"))};;$RR("',
))
: ((a.sentCompleteBoundaryFunction = !0),
(a.sentStyleInsertionFunction = !0),
l(
b,
- '$RC=function(b,c,e){c=document.getElementById(c);c.parentNode.removeChild(c);var a=document.getElementById(b);if(a){b=a.previousSibling;if(e)b.data="$!",a.setAttribute("data-dgst",e);else{e=b.parentNode;a=b.nextSibling;var f=0;do{if(a&&8===a.nodeType){var d=a.data;if("/$"===d)if(0===f)break;else f--;else"$"!==d&&"$?"!==d&&"$!"!==d||f++}d=a.nextSibling;e.removeChild(a);a=d}while(a);for(;c.firstChild;)e.insertBefore(c.firstChild,a);b.data="$"}b._reactRetry&&b._reactRetry()}};;$RM=new Map;\n$RR=function(p,q,v){function r(l){this.s=l}for(var t=$RC,u=$RM,m=new Map,n=document,g,e,f=n.querySelectorAll("link[data-precedence],style[data-precedence]"),d=0;e=f[d++];)m.set(e.dataset.precedence,g=e);e=0;f=[];for(var c,h,b,a;c=v[e++];){var k=0;h=c[k++];if(b=u.get(h))"l"!==b.s&&f.push(b);else{a=n.createElement("link");a.href=h;a.rel="stylesheet";for(a.dataset.precedence=d=c[k++];b=c[k++];)a.setAttribute(b,c[k++]);b=a._p=new Promise(function(l,w){a.onload=l;a.onerror=w});b.then(r.bind(b,\n"l"),r.bind(b,"e"));u.set(h,b);f.push(b);c=m.get(d)||g;c===g&&(g=a);m.set(d,a);c?c.parentNode.insertBefore(a,c.nextSibling):(d=n.head,d.insertBefore(a,d.firstChild))}}Promise.all(f).then(t.bind(null,p,q,""),t.bind(null,p,q,"Resource failed to load"))};;$RR("'
+ '$RC=function(b,c,e){c=document.getElementById(c);c.parentNode.removeChild(c);var a=document.getElementById(b);if(a){b=a.previousSibling;if(e)b.data="$!",a.setAttribute("data-dgst",e);else{e=b.parentNode;a=b.nextSibling;var f=0;do{if(a&&8===a.nodeType){var d=a.data;if("/$"===d)if(0===f)break;else f--;else"$"!==d&&"$?"!==d&&"$!"!==d||f++}d=a.nextSibling;e.removeChild(a);a=d}while(a);for(;c.firstChild;)e.insertBefore(c.firstChild,a);b.data="$"}b._reactRetry&&b._reactRetry()}};;$RM=new Map;\n$RR=function(p,q,v){function r(l){this.s=l}for(var t=$RC,u=$RM,m=new Map,n=document,g,e,f=n.querySelectorAll("link[data-precedence],style[data-precedence]"),d=0;e=f[d++];)m.set(e.dataset.precedence,g=e);e=0;f=[];for(var c,h,b,a;c=v[e++];){var k=0;h=c[k++];if(b=u.get(h))"l"!==b.s&&f.push(b);else{a=n.createElement("link");a.href=h;a.rel="stylesheet";for(a.dataset.precedence=d=c[k++];b=c[k++];)a.setAttribute(b,c[k++]);b=a._p=new Promise(function(l,w){a.onload=l;a.onerror=w});b.then(r.bind(b,\n"l"),r.bind(b,"e"));u.set(h,b);f.push(b);c=m.get(d)||g;c===g&&(g=a);m.set(d,a);c?c.parentNode.insertBefore(a,c.nextSibling):(d=n.head,d.insertBefore(a,d.firstChild))}}Promise.all(f).then(t.bind(null,p,q,""),t.bind(null,p,q,"Resource failed to load"))};;$RR("',
))
: a.sentCompleteBoundaryFunction
? l(b, '$RC("')
: ((a.sentCompleteBoundaryFunction = !0),
l(
b,
- '$RC=function(b,c,e){c=document.getElementById(c);c.parentNode.removeChild(c);var a=document.getElementById(b);if(a){b=a.previousSibling;if(e)b.data="$!",a.setAttribute("data-dgst",e);else{e=b.parentNode;a=b.nextSibling;var f=0;do{if(a&&8===a.nodeType){var d=a.data;if("/$"===d)if(0===f)break;else f--;else"$"!==d&&"$?"!==d&&"$!"!==d||f++}d=a.nextSibling;e.removeChild(a);a=d}while(a);for(;c.firstChild;)e.insertBefore(c.firstChild,a);b.data="$"}b._reactRetry&&b._reactRetry()}};;$RC("'
+ '$RC=function(b,c,e){c=document.getElementById(c);c.parentNode.removeChild(c);var a=document.getElementById(b);if(a){b=a.previousSibling;if(e)b.data="$!",a.setAttribute("data-dgst",e);else{e=b.parentNode;a=b.nextSibling;var f=0;do{if(a&&8===a.nodeType){var d=a.data;if("/$"===d)if(0===f)break;else f--;else"$"!==d&&"$?"!==d&&"$!"!==d||f++}d=a.nextSibling;e.removeChild(a);a=d}while(a);for(;c.firstChild;)e.insertBefore(c.firstChild,a);b.data="$"}b._reactRetry&&b._reactRetry()}};;$RC("',
));
- if (null === d)
- throw Error(
- "An ID must have been assigned before we can complete the boundary."
- );
+ if (null === d) throw Error("An ID must have been assigned before we can complete the boundary.");
e = e.toString(16);
l(b, d);
l(b, '","');
@@ -2775,9 +2451,7 @@ function Kc(a, b, c, d) {
var e = d.id;
if (-1 === e) {
if (-1 === (d.id = c.rootSegmentID))
- throw Error(
- "A root segment ID must have been assigned by now. This is a bug in React."
- );
+ throw Error("A root segment ID must have been assigned by now. This is a bug in React.");
return Ic(a, b, d);
}
Ic(a, b, d);
@@ -2788,7 +2462,7 @@ function Kc(a, b, c, d) {
: ((a.sentCompleteSegmentFunction = !0),
l(
b,
- '$RS=function(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};;$RS("'
+ '$RS=function(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};;$RS("',
));
l(b, a.segmentPrefix);
e = e.toString(16);
@@ -2829,12 +2503,9 @@ function Fc(a, b) {
: ((m.sentClientRenderFunction = !0),
l(
f,
- '$RX=function(b,c,d,e){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),b._reactRetry&&b._reactRetry())};;$RX("'
+ '$RX=function(b,c,d,e){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),b._reactRetry&&b._reactRetry())};;$RX("',
));
- if (null === k)
- throw Error(
- "An ID must have been assigned before we can complete the boundary."
- );
+ if (null === k) throw Error("An ID must have been assigned before we can complete the boundary.");
l(f, k);
l(f, '"');
if (p || n || q) l(f, ","), l(f, Ya(p || ""));
@@ -2909,10 +2580,7 @@ function Lc(a, b) {
try {
var c = a.abortableTasks;
if (0 < c.size) {
- var d =
- void 0 === b
- ? Error("The render was aborted by the server without a reason.")
- : b;
+ var d = void 0 === b ? Error("The render was aborted by the server without a reason.") : b;
c.forEach(function (b) {
return Ec(b, a, d);
});
@@ -2925,7 +2593,7 @@ function Lc(a, b) {
}
exports.renderToNodeStream = function () {
throw Error(
- "ReactDOMServer.renderToNodeStream(): The Node Stream API is not available in Bun. Use ReactDOMServer.renderToReadableStream() instead."
+ "ReactDOMServer.renderToNodeStream(): The Node Stream API is not available in Bun. Use ReactDOMServer.renderToReadableStream() instead.",
);
};
exports.renderToReadableStream = function (a, b) {
@@ -2944,7 +2612,7 @@ exports.renderToReadableStream = function (a, b) {
b ? b.bootstrapScriptContent : void 0,
b ? b.bootstrapScripts : void 0,
b ? b.bootstrapModules : void 0,
- b ? b.unstable_externalRuntimeSrc : void 0
+ b ? b.unstable_externalRuntimeSrc : void 0,
),
Ia(b ? b.namespaceURI : void 0),
b ? b.progressiveChunkSize : void 0,
@@ -2969,7 +2637,7 @@ exports.renderToReadableStream = function (a, b) {
Lc(h);
},
},
- { highWaterMark: 2048 }
+ { highWaterMark: 2048 },
);
a.allReady = g;
c(a);
@@ -2978,7 +2646,7 @@ exports.renderToReadableStream = function (a, b) {
g.catch(function () {});
d(a);
},
- e
+ e,
);
if (b && b.signal) {
var m = b.signal;
@@ -2996,7 +2664,7 @@ exports.renderToReadableStream = function (a, b) {
};
exports.renderToStaticNodeStream = function () {
throw Error(
- "ReactDOMServer.renderToStaticNodeStream(): The Node Stream API is not available in Bun. Use ReactDOMServer.renderToReadableStream() instead."
+ "ReactDOMServer.renderToStaticNodeStream(): The Node Stream API is not available in Bun. Use ReactDOMServer.renderToReadableStream() instead.",
);
};
exports.version = "18.2.0";
diff --git a/test/bun.js/react-dom.test.tsx b/test/bun.js/react-dom.test.tsx
index 04074acb8..b484982e0 100644
--- a/test/bun.js/react-dom.test.tsx
+++ b/test/bun.js/react-dom.test.tsx
@@ -103,10 +103,7 @@ describe("React", () => {
});
describe("ReactDOM", () => {
- for (let renderToReadableStream of [
- renderToReadableStreamBun,
- renderToReadableStreamBrowser,
- ]) {
+ for (let renderToReadableStream of [renderToReadableStreamBun, renderToReadableStreamBrowser]) {
for (let [inputString, reactElement] of fixtures) {
describe(`${renderToReadableStream.name}(${inputString})`, () => {
it("Response.text()", async () => {
@@ -208,9 +205,7 @@ describe("ReactDOM", () => {
for await (let chunk of stream) {
chunks.push(chunk);
}
- const text = new TextDecoder().decode(
- await new Response(chunks as any).arrayBuffer(),
- );
+ const text = new TextDecoder().decode(await new Response(chunks as any).arrayBuffer());
gc();
expect(text.replaceAll("<!-- -->", "")).toBe(inputString);
gc();
@@ -218,10 +213,7 @@ describe("ReactDOM", () => {
});
}
}
- for (let renderToReadableStream of [
- renderToReadableStreamBun,
- renderToReadableStreamBrowser,
- ]) {
+ for (let renderToReadableStream of [renderToReadableStreamBun, renderToReadableStreamBrowser]) {
// there is an event loop bug that causes deadlocks
// the bug is with `fetch`, not with the HTTP server
for (let [inputString, reactElement] of fixtures) {
@@ -233,15 +225,11 @@ describe("ReactDOM", () => {
server = serve({
port: port++,
async fetch(req) {
- return new Response(
- await renderToReadableStream(reactElement),
- );
+ return new Response(await renderToReadableStream(reactElement));
},
});
const resp = await fetch("http://localhost:" + server.port + "/");
- expect((await resp.text()).replaceAll("<!-- -->", "")).toBe(
- inputString,
- );
+ expect((await resp.text()).replaceAll("<!-- -->", "")).toBe(inputString);
gc();
} catch (e) {
throw e;
@@ -251,10 +239,7 @@ describe("ReactDOM", () => {
}
})();
gc();
- expect(
- heapStats().objectTypeCounts.ReadableHTTPResponseSinkController ??
- 0,
- ).toBe(1);
+ expect(heapStats().objectTypeCounts.ReadableHTTPResponseSinkController ?? 0).toBe(1);
});
const count = 4;
it(`http server, ${count} requests`, async () => {
@@ -265,17 +250,13 @@ describe("ReactDOM", () => {
server = serve({
port: port++,
async fetch(req) {
- return new Response(
- await renderToReadableStream(reactElement),
- );
+ return new Response(await renderToReadableStream(reactElement));
},
});
gc();
while (remain--) {
var attempt = remain + 1;
- const response = await fetch(
- "http://localhost:" + server.port + "/",
- );
+ const response = await fetch("http://localhost:" + server.port + "/");
gc();
const result = await response.text();
try {
@@ -294,8 +275,7 @@ describe("ReactDOM", () => {
}
})();
- const { ReadableHTTPResponseSinkController = 0 } =
- heapStats().objectTypeCounts;
+ const { ReadableHTTPResponseSinkController = 0 } = heapStats().objectTypeCounts;
expect(ReadableHTTPResponseSinkController).toBe(1);
expect(remain + 1).toBe(0);
});
diff --git a/test/bun.js/readline.node.test.ts b/test/bun.js/readline.node.test.ts
index c681a8e15..4a6c4be8c 100644
--- a/test/bun.js/readline.node.test.ts
+++ b/test/bun.js/readline.node.test.ts
@@ -2,11 +2,7 @@ import { beforeEach, describe, it } from "bun:test";
import readline from "node:readline";
import { Writable, PassThrough } from "node:stream";
import { EventEmitter } from "node:events";
-import {
- createDoneDotAll,
- createCallCheckCtx,
- assert,
-} from "./node-test-helpers";
+import { createDoneDotAll, createCallCheckCtx, assert } from "./node-test-helpers";
var {
CSI,
@@ -82,7 +78,7 @@ describe("CSI", () => {
});
describe("readline.clearScreenDown()", () => {
- it("should put clear screen sequence into writable when called", (done) => {
+ it("should put clear screen sequence into writable when called", done => {
const { mustCall } = createCallCheckCtx(done);
assert.strictEqual(readline.clearScreenDown(writable), true);
@@ -97,12 +93,12 @@ describe("readline.clearScreenDown()", () => {
}, /ERR_INVALID_ARG_TYPE/);
});
- it("should that clearScreenDown() does not throw on null or undefined stream", (done) => {
+ it("should that clearScreenDown() does not throw on null or undefined stream", done => {
const { mustCall } = createCallCheckCtx(done);
assert.strictEqual(
readline.clearScreenDown(
null,
- mustCall((err) => {
+ mustCall(err => {
assert.strictEqual(err, null);
}),
),
@@ -132,7 +128,7 @@ describe("readline.clearLine()", () => {
assert.deepStrictEqual(writable.data, CSI.kClearLine);
});
- it("should call callback after clearing line", (done) => {
+ it("should call callback after clearing line", done => {
const { mustCall } = createCallCheckCtx(done);
assert.strictEqual(readline.clearLine(writable, -1, mustCall()), true);
assert.deepStrictEqual(writable.data, CSI.kClearToLineBeginning);
@@ -145,7 +141,7 @@ describe("readline.clearLine()", () => {
}, /ERR_INVALID_ARG_TYPE/);
});
- it("shouldn't throw on on null or undefined stream", (done) => {
+ it("shouldn't throw on on null or undefined stream", done => {
const { mustCall } = createCallCheckCtx(done);
// Verify that clearLine() does not throw on null or undefined stream.
assert.strictEqual(readline.clearLine(null, 0), true);
@@ -154,7 +150,7 @@ describe("readline.clearLine()", () => {
readline.clearLine(
null,
0,
- mustCall((err) => {
+ mustCall(err => {
assert.strictEqual(err, null);
}),
),
@@ -165,7 +161,7 @@ describe("readline.clearLine()", () => {
});
describe("readline.moveCursor()", () => {
- it("shouldn't write when moveCursor(0, 0) is called", (done) => {
+ it("shouldn't write when moveCursor(0, 0) is called", done => {
const { mustCall } = createCallCheckCtx(done);
// Nothing is written when moveCursor 0, 0
[
@@ -178,15 +174,12 @@ describe("readline.moveCursor()", () => {
[-1, 1, "\x1b[1D\x1b[1B"],
[-1, -1, "\x1b[1D\x1b[1A"],
[1, -1, "\x1b[1C\x1b[1A"],
- ].forEach((set) => {
+ ].forEach(set => {
writable.data = "";
assert.strictEqual(readline.moveCursor(writable, set[0], set[1]), true);
assert.deepStrictEqual(writable.data, set[2]);
writable.data = "";
- assert.strictEqual(
- readline.moveCursor(writable, set[0], set[1], mustCall()),
- true,
- );
+ assert.strictEqual(readline.moveCursor(writable, set[0], set[1], mustCall()), true);
assert.deepStrictEqual(writable.data, set[2]);
});
});
@@ -198,7 +191,7 @@ describe("readline.moveCursor()", () => {
}, /ERR_INVALID_ARG_TYPE/);
});
- it("should not throw on null or undefined stream", (done) => {
+ it("should not throw on null or undefined stream", done => {
const { mustCall } = createCallCheckCtx(done);
// Verify that moveCursor() does not throw on null or undefined stream.
assert.strictEqual(readline.moveCursor(null, 1, 1), true);
@@ -208,7 +201,7 @@ describe("readline.moveCursor()", () => {
null,
1,
1,
- mustCall((err) => {
+ mustCall(err => {
assert.strictEqual(err, null);
}),
),
@@ -223,7 +216,7 @@ describe("readline.cursorTo()", () => {
writable.data = "";
});
- it("should not throw on undefined or null as stream", (done) => {
+ it("should not throw on undefined or null as stream", done => {
const { mustCall } = createCallCheckCtx(done);
// Undefined or null as stream should not throw.
assert.strictEqual(readline.cursorTo(null), true);
@@ -234,7 +227,7 @@ describe("readline.cursorTo()", () => {
undefined,
1,
1,
- mustCall((err) => {
+ mustCall(err => {
assert.strictEqual(err, null);
}),
),
@@ -261,7 +254,7 @@ describe("readline.cursorTo()", () => {
assert.strictEqual(writable.data, "");
});
- it("should write when given value cursor positions", (done) => {
+ it("should write when given value cursor positions", done => {
const { mustCall } = createCallCheckCtx(done);
assert.strictEqual(readline.cursorTo(writable, 1, "a"), true);
@@ -389,7 +382,7 @@ describe("readline.Interface", () => {
});
it("should throw on invalid escapeCodeTimeout", () => {
- [null, {}, NaN, "50"].forEach((invalidInput) => {
+ [null, {}, NaN, "50"].forEach(invalidInput => {
assert.throws(
() => {
const fi = new FakeInput();
@@ -414,13 +407,13 @@ describe("readline.Interface", () => {
assert.ok(rl instanceof readline.Interface);
});
- it("should call completer when input emits data", (done) => {
+ it("should call completer when input emits data", done => {
const { mustCall } = createCallCheckCtx(done);
const fi = new FakeInput();
const rli = new readline.Interface(
fi,
fi,
- mustCall((line) => [[], line]),
+ mustCall(line => [[], line]),
true,
);
@@ -430,7 +423,7 @@ describe("readline.Interface", () => {
});
it("should allow crlfDelay to be set", () => {
- [undefined, 50, 0, 100.5, 5000].forEach((crlfDelay) => {
+ [undefined, 50, 0, 100.5, 5000].forEach(crlfDelay => {
const [rli] = getInterface({ crlfDelay });
assert.strictEqual(rli.crlfDelay, Math.max(crlfDelay || 100, 100));
rli.close();
@@ -438,7 +431,7 @@ describe("readline.Interface", () => {
});
it("should throw if completer is not a function or is undefined", () => {
- ["not an array", 123, 123n, {}, true, Symbol(), null].forEach((invalid) => {
+ ["not an array", 123, 123n, {}, true, Symbol(), null].forEach(invalid => {
assert.throws(
() => {
readline.createInterface({
@@ -455,7 +448,7 @@ describe("readline.Interface", () => {
});
it("should throw if history is not an array", () => {
- ["not an array", 123, 123, {}, true, Symbol(), null].forEach((history) => {
+ ["not an array", 123, 123, {}, true, Symbol(), null].forEach(history => {
assert.throws(
() => {
readline.createInterface({
@@ -472,24 +465,22 @@ describe("readline.Interface", () => {
});
it("should throw if historySize is not a positive number", () => {
- ["not a number", -1, NaN, {}, true, Symbol(), null].forEach(
- (historySize) => {
- assert.throws(
- () => {
- readline.createInterface({
- input,
- historySize,
- });
- },
- {
- // TODO: Revert to Range error when properly implemented errors with multiple bases
- // name: "RangeError",
- name: "TypeError",
- code: "ERR_INVALID_ARG_VALUE",
- },
- );
- },
- );
+ ["not a number", -1, NaN, {}, true, Symbol(), null].forEach(historySize => {
+ assert.throws(
+ () => {
+ readline.createInterface({
+ input,
+ historySize,
+ });
+ },
+ {
+ // TODO: Revert to Range error when properly implemented errors with multiple bases
+ // name: "RangeError",
+ name: "TypeError",
+ code: "ERR_INVALID_ARG_VALUE",
+ },
+ );
+ });
});
it("should throw on invalid tabSize", () => {
@@ -528,7 +519,7 @@ describe("readline.Interface", () => {
});
// Sending a single character with no newline
- it("should not emit line when only a single character sent with no newline", (done) => {
+ it("should not emit line when only a single character sent with no newline", done => {
const { mustNotCall } = createCallCheckCtx(done);
const fi = new FakeInput();
const rli = new readline.Interface(fi, {});
@@ -537,7 +528,7 @@ describe("readline.Interface", () => {
rli.close();
});
- it("should treat \\r like \\n when alone", (done) => {
+ it("should treat \\r like \\n when alone", done => {
const { mustCall } = createCallCheckCtx(done);
// Sending multiple newlines at once that does not end with a new line and a
// `end` event(last line is). \r should behave like \n when alone.
@@ -545,7 +536,7 @@ describe("readline.Interface", () => {
const expectedLines = ["foo", "bar", "baz", "bat"];
rli.on(
"line",
- mustCall((line) => {
+ mustCall(line => {
assert.strictEqual(line, expectedLines.shift());
}, expectedLines.length - 1),
);
@@ -554,13 +545,13 @@ describe("readline.Interface", () => {
});
// \r at start of input should output blank line
- it("should output blank line when \\r at start of input", (done) => {
+ it("should output blank line when \\r at start of input", done => {
const { mustCall } = createCallCheckCtx(done);
const [rli, fi] = getInterface({ terminal: true });
const expectedLines = ["", "foo"];
rli.on(
"line",
- mustCall((line) => {
+ mustCall(line => {
assert.strictEqual(line, expectedLines.shift());
}, expectedLines.length),
);
@@ -569,13 +560,13 @@ describe("readline.Interface", () => {
});
// \t does not become part of the input when there is a completer function
- it("should not include \\t in input when there is a completer function", (done) => {
+ it("should not include \\t in input when there is a completer function", done => {
const { mustCall } = createCallCheckCtx(done);
- const completer = (line) => [[], line];
+ const completer = line => [[], line];
const [rli, fi] = getInterface({ terminal: true, completer });
rli.on(
"line",
- mustCall((line) => {
+ mustCall(line => {
assert.strictEqual(line, "foo");
}),
);
@@ -588,12 +579,12 @@ describe("readline.Interface", () => {
// \t when there is no completer function should behave like an ordinary
// character
- it("should treat \\t as an ordinary character when there is no completer function", (done) => {
+ it("should treat \\t as an ordinary character when there is no completer function", done => {
const { mustCall } = createCallCheckCtx(done);
const [rli, fi] = getInterface({ terminal: true });
rli.on(
"line",
- mustCall((line) => {
+ mustCall(line => {
assert.strictEqual(line, "\t");
}),
);
@@ -604,16 +595,14 @@ describe("readline.Interface", () => {
// Adding history lines should emit the history event with
// the history array
- it("should emit history event when adding history lines", (done) => {
+ it("should emit history event when adding history lines", done => {
const { mustCall } = createCallCheckCtx(done);
const [rli, fi] = getInterface({ terminal: true });
const expectedLines = ["foo", "bar", "baz", "bat"];
rli.on(
"history",
- mustCall((history) => {
- const expectedHistory = expectedLines
- .slice(0, history.length)
- .reverse();
+ mustCall(history => {
+ const expectedHistory = expectedLines.slice(0, history.length).reverse();
assert.deepStrictEqual(history, expectedHistory);
}, expectedLines.length),
);
@@ -625,20 +614,20 @@ describe("readline.Interface", () => {
// Altering the history array in the listener should not alter
// the line being processed
- it("should not alter the line being processed when history is altered", (done) => {
+ it("should not alter the line being processed when history is altered", done => {
const { mustCall } = createCallCheckCtx(done);
const [rli, fi] = getInterface({ terminal: true });
const expectedLine = "foo";
rli.on(
"history",
- mustCall((history) => {
+ mustCall(history => {
assert.strictEqual(history[0], expectedLine);
history.shift();
}),
);
rli.on(
"line",
- mustCall((line) => {
+ mustCall(line => {
assert.strictEqual(line, expectedLine);
assert.strictEqual(rli.history.length, 0);
}),
@@ -657,7 +646,7 @@ describe("readline.Interface", () => {
const expectedLines = ["foo", "bar", "baz", "bar", "bat", "bat"];
// ['foo', 'baz', 'bar', bat'];
let callCount = 0;
- rli.on("line", (line) => {
+ rli.on("line", line => {
assert.strictEqual(line, expectedLines[callCount]);
callCount++;
});
@@ -733,7 +722,7 @@ describe("readline.Interface", () => {
});
const expectedLines = ["foo", "bar", "baz", "bar", "bat", "bat"];
let callCount = 0;
- rli.on("line", (line) => {
+ rli.on("line", line => {
assert.strictEqual(line, expectedLines[callCount]);
callCount++;
});
@@ -768,7 +757,7 @@ describe("readline.Interface", () => {
});
assert.throws(
() => fi.emit("data", "fooX"),
- (e) => {
+ e => {
console.log("ERRROR!", e);
assert.strictEqual(e, err);
return true;
@@ -803,11 +792,7 @@ describe("readline.Interface", () => {
const [rli] = getInterface({ terminal: true });
const expectedLines = ["foo", "bar"];
rli.question(expectedLines.join("\n"), () => rli.close());
- assertCursorRowsAndCols(
- rli,
- expectedLines.length - 1,
- expectedLines.slice(-1)[0].length,
- );
+ assertCursorRowsAndCols(rli, expectedLines.length - 1, expectedLines.slice(-1)[0].length);
rli.close();
});
@@ -844,7 +829,7 @@ describe("readline.Interface", () => {
});
// Back and Forward one astral character
- it("should handle going back and forward one astral character", (done) => {
+ it("should handle going back and forward one astral character", done => {
const { mustCall } = createCallCheckCtx(done);
const [rli, fi] = getInterface({ terminal: true, prompt: "" });
fi.emit("data", "💻");
@@ -859,7 +844,7 @@ describe("readline.Interface", () => {
rli.on(
"line",
- mustCall((line) => {
+ mustCall(line => {
assert.strictEqual(line, "💻");
}),
);
@@ -868,7 +853,7 @@ describe("readline.Interface", () => {
});
// Two astral characters left
- it("should handle two astral characters left", (done) => {
+ it("should handle two astral characters left", done => {
const { mustCall } = createCallCheckCtx(done);
const [rli, fi] = getInterface({ terminal: true, prompt: "" });
fi.emit("data", "💻");
@@ -882,7 +867,7 @@ describe("readline.Interface", () => {
rli.on(
"line",
- mustCall((line) => {
+ mustCall(line => {
assert.strictEqual(line, "🐕💻");
}),
);
@@ -891,7 +876,7 @@ describe("readline.Interface", () => {
});
// Two astral characters right
- it("should handle two astral characters right", (done) => {
+ it("should handle two astral characters right", done => {
const { mustCall } = createCallCheckCtx(done);
const [rli, fi] = getInterface({ terminal: true, prompt: "" });
fi.emit("data", "💻");
@@ -905,7 +890,7 @@ describe("readline.Interface", () => {
rli.on(
"line",
- mustCall((line) => {
+ mustCall(line => {
assert.strictEqual(line, "💻🐕");
}),
);
@@ -929,19 +914,19 @@ describe("readline.Interface", () => {
});
// `deleteWordLeft`
- it("should handle deleteWordLeft", (done) => {
+ it("should handle deleteWordLeft", done => {
const { mustCall } = createCallCheckCtx(done);
[
{ ctrl: true, name: "w" },
{ ctrl: true, name: "backspace" },
{ meta: true, name: "backspace" },
- ].forEach((deleteWordLeftKey) => {
+ ].forEach(deleteWordLeftKey => {
let [rli, fi] = getInterface({ terminal: true, prompt: "" });
fi.emit("data", "the quick brown fox");
fi.emit("keypress", ".", { ctrl: true, name: "left" });
rli.on(
"line",
- mustCall((line) => {
+ mustCall(line => {
assert.strictEqual(line, "the quick fox");
}),
);
@@ -955,7 +940,7 @@ describe("readline.Interface", () => {
fi.emit("keypress", ".", { ctrl: true, name: "a" });
rli.on(
"line",
- mustCall((line) => {
+ mustCall(line => {
assert.strictEqual(line, "the quick brown fox");
}),
);
@@ -966,20 +951,20 @@ describe("readline.Interface", () => {
});
// `deleteWordRight`
- it("should handle deleteWordRight", (done) => {
+ it("should handle deleteWordRight", done => {
const { mustCall } = createCallCheckCtx(done);
[
{ ctrl: true, name: "delete" },
{ meta: true, name: "delete" },
{ meta: true, name: "d" },
- ].forEach((deleteWordRightKey) => {
+ ].forEach(deleteWordRightKey => {
let [rli, fi] = getInterface({ terminal: true, prompt: "" });
fi.emit("data", "the quick brown fox");
fi.emit("keypress", ".", { ctrl: true, name: "left" });
fi.emit("keypress", ".", { ctrl: true, name: "left" });
rli.on(
"line",
- mustCall((line) => {
+ mustCall(line => {
assert.strictEqual(line, "the quick fox");
}),
);
@@ -992,7 +977,7 @@ describe("readline.Interface", () => {
fi.emit("data", "the quick brown fox");
rli.on(
"line",
- mustCall((line) => {
+ mustCall(line => {
assert.strictEqual(line, "the quick brown fox");
}),
);
@@ -1003,7 +988,7 @@ describe("readline.Interface", () => {
});
// deleteLeft
- it("should handle deleteLeft", (done) => {
+ it("should handle deleteLeft", done => {
const { mustCall } = createCallCheckCtx(done);
const [rli, fi] = getInterface({ terminal: true, prompt: "" });
fi.emit("data", "the quick brown fox");
@@ -1014,7 +999,7 @@ describe("readline.Interface", () => {
assertCursorRowsAndCols(rli, 0, 18);
rli.on(
"line",
- mustCall((line) => {
+ mustCall(line => {
assert.strictEqual(line, "the quick brown fo");
}),
);
@@ -1023,7 +1008,7 @@ describe("readline.Interface", () => {
});
// deleteLeft astral character
- it("should handle deleteLeft astral character", (done) => {
+ it("should handle deleteLeft astral character", done => {
const { mustCall } = createCallCheckCtx(done);
const [rli, fi] = getInterface({ terminal: true, prompt: "" });
fi.emit("data", "💻");
@@ -1033,7 +1018,7 @@ describe("readline.Interface", () => {
assertCursorRowsAndCols(rli, 0, 0);
rli.on(
"line",
- mustCall((line) => {
+ mustCall(line => {
assert.strictEqual(line, "");
}),
);
@@ -1042,7 +1027,7 @@ describe("readline.Interface", () => {
});
// deleteRight
- it("should handle deleteRight", (done) => {
+ it("should handle deleteRight", done => {
const { mustCall } = createCallCheckCtx(done);
const [rli, fi] = getInterface({ terminal: true, prompt: "" });
fi.emit("data", "the quick brown fox");
@@ -1056,7 +1041,7 @@ describe("readline.Interface", () => {
assertCursorRowsAndCols(rli, 0, 0);
rli.on(
"line",
- mustCall((line) => {
+ mustCall(line => {
assert.strictEqual(line, "he quick brown fox");
}),
);
@@ -1065,7 +1050,7 @@ describe("readline.Interface", () => {
});
// deleteRight astral character
- it("should handle deleteRight of astral characters", (done) => {
+ it("should handle deleteRight of astral characters", done => {
const { mustCall } = createCallCheckCtx(done);
const [rli, fi] = getInterface({ terminal: true, prompt: "" });
fi.emit("data", "💻");
@@ -1079,7 +1064,7 @@ describe("readline.Interface", () => {
assertCursorRowsAndCols(rli, 0, 0);
rli.on(
"line",
- mustCall((line) => {
+ mustCall(line => {
assert.strictEqual(line, "");
}),
);
@@ -1088,7 +1073,7 @@ describe("readline.Interface", () => {
});
// deleteLineLeft
- it("should handle deleteLineLeft", (done) => {
+ it("should handle deleteLineLeft", done => {
const { mustCall } = createCallCheckCtx(done);
const [rli, fi] = getInterface({ terminal: true, prompt: "" });
fi.emit("data", "the quick brown fox");
@@ -1099,7 +1084,7 @@ describe("readline.Interface", () => {
assertCursorRowsAndCols(rli, 0, 0);
rli.on(
"line",
- mustCall((line) => {
+ mustCall(line => {
assert.strictEqual(line, "");
}),
);
@@ -1108,7 +1093,7 @@ describe("readline.Interface", () => {
});
// deleteLineRight
- it("should handle deleteLineRight", (done) => {
+ it("should handle deleteLineRight", done => {
const { mustCall } = createCallCheckCtx(done);
const [rli, fi] = getInterface({ terminal: true, prompt: "" });
fi.emit("data", "the quick brown fox");
@@ -1122,7 +1107,7 @@ describe("readline.Interface", () => {
assertCursorRowsAndCols(rli, 0, 0);
rli.on(
"line",
- mustCall((line) => {
+ mustCall(line => {
assert.strictEqual(line, "");
}),
);
@@ -1131,7 +1116,7 @@ describe("readline.Interface", () => {
});
// yank
- it("should handle yank", (done) => {
+ it("should handle yank", done => {
const { mustCall } = createCallCheckCtx(done);
const [rli, fi] = getInterface({ terminal: true, prompt: "" });
fi.emit("data", "the quick brown fox");
@@ -1151,7 +1136,7 @@ describe("readline.Interface", () => {
rli.on(
"line",
- mustCall((line) => {
+ mustCall(line => {
assert.strictEqual(line, "the quick brown fox");
}),
);
@@ -1161,7 +1146,7 @@ describe("readline.Interface", () => {
});
// yank pop
- it("should handle yank pop", (done) => {
+ it("should handle yank pop", done => {
const { mustCall } = createCallCheckCtx(done);
const [rli, fi] = getInterface({ terminal: true, prompt: "" });
fi.emit("data", "the quick brown fox");
@@ -1200,7 +1185,7 @@ describe("readline.Interface", () => {
rli.on(
"line",
- mustCall((line) => {
+ mustCall(line => {
assert.strictEqual(line, "he quick brown foxthe ");
}),
);
@@ -1295,7 +1280,7 @@ describe("readline.Interface", () => {
});
// Clear the whole screen
- it("should clear the whole screen", (done) => {
+ it("should clear the whole screen", done => {
const { mustCall } = createCallCheckCtx(done);
const [rli, fi] = getInterface({ terminal: true, prompt: "" });
const lines = ["line 1", "line 2", "line 3"];
@@ -1304,7 +1289,7 @@ describe("readline.Interface", () => {
assertCursorRowsAndCols(rli, 0, 6);
rli.on(
"line",
- mustCall((line) => {
+ mustCall(line => {
assert.strictEqual(line, "line 3");
}),
);
@@ -1845,7 +1830,7 @@ describe("readline.Interface", () => {
});
describe("readline.createInterface()", () => {
- it("should emit line when input ends line", (done) => {
+ it("should emit line when input ends line", done => {
const createDone = createDoneDotAll(done);
const lineDone = createDone(2000);
const { mustCall } = createCallCheckCtx(createDone(2000));
@@ -1857,7 +1842,7 @@ describe("readline.createInterface()", () => {
rl.on(
"line",
- mustCall((data) => {
+ mustCall(data => {
assert.strictEqual(data, "abc");
lineDone();
}),
@@ -1866,7 +1851,7 @@ describe("readline.createInterface()", () => {
input.end("abc");
});
- it("should not emit line when input ends without newline", (done) => {
+ it("should not emit line when input ends without newline", done => {
const { mustNotCall } = createCallCheckCtx(done);
const input = new PassThrough();
@@ -1879,7 +1864,7 @@ describe("readline.createInterface()", () => {
input.write("abc");
});
- it("should read line by line", (done) => {
+ it("should read line by line", done => {
const createDone = createDoneDotAll(done);
const { mustCall } = createCallCheckCtx(createDone(3000));
const lineDone = createDone(2000);
@@ -1891,7 +1876,7 @@ describe("readline.createInterface()", () => {
rl.on(
"line",
- mustCall((data) => {
+ mustCall(data => {
assert.strictEqual(data, "abc");
lineDone();
}),
@@ -1929,7 +1914,7 @@ describe("readline.createInterface()", () => {
},
};
- [key.xterm, key.gnome, key.rxvt, key.putty].forEach((key) => {
+ [key.xterm, key.gnome, key.rxvt, key.putty].forEach(key => {
rl.write.apply(rl, key.home);
assert.strictEqual(rl.cursor, 0);
rl.write.apply(rl, key.end);
@@ -1989,9 +1974,7 @@ describe("readline.createInterface()", () => {
rl.write("foo bar.hop/zoo");
rl.write.apply(rl, key.xterm.home);
- ["bar.hop/zoo", ".hop/zoo", "hop/zoo", "/zoo", "zoo", ""].forEach(function (
- expectedLine,
- ) {
+ ["bar.hop/zoo", ".hop/zoo", "hop/zoo", "/zoo", "zoo", ""].forEach(function (expectedLine) {
rl.write.apply(rl, key.xterm.metad);
assert.strictEqual(rl.cursor, 0);
assert.strictEqual(rl.line, expectedLine);
diff --git a/test/bun.js/readline_promises.node.test.ts b/test/bun.js/readline_promises.node.test.ts
index eadd289e3..93093aecd 100644
--- a/test/bun.js/readline_promises.node.test.ts
+++ b/test/bun.js/readline_promises.node.test.ts
@@ -1,11 +1,7 @@
import { describe, it } from "bun:test";
import readlinePromises from "node:readline/promises";
import { EventEmitter } from "node:events";
-import {
- createDoneDotAll,
- createCallCheckCtx,
- assert,
-} from "./node-test-helpers";
+import { createDoneDotAll, createCallCheckCtx, assert } from "./node-test-helpers";
// ----------------------------------------------------------------------------
// Helpers
@@ -29,7 +25,7 @@ class FakeInput extends EventEmitter {
// ----------------------------------------------------------------------------
describe("readline/promises.createInterface()", () => {
- it("should throw an error when failed completion", (done) => {
+ it("should throw an error when failed completion", done => {
const createDone = createDoneDotAll(done);
const { mustCall, mustNotCall } = createCallCheckCtx(createDone());
diff --git a/test/bun.js/resolve-dns.test.ts b/test/bun.js/resolve-dns.test.ts
index 225a11e2a..d83e23b56 100644
--- a/test/bun.js/resolve-dns.test.ts
+++ b/test/bun.js/resolve-dns.test.ts
@@ -3,11 +3,7 @@ import { describe, expect, it, test } from "bun:test";
import { withoutAggressiveGC } from "gc";
describe("dns.lookup", () => {
- const backends = [
- process.platform === "darwin" ? "system" : undefined,
- "libc",
- "c-ares",
- ].filter(Boolean);
+ const backends = [process.platform === "darwin" ? "system" : undefined, "libc", "c-ares"].filter(Boolean);
for (let backend of backends) {
it(backend + " parallell x 10", async () => {
const promises = [];
@@ -37,18 +33,14 @@ describe("dns.lookup", () => {
console.log(first, second);
});
- it(
- backend +
- " failing domain throws an error without taking a very long time",
- async () => {
- try {
- await dns.lookup("yololololololo1234567.com", { backend });
- throw 42;
- } catch (e) {
- expect(typeof e).not.toBe("number");
- expect(e.code).toBe("DNS_ENOTFOUND");
- }
- },
- );
+ it(backend + " failing domain throws an error without taking a very long time", async () => {
+ try {
+ await dns.lookup("yololololololo1234567.com", { backend });
+ throw 42;
+ } catch (e) {
+ expect(typeof e).not.toBe("number");
+ expect(e.code).toBe("DNS_ENOTFOUND");
+ }
+ });
}
-}); \ No newline at end of file
+});
diff --git a/test/bun.js/resolve.test.js b/test/bun.js/resolve.test.js
index b794c7604..fcc4152f5 100644
--- a/test/bun.js/resolve.test.js
+++ b/test/bun.js/resolve.test.js
@@ -3,16 +3,13 @@ import { mkdirSync, writeFileSync } from "fs";
import { join, resolve } from "path";
function resolveFrom(from) {
- return (specifier) => import.meta.resolveSync(specifier, from);
+ return specifier => import.meta.resolveSync(specifier, from);
}
it("#imports", async () => {
await writePackageJSONImportsFixture();
- const baz = await import.meta.resolve(
- "#foo",
- join(await import.meta.resolve("package-json-imports/baz"), "../"),
- );
+ const baz = await import.meta.resolve("#foo", join(await import.meta.resolve("package-json-imports/baz"), "../"));
expect(baz.endsWith("foo/private-foo.js")).toBe(true);
const subpath = await import.meta.resolve(
@@ -50,15 +47,9 @@ it("#imports", async () => {
it("#imports with wildcard", async () => {
await writePackageJSONImportsFixture();
- const run = resolveFrom(
- resolve(
- import.meta.dir + "/node_modules/package-json-imports/package.json",
- ),
- );
+ const run = resolveFrom(resolve(import.meta.dir + "/node_modules/package-json-imports/package.json"));
- const wildcard = resolve(
- import.meta.dir + "/node_modules/package-json-imports/foo/wildcard.js",
- );
+ const wildcard = resolve(import.meta.dir + "/node_modules/package-json-imports/foo/wildcard.js");
expect(run("#foo/wildcard.js")).toBe(wildcard);
expect(run("#foo/extensionless/wildcard")).toBe(wildcard);
});
@@ -66,30 +57,21 @@ it("#imports with wildcard", async () => {
it("import.meta.resolve", async () => {
expect(await import.meta.resolve("./resolve.test.js")).toBe(import.meta.path);
- expect(await import.meta.resolve("./resolve.test.js", import.meta.path)).toBe(
- import.meta.path,
- );
+ expect(await import.meta.resolve("./resolve.test.js", import.meta.path)).toBe(import.meta.path);
expect(
// optional second param can be any path, including a dir
- await import.meta.resolve(
- "./bun.js/resolve.test.js",
- join(import.meta.path, "../"),
- ),
+ await import.meta.resolve("./bun.js/resolve.test.js", join(import.meta.path, "../")),
).toBe(import.meta.path);
// can be a package path
- expect(
- (await import.meta.resolve("react", import.meta.path)).length > 0,
- ).toBe(true);
+ expect((await import.meta.resolve("react", import.meta.path)).length > 0).toBe(true);
// file extensions are optional
expect(await import.meta.resolve("./resolve.test")).toBe(import.meta.path);
// works with tsconfig.json "paths"
- expect(await import.meta.resolve("foo/bar")).toBe(
- join(import.meta.path, "../baz.js"),
- );
+ expect(await import.meta.resolve("foo/bar")).toBe(join(import.meta.path, "../baz.js"));
// works with package.json "exports"
writePackageJSONExportsFixture();
@@ -130,25 +112,19 @@ it("import.meta.resolve", async () => {
// the slightly lower level API, which doesn't prefill the second param
// and expects a directory instead of a filepath
it("Bun.resolve", async () => {
- expect(await Bun.resolve("./resolve.test.js", import.meta.dir)).toBe(
- import.meta.path,
- );
+ expect(await Bun.resolve("./resolve.test.js", import.meta.dir)).toBe(import.meta.path);
});
// synchronous
it("Bun.resolveSync", () => {
- expect(Bun.resolveSync("./resolve.test.js", import.meta.dir)).toBe(
- import.meta.path,
- );
+ expect(Bun.resolveSync("./resolve.test.js", import.meta.dir)).toBe(import.meta.path);
});
it("self-referencing imports works", async () => {
await writePackageJSONExportsFixture();
const baz = await import.meta.resolve("package-json-exports/baz");
- const namespace = await import.meta.resolve(
- "package-json-exports/references-baz",
- );
+ const namespace = await import.meta.resolve("package-json-exports/references-baz");
Loader.registry.delete(baz);
Loader.registry.delete(namespace);
var a = await import(baz);
@@ -188,22 +164,13 @@ it("self-referencing imports works", async () => {
function writePackageJSONExportsFixture() {
try {
- mkdirSync(
- join(import.meta.dir, "./node_modules/package-json-exports/foo"),
- {
- recursive: true,
- },
- );
+ mkdirSync(join(import.meta.dir, "./node_modules/package-json-exports/foo"), {
+ recursive: true,
+ });
} catch (exception) {}
+ writeFileSync(join(import.meta.dir, "./node_modules/package-json-exports/foo/bar.js"), "export const bar = 1;");
writeFileSync(
- join(import.meta.dir, "./node_modules/package-json-exports/foo/bar.js"),
- "export const bar = 1;",
- );
- writeFileSync(
- join(
- import.meta.dir,
- "./node_modules/package-json-exports/foo/references-baz.js",
- ),
+ join(import.meta.dir, "./node_modules/package-json-exports/foo/references-baz.js"),
"export {bar} from 'package-json-exports/baz';",
);
writeFileSync(
@@ -224,29 +191,17 @@ function writePackageJSONExportsFixture() {
function writePackageJSONImportsFixture() {
try {
- mkdirSync(
- join(import.meta.dir, "./node_modules/package-json-imports/foo"),
- {
- recursive: true,
- },
- );
+ mkdirSync(join(import.meta.dir, "./node_modules/package-json-imports/foo"), {
+ recursive: true,
+ });
} catch (exception) {}
+ writeFileSync(join(import.meta.dir, "./node_modules/package-json-imports/foo/bar.js"), "export const bar = 1;");
writeFileSync(
- join(import.meta.dir, "./node_modules/package-json-imports/foo/bar.js"),
- "export const bar = 1;",
- );
- writeFileSync(
- join(
- import.meta.dir,
- "./node_modules/package-json-imports/foo/wildcard.js",
- ),
+ join(import.meta.dir, "./node_modules/package-json-imports/foo/wildcard.js"),
"export const wildcard = 1;",
);
writeFileSync(
- join(
- import.meta.dir,
- "./node_modules/package-json-imports/foo/private-foo.js",
- ),
+ join(import.meta.dir, "./node_modules/package-json-imports/foo/private-foo.js"),
"export {bar} from 'package-json-imports/#foo';",
);
writeFileSync(
diff --git a/test/bun.js/serve.test.ts b/test/bun.js/serve.test.ts
index 86c5585ce..f1fdabd00 100644
--- a/test/bun.js/serve.test.ts
+++ b/test/bun.js/serve.test.ts
@@ -19,10 +19,7 @@ async function runTest(serverOptions, test) {
server = serve(serverOptions);
break;
} catch (e: any) {
- if (
- e?.message !==
- `Failed to start server. Is port ${serverOptions.port} in use?`
- ) {
+ if (e?.message !== `Failed to start server. Is port ${serverOptions.port} in use?`) {
throw e;
}
}
@@ -39,7 +36,7 @@ afterAll(() => {
}
});
-[ 100, 101, 418, 999 ].forEach((statusCode) => {
+[100, 101, 418, 999].forEach(statusCode => {
it(`should response with HTTP status code (${statusCode})`, async () => {
await runTest(
{
@@ -47,7 +44,7 @@ afterAll(() => {
return new Response("Foo Bar", { status: statusCode });
},
},
- async (server) => {
+ async server => {
const response = await fetch(`http://${server.hostname}:${server.port}`);
expect(response.status).toBe(statusCode);
expect(await response.text()).toBe("Foo Bar");
@@ -56,7 +53,7 @@ afterAll(() => {
});
});
-[ -200, 42, 12345, Math.PI ].forEach((statusCode) => {
+[-200, 42, 12345, Math.PI].forEach(statusCode => {
it(`should ignore invalid HTTP status code (${statusCode})`, async () => {
await runTest(
{
@@ -64,11 +61,11 @@ afterAll(() => {
return new Response("Foo Bar", { status: statusCode });
},
},
- async (server) => {
+ async server => {
const response = await fetch(`http://${server.hostname}:${server.port}`);
expect(response.status).toBe(200);
expect(await response.text()).toBe("Foo Bar");
- }
+ },
);
});
});
@@ -80,7 +77,7 @@ it("should display a welcome message when the response value type is incorrect",
return Symbol("invalid response type");
},
},
- async (server) => {
+ async server => {
const response = await fetch(`http://${server.hostname}:${server.port}`);
const text = await response.text();
expect(text).toContain("Welcome to Bun!");
@@ -97,7 +94,7 @@ it("should work for a file", async () => {
return new Response(file(fixture));
},
},
- async (server) => {
+ async server => {
const response = await fetch(`http://${server.hostname}:${server.port}`);
expect(await response.text()).toBe(textToExpect);
},
@@ -115,7 +112,7 @@ it("request.url should log successfully", async () => {
return new Response(file(fixture));
},
},
- async (server) => {
+ async server => {
expected = `http://localhost:${server.port}/helloooo`;
const response = await fetch(expected);
expect(response.url).toBe(expected);
@@ -134,7 +131,7 @@ it("request.url should be based on the Host header", async () => {
return new Response(file(fixture));
},
},
- async (server) => {
+ async server => {
const expected = `http://${server.hostname}:${server.port}/helloooo`;
const response = await fetch(expected, {
headers: {
@@ -167,10 +164,8 @@ describe("streaming", () => {
);
},
},
- async (server) => {
- const response = await fetch(
- `http://${server.hostname}:${server.port}`,
- );
+ async server => {
+ const response = await fetch(`http://${server.hostname}:${server.port}`);
if (response.status > 0) {
expect(response.status).toBe(555);
expect(await response.text()).toBe("PASS");
@@ -200,10 +195,8 @@ describe("streaming", () => {
);
},
},
- async (server) => {
- const response = await fetch(
- `http://${server.hostname}:${server.port}`,
- );
+ async server => {
+ const response = await fetch(`http://${server.hostname}:${server.port}`);
// connection terminated
expect(response.status).toBe(200);
expect(await response.text()).toBe("PASS");
@@ -229,10 +222,8 @@ describe("streaming", () => {
);
},
},
- async (server) => {
- const response = await fetch(
- `http://${server.hostname}:${server.port}`,
- );
+ async server => {
+ const response = await fetch(`http://${server.hostname}:${server.port}`);
const text = await response.text();
expect(text.length).toBe(textToExpect.length);
expect(text).toBe(textToExpect);
@@ -256,10 +247,8 @@ describe("streaming", () => {
);
},
},
- async (server) => {
- const response = await fetch(
- `http://${server.hostname}:${server.port}`,
- );
+ async server => {
+ const response = await fetch(`http://${server.hostname}:${server.port}`);
expect(await response.text()).toBe(textToExpect);
},
);
@@ -285,10 +274,8 @@ describe("streaming", () => {
);
},
},
- async (server) => {
- const response = await fetch(
- `http://${server.hostname}:${server.port}`,
- );
+ async server => {
+ const response = await fetch(`http://${server.hostname}:${server.port}`);
expect(response.status).toBe(200);
expect(await response.text()).toBe("Test Passed");
},
@@ -317,10 +304,8 @@ describe("streaming", () => {
);
},
},
- async (server) => {
- const response = await fetch(
- `http://${server.hostname}:${server.port}`,
- );
+ async server => {
+ const response = await fetch(`http://${server.hostname}:${server.port}`);
expect(response.status).toBe(500);
},
);
@@ -346,10 +331,8 @@ describe("streaming", () => {
);
},
},
- async (server) => {
- const response = await fetch(
- `http://${server.hostname}:${server.port}`,
- );
+ async server => {
+ const response = await fetch(`http://${server.hostname}:${server.port}`);
expect(response.status).toBe(500);
expect(await response.text()).toBe("Fail");
expect(pass).toBe(true);
@@ -378,10 +361,8 @@ describe("streaming", () => {
);
},
},
- async (server) => {
- const response = await fetch(
- `http://${server.hostname}:${server.port}`,
- );
+ async server => {
+ const response = await fetch(`http://${server.hostname}:${server.port}`);
expect(await response.text()).toBe(textToExpect);
},
);
@@ -403,10 +384,8 @@ describe("streaming", () => {
);
},
},
- async (server) => {
- const response = await fetch(
- `http://${server.hostname}:${server.port}`,
- );
+ async server => {
+ const response = await fetch(`http://${server.hostname}:${server.port}`);
const text = await response.text();
expect(text).toBe(textToExpect);
},
@@ -432,10 +411,8 @@ describe("streaming", () => {
);
},
},
- async (server) => {
- const response = await fetch(
- `http://${server.hostname}:${server.port}`,
- );
+ async server => {
+ const response = await fetch(`http://${server.hostname}:${server.port}`);
expect(await response.text()).toBe(textToExpect);
},
);
@@ -470,10 +447,8 @@ describe("streaming", () => {
);
},
},
- async (server) => {
- const response = await fetch(
- `http://${server.hostname}:${server.port}`,
- );
+ async server => {
+ const response = await fetch(`http://${server.hostname}:${server.port}`);
expect(await response.text()).toBe(textToExpect);
count++;
},
@@ -501,10 +476,8 @@ describe("streaming", () => {
);
},
},
- async (server) => {
- const response = await fetch(
- `http://${server.hostname}:${server.port}`,
- );
+ async server => {
+ const response = await fetch(`http://${server.hostname}:${server.port}`);
expect(await response.text()).toBe(textToExpect);
},
);
@@ -523,7 +496,7 @@ describe("streaming", () => {
for (let i = 0; i < 10 && remain.length > 0; i++) {
controller.enqueue(remain.substring(0, 100));
remain = remain.substring(100);
- await new Promise((resolve) => queueMicrotask(resolve));
+ await new Promise(resolve => queueMicrotask(resolve));
}
controller.enqueue(remain);
@@ -533,10 +506,8 @@ describe("streaming", () => {
);
},
},
- async (server) => {
- const response = await fetch(
- `http://${server.hostname}:${server.port}`,
- );
+ async server => {
+ const response = await fetch(`http://${server.hostname}:${server.port}`);
expect(await response.text()).toBe(textToExpect);
},
);
@@ -550,7 +521,7 @@ it("should work for a hello world", async () => {
return new Response(`Hello, world!`);
},
},
- async (server) => {
+ async server => {
const response = await fetch(`http://${server.hostname}:${server.port}`);
expect(await response.text()).toBe("Hello, world!");
},
@@ -566,7 +537,7 @@ it("should work for a blob", async () => {
return new Response(new Blob([textToExpect]));
},
},
- async (server) => {
+ async server => {
const response = await fetch(`http://${server.hostname}:${server.port}`);
expect(await response.text()).toBe(textToExpect);
},
@@ -582,7 +553,7 @@ it("should work for a blob stream", async () => {
return new Response(new Blob([textToExpect]).stream());
},
},
- async (server) => {
+ async server => {
const response = await fetch(`http://${server.hostname}:${server.port}`);
expect(await response.text()).toBe(textToExpect);
},
@@ -598,7 +569,7 @@ it("should work for a file stream", async () => {
return new Response(file(fixture).stream());
},
},
- async (server) => {
+ async server => {
const response = await fetch(`http://${server.hostname}:${server.port}`);
expect(await response.text()).toBe(textToExpect);
},
@@ -618,7 +589,7 @@ it("fetch should work with headers", async () => {
});
},
},
- async (server) => {
+ async server => {
const response = await fetch(`http://${server.hostname}:${server.port}`, {
headers: {
"X-Foo": "bar",
@@ -639,11 +610,9 @@ it(`should work for a file ${count} times serial`, async () => {
return new Response(file(fixture));
},
},
- async (server) => {
+ async server => {
for (let i = 0; i < count; i++) {
- const response = await fetch(
- `http://${server.hostname}:${server.port}`,
- );
+ const response = await fetch(`http://${server.hostname}:${server.port}`);
expect(await response.text()).toBe(textToExpect);
}
},
@@ -658,11 +627,9 @@ it(`should work for ArrayBuffer ${count} times serial`, async () => {
return new Response(new TextEncoder().encode(textToExpect));
},
},
- async (server) => {
+ async server => {
for (let i = 0; i < count; i++) {
- const response = await fetch(
- `http://${server.hostname}:${server.port}`,
- );
+ const response = await fetch(`http://${server.hostname}:${server.port}`);
expect(await response.text()).toBe(textToExpect);
}
},
@@ -678,7 +645,7 @@ describe("parallel", () => {
return new Response(textToExpect);
},
},
- async (server) => {
+ async server => {
for (let i = 0; i < count; ) {
let responses = await Promise.all([
fetch(`http://${server.hostname}:${server.port}`),
@@ -704,7 +671,7 @@ describe("parallel", () => {
return new Response(new TextEncoder().encode(textToExpect));
},
},
- async (server) => {
+ async server => {
for (let i = 0; i < count; ) {
let responses = await Promise.all([
fetch(`http://${server.hostname}:${server.port}`),
@@ -725,13 +692,13 @@ describe("parallel", () => {
});
it("should support reloading", async () => {
- const first = (req) => new Response("first");
- const second = (req) => new Response("second");
+ const first = req => new Response("first");
+ const second = req => new Response("second");
await runTest(
{
fetch: first,
},
- async (server) => {
+ async server => {
const response = await fetch(`http://${server.hostname}:${server.port}`);
expect(await response.text()).toBe("first");
server.reload({ fetch: second });
@@ -812,10 +779,8 @@ describe("status code text", () => {
return new Response("hey", { status: +code });
},
},
- async (server) => {
- const response = await fetch(
- `http://${server.hostname}:${server.port}`,
- );
+ async server => {
+ const response = await fetch(`http://${server.hostname}:${server.port}`);
expect(response.status).toBe(parseInt(code));
expect(response.statusText).toBe(fixture[code]);
},
@@ -837,28 +802,19 @@ it("should support multiple Set-Cookie headers", async () => {
});
},
},
- async (server) => {
+ async server => {
const response = await fetch(`http://${server.hostname}:${server.port}`);
- expect(response.headers.getAll("Set-Cookie")).toEqual([
- "foo=bar",
- "baz=qux",
- ]);
+ expect(response.headers.getAll("Set-Cookie")).toEqual(["foo=bar", "baz=qux"]);
expect(response.headers.get("Set-Cookie")).toEqual("foo=bar, baz=qux");
const cloned = response.clone().headers;
- expect(response.headers.getAll("Set-Cookie")).toEqual([
- "foo=bar",
- "baz=qux",
- ]);
+ expect(response.headers.getAll("Set-Cookie")).toEqual(["foo=bar", "baz=qux"]);
response.headers.delete("Set-Cookie");
expect(response.headers.getAll("Set-Cookie")).toEqual([]);
response.headers.delete("Set-Cookie");
expect(cloned.getAll("Set-Cookie")).toEqual(["foo=bar", "baz=qux"]);
- expect(new Headers(cloned).getAll("Set-Cookie")).toEqual([
- "foo=bar",
- "baz=qux",
- ]);
+ expect(new Headers(cloned).getAll("Set-Cookie")).toEqual(["foo=bar", "baz=qux"]);
},
);
});
@@ -902,17 +858,12 @@ describe("should support Content-Range with Bun.file()", () => {
for (const [start, end] of good) {
it(`good range: ${start} - ${end}`, async () => {
- await getServer(async (server) => {
- const response = await fetch(
- `http://${server.hostname}:${server.port}/?start=${start}&end=${end}`,
- { verbose: true },
- );
- expect(await response.arrayBuffer()).toEqual(
- full.buffer.slice(start, end),
- );
- expect(response.status).toBe(
- start > 0 || end < full.byteLength ? 206 : 200,
- );
+ await getServer(async server => {
+ const response = await fetch(`http://${server.hostname}:${server.port}/?start=${start}&end=${end}`, {
+ verbose: true,
+ });
+ expect(await response.arrayBuffer()).toEqual(full.buffer.slice(start, end));
+ expect(response.status).toBe(start > 0 || end < full.byteLength ? 206 : 200);
});
});
}
@@ -931,10 +882,8 @@ describe("should support Content-Range with Bun.file()", () => {
for (const [start, end] of emptyRanges) {
it(`empty range: ${start} - ${end}`, async () => {
- await getServer(async (server) => {
- const response = await fetch(
- `http://${server.hostname}:${server.port}/?start=${start}&end=${end}`,
- );
+ await getServer(async server => {
+ const response = await fetch(`http://${server.hostname}:${server.port}/?start=${start}&end=${end}`);
const out = await response.arrayBuffer();
expect(out).toEqual(new ArrayBuffer(0));
expect(response.status).toBe(206);
@@ -955,10 +904,8 @@ describe("should support Content-Range with Bun.file()", () => {
for (const [start, end] of badRanges) {
it(`bad range: ${start} - ${end}`, async () => {
- await getServer(async (server) => {
- const response = await fetch(
- `http://${server.hostname}:${server.port}/?start=${start}&end=${end}`,
- );
+ await getServer(async server => {
+ const response = await fetch(`http://${server.hostname}:${server.port}/?start=${start}&end=${end}`);
const out = await response.arrayBuffer();
expect(out).toEqual(new ArrayBuffer(0));
expect(response.status).toBe(206);
diff --git a/test/bun.js/setInterval.test.js b/test/bun.js/setInterval.test.js
index 57ee54aa0..0981df8b1 100644
--- a/test/bun.js/setInterval.test.js
+++ b/test/bun.js/setInterval.test.js
@@ -6,20 +6,24 @@ it("setInterval", async () => {
const result = await new Promise((resolve, reject) => {
start = performance.now();
- var id = setInterval((...args) => {
- counter++;
- if (counter === 10) {
- resolve(counter);
- clearInterval(id);
- }
- try {
- expect(args.length).toBe(1);
- expect(args[0]).toBe("foo");
- } catch (err) {
- reject(err);
- clearInterval(id);
- }
- }, 1, "foo");
+ var id = setInterval(
+ (...args) => {
+ counter++;
+ if (counter === 10) {
+ resolve(counter);
+ clearInterval(id);
+ }
+ try {
+ expect(args.length).toBe(1);
+ expect(args[0]).toBe("foo");
+ } catch (err) {
+ reject(err);
+ clearInterval(id);
+ }
+ },
+ 1,
+ "foo",
+ );
});
expect(result).toBe(10);
diff --git a/test/bun.js/setTimeout.test.js b/test/bun.js/setTimeout.test.js
index 015bb1d7b..9cd16ece2 100644
--- a/test/bun.js/setTimeout.test.js
+++ b/test/bun.js/setTimeout.test.js
@@ -6,18 +6,22 @@ it("setTimeout", async () => {
var numbers = [];
for (let i = 0; i < 10; i++) {
- const id = setTimeout((...args) => {
- numbers.push(i);
- if (i === 9) {
- resolve(numbers);
- }
- try {
- expect(args.length).toBe(1);
- expect(args[0]).toBe("foo");
- } catch (err) {
- reject(err);
- }
- }, i, "foo");
+ const id = setTimeout(
+ (...args) => {
+ numbers.push(i);
+ if (i === 9) {
+ resolve(numbers);
+ }
+ try {
+ expect(args.length).toBe(1);
+ expect(args[0]).toBe("foo");
+ } catch (err) {
+ reject(err);
+ }
+ },
+ i,
+ "foo",
+ );
expect(id > lastID).toBe(true);
lastID = id;
}
diff --git a/test/bun.js/snapshots.debug.js b/test/bun.js/snapshots.debug.js
index e130188c0..cb774b382 100644
--- a/test/bun.js/snapshots.debug.js
+++ b/test/bun.js/snapshots.debug.js
@@ -1,8 +1,6 @@
// test/bun.js/module-require.snapshot.js
import { __require as require } from "bun:wrap";
-console.log(
- import.meta.require("/Users/jarred/Code/bun/node_modules/react/index.js"),
-);
+console.log(import.meta.require("/Users/jarred/Code/bun/node_modules/react/index.js"));
// test/bun.js/require-referenceerror.snapshot.js
diff --git a/test/bun.js/snapshots.js b/test/bun.js/snapshots.js
index e130188c0..cb774b382 100644
--- a/test/bun.js/snapshots.js
+++ b/test/bun.js/snapshots.js
@@ -1,8 +1,6 @@
// test/bun.js/module-require.snapshot.js
import { __require as require } from "bun:wrap";
-console.log(
- import.meta.require("/Users/jarred/Code/bun/node_modules/react/index.js"),
-);
+console.log(import.meta.require("/Users/jarred/Code/bun/node_modules/react/index.js"));
// test/bun.js/require-referenceerror.snapshot.js
diff --git a/test/bun.js/socket/echo.js b/test/bun.js/socket/echo.js
index 3c5d1b7b1..f02637739 100644
--- a/test/bun.js/socket/echo.js
+++ b/test/bun.js/socket/echo.js
@@ -68,7 +68,7 @@ function createOptions(type, message, closeOnDone) {
}
const server = Bun.listen(
- createOptions("[Server]", "response", (socket) => {
+ createOptions("[Server]", "response", socket => {
server.stop();
socket.end();
}),
diff --git a/test/bun.js/socket/node-net.test.ts b/test/bun.js/socket/node-net.test.ts
index 3a6749533..e6c17d931 100644
--- a/test/bun.js/socket/node-net.test.ts
+++ b/test/bun.js/socket/node-net.test.ts
@@ -1,12 +1,4 @@
-import {
- afterAll,
- afterEach,
- beforeAll,
- beforeEach,
- describe,
- expect,
- it,
-} from "bun:test";
+import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from "bun:test";
import { connect, isIP, isIPv4, isIPv6, Socket } from "net";
it("should support net.isIP()", () => {
@@ -41,7 +33,7 @@ describe("net.Socket read", () => {
]) {
describe(label, () => {
function runWithServer(cb) {
- return (done) => {
+ return done => {
function drain(socket) {
const message = socket.data.message;
const written = socket.write(message);
@@ -94,7 +86,7 @@ describe("net.Socket read", () => {
expect(socket.connecting).toBe(false);
})
.setEncoding("utf8")
- .on("data", (chunk) => {
+ .on("data", chunk => {
data += chunk;
})
.on("end", () => {
@@ -120,7 +112,7 @@ describe("net.Socket read", () => {
expect(socket.connecting).toBe(false);
})
.setEncoding("utf8")
- .on("data", (chunk) => {
+ .on("data", chunk => {
data += chunk;
})
.on("end", () => {
@@ -146,7 +138,7 @@ describe("net.Socket read", () => {
expect(socket.connecting).toBe(false);
})
.setEncoding("utf8")
- .on("data", (chunk) => {
+ .on("data", chunk => {
data += chunk;
})
.on("end", () => {
@@ -169,7 +161,7 @@ describe("net.Socket write", () => {
let port = 53213;
function runWithServer(cb) {
- return (done) => {
+ return done => {
let server;
function close(socket) {
@@ -263,11 +255,11 @@ describe("net.Socket write", () => {
);
});
-it("should handle connection error", (done) => {
+it("should handle connection error", done => {
var data = {};
connect(55555, () => {
done(new Error("Should not have connected"));
- }).on("error", (error) => {
+ }).on("error", error => {
expect(error).toBeDefined();
expect(error.name).toBe("SystemError");
expect(error.message).toBe("Failed to connect");
diff --git a/test/bun.js/socket/socket.test.ts b/test/bun.js/socket/socket.test.ts
index 3c41c96f7..f7240bf72 100644
--- a/test/bun.js/socket/socket.test.ts
+++ b/test/bun.js/socket/socket.test.ts
@@ -45,7 +45,7 @@ it("listen() should throw connection error for invalid host", () => {
}).toThrow();
});
-it("should reject on connection error, calling both connectError() and rejecting the promise", (done) => {
+it("should reject on connection error, calling both connectError() and rejecting the promise", done => {
var data = {};
connect({
data,
@@ -80,7 +80,7 @@ it("should reject on connection error, calling both connectError() and rejecting
},
}).then(
() => done(new Error("Promise should reject instead")),
- (err) => {
+ err => {
expect(err).toBeDefined();
expect(err.name).toBe("SystemError");
expect(err.message).toBe("Failed to connect");
@@ -91,7 +91,7 @@ it("should reject on connection error, calling both connectError() and rejecting
});
// this also tests we mark the promise as handled if connectError() is called
-it("should handle connection error", (done) => {
+it("should handle connection error", done => {
var data = {};
connect({
data,
diff --git a/test/bun.js/some-fs.js b/test/bun.js/some-fs.js
index b22423dc7..c162ed45a 100644
--- a/test/bun.js/some-fs.js
+++ b/test/bun.js/some-fs.js
@@ -15,9 +15,7 @@ for (let i = 0; i < count; i++) {
}
if (existsSync(tempdir)) {
- throw new Error(
- `existsSync reports ${tempdir} exists, but it probably does not`,
- );
+ throw new Error(`existsSync reports ${tempdir} exists, but it probably does not`);
}
var origTempDir = tempdir;
@@ -39,13 +37,9 @@ for (let i = 0; i < total; i++) {
console.log("MKDIR " + total + " depth took:", performance.now() - start, "ms");
if (!existsSync(tempdir)) {
- throw new Error(
- "Expected directory to exist after mkdirSync, but it doesn't",
- );
+ throw new Error("Expected directory to exist after mkdirSync, but it doesn't");
}
if (mkdirSync(tempdir, { recursive: true })) {
- throw new Error(
- "mkdirSync shouldn't return directory name on existing directories",
- );
+ throw new Error("mkdirSync shouldn't return directory name on existing directories");
}
diff --git a/test/bun.js/spawn-streaming-stdin.test.ts b/test/bun.js/spawn-streaming-stdin.test.ts
index a71a0e2a9..74bf3dbc9 100644
--- a/test/bun.js/spawn-streaming-stdin.test.ts
+++ b/test/bun.js/spawn-streaming-stdin.test.ts
@@ -38,7 +38,7 @@ test("spawn can write to stdin multiple chunks", async () => {
while (true) {
proc.stdin.write("Wrote to stdin!\n");
inCounter++;
- await new Promise((resolve) => setTimeout(resolve, 8));
+ await new Promise(resolve => setTimeout(resolve, 8));
if (inCounter === 4) break;
}
@@ -46,9 +46,7 @@ test("spawn can write to stdin multiple chunks", async () => {
})();
await Promise.all([prom, prom2]);
- expect(Buffer.concat(chunks).toString().trim()).toBe(
- "Wrote to stdin!\n".repeat(4).trim(),
- );
+ expect(Buffer.concat(chunks).toString().trim()).toBe("Wrote to stdin!\n".repeat(4).trim());
await proc.exited;
})();
}
diff --git a/test/bun.js/spawn.test.ts b/test/bun.js/spawn.test.ts
index d34a217a8..84b0071ea 100644
--- a/test/bun.js/spawn.test.ts
+++ b/test/bun.js/spawn.test.ts
@@ -1,10 +1,4 @@
-import {
- ArrayBufferSink,
- readableStreamToText,
- spawn,
- spawnSync,
- write,
-} from "bun";
+import { ArrayBufferSink, readableStreamToText, spawn, spawnSync, write } from "bun";
import { describe, expect, it } from "bun:test";
import { gcTick as _gcTick } from "./gc";
import { rmdirSync, unlinkSync, rmSync, writeFileSync } from "node:fs";
@@ -99,9 +93,7 @@ for (let [gcTick, label] of [
});
gcTick();
await exited;
- expect(require("fs").readFileSync("/tmp/out.123.txt", "utf8")).toBe(
- hugeString,
- );
+ expect(require("fs").readFileSync("/tmp/out.123.txt", "utf8")).toBe(hugeString);
gcTick();
});
@@ -133,7 +125,7 @@ for (let [gcTick, label] of [
it("check exit code from onExit", async () => {
for (let i = 0; i < 1000; i++) {
var exitCode1, exitCode2;
- await new Promise<void>((resolve) => {
+ await new Promise<void>(resolve => {
var counter = 0;
spawn({
cmd: ["ls"],
@@ -343,10 +335,10 @@ for (let [gcTick, label] of [
var reader = process.stdout?.getReader();
reader?.closed.then(
- (a) => {
+ a => {
console.log("Closed!");
},
- (err) => {
+ err => {
console.log("Closed!", err);
},
);
diff --git a/test/bun.js/spawned-child.js b/test/bun.js/spawned-child.js
index 738d42f7e..263c566f9 100644
--- a/test/bun.js/spawned-child.js
+++ b/test/bun.js/spawned-child.js
@@ -12,7 +12,7 @@ if (TARGET === "STDIN") {
}
});
} else {
- process.stdin.on("data", (chunk) => {
+ process.stdin.on("data", chunk => {
data += chunk;
});
}
diff --git a/test/bun.js/sql-raw.test.js b/test/bun.js/sql-raw.test.js
index 6cf052e0e..9b6312dda 100644
--- a/test/bun.js/sql-raw.test.js
+++ b/test/bun.js/sql-raw.test.js
@@ -6,51 +6,34 @@ const dbPath = import.meta.dir + "/northwind.testdb";
it("works", () => {
const handle = SQL.open(dbPath);
- const stmt = SQL.prepare(
- handle,
- 'SELECT * FROM "Orders" WHERE OrderDate > date($date)',
- );
- expect(stmt.toString()).toBe(
- `SELECT * FROM "Orders" WHERE OrderDate > date(NULL)`,
- );
+ const stmt = SQL.prepare(handle, 'SELECT * FROM "Orders" WHERE OrderDate > date($date)');
+ expect(stmt.toString()).toBe(`SELECT * FROM "Orders" WHERE OrderDate > date(NULL)`);
expect(
Array.isArray(
stmt.all({
// do the conversion this way so that this test runs in multiple timezones
- $date: new Date(
- new Date(1996, 8, 1, 0, 0, 0, 0).toUTCString(),
- ).toISOString(),
+ $date: new Date(new Date(1996, 8, 1, 0, 0, 0, 0).toUTCString()).toISOString(),
}),
),
).toBe(true);
- expect(stmt.toString()).toBe(
- `SELECT * FROM "Orders" WHERE OrderDate > date('1996-09-01T07:00:00.000Z')`,
- );
+ expect(stmt.toString()).toBe(`SELECT * FROM "Orders" WHERE OrderDate > date('1996-09-01T07:00:00.000Z')`);
var ran = stmt.run({
- $date: new Date(
- new Date(1997, 8, 1, 0, 0, 0, 0).toUTCString(),
- ).toISOString(),
+ $date: new Date(new Date(1997, 8, 1, 0, 0, 0, 0).toUTCString()).toISOString(),
});
expect(Array.isArray(ran)).toBe(false);
expect(ran === undefined).toBe(true);
- expect(stmt.toString()).toBe(
- `SELECT * FROM "Orders" WHERE OrderDate > date('1997-09-01T07:00:00.000Z')`,
- );
+ expect(stmt.toString()).toBe(`SELECT * FROM "Orders" WHERE OrderDate > date('1997-09-01T07:00:00.000Z')`);
expect(
Array.isArray(
stmt.get({
- $date: new Date(
- new Date(1998, 8, 1, 0, 0, 0, 0).toUTCString(),
- ).toISOString(),
+ $date: new Date(new Date(1998, 8, 1, 0, 0, 0, 0).toUTCString()).toISOString(),
}),
),
).toBe(false);
- expect(stmt.toString()).toBe(
- `SELECT * FROM "Orders" WHERE OrderDate > date('1998-09-01T07:00:00.000Z')`,
- );
+ expect(stmt.toString()).toBe(`SELECT * FROM "Orders" WHERE OrderDate > date('1998-09-01T07:00:00.000Z')`);
expect(stmt.paramsCount).toBe(1);
expect(stmt.columnsCount).toBe(14);
expect(stmt.columns.length).toBe(14);
diff --git a/test/bun.js/sqlite.test.js b/test/bun.js/sqlite.test.js
index f78d3b481..3120283f4 100644
--- a/test/bun.js/sqlite.test.js
+++ b/test/bun.js/sqlite.test.js
@@ -4,15 +4,12 @@ import { existsSync, fstat, realpathSync, rmSync, writeFileSync } from "fs";
import { spawnSync } from "bun";
import { bunExe } from "bunExe";
import { tmpdir } from "os";
-var encode = (text) => new TextEncoder().encode(text);
+var encode = text => new TextEncoder().encode(text);
it("Database.open", () => {
// in a folder which doesn't exist
try {
- Database.open(
- "/this/database/does/not/exist.sqlite",
- constants.SQLITE_OPEN_READWRITE,
- );
+ Database.open("/this/database/does/not/exist.sqlite", constants.SQLITE_OPEN_READWRITE);
throw new Error("Expected an error to be thrown");
} catch (error) {
expect(error.message).toBe("unable to open database file");
@@ -20,10 +17,7 @@ it("Database.open", () => {
// in a file which doesn't exist
try {
- Database.open(
- `/tmp/database-${Math.random()}.sqlite`,
- constants.SQLITE_OPEN_READWRITE,
- );
+ Database.open(`/tmp/database-${Math.random()}.sqlite`, constants.SQLITE_OPEN_READWRITE);
throw new Error("Expected an error to be thrown");
} catch (error) {
expect(error.message).toBe("unable to open database file");
@@ -60,23 +54,17 @@ it("Database.open", () => {
it("upsert cross-process, see #1366", () => {
const dir = realpathSync(tmpdir()) + "/";
- const { exitCode } = spawnSync(
- [bunExe(), import.meta.dir + "/sqlite-cross-process.js"],
- {
- env: {
- SQLITE_DIR: dir,
- },
- stderr: "inherit",
+ const { exitCode } = spawnSync([bunExe(), import.meta.dir + "/sqlite-cross-process.js"], {
+ env: {
+ SQLITE_DIR: dir,
},
- );
+ stderr: "inherit",
+ });
expect(exitCode).toBe(0);
const db2 = Database.open(dir + "get-persist.sqlite");
- expect(db2.query(`SELECT id FROM examples`).all()).toEqual([
- { id: "hello" },
- { id: "world" },
- ]);
+ expect(db2.query(`SELECT id FROM examples`).all()).toEqual([{ id: "hello" }, { id: "world" }]);
});
it("creates", () => {
@@ -84,31 +72,11 @@ it("creates", () => {
db.exec(
"CREATE TABLE test (id INTEGER PRIMARY KEY, name TEXT, value INTEGER, created TEXT, deci FLOAT, blobby BLOB)",
);
- const stmt = db.prepare(
- "INSERT INTO test (name, value, deci, created, blobby) VALUES (?, ?, ?, ?, ?)",
- );
+ const stmt = db.prepare("INSERT INTO test (name, value, deci, created, blobby) VALUES (?, ?, ?, ?, ?)");
- stmt.run([
- "foo",
- 1,
- Math.fround(1.111),
- new Date(1995, 12, 19).toISOString(),
- encode("Hello World"),
- ]);
- stmt.run([
- "bar",
- 2,
- Math.fround(2.222),
- new Date(1995, 12, 19).toISOString(),
- encode("Hello World"),
- ]);
- stmt.run([
- "baz",
- 3,
- Math.fround(3.333),
- new Date(1995, 12, 19).toISOString(),
- encode("Hello World"),
- ]);
+ stmt.run(["foo", 1, Math.fround(1.111), new Date(1995, 12, 19).toISOString(), encode("Hello World")]);
+ stmt.run(["bar", 2, Math.fround(2.222), new Date(1995, 12, 19).toISOString(), encode("Hello World")]);
+ stmt.run(["baz", 3, Math.fround(3.333), new Date(1995, 12, 19).toISOString(), encode("Hello World")]);
stmt.finalize();
@@ -162,9 +130,7 @@ it("int52", () => {
const db = Database.open(":memory:");
db.exec("CREATE TABLE test (id INTEGER PRIMARY KEY, int64 INTEGER)");
db.run("INSERT INTO test (int64) VALUES (?)", Number.MAX_SAFE_INTEGER);
- expect(db.query("SELECT * FROM test").get().int64).toBe(
- Number.MAX_SAFE_INTEGER,
- );
+ expect(db.query("SELECT * FROM test").get().int64).toBe(Number.MAX_SAFE_INTEGER);
});
it("typechecks", () => {
@@ -175,7 +141,7 @@ it("typechecks", () => {
const q = db.prepare("SELECT * FROM test WHERE (name = ?)");
- var expectfail = (val) => {
+ var expectfail = val => {
try {
q.run([val]);
throw new Error("Expected error");
@@ -238,13 +204,7 @@ it("db.query supports TypedArray", () => {
}),
);
- expect(
- JSON.stringify(
- db
- .query("SELECT * FROM test WHERE (blobby = ?)")
- .get([encode("Hello World")]),
- ),
- ).toBe(
+ expect(JSON.stringify(db.query("SELECT * FROM test WHERE (blobby = ?)").get([encode("Hello World")]))).toBe(
JSON.stringify({
id: 1,
blobby: encode("Hello World"),
@@ -363,20 +323,12 @@ it("db.query()", () => {
}
// check that it supports multiple arguments
- expect(
- JSON.stringify(
- db
- .query("SELECT * FROM test where (name = ? OR name = ?)")
- .all(["Hello", "Fooooo"]),
- ),
- ).toBe(JSON.stringify([{ id: 1, name: "Hello" }]));
- expect(
- JSON.stringify(
- db
- .query("SELECT * FROM test where (name = ? OR name = ?)")
- .all("Hello", "Fooooo"),
- ),
- ).toBe(JSON.stringify([{ id: 1, name: "Hello" }]));
+ expect(JSON.stringify(db.query("SELECT * FROM test where (name = ? OR name = ?)").all(["Hello", "Fooooo"]))).toBe(
+ JSON.stringify([{ id: 1, name: "Hello" }]),
+ );
+ expect(JSON.stringify(db.query("SELECT * FROM test where (name = ? OR name = ?)").all("Hello", "Fooooo"))).toBe(
+ JSON.stringify([{ id: 1, name: "Hello" }]),
+ );
// throws if insufficeint arguments
try {
@@ -388,12 +340,10 @@ it("db.query()", () => {
// named parameters
expect(
JSON.stringify(
- db
- .query("SELECT * FROM test where (name = $hello OR name = $goodbye)")
- .all({
- $hello: "Hello",
- $goodbye: "Fooooo",
- }),
+ db.query("SELECT * FROM test where (name = $hello OR name = $goodbye)").all({
+ $hello: "Hello",
+ $goodbye: "Fooooo",
+ }),
),
).toBe(JSON.stringify([{ id: 1, name: "Hello" }]));
@@ -418,16 +368,12 @@ it("db.query()", () => {
it("db.transaction()", () => {
const db = Database.open(":memory:");
- db.exec(
- "CREATE TABLE cats (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT UNIQUE, age INTEGER)",
- );
+ db.exec("CREATE TABLE cats (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT UNIQUE, age INTEGER)");
- const insert = db.prepare(
- "INSERT INTO cats (name, age) VALUES (@name, @age)",
- );
+ const insert = db.prepare("INSERT INTO cats (name, age) VALUES (@name, @age)");
expect(db.inTransaction).toBe(false);
- const insertMany = db.transaction((cats) => {
+ const insertMany = db.transaction(cats => {
expect(db.inTransaction).toBe(true);
try {
for (const cat of cats) insert.run(cat);
@@ -466,9 +412,7 @@ it("db.transaction()", () => {
it("inlineCapacity #987", async () => {
const path = "/tmp/bun-987.db";
if (!existsSync(path)) {
- const arrayBuffer = await (
- await fetch("https://github.com/oven-sh/bun/files/9265429/logs.log")
- ).arrayBuffer();
+ const arrayBuffer = await (await fetch("https://github.com/oven-sh/bun/files/9265429/logs.log")).arrayBuffer();
writeFileSync(path, arrayBuffer);
}
@@ -522,9 +466,7 @@ it("inlineCapacity #987", async () => {
// https://github.com/oven-sh/bun/issues/1553
it("latin1 supplement chars", () => {
const db = new Database();
- db.run(
- "CREATE TABLE IF NOT EXISTS foo (id INTEGER PRIMARY KEY AUTOINCREMENT, greeting TEXT)",
- );
+ db.run("CREATE TABLE IF NOT EXISTS foo (id INTEGER PRIMARY KEY AUTOINCREMENT, greeting TEXT)");
db.run("INSERT INTO foo (greeting) VALUES (?)", "Welcome to bun!");
db.run("INSERT INTO foo (greeting) VALUES (?)", "Español");
db.run("INSERT INTO foo (greeting) VALUES (?)", "¿Qué sucedió?");
diff --git a/test/bun.js/stdio-test-instance-a-lot.js b/test/bun.js/stdio-test-instance-a-lot.js
index 2b65d786c..71815ddea 100644
--- a/test/bun.js/stdio-test-instance-a-lot.js
+++ b/test/bun.js/stdio-test-instance-a-lot.js
@@ -6,11 +6,7 @@ sink.write("hello");
sink.write(" ");
sink.write("world");
sink.write(new TextEncoder().encode("hello again|"));
-sink.write(
- new TextEncoder().encode(
- "😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌",
- ),
-);
+sink.write(new TextEncoder().encode("😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌"));
const string = Buffer.from(sink.end()).toString().repeat(9999);
diff --git a/test/bun.js/stdio-test-instance.js b/test/bun.js/stdio-test-instance.js
index 36e48f472..fd820dc25 100644
--- a/test/bun.js/stdio-test-instance.js
+++ b/test/bun.js/stdio-test-instance.js
@@ -2,8 +2,4 @@ process.stdout.write("hello");
process.stdout.write(" ");
process.stdout.write("world");
process.stdout.write(new TextEncoder().encode("hello again|"));
-process.stdout.write(
- new TextEncoder().encode(
- "😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌",
- ),
-);
+process.stdout.write(new TextEncoder().encode("😋 Get Emoji — All Emojis to ✂️ Copy and 📋 Paste 👌"));
diff --git a/test/bun.js/streams.test.js b/test/bun.js/streams.test.js
index ec803a9dd..253e4d2f2 100644
--- a/test/bun.js/streams.test.js
+++ b/test/bun.js/streams.test.js
@@ -1,9 +1,4 @@
-import {
- file,
- readableStreamToArrayBuffer,
- readableStreamToArray,
- readableStreamToText,
-} from "bun";
+import { file, readableStreamToArrayBuffer, readableStreamToArray, readableStreamToText } from "bun";
import { expect, it, beforeEach, afterEach, describe } from "bun:test";
import { mkfifo } from "mkfifo";
import { unlinkSync, writeFileSync } from "node:fs";
@@ -39,9 +34,7 @@ describe("WritableStream", () => {
await writer.close();
- expect(JSON.stringify(Array.from(Buffer.concat(chunks)))).toBe(
- JSON.stringify([1, 2, 3, 4, 5, 6]),
- );
+ expect(JSON.stringify(Array.from(Buffer.concat(chunks)))).toBe(JSON.stringify([1, 2, 3, 4, 5, 6]));
} catch (e) {
console.log(e);
console.log(e.stack);
@@ -245,11 +238,7 @@ it("Bun.file() read text from pipe", async () => {
const chunks = [];
const proc = Bun.spawn({
- cmd: [
- "bash",
- join(import.meta.dir + "/", "bun-streams-test-fifo.sh"),
- "/tmp/fifo",
- ],
+ cmd: ["bash", join(import.meta.dir + "/", "bun-streams-test-fifo.sh"), "/tmp/fifo"],
stderr: "inherit",
stdout: null,
stdin: null,
@@ -463,9 +452,7 @@ it("ReadableStream for Blob", async () => {
if (chunk.done) break;
chunks.push(new TextDecoder().decode(chunk.value));
}
- expect(chunks.join("")).toBe(
- new TextDecoder().decode(Buffer.from("abdefghijklmnop")),
- );
+ expect(chunks.join("")).toBe(new TextDecoder().decode(Buffer.from("abdefghijklmnop")));
});
it("ReadableStream for File", async () => {
@@ -481,7 +468,7 @@ it("ReadableStream for File", async () => {
}
reader = undefined;
const output = new Uint8Array(await blob.arrayBuffer()).join("");
- const input = chunks.map((a) => a.join("")).join("");
+ const input = chunks.map(a => a.join("")).join("");
expect(output).toBe(input);
});
diff --git a/test/bun.js/string-decoder.test.js b/test/bun.js/string-decoder.test.js
index 449f35620..4bc9d7e8b 100644
--- a/test/bun.js/string-decoder.test.js
+++ b/test/bun.js/string-decoder.test.js
@@ -4,9 +4,7 @@ import { withoutAggressiveGC } from "gc";
const RealStringDecoder = require("string_decoder").StringDecoder;
it("require('string_decoder')", async () => {
- expect((await import("string_decoder")).StringDecoder).toBe(
- RealStringDecoder,
- );
+ expect((await import("string_decoder")).StringDecoder).toBe(RealStringDecoder);
});
it("Bun.inspect(StringDecoder)", async () => {
@@ -35,9 +33,7 @@ for (const StringDecoder of [FakeStringDecoderCall, RealStringDecoder]) {
// U+3045 -> E3 81 85
test(
"utf-8",
- Buffer.from([
- 0xcb, 0xa4, 0x64, 0xe1, 0x8b, 0xa4, 0x30, 0xe3, 0x81, 0x85,
- ]),
+ Buffer.from([0xcb, 0xa4, 0x64, 0xe1, 0x8b, 0xa4, 0x30, 0xe3, 0x81, 0x85]),
"\u02e4\u0064\u12e4\u0030\u3045",
);
});
@@ -60,9 +56,7 @@ for (const StringDecoder of [FakeStringDecoderCall, RealStringDecoder]) {
expect(decoder.end()).toBe("");
decoder = new StringDecoder("utf8");
- expect(decoder.write(Buffer.from("\ufffd\ufffd\ufffd"))).toBe(
- "\ufffd\ufffd\ufffd",
- );
+ expect(decoder.write(Buffer.from("\ufffd\ufffd\ufffd"))).toBe("\ufffd\ufffd\ufffd");
expect(decoder.end()).toBe("");
decoder = new StringDecoder("utf8");
@@ -114,10 +108,10 @@ for (const StringDecoder of [FakeStringDecoderCall, RealStringDecoder]) {
} else {
sequences = [singleSequence];
}
- sequences.forEach((sequence) => {
+ sequences.forEach(sequence => {
const decoder = new StringDecoder(encoding);
let output = "";
- sequence.forEach((write) => {
+ sequence.forEach(write => {
output += decoder.write(input.slice(write[0], write[1]));
});
output += decoder.end();
@@ -146,28 +140,16 @@ for (const StringDecoder of [FakeStringDecoderCall, RealStringDecoder]) {
let sequences = [];
for (let end = length; end > start; end--) {
const subSequence = sequence.concat([[start, end]]);
- const subSequences = writeSequences(
- length,
- end,
- subSequence,
- sequences,
- );
+ const subSequences = writeSequences(length, end, subSequence, sequences);
sequences = sequences.concat(subSequences);
}
return sequences;
}
describe("StringDecoder.end", () => {
- const encodings = [
- "base64",
- "base64url",
- "hex",
- "utf8",
- "utf16le",
- "ucs2",
- ];
+ const encodings = ["base64", "base64url", "hex", "utf8", "utf16le", "ucs2"];
- const bufs = ["☃💩", "asdf"].map((b) => Buffer.from(b));
+ const bufs = ["☃💩", "asdf"].map(b => Buffer.from(b));
// Also test just arbitrary bytes from 0-15.
for (let i = 1; i <= 16; i++) {
@@ -189,72 +171,32 @@ for (const StringDecoder of [FakeStringDecoderCall, RealStringDecoder]) {
testEnd("utf8", Buffer.of(0xe2, 0x82, 0xac), Buffer.of(0x61), "€a");
testEnd("utf16le", Buffer.of(0x3d), Buffer.of(0x61, 0x00), "a");
- testEnd(
- "utf16le",
- Buffer.of(0x3d),
- Buffer.of(0xd8, 0x4d, 0xdc),
- "\u4DD8",
- );
+ testEnd("utf16le", Buffer.of(0x3d), Buffer.of(0xd8, 0x4d, 0xdc), "\u4DD8");
testEnd("utf16le", Buffer.of(0x3d, 0xd8), Buffer.of(), "\uD83D");
- testEnd(
- "utf16le",
- Buffer.of(0x3d, 0xd8),
- Buffer.of(0x61, 0x00),
- "\uD83Da",
- );
- testEnd(
- "utf16le",
- Buffer.of(0x3d, 0xd8),
- Buffer.of(0x4d, 0xdc),
- "\uD83D\uDC4D",
- );
+ testEnd("utf16le", Buffer.of(0x3d, 0xd8), Buffer.of(0x61, 0x00), "\uD83Da");
+ testEnd("utf16le", Buffer.of(0x3d, 0xd8), Buffer.of(0x4d, 0xdc), "\uD83D\uDC4D");
testEnd("utf16le", Buffer.of(0x3d, 0xd8, 0x4d), Buffer.of(), "\uD83D");
- testEnd(
- "utf16le",
- Buffer.of(0x3d, 0xd8, 0x4d),
- Buffer.of(0x61, 0x00),
- "\uD83Da",
- );
- testEnd(
- "utf16le",
- Buffer.of(0x3d, 0xd8, 0x4d),
- Buffer.of(0xdc),
- "\uD83D",
- );
- testEnd(
- "utf16le",
- Buffer.of(0x3d, 0xd8, 0x4d, 0xdc),
- Buffer.of(0x61, 0x00),
- "👍a",
- );
+ testEnd("utf16le", Buffer.of(0x3d, 0xd8, 0x4d), Buffer.of(0x61, 0x00), "\uD83Da");
+ testEnd("utf16le", Buffer.of(0x3d, 0xd8, 0x4d), Buffer.of(0xdc), "\uD83D");
+ testEnd("utf16le", Buffer.of(0x3d, 0xd8, 0x4d, 0xdc), Buffer.of(0x61, 0x00), "👍a");
testEnd("base64", Buffer.of(0x61), Buffer.of(), "YQ==");
testEnd("base64", Buffer.of(0x61), Buffer.of(0x61), "YQ==YQ==");
testEnd("base64", Buffer.of(0x61, 0x61), Buffer.of(), "YWE=");
testEnd("base64", Buffer.of(0x61, 0x61), Buffer.of(0x61), "YWE=YQ==");
testEnd("base64", Buffer.of(0x61, 0x61, 0x61), Buffer.of(), "YWFh");
- testEnd(
- "base64",
- Buffer.of(0x61, 0x61, 0x61),
- Buffer.of(0x61),
- "YWFhYQ==",
- );
+ testEnd("base64", Buffer.of(0x61, 0x61, 0x61), Buffer.of(0x61), "YWFhYQ==");
testEnd("base64url", Buffer.of(0x61), Buffer.of(), "YQ");
testEnd("base64url", Buffer.of(0x61), Buffer.of(0x61), "YQYQ");
testEnd("base64url", Buffer.of(0x61, 0x61), Buffer.of(), "YWE");
testEnd("base64url", Buffer.of(0x61, 0x61), Buffer.of(0x61), "YWEYQ");
testEnd("base64url", Buffer.of(0x61, 0x61, 0x61), Buffer.of(), "YWFh");
- testEnd(
- "base64url",
- Buffer.of(0x61, 0x61, 0x61),
- Buffer.of(0x61),
- "YWFhYQ",
- );
+ testEnd("base64url", Buffer.of(0x61, 0x61, 0x61), Buffer.of(0x61), "YWFhYQ");
function testEncoding(encoding) {
it(encoding + " testbuf", () => {
- bufs.forEach((buf) => {
+ bufs.forEach(buf => {
testBuf(encoding, buf);
});
});
diff --git a/test/bun.js/tcp-server.test.ts b/test/bun.js/tcp-server.test.ts
index 6ddacd662..6f3f869ec 100644
--- a/test/bun.js/tcp-server.test.ts
+++ b/test/bun.js/tcp-server.test.ts
@@ -1,10 +1,4 @@
-import {
- listen,
- connect,
- TCPSocketListener,
- TCPSocketOptions,
- SocketHandler,
-} from "bun";
+import { listen, connect, TCPSocketListener, TCPSocketOptions, SocketHandler } from "bun";
import { describe, expect, it } from "bun:test";
import * as JSC from "bun:jsc";
@@ -45,9 +39,7 @@ it("echo server 1 on 1", async () => {
if (serverData) serverData.other = clientData;
},
data(socket, buffer) {
- const msg = `${
- socket.data.isServer ? "server:" : "client:"
- } Hello World! ${socket.data.counter++}`;
+ const msg = `${socket.data.isServer ? "server:" : "client:"} Hello World! ${socket.data.counter++}`;
socket.data.sendQueue.push(msg);
expect(decoder.decode(buffer)).toBe(socket.data.other.sendQueue.pop());
@@ -155,14 +147,10 @@ describe("tcp socket binaryType", () => {
? Buffer
: Error),
).toBe(true);
- const msg = `${
- socket.data.isServer ? "server:" : "client:"
- } Hello World! ${socket.data.counter++}`;
+ const msg = `${socket.data.isServer ? "server:" : "client:"} Hello World! ${socket.data.counter++}`;
socket.data.sendQueue.push(msg);
- expect(decoder.decode(buffer)).toBe(
- socket.data.other.sendQueue.pop(),
- );
+ expect(decoder.decode(buffer)).toBe(socket.data.other.sendQueue.pop());
if (socket.data.counter > 10) {
if (!socket.data.finished) {
diff --git a/test/bun.js/test-test.test.ts b/test/bun.js/test-test.test.ts
index 321abd5e3..00a760abf 100644
--- a/test/bun.js/test-test.test.ts
+++ b/test/bun.js/test-test.test.ts
@@ -1205,25 +1205,15 @@ test("toHaveProperty() - with string or array", () => {
expect(houseForSale).toHaveProperty("bedrooms", 4);
expect(houseForSale).toHaveProperty(["sunroom"], "yes");
expect(houseForSale).toHaveProperty("kitchen.area", 20);
- expect(houseForSale).toHaveProperty("kitchen.amenities", [
- "oven",
- "stove",
- "washer",
- ]);
+ expect(houseForSale).toHaveProperty("kitchen.amenities", ["oven", "stove", "washer"]);
expect(houseForSale).not.toHaveProperty(["kitchen", "area"], 21);
expect(houseForSale).toHaveProperty(["kitchen", "area"], 20);
expect(houseForSale).not.toHaveProperty(["kitchen", "area"], 29);
- expect(houseForSale).toHaveProperty(
- ["kitchen", "amenities"],
- ["oven", "stove", "washer"],
- );
+ expect(houseForSale).toHaveProperty(["kitchen", "amenities"], ["oven", "stove", "washer"]);
expect(houseForSale).toHaveProperty("kitchen.amenities[2]", "washer");
expect(houseForSale).toHaveProperty(["kitchen", "amenities", 1], "stove");
expect(houseForSale).toHaveProperty(["kitchen", "amenities", 0], "oven");
- expect(houseForSale).toHaveProperty(
- "livingroom.amenities[0].couch[0][1].dimensions[0]",
- 20,
- );
+ expect(houseForSale).toHaveProperty("livingroom.amenities[0].couch[0][1].dimensions[0]", 20);
expect(houseForSale).toHaveProperty(["kitchen", "nice.oven"]);
expect(houseForSale).not.toHaveProperty(["kitchen", "open"]);
expect(houseForSale).toHaveProperty(["ceiling.height"], 20);
@@ -1327,10 +1317,7 @@ test("toHaveProperty() - all", () => {
// test object with property "a" with value set, map, string
expect({ a: new Set([1, 2, 3]) }).toHaveProperty("a", new Set([3, 2, 1]));
- expect({ a: new Map([{ a: 1 }, { b: 2 }, { c: 3 }]) }).toHaveProperty(
- "a",
- new Map([{ c: 3 }, { b: 2 }, { a: 1 }]),
- );
+ expect({ a: new Map([{ a: 1 }, { b: 2 }, { c: 3 }]) }).toHaveProperty("a", new Map([{ c: 3 }, { b: 2 }, { a: 1 }]));
expect({ a: new String("a") }).toHaveProperty("a", new String("a"));
expect({ a: new String("a") }).not.toHaveProperty("a", "a");
expect({ a: new String("a") }).not.toHaveProperty("a", "b");
@@ -1350,10 +1337,7 @@ test("toHaveProperty() - all", () => {
expect({ a: new String("a") }).not.toHaveProperty("a", Symbol("a"));
expect({ a: new String("a") }).not.toHaveProperty("a", new Int8Array());
expect({ a: new String("a") }).not.toHaveProperty("a", new Uint8Array());
- expect({ a: new String("a") }).not.toHaveProperty(
- "a",
- new Uint8ClampedArray(),
- );
+ expect({ a: new String("a") }).not.toHaveProperty("a", new Uint8ClampedArray());
expect({ a: new String("a") }).not.toHaveProperty("a", new Int16Array());
expect({ a: new String("a") }).not.toHaveProperty("a", new Uint16Array());
expect({ a: new String("a") }).not.toHaveProperty("a", new Int32Array());
@@ -1363,21 +1347,12 @@ test("toHaveProperty() - all", () => {
expect({ a: new String("a") }).not.toHaveProperty("a", new BigInt64Array());
expect({ a: new String("a") }).not.toHaveProperty("a", new BigUint64Array());
expect({ a: new String("a") }).not.toHaveProperty("a", new ArrayBuffer());
- expect({ a: new String("a") }).not.toHaveProperty(
- "a",
- new SharedArrayBuffer(),
- );
- expect({ a: new String("a") }).not.toHaveProperty(
- "a",
- new DataView(new ArrayBuffer(1)),
- );
+ expect({ a: new String("a") }).not.toHaveProperty("a", new SharedArrayBuffer());
+ expect({ a: new String("a") }).not.toHaveProperty("a", new DataView(new ArrayBuffer(1)));
// test property equality with sets, maps, objects, arrays, and String
expect({ a: new Set([1, 2, 3]) }).toHaveProperty("a", new Set([1, 2, 3]));
- expect({ a: new Map([{ a: 1 }, { b: 2 }, { c: 3 }]) }).toHaveProperty(
- "a",
- new Map([{ a: 1 }, { b: 2 }, { c: 3 }]),
- );
+ expect({ a: new Map([{ a: 1 }, { b: 2 }, { c: 3 }]) }).toHaveProperty("a", new Map([{ a: 1 }, { b: 2 }, { c: 3 }]));
expect({ a: { a: 1, b: 2, c: 3 } }).toHaveProperty("a", { a: 1, b: 2, c: 3 });
expect({ a: [1, 2, 3] }).toHaveProperty("a", [1, 2, 3]);
expect({ a: "a" }).toHaveProperty("a", "a");
@@ -1412,9 +1387,7 @@ test("toBe()", () => {
});
test("toHaveLength()", () => {
- expect({ length: Number.MAX_SAFE_INTEGER }).toHaveLength(
- Number.MAX_SAFE_INTEGER,
- );
+ expect({ length: Number.MAX_SAFE_INTEGER }).toHaveLength(Number.MAX_SAFE_INTEGER);
expect("123").toHaveLength(3);
expect([1, 2, 3]).toHaveLength(3);
expect([1, 2, 3]).not.toHaveLength(2);
@@ -1422,9 +1395,7 @@ test("toHaveLength()", () => {
expect({ length: 3 }).toHaveLength(3);
expect({ length: 3 }).not.toHaveLength(2);
expect({ length: 3 }).not.toHaveLength(Number.MAX_SAFE_INTEGER);
- expect({ length: Number.MAX_SAFE_INTEGER }).not.toHaveLength(
- Number.MAX_SAFE_INTEGER - 1,
- );
+ expect({ length: Number.MAX_SAFE_INTEGER }).not.toHaveLength(Number.MAX_SAFE_INTEGER - 1);
expect({ length: 3.3 }).not.toHaveLength(3);
expect("123").not.toHaveLength(-0);
});
@@ -1544,9 +1515,7 @@ test("toBeGreaterThan()", () => {
expect(1).not.toBeGreaterThan(Number.MAX_SAFE_INTEGER);
expect(1).not.toBeGreaterThan(BigInt(Number.MAX_SAFE_INTEGER));
expect(Number.MAX_SAFE_INTEGER).not.toBeGreaterThan(Number.MAX_SAFE_INTEGER);
- expect(BigInt(Number.MAX_SAFE_INTEGER)).not.toBeGreaterThan(
- BigInt(Number.MAX_SAFE_INTEGER),
- );
+ expect(BigInt(Number.MAX_SAFE_INTEGER)).not.toBeGreaterThan(BigInt(Number.MAX_SAFE_INTEGER));
expect(Infinity).toBeGreaterThan(-Infinity);
expect(-Infinity).not.toBeGreaterThan(Infinity);
@@ -1656,12 +1625,8 @@ test("toBeGreaterThanOrEqual()", () => {
expect(1).not.toBeGreaterThanOrEqual(Number.MAX_SAFE_INTEGER);
expect(1).not.toBeGreaterThanOrEqual(BigInt(Number.MAX_SAFE_INTEGER));
expect(1).not.toBeGreaterThanOrEqual(BigInt(Number.MAX_VALUE));
- expect(Number.MAX_SAFE_INTEGER).toBeGreaterThanOrEqual(
- Number.MAX_SAFE_INTEGER,
- );
- expect(BigInt(Number.MAX_SAFE_INTEGER)).toBeGreaterThanOrEqual(
- BigInt(Number.MAX_SAFE_INTEGER),
- );
+ expect(Number.MAX_SAFE_INTEGER).toBeGreaterThanOrEqual(Number.MAX_SAFE_INTEGER);
+ expect(BigInt(Number.MAX_SAFE_INTEGER)).toBeGreaterThanOrEqual(BigInt(Number.MAX_SAFE_INTEGER));
expect(Infinity).toBeGreaterThanOrEqual(-Infinity);
expect(-Infinity).not.toBeGreaterThanOrEqual(Infinity);
@@ -1766,9 +1731,7 @@ test("toBeLessThan()", () => {
expect(1).toBeLessThan(Number.MAX_SAFE_INTEGER);
expect(1).toBeLessThan(BigInt(Number.MAX_SAFE_INTEGER));
expect(Number.MAX_SAFE_INTEGER).not.toBeLessThan(Number.MAX_SAFE_INTEGER);
- expect(BigInt(Number.MAX_SAFE_INTEGER)).not.toBeLessThan(
- BigInt(Number.MAX_SAFE_INTEGER),
- );
+ expect(BigInt(Number.MAX_SAFE_INTEGER)).not.toBeLessThan(BigInt(Number.MAX_SAFE_INTEGER));
expect(Number.MAX_VALUE).not.toBeLessThan(BigInt(Number.MAX_VALUE));
@@ -1879,9 +1842,7 @@ test("toBeLessThanOrEqual()", () => {
expect(1).toBeLessThanOrEqual(Number.MAX_SAFE_INTEGER);
expect(1).toBeLessThanOrEqual(BigInt(Number.MAX_SAFE_INTEGER));
expect(Number.MAX_SAFE_INTEGER).toBeLessThanOrEqual(Number.MAX_SAFE_INTEGER);
- expect(BigInt(Number.MAX_SAFE_INTEGER)).toBeLessThanOrEqual(
- BigInt(Number.MAX_SAFE_INTEGER),
- );
+ expect(BigInt(Number.MAX_SAFE_INTEGER)).toBeLessThanOrEqual(BigInt(Number.MAX_SAFE_INTEGER));
expect(Number.MAX_VALUE).toBeLessThanOrEqual(BigInt(Number.MAX_VALUE));
expect(BigInt(Number.MAX_VALUE)).toBeLessThanOrEqual(Number.MAX_VALUE);
@@ -2085,18 +2046,12 @@ test("test async exceptions fail tests", () => {
try {
mkdirSync("/tmp/test-throwing-bun", { recursive: true });
} catch (e) {}
- writeFileSync(
- "/tmp/test-throwing-bun/test-throwing-eventemitter.test.js",
- code,
- );
+ writeFileSync("/tmp/test-throwing-bun/test-throwing-eventemitter.test.js", code);
- const { stderr, exitCode } = spawnSync(
- [bunExe(), "wiptest", "test-throwing-eventemitter"],
- {
- cwd: realpathSync("/tmp/test-throwing-bun"),
- env: bunEnv,
- },
- );
+ const { stderr, exitCode } = spawnSync([bunExe(), "wiptest", "test-throwing-eventemitter"], {
+ cwd: realpathSync("/tmp/test-throwing-bun"),
+ env: bunEnv,
+ });
const str = stderr!.toString();
expect(str).toContain("#FAIL001");
@@ -2111,7 +2066,7 @@ test("test async exceptions fail tests", () => {
expect(exitCode).toBe(1);
});
-it("should return non-zero exit code for invalid syntax", async() => {
+it("should return non-zero exit code for invalid syntax", async () => {
const test_dir = realpathSync(await mkdtemp(join(tmpdir(), "test")));
try {
await writeFile(join(test_dir, "bad.test.js"), "!!!");
diff --git a/test/bun.js/test-util-types.test.js b/test/bun.js/test-util-types.test.js
index ce10713e4..f33ab4b1a 100644
--- a/test/bun.js/test-util-types.test.js
+++ b/test/bun.js/test-util-types.test.js
@@ -54,8 +54,7 @@ for (const [value, _method] of [
for (const key of Object.keys(types)) {
if (
- ((types.isArrayBufferView(value) || types.isAnyArrayBuffer(value)) &&
- key.includes("Array")) ||
+ ((types.isArrayBufferView(value) || types.isAnyArrayBuffer(value)) && key.includes("Array")) ||
key === "isBoxedPrimitive"
) {
continue;
@@ -68,13 +67,9 @@ for (const [value, _method] of [
// Check boxed primitives.
test("isBoxedPrimitive", () => {
- [
- new Boolean(),
- new Number(),
- new String(),
- Object(Symbol()),
- Object(BigInt(0)),
- ].forEach((entry) => assert(types.isBoxedPrimitive(entry)));
+ [new Boolean(), new Number(), new String(), Object(Symbol()), Object(BigInt(0))].forEach(entry =>
+ assert(types.isBoxedPrimitive(entry)),
+ );
});
{
@@ -108,54 +103,18 @@ test("isBoxedPrimitive", () => {
const fakeBigInt64Array = Object.create(BigInt64Array.prototype);
const fakeBigUint64Array = Object.create(BigUint64Array.prototype);
- const stealthyDataView = Object.setPrototypeOf(
- new DataView(arrayBuffer),
- Uint8Array.prototype,
- );
- const stealthyUint8Array = Object.setPrototypeOf(
- new Uint8Array(arrayBuffer),
- ArrayBuffer.prototype,
- );
- const stealthyUint8ClampedArray = Object.setPrototypeOf(
- new Uint8ClampedArray(arrayBuffer),
- ArrayBuffer.prototype,
- );
- const stealthyUint16Array = Object.setPrototypeOf(
- new Uint16Array(arrayBuffer),
- Uint16Array.prototype,
- );
- const stealthyUint32Array = Object.setPrototypeOf(
- new Uint32Array(arrayBuffer),
- Uint32Array.prototype,
- );
- const stealthyInt8Array = Object.setPrototypeOf(
- new Int8Array(arrayBuffer),
- Int8Array.prototype,
- );
- const stealthyInt16Array = Object.setPrototypeOf(
- new Int16Array(arrayBuffer),
- Int16Array.prototype,
- );
- const stealthyInt32Array = Object.setPrototypeOf(
- new Int32Array(arrayBuffer),
- Int32Array.prototype,
- );
- const stealthyFloat32Array = Object.setPrototypeOf(
- new Float32Array(arrayBuffer),
- Float32Array.prototype,
- );
- const stealthyFloat64Array = Object.setPrototypeOf(
- new Float64Array(arrayBuffer),
- Float64Array.prototype,
- );
- const stealthyBigInt64Array = Object.setPrototypeOf(
- new BigInt64Array(arrayBuffer),
- BigInt64Array.prototype,
- );
- const stealthyBigUint64Array = Object.setPrototypeOf(
- new BigUint64Array(arrayBuffer),
- BigUint64Array.prototype,
- );
+ const stealthyDataView = Object.setPrototypeOf(new DataView(arrayBuffer), Uint8Array.prototype);
+ const stealthyUint8Array = Object.setPrototypeOf(new Uint8Array(arrayBuffer), ArrayBuffer.prototype);
+ const stealthyUint8ClampedArray = Object.setPrototypeOf(new Uint8ClampedArray(arrayBuffer), ArrayBuffer.prototype);
+ const stealthyUint16Array = Object.setPrototypeOf(new Uint16Array(arrayBuffer), Uint16Array.prototype);
+ const stealthyUint32Array = Object.setPrototypeOf(new Uint32Array(arrayBuffer), Uint32Array.prototype);
+ const stealthyInt8Array = Object.setPrototypeOf(new Int8Array(arrayBuffer), Int8Array.prototype);
+ const stealthyInt16Array = Object.setPrototypeOf(new Int16Array(arrayBuffer), Int16Array.prototype);
+ const stealthyInt32Array = Object.setPrototypeOf(new Int32Array(arrayBuffer), Int32Array.prototype);
+ const stealthyFloat32Array = Object.setPrototypeOf(new Float32Array(arrayBuffer), Float32Array.prototype);
+ const stealthyFloat64Array = Object.setPrototypeOf(new Float64Array(arrayBuffer), Float64Array.prototype);
+ const stealthyBigInt64Array = Object.setPrototypeOf(new BigInt64Array(arrayBuffer), BigInt64Array.prototype);
+ const stealthyBigUint64Array = Object.setPrototypeOf(new BigUint64Array(arrayBuffer), BigUint64Array.prototype);
const all = [
primitive,
diff --git a/test/bun.js/text-decoder.test.js b/test/bun.js/text-decoder.test.js
index a91eae318..be3f8421b 100644
--- a/test/bun.js/text-decoder.test.js
+++ b/test/bun.js/text-decoder.test.js
@@ -1,7 +1,7 @@
import { expect, it, describe } from "bun:test";
import { gc as gcTrace, withoutAggressiveGC } from "./gc";
-const getByteLength = (str) => {
+const getByteLength = str => {
// returns the byte length of an utf8 string
var s = str.length;
for (var i = str.length - 1; i >= 0; i--) {
@@ -17,13 +17,7 @@ describe("TextDecoder", () => {
it("should not crash on empty text", () => {
const decoder = new TextDecoder();
gcTrace(true);
- const fixtures = [
- new Uint8Array(),
- new Uint8Array([]),
- new Buffer(0),
- new ArrayBuffer(0),
- new Uint16Array(0),
- ];
+ const fixtures = [new Uint8Array(), new Uint8Array([]), new Buffer(0), new ArrayBuffer(0), new Uint16Array(0)];
for (let input of fixtures) {
expect(decoder.decode(input)).toBe("");
@@ -50,9 +44,7 @@ describe("TextDecoder", () => {
gcTrace(true);
const result = [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33];
gcTrace(true);
- expect(decoder.decode(Uint8Array.from(result))).toBe(
- String.fromCharCode(...result),
- );
+ expect(decoder.decode(Uint8Array.from(result))).toBe(String.fromCharCode(...result));
gcTrace(true);
});
@@ -61,9 +53,7 @@ describe("TextDecoder", () => {
gcTrace(true);
var text = `❤️ Red Heart`;
- const bytes = [
- 226, 157, 164, 239, 184, 143, 32, 82, 101, 100, 32, 72, 101, 97, 114, 116,
- ];
+ const bytes = [226, 157, 164, 239, 184, 143, 32, 82, 101, 100, 32, 72, 101, 97, 114, 116];
const decoded = decoder.decode(Uint8Array.from(bytes));
expect(decoder.encoding).toBe("utf-8");
@@ -134,30 +124,12 @@ it("truncated sequences", () => {
// Truncated sequences
assert_equals(new TextDecoder().decode(new Uint8Array([0xf0])), "\uFFFD");
- assert_equals(
- new TextDecoder().decode(new Uint8Array([0xf0, 0x9f])),
- "\uFFFD",
- );
- assert_equals(
- new TextDecoder().decode(new Uint8Array([0xf0, 0x9f, 0x92])),
- "\uFFFD",
- );
+ assert_equals(new TextDecoder().decode(new Uint8Array([0xf0, 0x9f])), "\uFFFD");
+ assert_equals(new TextDecoder().decode(new Uint8Array([0xf0, 0x9f, 0x92])), "\uFFFD");
// Errors near end-of-queue
- assert_equals(
- new TextDecoder().decode(new Uint8Array([0xf0, 0x9f, 0x41])),
- "\uFFFDA",
- );
- assert_equals(
- new TextDecoder().decode(new Uint8Array([0xf0, 0x41, 0x42])),
- "\uFFFDAB",
- );
- assert_equals(
- new TextDecoder().decode(new Uint8Array([0xf0, 0x41, 0xf0])),
- "\uFFFDA\uFFFD",
- );
- assert_equals(
- new TextDecoder().decode(new Uint8Array([0xf0, 0x8f, 0x92])),
- "\uFFFD\uFFFD\uFFFD",
- );
+ assert_equals(new TextDecoder().decode(new Uint8Array([0xf0, 0x9f, 0x41])), "\uFFFDA");
+ assert_equals(new TextDecoder().decode(new Uint8Array([0xf0, 0x41, 0x42])), "\uFFFDAB");
+ assert_equals(new TextDecoder().decode(new Uint8Array([0xf0, 0x41, 0xf0])), "\uFFFDA\uFFFD");
+ assert_equals(new TextDecoder().decode(new Uint8Array([0xf0, 0x8f, 0x92])), "\uFFFD\uFFFD\uFFFD");
});
diff --git a/test/bun.js/text-encoder.test.js b/test/bun.js/text-encoder.test.js
index 7d3a11032..3f1d2acee 100644
--- a/test/bun.js/text-encoder.test.js
+++ b/test/bun.js/text-encoder.test.js
@@ -1,7 +1,7 @@
import { expect, it, describe } from "bun:test";
import { gc as gcTrace, withoutAggressiveGC } from "./gc";
-const getByteLength = (str) => {
+const getByteLength = str => {
// returns the byte length of an utf8 string
var s = str.length;
for (var i = str.length - 1; i >= 0; i--) {
@@ -27,10 +27,7 @@ describe("TextEncoder", () => {
expect(out.read).toBe(text.length);
expect(encoded instanceof Uint8Array).toBe(true);
- const result = [
- 72, 194, 169, 101, 108, 108, 194, 169, 111, 32, 87, 111, 114, 194, 169,
- 108, 100, 33,
- ];
+ const result = [72, 194, 169, 101, 108, 108, 194, 169, 111, 32, 87, 111, 114, 194, 169, 108, 100, 33];
for (let i = 0; i < result.length; i++) {
expect(encoded[i]).toBe(result[i]);
expect(into[i]).toBe(result[i]);
@@ -83,7 +80,7 @@ describe("TextEncoder", () => {
const decoded = new TextDecoder().decode(encoded);
expect(decoded).toBe(text);
gcTrace();
- await new Promise((resolve) => setTimeout(resolve, 1));
+ await new Promise(resolve => setTimeout(resolve, 1));
gcTrace();
expect(decoded).toBe(text);
});
@@ -126,10 +123,7 @@ describe("TextEncoder", () => {
expect(out.read).toBe(text.length);
expect(encoded instanceof Uint8Array).toBe(true);
- const result = [
- 72, 194, 169, 101, 108, 108, 194, 169, 111, 32, 87, 111, 114, 194, 169,
- 108, 100, 33,
- ];
+ const result = [72, 194, 169, 101, 108, 108, 194, 169, 111, 32, 87, 111, 114, 194, 169, 108, 100, 33];
for (let i = 0; i < result.length; i++) {
expect(encoded[i]).toBe(into[i]);
@@ -195,14 +189,8 @@ describe("TextEncoder", () => {
bad.forEach(function (t) {
it(t.encoding + " - " + t.name, () => {
gcTrace(true);
- expect(
- new TextDecoder(t.encoding).decode(new Uint8Array(t.input)),
- ).toBe(t.expected);
- expect(
- new TextDecoder(t.encoding).decode(
- new Uint16Array(new Uint8Array(t.input).buffer),
- ),
- ).toBe(t.expected);
+ expect(new TextDecoder(t.encoding).decode(new Uint8Array(t.input))).toBe(t.expected);
+ expect(new TextDecoder(t.encoding).decode(new Uint16Array(new Uint8Array(t.input).buffer))).toBe(t.expected);
gcTrace(true);
});
// test(function () {
diff --git a/test/bun.js/third-party/body-parser-test/express-body-parser-test.test.ts b/test/bun.js/third-party/body-parser-test/express-body-parser-test.test.ts
index 905cc4ce2..8e0523b7c 100644
--- a/test/bun.js/third-party/body-parser-test/express-body-parser-test.test.ts
+++ b/test/bun.js/third-party/body-parser-test/express-body-parser-test.test.ts
@@ -7,10 +7,7 @@ test("iconv works", () => {
var iconv = require("iconv-lite");
// Convert from an encoded buffer to a js string.
- var str = iconv.decode(
- Buffer.from([0x68, 0x65, 0x6c, 0x6c, 0x6f]),
- "win1251",
- );
+ var str = iconv.decode(Buffer.from([0x68, 0x65, 0x6c, 0x6c, 0x6f]), "win1251");
// Convert from a js string to an encoded buffer.
var buf = iconv.encode("Sample input string", "win1251");
@@ -22,7 +19,7 @@ test("iconv works", () => {
});
// https://github.com/oven-sh/bun/issues/1913
-test("httpServer", async (done) => {
+test("httpServer", async done => {
// Constants
const PORT = 8412;
@@ -30,7 +27,7 @@ test("httpServer", async (done) => {
const app: Application = express();
const httpServer = require("http").createServer(app);
- app.on("error", (err) => {
+ app.on("error", err => {
done(err);
});
app.use(json());
diff --git a/test/bun.js/third-party/napi_create_external/napi-create-external.test.ts b/test/bun.js/third-party/napi_create_external/napi-create-external.test.ts
index 9084b5256..ca7e50b99 100644
--- a/test/bun.js/third-party/napi_create_external/napi-create-external.test.ts
+++ b/test/bun.js/third-party/napi_create_external/napi-create-external.test.ts
@@ -3,7 +3,7 @@ import { withoutAggressiveGC } from "gc";
import * as _ from "lodash";
function rebase(str, inBase, outBase) {
- const mapBase = (b) => (b === 2 ? 32 : b === 16 ? 8 : null);
+ const mapBase = b => (b === 2 ? 32 : b === 16 ? 8 : null);
const stride = mapBase(inBase);
const pad = mapBase(outBase);
if (!stride) throw new Error(`Bad inBase ${inBase}`);
@@ -31,10 +31,7 @@ class HashMaker {
_dist: any;
binToHex(binHash) {
- if (binHash.length !== this.length)
- throw new Error(
- `Hash length mismatch ${this.length} != ${binHash.length}`,
- );
+ if (binHash.length !== this.length) throw new Error(`Hash length mismatch ${this.length} != ${binHash.length}`);
return rebase(binHash, 2, 16);
}
@@ -46,8 +43,7 @@ class HashMaker {
makeRandom() {
const bits = [];
- for (let i = 0; i < this.length; i++)
- bits.push(Math.random() < 0.5 ? 1 : 0);
+ for (let i = 0; i < this.length; i++) bits.push(Math.random() < 0.5 ? 1 : 0);
return bits;
}
@@ -84,7 +80,7 @@ class HashMaker {
}
distance(a, b) {
- const bitCount = (n) => {
+ const bitCount = n => {
n = n - ((n >> 1) & 0x55555555);
n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
return (((n + (n >> 4)) & 0xf0f0f0f) * 0x1010101) >> 24;
@@ -126,20 +122,17 @@ withoutAggressiveGC(() => {
describe(`Key length: ${keyLen}`, () => {
it("should compute distance", () => {
const tree = new treeClass(keyLen);
- for (const a of hm.data)
- for (const b of hm.data)
- expect(tree.distance(a, b)).toBe(hm.distance(a, b));
+ for (const a of hm.data) for (const b of hm.data) expect(tree.distance(a, b)).toBe(hm.distance(a, b));
});
it("should know which keys it has", () => {
const tree = new treeClass(keyLen).add(hm.data);
expectDeepEqual(
- hm.data.map((hash) => tree.has(hash)),
+ hm.data.map(hash => tree.has(hash)),
hm.data.map(() => true),
);
// Not interested in the hash
- for (const hash of hm.data)
- expect(tree.has(hm.randomKey())).toBe(false);
+ for (const hash of hm.data) expect(tree.has(hm.randomKey())).toBe(false);
});
it("should know the tree size", () => {
@@ -166,9 +159,7 @@ withoutAggressiveGC(() => {
for (const baseKey of [hm.random, hm.data[0]]) {
const baseKey = hm.random;
const got = [];
- tree.query(baseKey, dist, (key, distance) =>
- got.push({ key, distance }),
- );
+ tree.query(baseKey, dist, (key, distance) => got.push({ key, distance }));
const want = hm.query(baseKey, dist);
expectDeepEqual(
got.sort((a, b) => a.distance - b.distance),
diff --git a/test/bun.js/toml.test.js b/test/bun.js/toml.test.js
index 900d30bf0..a1aa09a4c 100644
--- a/test/bun.js/toml.test.js
+++ b/test/bun.js/toml.test.js
@@ -19,12 +19,8 @@ it("syntax", async () => {
expect(toml.inline.array[0]).toBe(1234);
expect(toml.inline.array[1]).toBe(4);
expect(toml.dev["foo.bar"]).toBe("baz");
- expect(toml.install.scopes["@mybigcompany"].url).toBe(
- "https://registry.mybigcompany.com",
- );
- expect(toml.install.scopes["@mybigcompany2"].url).toBe(
- "https://registry.mybigcompany.com",
- );
+ expect(toml.install.scopes["@mybigcompany"].url).toBe("https://registry.mybigcompany.com");
+ expect(toml.install.scopes["@mybigcompany2"].url).toBe("https://registry.mybigcompany.com");
expect(toml.install.scopes["@mybigcompany3"].three).toBe(4);
gc();
});
diff --git a/test/bun.js/transpiler.test.js b/test/bun.js/transpiler.test.js
index 62df8d76b..352e0c2ec 100644
--- a/test/bun.js/transpiler.test.js
+++ b/test/bun.js/transpiler.test.js
@@ -66,18 +66,12 @@ describe("Bun.Transpiler", () => {
};
it("normalizes \\r\\n", () => {
- ts.expectPrinted_(
- "console.log(`\r\n\r\n\r\n`)",
- "console.log(`\n\n\n`);\n",
- );
+ ts.expectPrinted_("console.log(`\r\n\r\n\r\n`)", "console.log(`\n\n\n`);\n");
});
describe("TypeScript", () => {
it("import Foo = Baz.Bar", () => {
- ts.expectPrinted_(
- "import Foo = Baz.Bar;\nexport default Foo;",
- "const Foo = Baz.Bar;\nexport default Foo",
- );
+ ts.expectPrinted_("import Foo = Baz.Bar;\nexport default Foo;", "const Foo = Baz.Bar;\nexport default Foo");
});
it("modifiers", () => {
@@ -90,56 +84,23 @@ describe("Bun.Transpiler", () => {
exp("class Foo { declare public foo: number }", "class Foo {\n}");
exp("class Foo { public declare foo: number }", "class Foo {\n}");
exp("class Foo { override foo: number }", "class Foo {\n foo;\n}");
- exp(
- "class Foo { override public foo: number }",
- "class Foo {\n foo;\n}",
- );
- exp(
- "class Foo { public override foo: number }",
- "class Foo {\n foo;\n}",
- );
- exp(
- "class Foo { declare override public foo: number }",
- "class Foo {\n}",
- );
+ exp("class Foo { override public foo: number }", "class Foo {\n foo;\n}");
+ exp("class Foo { public override foo: number }", "class Foo {\n foo;\n}");
+ exp("class Foo { declare override public foo: number }", "class Foo {\n}");
exp("class Foo { declare foo = 123 }", "class Foo {\n}");
- exp(
- "class Foo { public static foo: number }",
- "class Foo {\n static foo;\n}",
- );
- exp(
- "class Foo { private static foo: number }",
- "class Foo {\n static foo;\n}",
- );
- exp(
- "class Foo { protected static foo: number }",
- "class Foo {\n static foo;\n}",
- );
+ exp("class Foo { public static foo: number }", "class Foo {\n static foo;\n}");
+ exp("class Foo { private static foo: number }", "class Foo {\n static foo;\n}");
+ exp("class Foo { protected static foo: number }", "class Foo {\n static foo;\n}");
exp("class Foo { declare static foo: number }", "class Foo {\n}");
exp("class Foo { declare public static foo: number }", "class Foo {\n}");
exp("class Foo { public declare static foo: number }", "class Foo {\n}");
exp("class Foo { public static declare foo: number }", "class Foo {\n}");
- exp(
- "class Foo { override static foo: number }",
- "class Foo {\n static foo;\n}",
- );
- exp(
- "class Foo { override public static foo: number }",
- "class Foo {\n static foo;\n}",
- );
- exp(
- "class Foo { public override static foo: number }",
- "class Foo {\n static foo;\n}",
- );
- exp(
- "class Foo { public static override foo: number }",
- "class Foo {\n static foo;\n}",
- );
- exp(
- "class Foo { declare override public static foo: number }",
- "class Foo {\n}",
- );
+ exp("class Foo { override static foo: number }", "class Foo {\n static foo;\n}");
+ exp("class Foo { override public static foo: number }", "class Foo {\n static foo;\n}");
+ exp("class Foo { public override static foo: number }", "class Foo {\n static foo;\n}");
+ exp("class Foo { public static override foo: number }", "class Foo {\n static foo;\n}");
+ exp("class Foo { declare override public static foo: number }", "class Foo {\n}");
exp("class Foo { declare static foo = 123 }", "class Foo {\n}");
exp("class Foo { static declare foo = 123 }", "class Foo {\n}");
@@ -225,19 +186,12 @@ class Test extends Bar {
.trim()
.replaceAll("\n", "")
.replaceAll(" ", ""),
- ).toBe(
- ("var Test = " + out.trim() + ";\n")
- .replaceAll("\n", "")
- .replaceAll(" ", ""),
- );
+ ).toBe(("var Test = " + out.trim() + ";\n").replaceAll("\n", "").replaceAll(" ", ""));
}
});
it("import Foo = require('bar')", () => {
- ts.expectPrinted_(
- "import React = require('react')",
- 'const React = require("react")',
- );
+ ts.expectPrinted_("import React = require('react')", 'const React = require("react")');
});
it("import type Foo = require('bar')", () => {
@@ -249,10 +203,7 @@ class Test extends Bar {
});
it("export import Foo = Baz.Bar", () => {
- ts.expectPrinted_(
- "export import Foo = Baz.Bar;",
- "export const Foo = Baz.Bar",
- );
+ ts.expectPrinted_("export import Foo = Baz.Bar;", "export const Foo = Baz.Bar");
});
it("export = {foo: 123}", () => {
@@ -285,43 +236,16 @@ export default class {
});
it("satisfies", () => {
- ts.expectPrinted_(
- "const t1 = { a: 1 } satisfies I1;",
- "const t1 = { a: 1 };\n",
- );
- ts.expectPrinted_(
- "const t2 = { a: 1, b: 1 } satisfies I1;",
- "const t2 = { a: 1, b: 1 };\n",
- );
+ ts.expectPrinted_("const t1 = { a: 1 } satisfies I1;", "const t1 = { a: 1 };\n");
+ ts.expectPrinted_("const t2 = { a: 1, b: 1 } satisfies I1;", "const t2 = { a: 1, b: 1 };\n");
ts.expectPrinted_("const t3 = { } satisfies I1;", "const t3 = {};\n");
- ts.expectPrinted_(
- "const t4: T1 = { a: 'a' } satisfies T1;",
- 'const t4 = { a: "a" };\n',
- );
- ts.expectPrinted_(
- "const t5 = (m => m.substring(0)) satisfies T2;",
- "const t5 = (m) => m.substring(0);\n",
- );
- ts.expectPrinted_(
- "const t6 = [1, 2] satisfies [number, number];",
- "const t6 = [1, 2];\n",
- );
- ts.expectPrinted_(
- "let t7 = { a: 'test' } satisfies A;",
- 'let t7 = { a: "test" };\n',
- );
- ts.expectPrinted_(
- "let t8 = { a: 'test', b: 'test' } satisfies A;",
- 'let t8 = { a: "test", b: "test" };\n',
- );
- ts.expectPrinted_(
- "export default {} satisfies Foo;",
- "export default {};\n",
- );
- ts.expectPrinted_(
- "export default { a: 1 } satisfies Foo;",
- "export default { a: 1 };\n",
- );
+ ts.expectPrinted_("const t4: T1 = { a: 'a' } satisfies T1;", 'const t4 = { a: "a" };\n');
+ ts.expectPrinted_("const t5 = (m => m.substring(0)) satisfies T2;", "const t5 = (m) => m.substring(0);\n");
+ ts.expectPrinted_("const t6 = [1, 2] satisfies [number, number];", "const t6 = [1, 2];\n");
+ ts.expectPrinted_("let t7 = { a: 'test' } satisfies A;", 'let t7 = { a: "test" };\n');
+ ts.expectPrinted_("let t8 = { a: 'test', b: 'test' } satisfies A;", 'let t8 = { a: "test", b: "test" };\n');
+ ts.expectPrinted_("export default {} satisfies Foo;", "export default {};\n");
+ ts.expectPrinted_("export default { a: 1 } satisfies Foo;", "export default { a: 1 };\n");
ts.expectPrinted_(
"const p = { isEven: n => n % 2 === 0, isOdd: n => n % 2 === 1 } satisfies Predicates;",
"const p = { isEven: (n) => n % 2 === 0, isOdd: (n) => n % 2 === 1 };\n",
@@ -334,14 +258,8 @@ export default class {
"const car = { start() { }, move(d) { }, stop() { } } satisfies Movable & Record<string, unknown>;",
"const car = { start() {\n}, move(d) {\n}, stop() {\n} };\n",
);
- ts.expectPrinted_(
- "var v = undefined satisfies 1;",
- "var v = undefined;\n",
- );
- ts.expectPrinted_(
- "const a = { x: 10 } satisfies Partial<Point2d>;",
- "const a = { x: 10 };\n",
- );
+ ts.expectPrinted_("var v = undefined satisfies 1;", "var v = undefined;\n");
+ ts.expectPrinted_("const a = { x: 10 } satisfies Partial<Point2d>;", "const a = { x: 10 };\n");
ts.expectPrinted_(
'const p = { a: 0, b: "hello", x: 8 } satisfies Partial<Record<Keys, unknown>>;',
'const p = { a: 0, b: "hello", x: 8 };\n',
@@ -350,18 +268,12 @@ export default class {
'const p = { a: 0, b: "hello", x: 8 } satisfies Record<Keys, unknown>;',
'const p = { a: 0, b: "hello", x: 8 };\n',
);
- ts.expectPrinted_(
- 'const x2 = { m: true, s: "false" } satisfies Facts;',
- 'const x2 = { m: true, s: "false" };\n',
- );
+ ts.expectPrinted_('const x2 = { m: true, s: "false" } satisfies Facts;', 'const x2 = { m: true, s: "false" };\n');
ts.expectPrinted_(
"export const Palette = { white: { r: 255, g: 255, b: 255 }, black: { r: 0, g: 0, d: 0 }, blue: { r: 0, g: 0, b: 255 }, } satisfies Record<string, Color>;",
"export const Palette = { white: { r: 255, g: 255, b: 255 }, black: { r: 0, g: 0, d: 0 }, blue: { r: 0, g: 0, b: 255 } };\n",
);
- ts.expectPrinted_(
- 'const a: "baz" = "foo" satisfies "foo" | "bar";',
- 'const a = "foo";\n',
- );
+ ts.expectPrinted_('const a: "baz" = "foo" satisfies "foo" | "bar";', 'const a = "foo";\n');
ts.expectPrinted_(
'const b: { xyz: "baz" } = { xyz: "foo" } satisfies { xyz: "foo" | "bar" };',
'const b = { xyz: "foo" };\n',
@@ -685,9 +597,7 @@ export default <>hi</>
}, undefined, false, undefined, this);
`,
);
- expect(
- bun.transformSync("export var hi = <div {foo['baz'].bar?.baz} />"),
- ).toBe(
+ expect(bun.transformSync("export var hi = <div {foo['baz'].bar?.baz} />")).toBe(
`export var hi = $jsx("div", {
baz: foo["baz"].bar?.baz
}, undefined, false, undefined, this);
@@ -695,28 +605,20 @@ export default <>hi</>
);
// cursed
- expect(
- bun.transformSync(
- "export var hi = <div {foo[{name: () => true}.name].hi} />",
- ),
- ).toBe(
+ expect(bun.transformSync("export var hi = <div {foo[{name: () => true}.name].hi} />")).toBe(
`export var hi = $jsx("div", {
hi: foo[{ name: () => true }.name].hi
}, undefined, false, undefined, this);
`,
);
- expect(
- bun.transformSync("export var hi = <Foo {process.env.NODE_ENV} />"),
- ).toBe(
+ expect(bun.transformSync("export var hi = <Foo {process.env.NODE_ENV} />")).toBe(
`export var hi = $jsx(Foo, {
NODE_ENV: "development"
}, undefined, false, undefined, this);
`,
);
- expect(
- bun.transformSync("export var hi = <div {foo['baz'].bar?.baz} />"),
- ).toBe(
+ expect(bun.transformSync("export var hi = <div {foo['baz'].bar?.baz} />")).toBe(
`export var hi = $jsx("div", {
baz: foo["baz"].bar?.baz
}, undefined, false, undefined, this);
@@ -729,18 +631,14 @@ export default <>hi</>
expect(e.errors[0].message.includes('Expected ">"')).toBe(true);
}
- expect(
- bun.transformSync("export var hi = <div {Foo}><Foo></Foo></div>"),
- ).toBe(
+ expect(bun.transformSync("export var hi = <div {Foo}><Foo></Foo></div>")).toBe(
`export var hi = $jsx("div", {
Foo,
children: $jsx(Foo, {}, undefined, false, undefined, this)
}, undefined, false, undefined, this);
`,
);
- expect(
- bun.transformSync("export var hi = <div {Foo}><Foo></Foo></div>"),
- ).toBe(
+ expect(bun.transformSync("export var hi = <div {Foo}><Foo></Foo></div>")).toBe(
`export var hi = $jsx("div", {
Foo,
children: $jsx(Foo, {}, undefined, false, undefined, this)
@@ -841,27 +739,19 @@ export var ComponentThatHasSpreadCausesDeopt = $jsx(Hello, {
it("require with a dynamic non-string expression", () => {
var nodeTranspiler = new Bun.Transpiler({ platform: "node" });
- expect(nodeTranspiler.transformSync("require('hi' + bar)")).toBe(
- 'require("hi" + bar);\n',
- );
+ expect(nodeTranspiler.transformSync("require('hi' + bar)")).toBe('require("hi" + bar);\n');
});
it("CommonJS", () => {
var nodeTranspiler = new Bun.Transpiler({ platform: "node" });
- expect(nodeTranspiler.transformSync("module.require('hi' + 123)")).toBe(
- 'require("hi" + 123);\n',
- );
+ expect(nodeTranspiler.transformSync("module.require('hi' + 123)")).toBe('require("hi" + 123);\n');
- expect(
- nodeTranspiler.transformSync("module.require(1 ? 'foo' : 'bar')"),
- ).toBe('require("foo");\n');
- expect(nodeTranspiler.transformSync("require(1 ? 'foo' : 'bar')")).toBe(
- 'require("foo");\n',
- );
+ expect(nodeTranspiler.transformSync("module.require(1 ? 'foo' : 'bar')")).toBe('require("foo");\n');
+ expect(nodeTranspiler.transformSync("require(1 ? 'foo' : 'bar')")).toBe('require("foo");\n');
- expect(
- nodeTranspiler.transformSync("module.require(unknown ? 'foo' : 'bar')"),
- ).toBe('unknown ? require("foo") : require("bar");\n');
+ expect(nodeTranspiler.transformSync("module.require(unknown ? 'foo' : 'bar')")).toBe(
+ 'unknown ? require("foo") : require("bar");\n',
+ );
});
describe("regressions", () => {
@@ -908,12 +798,7 @@ export var ComponentThatHasSpreadCausesDeopt = $jsx(Hello, {
});
});
- const parsed = (
- code,
- trim = true,
- autoExport = false,
- transpiler_ = transpiler,
- ) => {
+ const parsed = (code, trim = true, autoExport = false, transpiler_ = transpiler) => {
if (autoExport) {
code = "export default (" + code + ")";
}
@@ -1058,10 +943,7 @@ export var ComponentThatHasSpreadCausesDeopt = $jsx(Hello, {
expectPrinted("await (x * y)", "await (x * y)");
expectPrinted("await (x ** y)", "await (x ** y)");
- expectPrinted_(
- "async function f() { await delete x }",
- "async function f() {\n await delete x;\n}",
- );
+ expectPrinted_("async function f() { await delete x }", "async function f() {\n await delete x;\n}");
// expectParseError(
// "await delete x",
@@ -1070,25 +952,13 @@ export var ComponentThatHasSpreadCausesDeopt = $jsx(Hello, {
});
it("import assert", () => {
- expectPrinted_(
- `import json from "./foo.json" assert { type: "json" };`,
- `import json from "./foo.json"`,
- );
- expectPrinted_(
- `import json from "./foo.json";`,
- `import json from "./foo.json"`,
- );
- expectPrinted_(
- `import("./foo.json", { type: "json" });`,
- `import("./foo.json")`,
- );
+ expectPrinted_(`import json from "./foo.json" assert { type: "json" };`, `import json from "./foo.json"`);
+ expectPrinted_(`import json from "./foo.json";`, `import json from "./foo.json"`);
+ expectPrinted_(`import("./foo.json", { type: "json" });`, `import("./foo.json")`);
});
it("import with unicode escape", () => {
- expectPrinted_(
- `import { name } from 'mod\\u1011';`,
- `import {name} from "mod\\u1011"`,
- );
+ expectPrinted_(`import { name } from 'mod\\u1011';`, `import {name} from "mod\\u1011"`);
});
it("fold string addition", () => {
@@ -1105,26 +975,14 @@ console.log(a)
`.trim(),
);
- expectPrinted_(
- `export const foo = "a" + "b";`,
- `export const foo = "ab"`,
- );
+ expectPrinted_(`export const foo = "a" + "b";`, `export const foo = "ab"`);
expectPrinted_(
`export const foo = "F" + "0" + "F" + "0123456789" + "ABCDEF" + "0123456789ABCDEFF0123456789ABCDEF00" + "b";`,
`export const foo = "F0F0123456789ABCDEF0123456789ABCDEFF0123456789ABCDEF00b"`,
);
- expectPrinted_(
- `export const foo = "a" + 1 + "b";`,
- `export const foo = "a" + 1 + "b"`,
- );
- expectPrinted_(
- `export const foo = "a" + "b" + 1 + "b";`,
- `export const foo = "ab" + 1 + "b"`,
- );
- expectPrinted_(
- `export const foo = "a" + "b" + 1 + "b" + "c";`,
- `export const foo = "ab" + 1 + "bc"`,
- );
+ expectPrinted_(`export const foo = "a" + 1 + "b";`, `export const foo = "a" + 1 + "b"`);
+ expectPrinted_(`export const foo = "a" + "b" + 1 + "b";`, `export const foo = "ab" + 1 + "b"`);
+ expectPrinted_(`export const foo = "a" + "b" + 1 + "b" + "c";`, `export const foo = "ab" + 1 + "bc"`);
});
it("numeric constants", () => {
@@ -1242,14 +1100,8 @@ export const { dead } = { dead: "hello world!" };
});
it("rewrite string to length", () => {
- expectPrinted_(
- `export const foo = "a".length + "b".length;`,
- `export const foo = 1 + 1`,
- );
- expectBunPrinted_(
- `export const foo = "a".length + "b".length;`,
- `export const foo = 2`,
- );
+ expectPrinted_(`export const foo = "a".length + "b".length;`, `export const foo = 1 + 1`);
+ expectBunPrinted_(`export const foo = "a".length + "b".length;`, `export const foo = 2`);
});
describe("Bun.js", () => {
@@ -1296,35 +1148,20 @@ console.log(resolve.length)
it('require.resolve("my-module") -> "/resolved/my-module"', () => {
// the module resolver & linker doesn't run with Bun.Transpiler
// so in this test, it becomes the same path string
- expectPrinted_(
- `export const foo = require.resolve('my-module')`,
- `export const foo = "my-module"`,
- );
+ expectPrinted_(`export const foo = require.resolve('my-module')`, `export const foo = "my-module"`);
});
});
it("define", () => {
- expectPrinted_(
- `export default typeof user_undefined === 'undefined';`,
- `export default true`,
- );
- expectPrinted_(
- `export default typeof user_undefined !== 'undefined';`,
- `export default false`,
- );
+ expectPrinted_(`export default typeof user_undefined === 'undefined';`, `export default true`);
+ expectPrinted_(`export default typeof user_undefined !== 'undefined';`, `export default false`);
- expectPrinted_(
- `export default typeof user_undefined !== 'undefined';`,
- `export default false`,
- );
+ expectPrinted_(`export default typeof user_undefined !== 'undefined';`, `export default false`);
expectPrinted_(`export default !user_undefined;`, `export default true`);
});
it("jsx symbol should work", () => {
- expectBunPrinted_(
- `var x = jsx; export default x;`,
- "var x = jsx;\nexport default x",
- );
+ expectBunPrinted_(`var x = jsx; export default x;`, "var x = jsx;\nexport default x");
});
it("decls", () => {
@@ -1349,18 +1186,9 @@ console.log(resolve.length)
expectParseError("const []", "This constant must be initialized");
// expectParseError("for (var x;;) ;", "");
// expectParseError("for (let x;;) ;", "");
- expectParseError(
- "for (const x;;) ;",
- 'The constant "x" must be initialized',
- );
- expectParseError(
- "for (const {};;) ;",
- "This constant must be initialized",
- );
- expectParseError(
- "for (const [];;) ;",
- "This constant must be initialized",
- );
+ expectParseError("for (const x;;) ;", 'The constant "x" must be initialized');
+ expectParseError("for (const {};;) ;", "This constant must be initialized");
+ expectParseError("for (const [];;) ;", "This constant must be initialized");
// Make sure bindings are visited during parsing
expectPrinted_("var {[x]: y} = {}", "var { [x]: y } = {}");
@@ -1370,15 +1198,9 @@ console.log(resolve.length)
expectPrinted_("var [...x] = []", "var [...x] = []");
expectPrinted_("var {...x} = {}", "var { ...x } = {}");
- expectPrinted_(
- "export var foo = ([...x] = []) => {}",
- "export var foo = ([...x] = []) => {\n}",
- );
+ expectPrinted_("export var foo = ([...x] = []) => {}", "export var foo = ([...x] = []) => {\n}");
- expectPrinted_(
- "export var foo = ({...x} = {}) => {}",
- "export var foo = ({ ...x } = {}) => {\n}",
- );
+ expectPrinted_("export var foo = ({...x} = {}) => {}", "export var foo = ({ ...x } = {}) => {\n}");
expectParseError("var [...x,] = []", 'Unexpected "," after rest pattern');
expectParseError("var {...x,} = {}", 'Unexpected "," after rest pattern');
@@ -1386,10 +1208,7 @@ console.log(resolve.length)
"export default function() { return ([...x,] = []) => {} }",
"Unexpected trailing comma after rest element",
);
- expectParseError(
- "({...x,} = {}) => {}",
- "Unexpected trailing comma after rest element",
- );
+ expectParseError("({...x,} = {}) => {}", "Unexpected trailing comma after rest element");
expectPrinted_("[b, ...c] = d", "[b, ...c] = d");
expectPrinted_("([b, ...c] = d)", "[b, ...c] = d");
@@ -1417,14 +1236,8 @@ console.log(resolve.length)
expectParseError("({}) = {}", "Invalid assignment target");
expectParseError("[([])] = [[]]", "Invalid assignment target");
expectParseError("({x: ({})} = {x: {}})", "Invalid assignment target");
- expectParseError(
- "(([]) = []) => {}",
- "Unexpected parentheses in binding pattern",
- );
- expectParseError(
- "(({}) = {}) => {}",
- "Unexpected parentheses in binding pattern",
- );
+ expectParseError("(([]) = []) => {}", "Unexpected parentheses in binding pattern");
+ expectParseError("(({}) = {}) => {}", "Unexpected parentheses in binding pattern");
expectParseError("function f(([]) = []) {}", "Parse error");
expectParseError(
"function f(({}) = {}) {}",
@@ -1448,14 +1261,8 @@ console.log(resolve.length)
expectParseError("[[...a, b]] = c", 'Unexpected "," after rest pattern');
expectParseError("[{...a, b}] = c", 'Unexpected "," after rest pattern');
- expectParseError(
- "({x: [...a, b]} = c)",
- 'Unexpected "," after rest pattern',
- );
- expectParseError(
- "({x: {...a, b}} = c)",
- 'Unexpected "," after rest pattern',
- );
+ expectParseError("({x: [...a, b]} = c)", 'Unexpected "," after rest pattern');
+ expectParseError("({x: {...a, b}} = c)", 'Unexpected "," after rest pattern');
expectParseError("[b, ...c,] = d", 'Unexpected "," after rest pattern');
expectParseError("([b, ...c,] = d)", 'Unexpected "," after rest pattern');
expectParseError("({b, ...c,} = d)", 'Unexpected "," after rest pattern');
@@ -1463,27 +1270,15 @@ console.log(resolve.length)
expectParseError("({x = {a = b}} = c)", 'Unexpected "="');
expectParseError("[a = {b = c}] = d", 'Unexpected "="');
- expectPrinted_(
- "for ([{a = {}}] in b) {}",
- "for ([{ a = {} }] in b) {\n}",
- );
- expectPrinted_(
- "for ([{a = {}}] of b) {}",
- "for ([{ a = {} }] of b) {\n}",
- );
+ expectPrinted_("for ([{a = {}}] in b) {}", "for ([{ a = {} }] in b) {\n}");
+ expectPrinted_("for ([{a = {}}] of b) {}", "for ([{ a = {} }] of b) {\n}");
expectPrinted_("for ({a = {}} in b) {}", "for ({ a = {} } in b) {\n}");
expectPrinted_("for ({a = {}} of b) {}", "for ({ a = {} } of b) {\n}");
expectParseError("({a = {}} in b)", 'Unexpected "="');
expectParseError("[{a = {}}]\nof()", 'Unexpected "="');
- expectParseError(
- "for ([...a, b] in c) {}",
- 'Unexpected "," after rest pattern',
- );
- expectParseError(
- "for ([...a, b] of c) {}",
- 'Unexpected "," after rest pattern',
- );
+ expectParseError("for ([...a, b] in c) {}", 'Unexpected "," after rest pattern');
+ expectParseError("for ([...a, b] of c) {}", 'Unexpected "," after rest pattern');
});
it("regexp", () => {
@@ -1496,22 +1291,13 @@ console.log(resolve.length)
expectPrinted("/gimme/g", "/gimme/g");
expectPrinted("/gimgim/g", "/gimgim/g");
- expectParseError(
- "/x/msuygig",
- 'Duplicate flag "g" in regular expression',
- );
+ expectParseError("/x/msuygig", 'Duplicate flag "g" in regular expression');
});
it("identifier escapes", () => {
expectPrinted_("var _\u0076\u0061\u0072", "var _var");
- expectParseError(
- "var \u0076\u0061\u0072",
- 'Expected identifier but found "\u0076\u0061\u0072"',
- );
- expectParseError(
- "\\u0076\\u0061\\u0072 foo",
- "Unexpected \\u0076\\u0061\\u0072",
- );
+ expectParseError("var \u0076\u0061\u0072", 'Expected identifier but found "\u0076\u0061\u0072"');
+ expectParseError("\\u0076\\u0061\\u0072 foo", "Unexpected \\u0076\\u0061\\u0072");
expectPrinted_("foo._\u0076\u0061\u0072", "foo._var");
expectPrinted_("foo.\u0076\u0061\u0072", "foo.var");
@@ -1527,111 +1313,42 @@ console.log(resolve.length)
expectParseError("this.#foo", 'Expected identifier but found "#foo"');
expectParseError("this?.#foo", 'Expected identifier but found "#foo"');
expectParseError("({ #foo: 1 })", 'Expected identifier but found "#foo"');
- expectParseError(
- "class Foo { x = { #foo: 1 } }",
- 'Expected identifier but found "#foo"',
- );
+ expectParseError("class Foo { x = { #foo: 1 } }", 'Expected identifier but found "#foo"');
expectParseError("class Foo { x = #foo }", 'Expected "in" but found "}"');
- expectParseError(
- "class Foo { #foo; foo() { delete this.#foo } }",
- 'Deleting the private name "#foo" is forbidden',
- );
+ expectParseError("class Foo { #foo; foo() { delete this.#foo } }", 'Deleting the private name "#foo" is forbidden');
expectParseError(
"class Foo { #foo; foo() { delete this?.#foo } }",
'Deleting the private name "#foo" is forbidden',
);
- expectParseError(
- "class Foo extends Bar { #foo; foo() { super.#foo } }",
- 'Expected identifier but found "#foo"',
- );
- expectParseError(
- "class Foo { #foo = () => { for (#foo in this) ; } }",
- "Unexpected #foo",
- );
- expectParseError(
- "class Foo { #foo = () => { for (x = #foo in this) ; } }",
- "Unexpected #foo",
- );
+ expectParseError("class Foo extends Bar { #foo; foo() { super.#foo } }", 'Expected identifier but found "#foo"');
+ expectParseError("class Foo { #foo = () => { for (#foo in this) ; } }", "Unexpected #foo");
+ expectParseError("class Foo { #foo = () => { for (x = #foo in this) ; } }", "Unexpected #foo");
expectPrinted_("class Foo { #foo }", "class Foo {\n #foo;\n}");
expectPrinted_("class Foo { #foo = 1 }", "class Foo {\n #foo = 1;\n}");
- expectPrinted_(
- "class Foo { #foo = #foo in this }",
- "class Foo {\n #foo = #foo in this;\n}",
- );
+ expectPrinted_("class Foo { #foo = #foo in this }", "class Foo {\n #foo = #foo in this;\n}");
expectPrinted_(
"class Foo { #foo = #foo in (#bar in this); #bar }",
"class Foo {\n #foo = #foo in (#bar in this);\n #bar;\n}",
);
- expectPrinted_(
- "class Foo { #foo() {} }",
- "class Foo {\n #foo() {\n }\n}",
- );
- expectPrinted_(
- "class Foo { get #foo() {} }",
- "class Foo {\n get #foo() {\n }\n}",
- );
- expectPrinted_(
- "class Foo { set #foo(x) {} }",
- "class Foo {\n set #foo(x) {\n }\n}",
- );
- expectPrinted_(
- "class Foo { static #foo }",
- "class Foo {\n static #foo;\n}",
- );
- expectPrinted_(
- "class Foo { static #foo = 1 }",
- "class Foo {\n static #foo = 1;\n}",
- );
- expectPrinted_(
- "class Foo { static #foo() {} }",
- "class Foo {\n static #foo() {\n }\n}",
- );
- expectPrinted_(
- "class Foo { static get #foo() {} }",
- "class Foo {\n static get #foo() {\n }\n}",
- );
- expectPrinted_(
- "class Foo { static set #foo(x) {} }",
- "class Foo {\n static set #foo(x) {\n }\n}",
- );
-
- expectParseError(
- "class Foo { #foo = #foo in #bar in this; #bar }",
- "Unexpected #bar",
- );
-
- expectParseError(
- "class Foo { #constructor }",
- 'Invalid field name "#constructor"',
- );
- expectParseError(
- "class Foo { #constructor() {} }",
- 'Invalid method name "#constructor"',
- );
- expectParseError(
- "class Foo { static #constructor }",
- 'Invalid field name "#constructor"',
- );
- expectParseError(
- "class Foo { static #constructor() {} }",
- 'Invalid method name "#constructor"',
- );
- expectParseError(
- "class Foo { #\\u0063onstructor }",
- 'Invalid field name "#constructor"',
- );
- expectParseError(
- "class Foo { #\\u0063onstructor() {} }",
- 'Invalid method name "#constructor"',
- );
- expectParseError(
- "class Foo { static #\\u0063onstructor }",
- 'Invalid field name "#constructor"',
- );
- expectParseError(
- "class Foo { static #\\u0063onstructor() {} }",
- 'Invalid method name "#constructor"',
- );
+ expectPrinted_("class Foo { #foo() {} }", "class Foo {\n #foo() {\n }\n}");
+ expectPrinted_("class Foo { get #foo() {} }", "class Foo {\n get #foo() {\n }\n}");
+ expectPrinted_("class Foo { set #foo(x) {} }", "class Foo {\n set #foo(x) {\n }\n}");
+ expectPrinted_("class Foo { static #foo }", "class Foo {\n static #foo;\n}");
+ expectPrinted_("class Foo { static #foo = 1 }", "class Foo {\n static #foo = 1;\n}");
+ expectPrinted_("class Foo { static #foo() {} }", "class Foo {\n static #foo() {\n }\n}");
+ expectPrinted_("class Foo { static get #foo() {} }", "class Foo {\n static get #foo() {\n }\n}");
+ expectPrinted_("class Foo { static set #foo(x) {} }", "class Foo {\n static set #foo(x) {\n }\n}");
+
+ expectParseError("class Foo { #foo = #foo in #bar in this; #bar }", "Unexpected #bar");
+
+ expectParseError("class Foo { #constructor }", 'Invalid field name "#constructor"');
+ expectParseError("class Foo { #constructor() {} }", 'Invalid method name "#constructor"');
+ expectParseError("class Foo { static #constructor }", 'Invalid field name "#constructor"');
+ expectParseError("class Foo { static #constructor() {} }", 'Invalid method name "#constructor"');
+ expectParseError("class Foo { #\\u0063onstructor }", 'Invalid field name "#constructor"');
+ expectParseError("class Foo { #\\u0063onstructor() {} }", 'Invalid method name "#constructor"');
+ expectParseError("class Foo { static #\\u0063onstructor }", 'Invalid field name "#constructor"');
+ expectParseError("class Foo { static #\\u0063onstructor() {} }", 'Invalid method name "#constructor"');
const errorText = '"#foo" has already been declared';
expectParseError("class Foo { #foo; #foo }", errorText);
expectParseError("class Foo { #foo; static #foo }", errorText);
@@ -1644,14 +1361,8 @@ console.log(resolve.length)
expectParseError("class Foo { set #foo(x) {} #foo }", errorText);
expectParseError("class Foo { get #foo() {} get #foo() {} }", errorText);
expectParseError("class Foo { set #foo(x) {} set #foo(x) {} }", errorText);
- expectParseError(
- "class Foo { get #foo() {} set #foo(x) {} #foo }",
- errorText,
- );
- expectParseError(
- "class Foo { set #foo(x) {} get #foo() {} #foo }",
- errorText,
- );
+ expectParseError("class Foo { get #foo() {} set #foo(x) {} #foo }", errorText);
+ expectParseError("class Foo { set #foo(x) {} get #foo() {} #foo }", errorText);
expectPrinted_(
"class Foo { get #foo() {} set #foo(x) { this.#foo } }",
@@ -1661,18 +1372,9 @@ console.log(resolve.length)
"class Foo { set #foo(x) { this.#foo } get #foo() {} }",
"class Foo {\n set #foo(x) {\n this.#foo;\n }\n get #foo() {\n }\n}",
);
- expectPrinted_(
- "class Foo { #foo } class Bar { #foo }",
- "class Foo {\n #foo;\n}\n\nclass Bar {\n #foo;\n}",
- );
- expectPrinted_(
- "class Foo { foo = this.#foo; #foo }",
- "class Foo {\n foo = this.#foo;\n #foo;\n}",
- );
- expectPrinted_(
- "class Foo { foo = this?.#foo; #foo }",
- "class Foo {\n foo = this?.#foo;\n #foo;\n}",
- );
+ expectPrinted_("class Foo { #foo } class Bar { #foo }", "class Foo {\n #foo;\n}\n\nclass Bar {\n #foo;\n}");
+ expectPrinted_("class Foo { foo = this.#foo; #foo }", "class Foo {\n foo = this.#foo;\n #foo;\n}");
+ expectPrinted_("class Foo { foo = this?.#foo; #foo }", "class Foo {\n foo = this?.#foo;\n #foo;\n}");
expectParseError(
"class Foo { #foo } class Bar { foo = this.#foo }",
'Private name "#foo" must be declared in an enclosing class',
@@ -1728,66 +1430,21 @@ console.log(resolve.length)
expectPrinted_("export type {foo} from 'bar'; x", "x");
expectPrinted_("export type {foo} from 'bar'\nx", "x");
expectPrinted_("export type {default} from 'bar'", "");
- expectPrinted_(
- "export { type } from 'mod'; type",
- 'export { type } from "mod";\ntype',
- );
- expectPrinted_(
- "export { type, as } from 'mod'",
- 'export { type, as } from "mod"',
- );
- expectPrinted_(
- "export { x, type foo } from 'mod'; x",
- 'export { x } from "mod";\nx',
- );
- expectPrinted_(
- "export { x, type as } from 'mod'; x",
- 'export { x } from "mod";\nx',
- );
- expectPrinted_(
- "export { x, type foo as bar } from 'mod'; x",
- 'export { x } from "mod";\nx',
- );
- expectPrinted_(
- "export { x, type foo as as } from 'mod'; x",
- 'export { x } from "mod";\nx',
- );
- expectPrinted_(
- "export { type as as } from 'mod'; as",
- 'export { type as as } from "mod";\nas',
- );
- expectPrinted_(
- "export { type as foo } from 'mod'; foo",
- 'export { type as foo } from "mod";\nfoo',
- );
- expectPrinted_(
- "export { type as type } from 'mod'; type",
- 'export { type } from "mod";\ntype',
- );
- expectPrinted_(
- "export { x, type as as foo } from 'mod'; x",
- 'export { x } from "mod";\nx',
- );
- expectPrinted_(
- "export { x, type as as as } from 'mod'; x",
- 'export { x } from "mod";\nx',
- );
- expectPrinted_(
- "export { x, type type as as } from 'mod'; x",
- 'export { x } from "mod";\nx',
- );
- expectPrinted_(
- "export { x, \\u0074ype y }; let x, y",
- "export { x };\nlet x, y",
- );
- expectPrinted_(
- "export { x, \\u0074ype y } from 'mod'",
- 'export { x } from "mod"',
- );
- expectPrinted_(
- "export { x, type if } from 'mod'",
- 'export { x } from "mod"',
- );
+ expectPrinted_("export { type } from 'mod'; type", 'export { type } from "mod";\ntype');
+ expectPrinted_("export { type, as } from 'mod'", 'export { type, as } from "mod"');
+ expectPrinted_("export { x, type foo } from 'mod'; x", 'export { x } from "mod";\nx');
+ expectPrinted_("export { x, type as } from 'mod'; x", 'export { x } from "mod";\nx');
+ expectPrinted_("export { x, type foo as bar } from 'mod'; x", 'export { x } from "mod";\nx');
+ expectPrinted_("export { x, type foo as as } from 'mod'; x", 'export { x } from "mod";\nx');
+ expectPrinted_("export { type as as } from 'mod'; as", 'export { type as as } from "mod";\nas');
+ expectPrinted_("export { type as foo } from 'mod'; foo", 'export { type as foo } from "mod";\nfoo');
+ expectPrinted_("export { type as type } from 'mod'; type", 'export { type } from "mod";\ntype');
+ expectPrinted_("export { x, type as as foo } from 'mod'; x", 'export { x } from "mod";\nx');
+ expectPrinted_("export { x, type as as as } from 'mod'; x", 'export { x } from "mod";\nx');
+ expectPrinted_("export { x, type type as as } from 'mod'; x", 'export { x } from "mod";\nx');
+ expectPrinted_("export { x, \\u0074ype y }; let x, y", "export { x };\nlet x, y");
+ expectPrinted_("export { x, \\u0074ype y } from 'mod'", 'export { x } from "mod"');
+ expectPrinted_("export { x, type if } from 'mod'", 'export { x } from "mod"');
expectPrinted_("export { x, type y as if }; let x", "export { x };\nlet x");
expectPrinted_("export { type x };", "");
});
@@ -1820,74 +1477,26 @@ class Foo {
});
it("class static blocks", () => {
- expectPrinted_(
- "class Foo { static {} }",
- "class Foo {\n static {\n }\n}",
- );
- expectPrinted_(
- "class Foo { static {} x = 1 }",
- "class Foo {\n static {\n }\n x = 1;\n}",
- );
- expectPrinted_(
- "class Foo { static { this.foo() } }",
- "class Foo {\n static {\n this.foo();\n }\n}",
- );
-
- expectParseError(
- "class Foo { static { yield } }",
- '"yield" is a reserved word and cannot be used in strict mode',
- );
- expectParseError(
- "class Foo { static { await } }",
- 'The keyword "await" cannot be used here',
- );
- expectParseError(
- "class Foo { static { return } }",
- "A return statement cannot be used here",
- );
- expectParseError(
- "class Foo { static { break } }",
- 'Cannot use "break" here',
- );
- expectParseError(
- "class Foo { static { continue } }",
- 'Cannot use "continue" here',
- );
- expectParseError(
- "x: { class Foo { static { break x } } }",
- 'There is no containing label named "x"',
- );
- expectParseError(
- "x: { class Foo { static { continue x } } }",
- 'There is no containing label named "x"',
- );
-
- expectParseError(
- "class Foo { get #x() { this.#x = 1 } }",
- 'Writing to getter-only property "#x" will throw',
- );
- expectParseError(
- "class Foo { get #x() { this.#x += 1 } }",
- 'Writing to getter-only property "#x" will throw',
- );
- expectParseError(
- "class Foo { set #x(x) { this.#x } }",
- 'Reading from setter-only property "#x" will throw',
- );
- expectParseError(
- "class Foo { set #x(x) { this.#x += 1 } }",
- 'Reading from setter-only property "#x" will throw',
- );
+ expectPrinted_("class Foo { static {} }", "class Foo {\n static {\n }\n}");
+ expectPrinted_("class Foo { static {} x = 1 }", "class Foo {\n static {\n }\n x = 1;\n}");
+ expectPrinted_("class Foo { static { this.foo() } }", "class Foo {\n static {\n this.foo();\n }\n}");
+
+ expectParseError("class Foo { static { yield } }", '"yield" is a reserved word and cannot be used in strict mode');
+ expectParseError("class Foo { static { await } }", 'The keyword "await" cannot be used here');
+ expectParseError("class Foo { static { return } }", "A return statement cannot be used here");
+ expectParseError("class Foo { static { break } }", 'Cannot use "break" here');
+ expectParseError("class Foo { static { continue } }", 'Cannot use "continue" here');
+ expectParseError("x: { class Foo { static { break x } } }", 'There is no containing label named "x"');
+ expectParseError("x: { class Foo { static { continue x } } }", 'There is no containing label named "x"');
+
+ expectParseError("class Foo { get #x() { this.#x = 1 } }", 'Writing to getter-only property "#x" will throw');
+ expectParseError("class Foo { get #x() { this.#x += 1 } }", 'Writing to getter-only property "#x" will throw');
+ expectParseError("class Foo { set #x(x) { this.#x } }", 'Reading from setter-only property "#x" will throw');
+ expectParseError("class Foo { set #x(x) { this.#x += 1 } }", 'Reading from setter-only property "#x" will throw');
// Writing to method warnings
- expectParseError(
- "class Foo { #x() { this.#x = 1 } }",
- 'Writing to read-only method "#x" will throw',
- );
- expectParseError(
- "class Foo { #x() { this.#x += 1 } }",
- 'Writing to read-only method "#x" will throw',
- );
+ expectParseError("class Foo { #x() { this.#x = 1 } }", 'Writing to read-only method "#x" will throw');
+ expectParseError("class Foo { #x() { this.#x += 1 } }", 'Writing to read-only method "#x" will throw');
});
describe("simplification", () => {
@@ -1908,11 +1517,7 @@ class Foo {
.transformSync("export function hello() {\n" + input + "\n}")
.trim()
.replaceAll(/^ /gm, ""),
- ).toBe(
- "export function hello() {\n" +
- output +
- "\n}".replaceAll(/^ /gm, ""),
- );
+ ).toBe("export function hello() {\n" + output + "\n}".replaceAll(/^ /gm, ""));
}
check("const x = 1; return x", "return 1;");
@@ -1920,10 +1525,7 @@ class Foo {
check("const x = 1; return x + x", "return 2;");
check("const x = 1; return x + x + 1", "return 3;");
check("const x = 1; return x + x + x", "return 3;");
- check(
- `const foo = "foo"; const bar = "bar"; return foo + bar`,
- `return "foobar";`,
- );
+ check(`const foo = "foo"; const bar = "bar"; return foo + bar`, `return "foobar";`);
check(
`
@@ -2055,11 +1657,7 @@ console.log(foo, array);
.transformSync("export function hello() {\n" + input + "\n}")
.trim()
.replaceAll(/^ /gm, ""),
- ).toBe(
- "export function hello() {\n" +
- output +
- "\n}".replaceAll(/^ /gm, ""),
- );
+ ).toBe("export function hello() {\n" + output + "\n}".replaceAll(/^ /gm, ""));
}
check("var x = 1; return x", "var x = 1;\nreturn x;");
check("let x = 1; return x", "return 1;");
@@ -2102,15 +1700,9 @@ console.log(foo, array);
check("let x = fn(); return x + arg0", "return fn() + arg0;");
check("let x = fn(); return arg0 + x", "let x = fn();\nreturn arg0 + x;");
check("let x = fn(); return x + fn2()", "return fn() + fn2();");
- check(
- "let x = fn(); return fn2() + x",
- "let x = fn();\nreturn fn2() + x;",
- );
+ check("let x = fn(); return fn2() + x", "let x = fn();\nreturn fn2() + x;");
check("let x = fn(); return x + undef", "return fn() + undef;");
- check(
- "let x = fn(); return undef + x",
- "let x = fn();\nreturn undef + x;",
- );
+ check("let x = fn(); return undef + x", "let x = fn();\nreturn undef + x;");
// Cannot substitute into mutating unary operators
check("let x = 1; ++x", "let x = 1;\n++x;");
@@ -2188,48 +1780,24 @@ console.log(foo, array);
// Cannot substitute code with side effects into branches
check("let x = fn(); return x ? arg0 : y;", "return fn() ? arg0 : y;");
- check(
- "let x = fn(); return arg0 ? x : y;",
- "let x = fn();\nreturn arg0 ? x : y;",
- );
- check(
- "let x = fn(); return arg0 ? y : x;",
- "let x = fn();\nreturn arg0 ? y : x;",
- );
+ check("let x = fn(); return arg0 ? x : y;", "let x = fn();\nreturn arg0 ? x : y;");
+ check("let x = fn(); return arg0 ? y : x;", "let x = fn();\nreturn arg0 ? y : x;");
check("let x = fn(); return x || arg0;", "return fn() || arg0;");
check("let x = fn(); return x && arg0;", "return fn() && arg0;");
check("let x = fn(); return x ?? arg0;", "return fn() ?? arg0;");
- check(
- "let x = fn(); return arg0 || x;",
- "let x = fn();\nreturn arg0 || x;",
- );
- check(
- "let x = fn(); return arg0 && x;",
- "let x = fn();\nreturn arg0 && x;",
- );
- check(
- "let x = fn(); return arg0 ?? x;",
- "let x = fn();\nreturn arg0 ?? x;",
- );
+ check("let x = fn(); return arg0 || x;", "let x = fn();\nreturn arg0 || x;");
+ check("let x = fn(); return arg0 && x;", "let x = fn();\nreturn arg0 && x;");
+ check("let x = fn(); return arg0 ?? x;", "let x = fn();\nreturn arg0 ?? x;");
// Test chaining
- check(
- "let x = fn(); let y = x[prop]; let z = y.val; throw z",
- "throw fn()[prop].val;",
- );
- check(
- "let x = fn(), y = x[prop], z = y.val; throw z",
- "throw fn()[prop].val;",
- );
+ check("let x = fn(); let y = x[prop]; let z = y.val; throw z", "throw fn()[prop].val;");
+ check("let x = fn(), y = x[prop], z = y.val; throw z", "throw fn()[prop].val;");
// Can substitute an initializer with side effects
check("let x = 0; let y = ++x; return y", "let x = 0;\nreturn ++x;");
// Can substitute an initializer without side effects past an expression without side effects
- check(
- "let x = 0; let y = x; return [x, y]",
- "let x = 0;\nreturn [x, x];",
- );
+ check("let x = 0; let y = x; return [x, y]", "let x = 0;\nreturn [x, x];");
// TODO: merge s_local
// Cannot substitute an initializer with side effects past an expression without side effects
@@ -2248,20 +1816,14 @@ console.log(foo, array);
// Cannot inline past a spread operator, since that evaluates code
check("let x = arg0; return [...x];", "return [...arg0];");
check("let x = arg0; return [x, ...arg1];", "return [arg0, ...arg1];");
- check(
- "let x = arg0; return [...arg1, x];",
- "let x = arg0;\nreturn [...arg1, x];",
- );
+ check("let x = arg0; return [...arg1, x];", "let x = arg0;\nreturn [...arg1, x];");
// TODO: preserve call here
// check("let x = arg0; return arg1(...x);", "return arg1(...arg0);");
// check(
// "let x = arg0; return arg1(x, ...arg1);",
// "return arg1(arg0, ...arg1);",
// );
- check(
- "let x = arg0; return arg1(...arg1, x);",
- "let x = arg0;\nreturn arg1(...arg1, x);",
- );
+ check("let x = arg0; return arg1(...arg1, x);", "let x = arg0;\nreturn arg1(...arg1, x);");
// Test various statement kinds
// TODO:
@@ -2270,20 +1832,11 @@ console.log(foo, array);
check("let x = arg0; throw x;", "throw arg0;");
check("let x = arg0; return x;", "return arg0;");
check("let x = arg0; if (x) return 1;", "if (arg0)\n return 1;");
- check(
- "let x = arg0; switch (x) { case 0: return 1; }",
- "switch (arg0) {\n case 0:\n return 1;\n}",
- );
- check(
- "let x = arg0; let y = x; return y + y;",
- "let y = arg0;\nreturn y + y;",
- );
+ check("let x = arg0; switch (x) { case 0: return 1; }", "switch (arg0) {\n case 0:\n return 1;\n}");
+ check("let x = arg0; let y = x; return y + y;", "let y = arg0;\nreturn y + y;");
// Loops must not be substituted into because they evaluate multiple times
- check(
- "let x = arg0; do {} while (x);",
- "let x = arg0;\ndo\n ;\nwhile (x);",
- );
+ check("let x = arg0; do {} while (x);", "let x = arg0;\ndo\n ;\nwhile (x);");
// TODO: convert while(x) to for (;x;)
check(
@@ -2291,10 +1844,7 @@ console.log(foo, array);
"let x = arg0;\nwhile (x)\n return 1;",
// "let x = arg0;\nfor (; x; )\n return 1;",
);
- check(
- "let x = arg0; for (; x; ) return 1;",
- "let x = arg0;\nfor (;x; )\n return 1;",
- );
+ check("let x = arg0; for (; x; ) return 1;", "let x = arg0;\nfor (;x; )\n return 1;");
// Can substitute an expression without side effects into a branch due to optional chaining
// TODO:
@@ -2304,92 +1854,47 @@ console.log(foo, array);
// Cannot substitute an expression with side effects into a branch due to optional chaining,
// since that would change the expression with side effects from being unconditionally
// evaluated to being conditionally evaluated, which is a behavior change
- check(
- "let x = fn(); return arg1?.[x];",
- "let x = fn();\nreturn arg1?.[x];",
- );
- check(
- "let x = fn(); return arg1?.(x);",
- "let x = fn();\nreturn arg1?.(x);",
- );
+ check("let x = fn(); return arg1?.[x];", "let x = fn();\nreturn arg1?.[x];");
+ check("let x = fn(); return arg1?.(x);", "let x = fn();\nreturn arg1?.(x);");
// Can substitute an expression past an optional chaining operation, since it has side effects
- check(
- "let x = arg0; return arg1?.a === x;",
- "let x = arg0;\nreturn arg1?.a === x;",
- );
- check(
- "let x = arg0; return arg1?.[0] === x;",
- "let x = arg0;\nreturn arg1?.[0] === x;",
- );
- check(
- "let x = arg0; return arg1?.(0) === x;",
- "let x = arg0;\nreturn arg1?.(0) === x;",
- );
- check(
- "let x = arg0; return arg1?.a[x];",
- "let x = arg0;\nreturn arg1?.a[x];",
- );
- check(
- "let x = arg0; return arg1?.a(x);",
- "let x = arg0;\nreturn arg1?.a(x);",
- );
+ check("let x = arg0; return arg1?.a === x;", "let x = arg0;\nreturn arg1?.a === x;");
+ check("let x = arg0; return arg1?.[0] === x;", "let x = arg0;\nreturn arg1?.[0] === x;");
+ check("let x = arg0; return arg1?.(0) === x;", "let x = arg0;\nreturn arg1?.(0) === x;");
+ check("let x = arg0; return arg1?.a[x];", "let x = arg0;\nreturn arg1?.a[x];");
+ check("let x = arg0; return arg1?.a(x);", "let x = arg0;\nreturn arg1?.a(x);");
// TODO:
// check(
// "let x = arg0; return arg1?.[a][x];",
// "let x = arg0;\nreturn arg1?.[a][x];",
// );
- check(
- "let x = arg0; return arg1?.[a](x);",
- "let x = arg0;\nreturn (arg1?.[a])(x);",
- );
- check(
- "let x = arg0; return arg1?.(a)[x];",
- "let x = arg0;\nreturn (arg1?.(a))[x];",
- );
- check(
- "let x = arg0; return arg1?.(a)(x);",
- "let x = arg0;\nreturn (arg1?.(a))(x);",
- );
+ check("let x = arg0; return arg1?.[a](x);", "let x = arg0;\nreturn (arg1?.[a])(x);");
+ check("let x = arg0; return arg1?.(a)[x];", "let x = arg0;\nreturn (arg1?.(a))[x];");
+ check("let x = arg0; return arg1?.(a)(x);", "let x = arg0;\nreturn (arg1?.(a))(x);");
// Can substitute into an object as long as there are no side effects
// beforehand. Note that computed properties must call "toString()" which
// can have side effects.
check("let x = arg0; return {x};", "return { x: arg0 };");
- check(
- "let x = arg0; return {x: y, y: x};",
- "let x = arg0;\nreturn { x: y, y: x };",
- );
+ check("let x = arg0; return {x: y, y: x};", "let x = arg0;\nreturn { x: y, y: x };");
// TODO:
// check(
// "let x = arg0; return {x: arg1, y: x};",
// "return { x: arg1, y: arg0 };",
// );
check("let x = arg0; return {[x]: 0};", "return { [arg0]: 0 };");
- check(
- "let x = arg0; return {[y]: x};",
- "let x = arg0;\nreturn { [y]: x };",
- );
- check(
- "let x = arg0; return {[arg1]: x};",
- "let x = arg0;\nreturn { [arg1]: x };",
- );
+ check("let x = arg0; return {[y]: x};", "let x = arg0;\nreturn { [y]: x };");
+ check("let x = arg0; return {[arg1]: x};", "let x = arg0;\nreturn { [arg1]: x };");
// TODO:
// check(
// "let x = arg0; return {y() {}, x};",
// "return { y() {\n}, x: arg0 };",
// );
- check(
- "let x = arg0; return {[y]() {}, x};",
- "let x = arg0;\nreturn { [y]() {\n}, x };",
- );
+ check("let x = arg0; return {[y]() {}, x};", "let x = arg0;\nreturn { [y]() {\n}, x };");
check("let x = arg0; return {...x};", "return { ...arg0 };");
check("let x = arg0; return {...x, y};", "return { ...arg0, y };");
check("let x = arg0; return {x, ...y};", "return { x: arg0, ...y };");
- check(
- "let x = arg0; return {...y, x};",
- "let x = arg0;\nreturn { ...y, x };",
- );
+ check("let x = arg0; return {...y, x};", "let x = arg0;\nreturn { ...y, x };");
// TODO:
// Check substitutions into template literals
@@ -2423,10 +1928,7 @@ console.log(foo, array);
// );
// Check substitutions into await expressions
- check(
- "return async () => { let x = arg0; await x; };",
- "return async () => {\n await arg0;\n};",
- );
+ check("return async () => { let x = arg0; await x; };", "return async () => {\n await arg0;\n};");
// TODO: combine with comma operator
// check(
@@ -2439,10 +1941,7 @@ console.log(foo, array);
// );
// Check substitutions into yield expressions
- check(
- "return function* () { let x = arg0; yield x; };",
- "return function* () {\n yield arg0;\n};",
- );
+ check("return function* () { let x = arg0; yield x; };", "return function* () {\n yield arg0;\n};");
// TODO: combine with comma operator
// check(
// "return function* () { let x = arg0; yield; return x; };",
@@ -2658,8 +2157,7 @@ console.log(foo, array);
}
if (line.includes("should_be_false")) {
- if (!line.includes("= false"))
- throw new Error(`Expected false in "${line}"`);
+ if (!line.includes("= false")) throw new Error(`Expected false in "${line}"`);
expect(line.includes("= false")).toBe(true);
}
@@ -2690,9 +2188,7 @@ console.log(foo, array);
describe("transform", () => {
it("supports macros", async () => {
const out = await transpiler.transform(`
- import {keepSecondArgument} from 'macro:${
- import.meta.dir
- }/macro-check.js';
+ import {keepSecondArgument} from 'macro:${import.meta.dir}/macro-check.js';
export default keepSecondArgument("Test failed", "Test passed");
export function otherNamesStillWork() {}
@@ -2707,9 +2203,7 @@ console.log(foo, array);
it("sync supports macros", () => {
const out = transpiler.transformSync(`
- import {keepSecondArgument} from 'macro:${
- import.meta.dir
- }/macro-check.js';
+ import {keepSecondArgument} from 'macro:${import.meta.dir}/macro-check.js';
export default keepSecondArgument("Test failed", "Test passed");
export function otherNamesStillWork() {
@@ -2731,10 +2225,7 @@ console.log(foo, array);
expect(out).toBe('import {ɵtest} from "foo";\n');
});
- const importLines = [
- "import {createElement, bacon} from 'react';",
- "import {bacon, createElement} from 'react';",
- ];
+ const importLines = ["import {createElement, bacon} from 'react';", "import {bacon, createElement} from 'react';"];
describe("sync supports macros remap", () => {
for (let importLine of importLines) {
it(importLine, () => {
diff --git a/test/bun.js/tsconfig.json b/test/bun.js/tsconfig.json
index 4763c09e6..91b0ad56d 100644
--- a/test/bun.js/tsconfig.json
+++ b/test/bun.js/tsconfig.json
@@ -3,14 +3,9 @@
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"paths": {
- "foo/bar": [
- "baz.js"
- ]
+ "foo/bar": ["baz.js"]
},
"baseUrl": "."
},
- "exclude": [
- "solid-dom-fixtures",
- "bundled"
- ]
-} \ No newline at end of file
+ "exclude": ["solid-dom-fixtures", "bundled"]
+}
diff --git a/test/bun.js/unsafe.test.js b/test/bun.js/unsafe.test.js
index 741dc0241..8ce7598db 100644
--- a/test/bun.js/unsafe.test.js
+++ b/test/bun.js/unsafe.test.js
@@ -7,7 +7,7 @@ it("arrayBufferToString u8", async () => {
gc(true);
expect(Bun.unsafe.arrayBufferToString(bytes)).toBe("hello world");
gc(true);
- await new Promise((resolve) => setTimeout(resolve, 0));
+ await new Promise(resolve => setTimeout(resolve, 0));
gc(true);
});
@@ -18,7 +18,7 @@ it("arrayBufferToString ArrayBuffer", async () => {
const out = Bun.unsafe.arrayBufferToString(bytes.buffer);
expect(out).toBe("hello world");
gc(true);
- await new Promise((resolve) => setTimeout(resolve, 0));
+ await new Promise(resolve => setTimeout(resolve, 0));
globalThis.bytes = bytes;
gc(true);
expect(out).toBe("hello world");
@@ -32,7 +32,7 @@ it("arrayBufferToString u16", () => {
const charCodes = Bun.unsafe
.arrayBufferToString(uint16)
.split("")
- .map((a) => a.charCodeAt(0));
+ .map(a => a.charCodeAt(0));
gc(true);
for (let i = 0; i < charCodes.length; i++) {
expect("hello world"[i]).toBe(String.fromCharCode(charCodes[i]));
diff --git a/test/bun.js/url.test.ts b/test/bun.js/url.test.ts
index f7ad84752..96640c1f9 100644
--- a/test/bun.js/url.test.ts
+++ b/test/bun.js/url.test.ts
@@ -2,19 +2,13 @@ import { describe, it, expect } from "bun:test";
describe("url", () => {
it("prints", () => {
- expect(Bun.inspect(new URL("https://example.com"))).toBe(
- "https://example.com/",
- );
+ expect(Bun.inspect(new URL("https://example.com"))).toBe("https://example.com/");
expect(
Bun.inspect(
- new URL(
- "https://github.com/oven-sh/bun/issues/135?hello%20i%20have%20spaces%20thank%20you%20good%20night",
- ),
+ new URL("https://github.com/oven-sh/bun/issues/135?hello%20i%20have%20spaces%20thank%20you%20good%20night"),
),
- ).toBe(
- "https://github.com/oven-sh/bun/issues/135?hello%20i%20have%20spaces%20thank%20you%20good%20night",
- );
+ ).toBe("https://github.com/oven-sh/bun/issues/135?hello%20i%20have%20spaces%20thank%20you%20good%20night");
});
it("works", () => {
const inputs = [
diff --git a/test/bun.js/util/util-promisify.test.js b/test/bun.js/util/util-promisify.test.js
index 067751321..336e070f7 100644
--- a/test/bun.js/util/util-promisify.test.js
+++ b/test/bun.js/util/util-promisify.test.js
@@ -60,17 +60,15 @@ describe("util.promisify", () => {
const promise = stat(__filename);
assert.equal(promise instanceof Promise, true);
promise.then(
- common.mustCall((value) => {
+ common.mustCall(value => {
assert.deepStrictEqual(value, fs.statSync(__filename));
}),
);
const promiseFileDontExist = stat("/dontexist");
promiseFileDontExist.catch(
- common.mustCall((error) => {
- assert(
- error.message.includes("ENOENT: no such file or directory, stat"),
- );
+ common.mustCall(error => {
+ assert(error.message.includes("ENOENT: no such file or directory, stat"));
}),
);
});
@@ -94,9 +92,7 @@ describe("util.promisify", () => {
// TODO: register shared symbol promisify.custom
// util.promisify.custom is a shared symbol which can be accessed
// as `Symbol.for("nodejs.util.promisify.custom")`.
- const kCustomPromisifiedSymbol = Symbol.for(
- "nodejs.util.promisify.custom",
- );
+ const kCustomPromisifiedSymbol = Symbol.for("nodejs.util.promisify.custom");
fn[kCustomPromisifiedSymbol] = promisifiedFn;
assert.strictEqual(kCustomPromisifiedSymbol, promisify.custom);
@@ -148,7 +144,7 @@ describe("util.promisify", () => {
called = true;
callback(null, "foo", "bar");
}
- await promisify(fn)().then((value) => {
+ await promisify(fn)().then(value => {
assert.strictEqual(value, "foo");
assert.strictEqual(called, true);
});
@@ -160,7 +156,7 @@ describe("util.promisify", () => {
called = true;
callback(null);
}
- await promisify(fn)().then((value) => {
+ await promisify(fn)().then(value => {
assert.strictEqual(value, undefined);
assert.strictEqual(called, true);
});
@@ -172,7 +168,7 @@ describe("util.promisify", () => {
called = true;
callback();
}
- await promisify(fn)().then((value) => {
+ await promisify(fn)().then(value => {
assert.strictEqual(value, undefined);
assert.strictEqual(called, true);
});
@@ -184,7 +180,7 @@ describe("util.promisify", () => {
called = true;
callback(err, val);
}
- await promisify(fn)(null, 42).then((value) => {
+ await promisify(fn)(null, 42).then(value => {
assert.strictEqual(value, 42);
assert.strictEqual(called, true);
});
@@ -196,7 +192,7 @@ describe("util.promisify", () => {
called = true;
callback(err, val);
}
- await promisify(fn)(new Error("oops"), null).catch((err) => {
+ await promisify(fn)(new Error("oops"), null).catch(err => {
assert.strictEqual(err.message, "oops");
assert.strictEqual(called, true);
});
@@ -227,16 +223,14 @@ describe("util.promisify", () => {
o.fn = fn;
- await o.fn().then((val) => {
+ await o.fn().then(val => {
assert.strictEqual(called, true);
assert.strictEqual(val, true);
});
});
it("should not have called callback with error", async () => {
- const err = new Error(
- "Should not have called the callback with the error.",
- );
+ const err = new Error("Should not have called the callback with the error.");
const stack = err.stack;
var called = false;
@@ -271,13 +265,13 @@ describe("util.promisify", () => {
});
await thrower(1, 2, 3)
.then(assert.fail)
- .then(assert.fail, (e) => assert.strictEqual(e, errToThrow));
+ .then(assert.fail, e => assert.strictEqual(e, errToThrow));
});
it("should also throw error inside Promise.all", async () => {
const err = new Error();
- const a = promisify((cb) => cb(err))();
+ const a = promisify(cb => cb(err))();
const b = promisify(() => {
throw err;
})();
@@ -298,7 +292,7 @@ describe("util.promisify", () => {
// is not thrown in the error. does it have different
// throw error implementation in bun?
it("should throw on invalid inputs for promisify", () => {
- [undefined, null, true, 0, "str", {}, [], Symbol()].forEach((input) => {
+ [undefined, null, true, 0, "str", {}, [], Symbol()].forEach(input => {
assert.throws(() => promisify(input), {
code: "ERR_INVALID_ARG_TYPE",
name: "TypeError",
diff --git a/test/bun.js/util/util.test.js b/test/bun.js/util/util.test.js
index ded15a435..f98a66029 100644
--- a/test/bun.js/util/util.test.js
+++ b/test/bun.js/util/util.test.js
@@ -234,10 +234,7 @@ describe("util", () => {
// true
// );
strictEqual(util.types.isNativeError({}), false);
- strictEqual(
- util.types.isNativeError({ name: "Error", message: "" }),
- false,
- );
+ strictEqual(util.types.isNativeError({ name: "Error", message: "" }), false);
strictEqual(util.types.isNativeError([]), false);
// strictEqual( // FIXME: failing test
// util.types.isNativeError(Object.create(Error.prototype)),
diff --git a/test/bun.js/web-crypto.test.ts b/test/bun.js/web-crypto.test.ts
index 19d068180..d7afd523c 100644
--- a/test/bun.js/web-crypto.test.ts
+++ b/test/bun.js/web-crypto.test.ts
@@ -49,11 +49,7 @@ describe("Web Crypto", () => {
async function signResponse(message, secret) {
const key = await importKey(secret);
- const signature = await crypto.subtle.sign(
- "HMAC",
- key,
- new TextEncoder().encode(message),
- );
+ const signature = await crypto.subtle.sign("HMAC", key, new TextEncoder().encode(message));
// Convert ArrayBuffer to Base64
return btoa(String.fromCharCode(...new Uint8Array(signature)));
@@ -63,14 +59,9 @@ describe("Web Crypto", () => {
const key = await importKey(secret);
// Convert Base64 to Uint8Array
- const sigBuf = Uint8Array.from(atob(signature), (c) => c.charCodeAt(0));
+ const sigBuf = Uint8Array.from(atob(signature), c => c.charCodeAt(0));
- return await crypto.subtle.verify(
- "HMAC",
- key,
- sigBuf,
- new TextEncoder().encode(message),
- );
+ return await crypto.subtle.verify("HMAC", key, sigBuf, new TextEncoder().encode(message));
}
const msg = `hello world`;
diff --git a/test/bun.js/web-globals.test.js b/test/bun.js/web-globals.test.js
index 58e5d696e..3d0bcc667 100644
--- a/test/bun.js/web-globals.test.js
+++ b/test/bun.js/web-globals.test.js
@@ -55,9 +55,7 @@ it("crypto.getRandomValues", () => {
{
var array = crypto.getRandomValues(foo);
expect(array).toBe(foo);
- expect(array.reduce((sum, a) => (sum += a === 0), 0) != foo.length).toBe(
- true,
- );
+ expect(array.reduce((sum, a) => (sum += a === 0), 0) != foo.length).toBe(true);
}
// disable it for this block because it tends to get stuck here running the GC forever
@@ -70,17 +68,13 @@ it("crypto.getRandomValues", () => {
});
// run it on a large input
- expect(
- !!crypto.getRandomValues(new Uint8Array(8096)).find((a) => a > 0),
- ).toBe(true);
+ expect(!!crypto.getRandomValues(new Uint8Array(8096)).find(a => a > 0)).toBe(true);
{
// any additional input into getRandomValues() makes it unbuffered
var array = crypto.getRandomValues(foo, "unbuffered");
expect(array).toBe(foo);
- expect(array.reduce((sum, a) => (sum += a === 0), 0) != foo.length).toBe(
- true,
- );
+ expect(array.reduce((sum, a) => (sum += a === 0), 0) != foo.length).toBe(true);
}
});
diff --git a/test/bun.js/websocket-server.test.ts b/test/bun.js/websocket-server.test.ts
index ce4056654..3205ff949 100644
--- a/test/bun.js/websocket-server.test.ts
+++ b/test/bun.js/websocket-server.test.ts
@@ -12,7 +12,7 @@ function getPort() {
}
describe("websocket server", () => {
- it("can do publish()", async (done) => {
+ it("can do publish()", async done => {
var server = serve({
port: getPort(),
websocket: {
@@ -35,7 +35,7 @@ describe("websocket server", () => {
var socket = new WebSocket(`ws://${server.hostname}:${server.port}`);
var clientCounter = 0;
- socket.onmessage = (e) => {
+ socket.onmessage = e => {
expect(e.data).toBe("hello");
resolve2();
};
@@ -49,7 +49,7 @@ describe("websocket server", () => {
done();
});
- it("can do publish() with publishToSelf: false", async (done) => {
+ it("can do publish() with publishToSelf: false", async done => {
var server = serve({
port: getPort(),
websocket: {
@@ -78,7 +78,7 @@ describe("websocket server", () => {
await new Promise<void>((resolve2, reject2) => {
var socket = new WebSocket(`ws://${server.hostname}:${server.port}`);
- socket.onmessage = (e) => {
+ socket.onmessage = e => {
expect(e.data).toBe("hello");
resolve2();
};
@@ -99,10 +99,7 @@ describe("websocket server", () => {
},
message(ws, msg) {},
close(ws) {
- ws[method](
- "all",
- method === "publishBinary" ? Buffer.from("bye!") : "bye!",
- );
+ ws[method]("all", method === "publishBinary" ? Buffer.from("bye!") : "bye!");
count++;
if (count >= 2) {
@@ -121,20 +118,16 @@ describe("websocket server", () => {
try {
const first = await new Promise<WebSocket>((resolve2, reject2) => {
- var socket = new WebSocket(
- `ws://${server.hostname}:${server.port}`,
- );
+ var socket = new WebSocket(`ws://${server.hostname}:${server.port}`);
socket.onopen = () => resolve2(socket);
});
await new Promise<WebSocket>((resolve2, reject2) => {
- var socket = new WebSocket(
- `ws://${server.hostname}:${server.port}`,
- );
+ var socket = new WebSocket(`ws://${server.hostname}:${server.port}`);
socket.onopen = () => {
queueMicrotask(() => first.close());
};
- socket.onmessage = (ev) => {
+ socket.onmessage = ev => {
var msg = ev.data;
if (typeof msg !== "string") {
msg = new TextDecoder().decode(msg);
@@ -195,8 +188,8 @@ describe("websocket server", () => {
websocket.onopen = () => {
websocket.close();
};
- websocket.onmessage = (e) => {};
- websocket.onerror = (e) => {};
+ websocket.onmessage = e => {};
+ websocket.onerror = e => {};
});
});
@@ -237,8 +230,8 @@ describe("websocket server", () => {
const websocket = new WebSocket(`ws://${server.hostname}:${server.port}`);
websocket.onopen = () => websocket.close();
- websocket.onmessage = (e) => {};
- websocket.onerror = (e) => {};
+ websocket.onmessage = e => {};
+ websocket.onerror = e => {};
});
});
it("can do hello world", async () => {
@@ -279,7 +272,7 @@ describe("websocket server", () => {
websocket.onopen = () => {
websocket.send("hello world");
};
- websocket.onmessage = (e) => {
+ websocket.onmessage = e => {
try {
expect(e.data).toBe("hello world");
resolve();
@@ -289,7 +282,7 @@ describe("websocket server", () => {
websocket.close();
}
};
- websocket.onerror = (e) => {
+ websocket.onerror = e => {
reject(e);
};
});
@@ -338,7 +331,7 @@ describe("websocket server", () => {
websocket.onopen = () => {
websocket.send("hello world");
};
- websocket.onmessage = (e) => {
+ websocket.onmessage = e => {
try {
expect(e.data).toBe("hello world");
resolve();
@@ -348,7 +341,7 @@ describe("websocket server", () => {
websocket.close();
}
};
- websocket.onerror = (e) => {
+ websocket.onerror = e => {
reject(e);
};
});
@@ -398,7 +391,7 @@ describe("websocket server", () => {
websocket.onopen = () => {
websocket.send("hello world");
};
- websocket.onmessage = (e) => {
+ websocket.onmessage = e => {
try {
expect(e.data).toBe("hello world");
resolve();
@@ -408,7 +401,7 @@ describe("websocket server", () => {
websocket.close();
}
};
- websocket.onerror = (e) => {
+ websocket.onerror = e => {
reject(e);
};
});
@@ -455,7 +448,7 @@ describe("websocket server", () => {
websocket.onopen = () => {
websocket.send(Buffer.from("hello world"));
};
- websocket.onmessage = (e) => {
+ websocket.onmessage = e => {
try {
expect(e.data).toBe("hello world");
@@ -469,7 +462,7 @@ describe("websocket server", () => {
reject(r);
}
};
- websocket.onerror = (e) => {
+ websocket.onerror = e => {
reject(e);
};
});
@@ -509,9 +502,7 @@ describe("websocket server", () => {
server.stop();
expect(() => {
server.upgrade(req);
- }).toThrow(
- 'To enable websocket support, set the "websocket" object in Bun.serve({})',
- );
+ }).toThrow('To enable websocket support, set the "websocket" object in Bun.serve({})');
return new Response("success");
},
});
@@ -544,7 +535,7 @@ describe("websocket server", () => {
await new Promise<void>((resolve, reject) => {
const websocket = new WebSocket(`ws://${server.hostname}:${server.port}`);
- websocket.onmessage = (e) => {
+ websocket.onmessage = e => {
try {
expect(e.data).toBe("hello world");
resolve();
@@ -554,7 +545,7 @@ describe("websocket server", () => {
websocket.close();
}
};
- websocket.onerror = (e) => {
+ websocket.onerror = e => {
reject(e);
};
});
@@ -698,7 +689,7 @@ describe("websocket server", () => {
await new Promise<void>((resolve, reject) => {
const websocket = new WebSocket(`ws://${server.hostname}:${server.port}`);
- websocket.onmessage = (e) => {
+ websocket.onmessage = e => {
try {
expect(e.data).toBe("hello world");
resolve();
@@ -708,7 +699,7 @@ describe("websocket server", () => {
websocket.close();
}
};
- websocket.onerror = (e) => {
+ websocket.onerror = e => {
reject(e);
};
});
@@ -744,13 +735,13 @@ describe("websocket server", () => {
await new Promise<void>((resolve, reject) => {
const websocket = new WebSocket(`ws://${server.hostname}:${server.port}`);
- websocket.onerror = (e) => {
+ websocket.onerror = e => {
reject(e);
};
var counter = 0;
websocket.onopen = () => websocket.send("first");
- websocket.onmessage = (e) => {
+ websocket.onmessage = e => {
try {
switch (counter++) {
case 0: {
@@ -819,13 +810,13 @@ describe("websocket server", () => {
await new Promise<void>((resolve, reject) => {
const websocket = new WebSocket(`ws://${server.hostname}:${server.port}`);
- websocket.onerror = (e) => {
+ websocket.onerror = e => {
reject(e);
};
var counter = 0;
websocket.onopen = () => websocket.send("first");
- websocket.onmessage = (e) => {
+ websocket.onmessage = e => {
try {
const expected = sendQueue[clientCounter++] + " ";
expect(e.data).toBe(expected);
@@ -870,12 +861,10 @@ describe("websocket server", () => {
}
ws.subscribe("test");
clientCount++;
- if (clientCount === 10)
- setTimeout(() => ws.publish("test", "hello world"), 1);
+ if (clientCount === 10) setTimeout(() => ws.publish("test", "hello world"), 1);
},
message(ws, msg) {
- if (serverCounter < sendQueue.length)
- ws.publish("test", sendQueue[serverCounter++] + " ");
+ if (serverCounter < sendQueue.length) ws.publish("test", sendQueue[serverCounter++] + " ");
},
},
fetch(req) {
@@ -894,7 +883,7 @@ describe("websocket server", () => {
const connections = new Array(10);
const websockets = new Array(connections.length);
var doneCounter = 0;
- await new Promise<void>((done) => {
+ await new Promise<void>(done => {
for (var i = 0; i < connections.length; i++) {
var j = i;
var resolve, reject, resolveConnection, rejectConnection;
@@ -907,10 +896,8 @@ describe("websocket server", () => {
reject = rej;
});
gcTick();
- const websocket = new WebSocket(
- `ws://${server.hostname}:${server.port}`,
- );
- websocket.onerror = (e) => {
+ const websocket = new WebSocket(`ws://${server.hostname}:${server.port}`);
+ websocket.onerror = e => {
reject(e);
};
websocket.onclose = () => {
@@ -930,7 +917,7 @@ describe("websocket server", () => {
let clientCounter = -1;
var hasSentThisTick = false;
- websocket.onmessage = (e) => {
+ websocket.onmessage = e => {
gcTick();
if (!hasOpened) {
@@ -945,7 +932,7 @@ describe("websocket server", () => {
}
try {
- expect(!!sendQueue.find((a) => a + " " === e.data)).toBe(true);
+ expect(!!sendQueue.find(a => a + " " === e.data)).toBe(true);
if (!hasSentThisTick) {
websocket.send("second");
diff --git a/test/bun.js/websocket-subprocess.ts b/test/bun.js/websocket-subprocess.ts
index cf64f18ef..fd25b7fd5 100644
--- a/test/bun.js/websocket-subprocess.ts
+++ b/test/bun.js/websocket-subprocess.ts
@@ -2,7 +2,7 @@ const host = process.argv[2];
const ws = new WebSocket(host);
-ws.onmessage = (message) => {
+ws.onmessage = message => {
if (message.data === "hello websocket") {
ws.send("hello");
} else if (message.data === "timeout") {
diff --git a/test/bun.js/websocket.test.js b/test/bun.js/websocket.test.js
index 9bd114c47..61c9ec054 100644
--- a/test/bun.js/websocket.test.js
+++ b/test/bun.js/websocket.test.js
@@ -5,8 +5,7 @@ import { bunExe } from "bunExe";
import { gc } from "./gc";
import { bunEnv } from "bunEnv";
-const TEST_WEBSOCKET_HOST =
- process.env.TEST_WEBSOCKET_HOST || "wss://ws.postman-echo.com/raw";
+const TEST_WEBSOCKET_HOST = process.env.TEST_WEBSOCKET_HOST || "wss://ws.postman-echo.com/raw";
describe("WebSocket", () => {
it("should connect", async () => {
@@ -35,7 +34,7 @@ describe("WebSocket", () => {
await closed;
});
- it("supports headers", (done) => {
+ it("supports headers", done => {
const server = Bun.serve({
port: 8024,
fetch(req, server) {
@@ -59,7 +58,7 @@ describe("WebSocket", () => {
});
});
- it("should connect over http", (done) => {
+ it("should connect over http", done => {
const server = Bun.serve({
port: 8025,
fetch(req, server) {
@@ -90,7 +89,7 @@ describe("WebSocket", () => {
// 10 messages in burst
var promise = new Promise((resolve, reject) => {
var remain = count;
- ws.onmessage = (event) => {
+ ws.onmessage = event => {
gc(true);
expect(event.data).toBe("Hello World!");
remain--;
@@ -116,7 +115,7 @@ describe("WebSocket", () => {
return new Promise((resolve, reject) => {
gc(true);
const msg = `Hello World! ${echo++}`;
- ws.onmessage = (event) => {
+ ws.onmessage = event => {
expect(event.data).toBe(msg);
resolve();
};
@@ -160,11 +159,7 @@ describe("websocket in subprocess", () => {
},
});
const subprocess = Bun.spawn({
- cmd: [
- bunExe(),
- import.meta.dir + "/websocket-subprocess.ts",
- `http://${server.hostname}:${server.port}`,
- ],
+ cmd: [bunExe(), import.meta.dir + "/websocket-subprocess.ts", `http://${server.hostname}:${server.port}`],
stderr: "pipe",
stdin: "pipe",
stdout: "pipe",
@@ -178,11 +173,7 @@ describe("websocket in subprocess", () => {
it("should exit after killed", async () => {
const subprocess = Bun.spawn({
- cmd: [
- bunExe(),
- import.meta.dir + "/websocket-subprocess.ts",
- TEST_WEBSOCKET_HOST,
- ],
+ cmd: [bunExe(), import.meta.dir + "/websocket-subprocess.ts", TEST_WEBSOCKET_HOST],
stderr: "pipe",
stdin: "pipe",
stdout: "pipe",
@@ -196,11 +187,7 @@ describe("websocket in subprocess", () => {
it("should exit with invalid url", async () => {
const subprocess = Bun.spawn({
- cmd: [
- bunExe(),
- import.meta.dir + "/websocket-subprocess.ts",
- "invalid url",
- ],
+ cmd: [bunExe(), import.meta.dir + "/websocket-subprocess.ts", "invalid url"],
stderr: "pipe",
stdin: "pipe",
stdout: "pipe",
@@ -236,11 +223,7 @@ describe("websocket in subprocess", () => {
},
});
const subprocess = Bun.spawn({
- cmd: [
- bunExe(),
- import.meta.dir + "/websocket-subprocess.ts",
- `http://${server.hostname}:${server.port}`,
- ],
+ cmd: [bunExe(), import.meta.dir + "/websocket-subprocess.ts", `http://${server.hostname}:${server.port}`],
stderr: "pipe",
stdin: "pipe",
stdout: "pipe",
@@ -270,11 +253,7 @@ describe("websocket in subprocess", () => {
});
const subprocess = Bun.spawn({
- cmd: [
- bunExe(),
- import.meta.dir + "/websocket-subprocess.ts",
- `http://${server.hostname}:${server.port}`,
- ],
+ cmd: [bunExe(), import.meta.dir + "/websocket-subprocess.ts", `http://${server.hostname}:${server.port}`],
stderr: "pipe",
stdin: "pipe",
stdout: "pipe",