aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/api/utils.md4
-rw-r--r--docs/api/workers.md2
-rw-r--r--docs/cli/run.md20
-rw-r--r--docs/runtime/configuration.md23
-rw-r--r--docs/runtime/web-apis.md4
-rw-r--r--examples/cat.ts3
-rw-r--r--packages/bun-types/tests/jsc.test-d.ts9
-rw-r--r--packages/bun-types/tests/worker.test-d.ts32
8 files changed, 71 insertions, 26 deletions
diff --git a/docs/api/utils.md b/docs/api/utils.md
index 7366649b7..2723edf7c 100644
--- a/docs/api/utils.md
+++ b/docs/api/utils.md
@@ -247,7 +247,7 @@ Bun.deepEquals(new Foo(), { a: 1 }, true); // false
## `Bun.escapeHTML()`
-`Bun.escapeHTML(value: string | object | number | boolean): boolean`
+`Bun.escapeHTML(value: string | object | number | boolean): string`
Escapes the following characters from an input string:
@@ -402,7 +402,7 @@ The second argument supports the same set of configuration options as [`Bun.gzip
## `Bun.inflateSync()`
-DEcompresses a `Uint8Array` using zlib's INFLATE algorithm.
+Decompresses a `Uint8Array` using zlib's INFLATE algorithm.
```ts
const buf = Buffer.from("hello".repeat(100));
diff --git a/docs/api/workers.md b/docs/api/workers.md
index af459d18e..ba45d7cc1 100644
--- a/docs/api/workers.md
+++ b/docs/api/workers.md
@@ -1,5 +1,5 @@
{% callout %}
-`Worker` support was added in Bun v0.6.15.
+`Worker` support was added in Bun v0.7.0.
{% /callout %}
[`Worker`](https://developer.mozilla.org/en-US/docs/Web/API/Worker) lets you start and communicate with a new JavaScript instance running on a separate thread while sharing I/O resources with the main thread.
diff --git a/docs/cli/run.md b/docs/cli/run.md
index 1398e10ca..60061ee5c 100644
--- a/docs/cli/run.md
+++ b/docs/cli/run.md
@@ -32,6 +32,26 @@ The "naked" `bun` command is equivalent to `bun run`.
$ bun index.tsx
```
+### `--watch`
+
+To run a file in watch mode, use the `--watch` flag.
+
+```bash
+$ bun --watch run index.tsx
+```
+
+### `--smol`
+
+{% callout %}
+Added in Bun v0.7.0.
+{% /callout %}
+
+In memory-constrained environments, use the `--smol` flag to reduce memory usage at a cost to performance.
+
+```bash
+$ bun --smol run index.tsx
+```
+
## Run a `package.json` script
{% note %}
diff --git a/docs/runtime/configuration.md b/docs/runtime/configuration.md
index 21a12d8b2..ff380cb8b 100644
--- a/docs/runtime/configuration.md
+++ b/docs/runtime/configuration.md
@@ -28,12 +28,8 @@ jsxImportSource = "react"
# Reduce memory usage at the cost of performance
smol = true
-# Set a default framework to use
-# By default, Bun will look for an npm package like `bun-framework-${framework}`, followed by `${framework}`
-logLevel = "debug"
-
-# publicDir = "public"
-# external = ["jquery"]
+# Set Bun's log level
+logLevel = "debug" # "debug", "warn", "error"
[define]
# Replace any usage of "process.env.bagel" with the string `lox`.
@@ -44,16 +40,13 @@ logLevel = "debug"
[loaders]
# When loading a .bagel file, run the JS parser
".bagel" = "js"
-# - "atom"
-# If you pass it a file path, it will open with the file path instead
-# It will recognize non-GUI editors, but I don't think it will work yet
```
## Test runner
```toml
[test]
-# setup scripts to run before all test files
+# Scripts to run before all test files
preload = ["./setup.ts"]
# Reduce memory usage at the cost of performance
@@ -215,13 +208,3 @@ These environment variables are checked by Bun to detect functionality and toggl
- If `DO_NOT_TRACK=1`, then analytics are [disabled](https://do-not-track.dev/). Bun records bundle timings (so we can answer with data, "is Bun getting faster?") and feature usage (e.g., "are people actually using macros?"). The request body size is about 60 bytes, so it's not a lot of data.
{% /table %}
-
-## smol mode
-
-To reduce Bun's memory footprint in the runtime and test runner, pass `--smol`.
-
-```bash
-$ bun --smol ./my-script.ts
-```
-
-This configures JavaScriptCore (the engine) to use a smaller heap size and run the garbage collector more frequently. This is currently disabled by default for performance reasons, but it may become the default in the future. This feature was introduced in Bun v0.6.15.
diff --git a/docs/runtime/web-apis.md b/docs/runtime/web-apis.md
index 46728bb62..366fa7819 100644
--- a/docs/runtime/web-apis.md
+++ b/docs/runtime/web-apis.md
@@ -16,10 +16,8 @@ The following Web APIs are partially or completely supported.
---
----
-
- Web Workers
-- [`Worker`](https://developer.mozilla.org/en-US/docs/Web/API/Worker) [`self.postMessage`](https://developer.mozilla.org/en-US/docs/Web/API/DedicatedWorkerGlobalScope/postMessage) [`structuredClone`](https://developer.mozilla.org/en-US/docs/Web/API/structuredClone)
+- [`Worker`](https://developer.mozilla.org/en-US/docs/Web/API/Worker) [`self.postMessage`](https://developer.mozilla.org/en-US/docs/Web/API/DedicatedWorkerGlobalScope/postMessage) [`structuredClone`](https://developer.mozilla.org/en-US/docs/Web/API/structuredClone). Missing `MessagePort`, `MessageChannel`, `BroadcastChannel`.
---
diff --git a/examples/cat.ts b/examples/cat.ts
index 01a059ad0..0634daaf1 100644
--- a/examples/cat.ts
+++ b/examples/cat.ts
@@ -4,3 +4,6 @@ import { argv } from "process";
const path = resolve(argv.at(-1)!);
await write(stdout, file(path));
+
+Bun.stdout;
+process.stdout;
diff --git a/packages/bun-types/tests/jsc.test-d.ts b/packages/bun-types/tests/jsc.test-d.ts
new file mode 100644
index 000000000..34e134338
--- /dev/null
+++ b/packages/bun-types/tests/jsc.test-d.ts
@@ -0,0 +1,9 @@
+import { serialize, deserialize } from "bun:jsc";
+import { deepEquals } from "bun";
+const obj = { a: 1, b: 2 };
+const buffer = serialize(obj);
+const clone = deserialize(buffer);
+
+if (deepEquals(obj, clone)) {
+ console.log("They are equal!");
+}
diff --git a/packages/bun-types/tests/worker.test-d.ts b/packages/bun-types/tests/worker.test-d.ts
new file mode 100644
index 000000000..78816c80d
--- /dev/null
+++ b/packages/bun-types/tests/worker.test-d.ts
@@ -0,0 +1,32 @@
+const worker = new Worker("./worker.ts");
+worker.addEventListener("message", (event: MessageEvent) => {
+ console.log("Message from worker:", event.data);
+});
+worker.postMessage("Hello from main thread!");
+
+const workerURL = new URL("worker.ts", import.meta.url).href;
+const _worker2 = new Worker(workerURL);
+
+worker.postMessage("hello");
+worker.onmessage = event => {
+ console.log(event.data);
+};
+
+// On the worker thread, `postMessage` is automatically "routed" to the parent thread.
+postMessage({ hello: "world" });
+
+// On the main thread
+worker.postMessage({ hello: "world" });
+
+// ...some time later
+worker.terminate();
+
+// Bun.pathToFileURL
+const _worker3 = new Worker(new URL("worker.ts", import.meta.url).href, {
+ bun: {
+ ref: true,
+ smol: true,
+ },
+});
+
+export { worker, _worker2, _worker3 };