diff --git a/docs/api/glob.md b/docs/api/glob.md index 90d45642a8..8566014830 100644 --- a/docs/api/glob.md +++ b/docs/api/glob.md @@ -15,6 +15,7 @@ for await (const file of glob.scan(".")) { } ``` + **Match a string against a glob pattern**: ```ts diff --git a/docs/api/globals.md b/docs/api/globals.md index 1a98bb0899..5e3cdd1113 100644 --- a/docs/api/globals.md +++ b/docs/api/globals.md @@ -385,3 +385,4 @@ Bun implements the following globals. -   {% /table %} + diff --git a/docs/api/streams.md b/docs/api/streams.md index fab5cdedfc..d55c9b33f2 100644 --- a/docs/api/streams.md +++ b/docs/api/streams.md @@ -28,6 +28,20 @@ for await (const chunk of stream) { } ``` +`ReadableStream` also provides convenience methods for consuming the entire stream: + +```ts +const stream = new ReadableStream({ + start(controller) { + controller.enqueue("hello world"); + controller.close(); + }, +}); + +const data = await stream.text(); // => "hello world" +// Also available: .json(), .bytes(), .blob() +``` + ## Direct `ReadableStream` Bun implements an optimized version of `ReadableStream` that avoid unnecessary data copying & queue management logic. With a traditional `ReadableStream`, chunks of data are _enqueued_. Each chunk is copied into a queue, where it sits until the stream is ready to send more data. diff --git a/docs/api/websockets.md b/docs/api/websockets.md index 2dc6cdab2e..7b49686e94 100644 --- a/docs/api/websockets.md +++ b/docs/api/websockets.md @@ -296,6 +296,17 @@ const socket = new WebSocket("ws://localhost:3000", { }); ``` +### Client compression + +WebSocket clients support permessage-deflate compression. The `extensions` property shows negotiated compression: + +```ts +const socket = new WebSocket("wss://echo.websocket.org"); +socket.addEventListener("open", () => { + console.log(socket.extensions); // => "permessage-deflate" +}); +``` + To add event listeners to the socket: ```ts diff --git a/docs/bundler/index.md b/docs/bundler/index.md index f64ade753e..68ef436040 100644 --- a/docs/bundler/index.md +++ b/docs/bundler/index.md @@ -313,6 +313,14 @@ $ bun build --entrypoints ./index.ts --outdir ./out --target browser Depending on the target, Bun will apply different module resolution rules and optimizations. +### Module resolution + +Bun supports the `NODE_PATH` environment variable for additional module resolution paths: + +```bash +NODE_PATH=./src bun build ./entry.js --outdir ./dist +``` + {% table %} diff --git a/docs/cli/test.md b/docs/cli/test.md index 627f48978b..6539a4b7a3 100644 --- a/docs/cli/test.md +++ b/docs/cli/test.md @@ -47,6 +47,8 @@ To filter by _test name_, use the `-t`/`--test-name-pattern` flag. $ bun test --test-name-pattern addition ``` +When no tests match the filter, `bun test` exits with code 1. + To run a specific file in the test runner, make sure the path starts with `./` or `/` to distinguish it from a filter name. ```bash