bun-types 1.2.19-canary.20250709T140635 → 1.2.19-canary.20250710T140803
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bun.d.ts +9 -9
- package/devserver.d.ts +3 -3
- package/docs/api/binary-data.md +1 -1
- package/docs/api/cc.md +1 -1
- package/docs/api/dns.md +3 -3
- package/docs/api/fetch.md +6 -6
- package/docs/api/file-io.md +3 -3
- package/docs/api/globals.md +4 -4
- package/docs/api/http.md +6 -6
- package/docs/api/s3.md +1 -1
- package/docs/api/spawn.md +1 -1
- package/docs/api/utils.md +3 -3
- package/docs/bundler/fullstack.md +2 -2
- package/docs/bundler/index.md +8 -8
- package/docs/bundler/loaders.md +5 -5
- package/docs/bundler/macros.md +1 -1
- package/docs/bundler/plugins.md +1 -1
- package/docs/bundler/vs-esbuild.md +5 -5
- package/docs/cli/bun-create.md +3 -3
- package/docs/cli/bun-install.md +1 -1
- package/docs/cli/bun-upgrade.md +1 -1
- package/docs/cli/filter.md +2 -2
- package/docs/cli/install.md +5 -5
- package/docs/cli/patch-commit.md +1 -1
- package/docs/cli/pm.md +1 -1
- package/docs/cli/publish.md +1 -1
- package/docs/cli/run.md +2 -2
- package/docs/cli/test.md +6 -6
- package/docs/ecosystem/express.md +3 -3
- package/docs/ecosystem/react.md +1 -1
- package/docs/guides/binary/arraybuffer-to-array.md +1 -1
- package/docs/guides/binary/arraybuffer-to-blob.md +1 -1
- package/docs/guides/binary/arraybuffer-to-buffer.md +1 -1
- package/docs/guides/binary/arraybuffer-to-string.md +1 -1
- package/docs/guides/binary/arraybuffer-to-typedarray.md +1 -1
- package/docs/guides/binary/blob-to-arraybuffer.md +1 -1
- package/docs/guides/binary/blob-to-dataview.md +1 -1
- package/docs/guides/binary/blob-to-stream.md +1 -1
- package/docs/guides/binary/blob-to-string.md +1 -1
- package/docs/guides/binary/blob-to-typedarray.md +1 -1
- package/docs/guides/binary/buffer-to-arraybuffer.md +1 -1
- package/docs/guides/binary/buffer-to-blob.md +1 -1
- package/docs/guides/binary/buffer-to-readablestream.md +1 -1
- package/docs/guides/binary/buffer-to-string.md +1 -1
- package/docs/guides/binary/buffer-to-typedarray.md +1 -1
- package/docs/guides/binary/dataview-to-string.md +1 -1
- package/docs/guides/binary/typedarray-to-arraybuffer.md +1 -1
- package/docs/guides/binary/typedarray-to-blob.md +1 -1
- package/docs/guides/binary/typedarray-to-buffer.md +1 -1
- package/docs/guides/binary/typedarray-to-dataview.md +1 -1
- package/docs/guides/binary/typedarray-to-readablestream.md +1 -1
- package/docs/guides/binary/typedarray-to-string.md +1 -1
- package/docs/guides/ecosystem/express.md +1 -1
- package/docs/guides/ecosystem/neon-drizzle.md +1 -1
- package/docs/guides/ecosystem/neon-serverless-postgres.md +1 -1
- package/docs/guides/ecosystem/nuxt.md +1 -1
- package/docs/guides/html-rewriter/extract-links.md +4 -4
- package/docs/guides/html-rewriter/extract-social-meta.md +3 -3
- package/docs/guides/http/fetch.md +2 -2
- package/docs/guides/http/file-uploads.md +1 -1
- package/docs/guides/http/hot.md +1 -1
- package/docs/guides/http/server.md +1 -1
- package/docs/guides/http/simple.md +1 -1
- package/docs/guides/http/stream-file.md +3 -3
- package/docs/guides/http/tls.md +1 -1
- package/docs/guides/install/add-dev.md +1 -1
- package/docs/guides/install/add-git.md +1 -1
- package/docs/guides/install/add-optional.md +1 -1
- package/docs/guides/install/add-peer.md +3 -3
- package/docs/guides/install/add-tarball.md +1 -1
- package/docs/guides/install/add.md +1 -1
- package/docs/guides/install/azure-artifacts.md +1 -1
- package/docs/guides/install/custom-registry.md +2 -2
- package/docs/guides/install/from-npm-install-to-bun-install.md +1 -1
- package/docs/guides/install/git-diff-bun-lockfile.md +1 -1
- package/docs/guides/install/npm-alias.md +1 -1
- package/docs/guides/install/registry-scope.md +3 -3
- package/docs/guides/install/trusted.md +1 -1
- package/docs/guides/install/workspaces.md +1 -1
- package/docs/guides/install/yarnlock.md +2 -2
- package/docs/guides/process/ctrl-c.md +1 -1
- package/docs/guides/process/ipc.md +2 -2
- package/docs/guides/process/nanoseconds.md +1 -1
- package/docs/guides/process/os-signals.md +1 -1
- package/docs/guides/process/spawn-stderr.md +2 -2
- package/docs/guides/process/spawn-stdout.md +2 -2
- package/docs/guides/process/spawn.md +2 -2
- package/docs/guides/process/stdin.md +1 -1
- package/docs/guides/read-file/arraybuffer.md +1 -1
- package/docs/guides/read-file/buffer.md +1 -1
- package/docs/guides/read-file/exists.md +1 -1
- package/docs/guides/read-file/mime.md +1 -1
- package/docs/guides/read-file/stream.md +1 -1
- package/docs/guides/read-file/uint8array.md +1 -1
- package/docs/guides/read-file/watch.md +1 -1
- package/docs/guides/runtime/delete-directory.md +1 -1
- package/docs/guides/runtime/delete-file.md +1 -1
- package/docs/guides/runtime/import-json.md +1 -1
- package/docs/guides/runtime/import-toml.md +1 -1
- package/docs/guides/runtime/read-env.md +1 -1
- package/docs/guides/runtime/set-env.md +1 -1
- package/docs/guides/runtime/shell.md +1 -1
- package/docs/guides/runtime/tsconfig-paths.md +1 -1
- package/docs/guides/runtime/typescript.md +1 -1
- package/docs/guides/runtime/vscode-debugger.md +1 -1
- package/docs/guides/streams/to-array.md +1 -1
- package/docs/guides/streams/to-arraybuffer.md +1 -1
- package/docs/guides/streams/to-blob.md +1 -1
- package/docs/guides/streams/to-buffer.md +1 -1
- package/docs/guides/streams/to-json.md +1 -1
- package/docs/guides/streams/to-string.md +1 -1
- package/docs/guides/streams/to-typedarray.md +1 -1
- package/docs/guides/test/run-tests.md +3 -3
- package/docs/guides/test/snapshot.md +3 -3
- package/docs/guides/test/update-snapshots.md +1 -1
- package/docs/guides/util/base64.md +1 -1
- package/docs/guides/util/deep-equals.md +3 -3
- package/docs/guides/util/deflate.md +1 -1
- package/docs/guides/util/entrypoint.md +2 -2
- package/docs/guides/util/escape-html.md +1 -1
- package/docs/guides/util/file-url-to-path.md +1 -1
- package/docs/guides/util/gzip.md +1 -1
- package/docs/guides/util/hash-a-password.md +1 -1
- package/docs/guides/util/import-meta-dir.md +2 -2
- package/docs/guides/util/import-meta-file.md +2 -2
- package/docs/guides/util/import-meta-path.md +2 -2
- package/docs/guides/util/javascript-uuid.md +1 -1
- package/docs/guides/util/main.md +1 -1
- package/docs/guides/util/path-to-file-url.md +1 -1
- package/docs/guides/util/sleep.md +1 -1
- package/docs/guides/util/version.md +2 -2
- package/docs/guides/util/which-path-to-executable-bin.md +1 -1
- package/docs/guides/websocket/context.md +1 -1
- package/docs/guides/websocket/simple.md +1 -1
- package/docs/guides/write-file/basic.md +2 -2
- package/docs/guides/write-file/blob.md +2 -2
- package/docs/guides/write-file/cat.md +2 -2
- package/docs/guides/write-file/file-cp.md +2 -2
- package/docs/guides/write-file/filesink.md +1 -1
- package/docs/guides/write-file/response.md +3 -3
- package/docs/guides/write-file/stdout.md +2 -2
- package/docs/guides/write-file/stream.md +2 -2
- package/docs/guides/write-file/unlink.md +1 -1
- package/docs/index.md +1 -1
- package/docs/install/lockfile.md +1 -1
- package/docs/install/npmrc.md +4 -4
- package/docs/install/patch.md +2 -2
- package/docs/install/registries.md +1 -1
- package/docs/install/workspaces.md +3 -3
- package/docs/installation.md +8 -8
- package/docs/project/benchmarking.md +1 -1
- package/docs/project/building-windows.md +2 -2
- package/docs/project/contributing.md +2 -2
- package/docs/quickstart.md +1 -1
- package/docs/runtime/autoimport.md +1 -1
- package/docs/runtime/bun-apis.md +36 -36
- package/docs/runtime/debugger.md +4 -4
- package/docs/runtime/env.md +1 -1
- package/docs/runtime/index.md +19 -19
- package/docs/runtime/jsx.md +1 -1
- package/docs/runtime/loaders.md +3 -3
- package/docs/runtime/nodejs-apis.md +4 -4
- package/docs/runtime/plugins.md +5 -5
- package/docs/runtime/typescript.md +1 -1
- package/docs/test/dom.md +1 -1
- package/package.json +2 -2
- package/shell.d.ts +2 -2
package/docs/cli/install.md
CHANGED
|
@@ -68,7 +68,7 @@ $ bun install --concurrent-scripts 5
|
|
|
68
68
|
|
|
69
69
|
## Workspaces
|
|
70
70
|
|
|
71
|
-
Bun supports `"workspaces"` in package.json. For complete documentation refer to [Package manager > Workspaces](https://bun.
|
|
71
|
+
Bun supports `"workspaces"` in package.json. For complete documentation refer to [Package manager > Workspaces](https://bun.com/docs/install/workspaces).
|
|
72
72
|
|
|
73
73
|
```json#package.json
|
|
74
74
|
{
|
|
@@ -93,11 +93,11 @@ $ bun install --filter '!pkg-c'
|
|
|
93
93
|
$ bun install --filter './packages/pkg-a'
|
|
94
94
|
```
|
|
95
95
|
|
|
96
|
-
For more information on filtering with `bun install`, refer to [Package Manager > Filtering](https://bun.
|
|
96
|
+
For more information on filtering with `bun install`, refer to [Package Manager > Filtering](https://bun.com/docs/cli/filter#bun-install-and-bun-outdated)
|
|
97
97
|
|
|
98
98
|
## Overrides and resolutions
|
|
99
99
|
|
|
100
|
-
Bun supports npm's `"overrides"` and Yarn's `"resolutions"` in `package.json`. These are mechanisms for specifying a version range for _metadependencies_—the dependencies of your dependencies. Refer to [Package manager > Overrides and resolutions](https://bun.
|
|
100
|
+
Bun supports npm's `"overrides"` and Yarn's `"resolutions"` in `package.json`. These are mechanisms for specifying a version range for _metadependencies_—the dependencies of your dependencies. Refer to [Package manager > Overrides and resolutions](https://bun.com/docs/install/overrides) for complete documentation.
|
|
101
101
|
|
|
102
102
|
```json-diff#package.json
|
|
103
103
|
{
|
|
@@ -142,7 +142,7 @@ For reproducible installs, use `--frozen-lockfile`. This will install the exact
|
|
|
142
142
|
$ bun install --frozen-lockfile
|
|
143
143
|
```
|
|
144
144
|
|
|
145
|
-
For more information on Bun's lockfile `bun.lock`, refer to [Package manager > Lockfile](https://bun.
|
|
145
|
+
For more information on Bun's lockfile `bun.lock`, refer to [Package manager > Lockfile](https://bun.com/docs/install/lockfile).
|
|
146
146
|
|
|
147
147
|
## Omitting dependencies
|
|
148
148
|
|
|
@@ -168,7 +168,7 @@ $ bun install --dry-run
|
|
|
168
168
|
|
|
169
169
|
## Non-npm dependencies
|
|
170
170
|
|
|
171
|
-
Bun supports installing dependencies from Git, GitHub, and local or remotely-hosted tarballs. For complete documentation refer to [Package manager > Git, GitHub, and tarball dependencies](https://bun.
|
|
171
|
+
Bun supports installing dependencies from Git, GitHub, and local or remotely-hosted tarballs. For complete documentation refer to [Package manager > Git, GitHub, and tarball dependencies](https://bun.com/docs/cli/add).
|
|
172
172
|
|
|
173
173
|
```json#package.json
|
|
174
174
|
{
|
package/docs/cli/patch-commit.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
An alias for `bun patch --commit` to maintain compatibility with pnpm.
|
|
2
2
|
|
|
3
|
-
To get started with patch, first prepare the package for patching with [`bun patch <pkg>`](https://bun.
|
|
3
|
+
To get started with patch, first prepare the package for patching with [`bun patch <pkg>`](https://bun.com/docs/install/patch).
|
|
4
4
|
|
|
5
5
|
### `--patches-dir`
|
|
6
6
|
|
package/docs/cli/pm.md
CHANGED
|
@@ -158,7 +158,7 @@ To display current package version and help:
|
|
|
158
158
|
|
|
159
159
|
```bash
|
|
160
160
|
$ bun pm version
|
|
161
|
-
bun pm version v1.2.19-canary.
|
|
161
|
+
bun pm version v1.2.19-canary.20250710T140803 (ca7428e9)
|
|
162
162
|
Current package version: v1.0.0
|
|
163
163
|
|
|
164
164
|
Increment:
|
package/docs/cli/publish.md
CHANGED
package/docs/cli/run.md
CHANGED
|
@@ -106,7 +106,7 @@ $ bun run clean
|
|
|
106
106
|
Done.
|
|
107
107
|
```
|
|
108
108
|
|
|
109
|
-
Bun executes the script command in a subshell. On Linux & macOS, it checks for the following shells in order, using the first one it finds: `bash`, `sh`, `zsh`. On windows, it uses [bun shell](https://bun.
|
|
109
|
+
Bun executes the script command in a subshell. On Linux & macOS, it checks for the following shells in order, using the first one it finds: `bash`, `sh`, `zsh`. On windows, it uses [bun shell](https://bun.com/docs/runtime/shell) to support bash-like syntax and many common commands.
|
|
110
110
|
|
|
111
111
|
{% callout %}
|
|
112
112
|
⚡️ The startup time for `npm run` on Linux is roughly 170ms; with Bun it is `6ms`.
|
|
@@ -164,7 +164,7 @@ bun run --filter 'ba*' <script>
|
|
|
164
164
|
|
|
165
165
|
will execute `<script>` in both `bar` and `baz`, but not in `foo`.
|
|
166
166
|
|
|
167
|
-
Find more details in the docs page for [filter](https://bun.
|
|
167
|
+
Find more details in the docs page for [filter](https://bun.com/docs/cli/filter#running-scripts-with-filter).
|
|
168
168
|
|
|
169
169
|
## `bun run -` to pipe code from stdin
|
|
170
170
|
|
package/docs/cli/test.md
CHANGED
|
@@ -17,7 +17,7 @@ Bun aims for compatibility with Jest, but not everything is implemented. To trac
|
|
|
17
17
|
$ bun test
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
Tests are written in JavaScript or TypeScript with a Jest-like API. Refer to [Writing tests](https://bun.
|
|
20
|
+
Tests are written in JavaScript or TypeScript with a Jest-like API. Refer to [Writing tests](https://bun.com/docs/test/writing) for full documentation.
|
|
21
21
|
|
|
22
22
|
```ts#math.test.ts
|
|
23
23
|
import { expect, test } from "bun:test";
|
|
@@ -53,7 +53,7 @@ To run a specific file in the test runner, make sure the path starts with `./` o
|
|
|
53
53
|
$ bun test ./test/specific-file.test.ts
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
-
The test runner runs all tests in a single process. It loads all `--preload` scripts (see [Lifecycle](https://bun.
|
|
56
|
+
The test runner runs all tests in a single process. It loads all `--preload` scripts (see [Lifecycle](https://bun.com/docs/test/lifecycle) for details), then runs all tests. If a test fails, the test runner will exit with a non-zero exit code.
|
|
57
57
|
|
|
58
58
|
## CI/CD integration
|
|
59
59
|
|
|
@@ -154,7 +154,7 @@ These hooks can be defined inside test files, or in a separate file that is prel
|
|
|
154
154
|
$ bun test --preload ./setup.ts
|
|
155
155
|
```
|
|
156
156
|
|
|
157
|
-
See [Test > Lifecycle](https://bun.
|
|
157
|
+
See [Test > Lifecycle](https://bun.com/docs/test/lifecycle) for complete documentation.
|
|
158
158
|
|
|
159
159
|
## Mocks
|
|
160
160
|
|
|
@@ -182,7 +182,7 @@ Alternatively, you can use `jest.fn()`, it behaves identically.
|
|
|
182
182
|
+ const random = jest.fn(() => Math.random());
|
|
183
183
|
```
|
|
184
184
|
|
|
185
|
-
See [Test > Mocks](https://bun.
|
|
185
|
+
See [Test > Mocks](https://bun.com/docs/test/mocks) for complete documentation.
|
|
186
186
|
|
|
187
187
|
## Snapshot testing
|
|
188
188
|
|
|
@@ -203,7 +203,7 @@ To update snapshots, use the `--update-snapshots` flag.
|
|
|
203
203
|
$ bun test --update-snapshots
|
|
204
204
|
```
|
|
205
205
|
|
|
206
|
-
See [Test > Snapshots](https://bun.
|
|
206
|
+
See [Test > Snapshots](https://bun.com/docs/test/snapshots) for complete documentation.
|
|
207
207
|
|
|
208
208
|
## UI & DOM testing
|
|
209
209
|
|
|
@@ -213,7 +213,7 @@ Bun is compatible with popular UI testing libraries:
|
|
|
213
213
|
- [DOM Testing Library](https://testing-library.com/docs/dom-testing-library/intro/)
|
|
214
214
|
- [React Testing Library](https://testing-library.com/docs/react-testing-library/intro)
|
|
215
215
|
|
|
216
|
-
See [Test > DOM Testing](https://bun.
|
|
216
|
+
See [Test > DOM Testing](https://bun.com/docs/test/dom) for complete documentation.
|
|
217
217
|
|
|
218
218
|
## Performance
|
|
219
219
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Projects that use Express and other major Node.js HTTP libraries should work out of the box.
|
|
2
2
|
|
|
3
3
|
{% callout %}
|
|
4
|
-
If you run into bugs, [please file an issue](https://bun.
|
|
4
|
+
If you run into bugs, [please file an issue](https://bun.com/issues) _in Bun's repo_, not the library. It is Bun's responsibility to address Node.js compatibility issues.
|
|
5
5
|
{% /callout %}
|
|
6
6
|
|
|
7
7
|
```ts
|
|
@@ -19,10 +19,10 @@ app.listen(port, () => {
|
|
|
19
19
|
});
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
Bun implements the [`node:http`](https://nodejs.org/api/http.html) and [`node:https`](https://nodejs.org/api/https.html) modules that these libraries rely on. These modules can also be used directly, though [`Bun.serve`](https://bun.
|
|
22
|
+
Bun implements the [`node:http`](https://nodejs.org/api/http.html) and [`node:https`](https://nodejs.org/api/https.html) modules that these libraries rely on. These modules can also be used directly, though [`Bun.serve`](https://bun.com/docs/api/http) is recommended for most use cases.
|
|
23
23
|
|
|
24
24
|
{% callout %}
|
|
25
|
-
**Note** — Refer to the [Runtime > Node.js APIs](https://bun.
|
|
25
|
+
**Note** — Refer to the [Runtime > Node.js APIs](https://bun.com/docs/runtime/nodejs-apis#node-http) page for more detailed compatibility information.
|
|
26
26
|
{% /callout %}
|
|
27
27
|
|
|
28
28
|
```ts
|
package/docs/ecosystem/react.md
CHANGED
|
@@ -36,7 +36,7 @@ function Div(props: {className: string;}) {
|
|
|
36
36
|
|
|
37
37
|
### Server-side rendering
|
|
38
38
|
|
|
39
|
-
To server-side render (SSR) React in an [HTTP server](https://bun.
|
|
39
|
+
To server-side render (SSR) React in an [HTTP server](https://bun.com/docs/api/http):
|
|
40
40
|
|
|
41
41
|
```tsx#ssr.tsx
|
|
42
42
|
import {renderToReadableStream} from 'react-dom/server';
|
|
@@ -24,4 +24,4 @@ const regularArr = Array.from(uintArr);
|
|
|
24
24
|
|
|
25
25
|
---
|
|
26
26
|
|
|
27
|
-
See [Docs > API > Binary Data](https://bun.
|
|
27
|
+
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
|
@@ -21,4 +21,4 @@ blob.type; // => "application/octet-stream"
|
|
|
21
21
|
|
|
22
22
|
---
|
|
23
23
|
|
|
24
|
-
See [Docs > API > Binary Data](https://bun.
|
|
24
|
+
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
|
@@ -22,4 +22,4 @@ const nodeBuffer = Buffer.from(arrBuffer, 0, 16); // view first 16 bytes
|
|
|
22
22
|
|
|
23
23
|
---
|
|
24
24
|
|
|
25
|
-
See [Docs > API > Binary Data](https://bun.
|
|
25
|
+
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
|
@@ -12,4 +12,4 @@ const str = decoder.decode(buf);
|
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
|
-
See [Docs > API > Binary Data](https://bun.
|
|
15
|
+
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
|
@@ -11,4 +11,4 @@ const buf = await blob.arrayBuffer();
|
|
|
11
11
|
|
|
12
12
|
---
|
|
13
13
|
|
|
14
|
-
See [Docs > API > Binary Data](https://bun.
|
|
14
|
+
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
|
@@ -11,4 +11,4 @@ const arr = new DataView(await blob.arrayBuffer());
|
|
|
11
11
|
|
|
12
12
|
---
|
|
13
13
|
|
|
14
|
-
See [Docs > API > Binary Data](https://bun.
|
|
14
|
+
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
|
@@ -11,4 +11,4 @@ const stream = await blob.stream();
|
|
|
11
11
|
|
|
12
12
|
---
|
|
13
13
|
|
|
14
|
-
See [Docs > API > Binary Data](https://bun.
|
|
14
|
+
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
|
@@ -12,4 +12,4 @@ const str = await blob.text();
|
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
|
-
See [Docs > API > Binary Data](https://bun.
|
|
15
|
+
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
|
@@ -11,4 +11,4 @@ const arr = new Uint8Array(await blob.arrayBuffer());
|
|
|
11
11
|
|
|
12
12
|
---
|
|
13
13
|
|
|
14
|
-
See [Docs > API > Binary Data](https://bun.
|
|
14
|
+
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
|
@@ -11,4 +11,4 @@ const arrBuf = nodeBuf.buffer;
|
|
|
11
11
|
|
|
12
12
|
---
|
|
13
13
|
|
|
14
|
-
See [Docs > API > Binary Data](https://bun.
|
|
14
|
+
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
|
@@ -11,4 +11,4 @@ const blob = new Blob([buf]);
|
|
|
11
11
|
|
|
12
12
|
---
|
|
13
13
|
|
|
14
|
-
See [Docs > API > Binary Data](https://bun.
|
|
14
|
+
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
|
@@ -38,4 +38,4 @@ const stream = blob.stream(1024);
|
|
|
38
38
|
|
|
39
39
|
---
|
|
40
40
|
|
|
41
|
-
See [Docs > API > Binary Data](https://bun.
|
|
41
|
+
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
|
@@ -22,4 +22,4 @@ const str = buf.toString("utf8", 0, 5);
|
|
|
22
22
|
|
|
23
23
|
---
|
|
24
24
|
|
|
25
|
-
See [Docs > API > Binary Data](https://bun.
|
|
25
|
+
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
|
@@ -11,4 +11,4 @@ buf instanceof Uint8Array; // => true
|
|
|
11
11
|
|
|
12
12
|
---
|
|
13
13
|
|
|
14
|
-
See [Docs > API > Binary Data](https://bun.
|
|
14
|
+
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
|
@@ -12,4 +12,4 @@ const str = decoder.decode(dv);
|
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
|
-
See [Docs > API > Binary Data](https://bun.
|
|
15
|
+
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
|
@@ -22,4 +22,4 @@ arr.byteLength; // => 32
|
|
|
22
22
|
|
|
23
23
|
---
|
|
24
24
|
|
|
25
|
-
See [Docs > API > Binary Data](https://bun.
|
|
25
|
+
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
|
@@ -13,4 +13,4 @@ console.log(await blob.text());
|
|
|
13
13
|
|
|
14
14
|
---
|
|
15
15
|
|
|
16
|
-
See [Docs > API > Binary Data](https://bun.
|
|
16
|
+
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
|
@@ -11,4 +11,4 @@ const buf = Buffer.from(arr);
|
|
|
11
11
|
|
|
12
12
|
---
|
|
13
13
|
|
|
14
|
-
See [Docs > API > Binary Data](https://bun.
|
|
14
|
+
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
|
@@ -11,4 +11,4 @@ const dv = new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
|
11
11
|
|
|
12
12
|
---
|
|
13
13
|
|
|
14
|
-
See [Docs > API > Binary Data](https://bun.
|
|
14
|
+
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
|
@@ -38,4 +38,4 @@ const stream = blob.stream(1024);
|
|
|
38
38
|
|
|
39
39
|
---
|
|
40
40
|
|
|
41
|
-
See [Docs > API > Binary Data](https://bun.
|
|
41
|
+
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
|
@@ -13,4 +13,4 @@ const str = decoder.decode(arr);
|
|
|
13
13
|
|
|
14
14
|
---
|
|
15
15
|
|
|
16
|
-
See [Docs > API > Binary Data](https://bun.
|
|
16
|
+
See [Docs > API > Binary Data](https://bun.com/docs/api/binary-data#conversion) for complete documentation on manipulating binary data with Bun.
|
|
@@ -5,7 +5,7 @@ name: Build an HTTP server using Express and Bun
|
|
|
5
5
|
Express and other major Node.js HTTP libraries should work out of the box. Bun implements the [`node:http`](https://nodejs.org/api/http.html) and [`node:https`](https://nodejs.org/api/https.html) modules that these libraries rely on.
|
|
6
6
|
|
|
7
7
|
{% callout %}
|
|
8
|
-
Refer to the [Runtime > Node.js APIs](https://bun.
|
|
8
|
+
Refer to the [Runtime > Node.js APIs](https://bun.com/docs/runtime/nodejs-apis#node-http) page for more detailed compatibility information.
|
|
9
9
|
{% /callout %}
|
|
10
10
|
|
|
11
11
|
```sh
|
|
@@ -31,7 +31,7 @@ import { neon } from '@neondatabase/serverless';
|
|
|
31
31
|
import { drizzle } from 'drizzle-orm/neon-http';
|
|
32
32
|
|
|
33
33
|
// Bun automatically loads the DATABASE_URL from .env.local
|
|
34
|
-
// Refer to: https://bun.
|
|
34
|
+
// Refer to: https://bun.com/docs/runtime/env for more information
|
|
35
35
|
const sql = neon(process.env.DATABASE_URL!);
|
|
36
36
|
|
|
37
37
|
export const db = drizzle(sql);
|
|
@@ -31,7 +31,7 @@ Paste the following code into your project's `index.ts` file.
|
|
|
31
31
|
import { neon } from "@neondatabase/serverless";
|
|
32
32
|
|
|
33
33
|
// Bun automatically loads the DATABASE_URL from .env.local
|
|
34
|
-
// Refer to: https://bun.
|
|
34
|
+
// Refer to: https://bun.com/docs/runtime/env for more information
|
|
35
35
|
const sql = neon(process.env.DATABASE_URL);
|
|
36
36
|
|
|
37
37
|
const rows = await sql`SELECT version()`;
|
|
@@ -9,7 +9,7 @@ $ bunx nuxi init my-nuxt-app
|
|
|
9
9
|
✔ Which package manager would you like to use?
|
|
10
10
|
bun
|
|
11
11
|
◐ Installing dependencies...
|
|
12
|
-
bun install v1.2.19-canary.
|
|
12
|
+
bun install v1.2.19-canary.20250710T140803 (16b4bf34)
|
|
13
13
|
+ @nuxt/devtools@0.8.2
|
|
14
14
|
+ nuxt@3.7.0
|
|
15
15
|
785 packages installed [2.67s]
|
|
@@ -4,7 +4,7 @@ name: Extract links from a webpage using HTMLRewriter
|
|
|
4
4
|
|
|
5
5
|
## Extract links from a webpage
|
|
6
6
|
|
|
7
|
-
Bun's [HTMLRewriter](https://bun.
|
|
7
|
+
Bun's [HTMLRewriter](https://bun.com/docs/api/html-rewriter) API can be used to efficiently extract links from HTML content. It works by chaining together CSS selectors to match the elements, text, and attributes you want to process. This is a simple example of how to extract links from a webpage. You can pass `.transform` a `Response`, `Blob`, or `string`.
|
|
8
8
|
|
|
9
9
|
```ts
|
|
10
10
|
async function extractLinks(url: string) {
|
|
@@ -22,11 +22,11 @@ async function extractLinks(url: string) {
|
|
|
22
22
|
|
|
23
23
|
// Wait for the response to be processed
|
|
24
24
|
await rewriter.transform(response).blob();
|
|
25
|
-
console.log([...links]); // ["https://bun.
|
|
25
|
+
console.log([...links]); // ["https://bun.com", "/docs", ...]
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
// Extract all links from the Bun website
|
|
29
|
-
await extractLinks("https://bun.
|
|
29
|
+
await extractLinks("https://bun.com");
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
---
|
|
@@ -65,4 +65,4 @@ const websiteLinks = await extractLinksFromURL("https://example.com");
|
|
|
65
65
|
|
|
66
66
|
---
|
|
67
67
|
|
|
68
|
-
See [Docs > API > HTMLRewriter](https://bun.
|
|
68
|
+
See [Docs > API > HTMLRewriter](https://bun.com/docs/api/html-rewriter) for complete documentation on HTML transformation with Bun.
|
|
@@ -4,7 +4,7 @@ name: Extract social share images and Open Graph tags
|
|
|
4
4
|
|
|
5
5
|
## Extract social share images and Open Graph tags
|
|
6
6
|
|
|
7
|
-
Bun's [HTMLRewriter](https://bun.
|
|
7
|
+
Bun's [HTMLRewriter](https://bun.com/docs/api/html-rewriter) API can be used to efficiently extract social share images and Open Graph metadata from HTML content. This is particularly useful for building link preview features, social media cards, or web scrapers. We can use HTMLRewriter to match CSS selectors to HTML elements, text, and attributes we want to process.
|
|
8
8
|
|
|
9
9
|
```ts
|
|
10
10
|
interface SocialMetadata {
|
|
@@ -81,12 +81,12 @@ async function extractSocialMetadata(url: string): Promise<SocialMetadata> {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
// Example usage
|
|
84
|
-
const metadata = await extractSocialMetadata("https://bun.
|
|
84
|
+
const metadata = await extractSocialMetadata("https://bun.com");
|
|
85
85
|
console.log(metadata);
|
|
86
86
|
// {
|
|
87
87
|
// title: "Bun — A fast all-in-one JavaScript runtime",
|
|
88
88
|
// description: "Bundle, transpile, install and run JavaScript & TypeScript projects — all in Bun. Bun is a fast all-in-one JavaScript runtime & toolkit designed for speed, complete with a bundler, test runner, and Node.js-compatible package manager.",
|
|
89
|
-
// image: "https://bun.
|
|
89
|
+
// image: "https://bun.com/share.jpg",
|
|
90
90
|
// type: "website",
|
|
91
91
|
// ...
|
|
92
92
|
// }
|
|
@@ -5,7 +5,7 @@ name: Send an HTTP request using fetch
|
|
|
5
5
|
Bun implements the Web-standard [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) API for sending HTTP requests. To send a simple `GET` request to a URL:
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
|
-
const response = await fetch("https://bun.
|
|
8
|
+
const response = await fetch("https://bun.com");
|
|
9
9
|
const html = await response.text(); // HTML string
|
|
10
10
|
```
|
|
11
11
|
|
|
@@ -14,7 +14,7 @@ const html = await response.text(); // HTML string
|
|
|
14
14
|
To send a `POST` request to an API endpoint.
|
|
15
15
|
|
|
16
16
|
```ts
|
|
17
|
-
const response = await fetch("https://bun.
|
|
17
|
+
const response = await fetch("https://bun.com/api", {
|
|
18
18
|
method: "POST",
|
|
19
19
|
body: JSON.stringify({ message: "Hello from Bun!" }),
|
|
20
20
|
headers: { "Content-Type": "application/json" },
|
|
@@ -61,7 +61,7 @@ Our form will send a `POST` request to the `/action` endpoint with the form data
|
|
|
61
61
|
|
|
62
62
|
First we use the [`.formData()`](https://developer.mozilla.org/en-US/docs/Web/API/Request/formData) method on the incoming `Request` to asynchronously parse its contents to a `FormData` instance. Then we can use the [`.get()`](https://developer.mozilla.org/en-US/docs/Web/API/FormData/get) method to extract the value of the `name` and `profilePicture` fields. Here `name` corresponds to a `string` and `profilePicture` is a `Blob`.
|
|
63
63
|
|
|
64
|
-
Finally, we write the `Blob` to disk using [`Bun.write()`](https://bun.
|
|
64
|
+
Finally, we write the `Blob` to disk using [`Bun.write()`](https://bun.com/docs/api/file-io#writing-files-bun-write).
|
|
65
65
|
|
|
66
66
|
```ts-diff#index.ts
|
|
67
67
|
const server = Bun.serve({
|
package/docs/guides/http/hot.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: Hot reload an HTTP server
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
Bun supports the [`--hot`](https://bun.
|
|
5
|
+
Bun supports the [`--hot`](https://bun.com/docs/runtime/hot#hot-mode) flag to run a file with hot reloading enabled. When any module or file changes, Bun re-runs the file.
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
8
|
$ bun --hot run index.ts
|
|
@@ -4,7 +4,7 @@ name: Common HTTP server usage
|
|
|
4
4
|
|
|
5
5
|
This starts an HTTP server listening on port `3000`. It demonstrates basic routing with a number of common responses and also handles POST data from standard forms or as JSON.
|
|
6
6
|
|
|
7
|
-
See [`Bun.serve`](https://bun.
|
|
7
|
+
See [`Bun.serve`](https://bun.com/docs/api/http) for details.
|
|
8
8
|
|
|
9
9
|
```ts
|
|
10
10
|
const server = Bun.serve({
|
|
@@ -4,7 +4,7 @@ name: Write a simple HTTP server
|
|
|
4
4
|
|
|
5
5
|
This starts an HTTP server listening on port `3000`. It responds to all requests with a `Response` with status `200` and body `"Welcome to Bun!"`.
|
|
6
6
|
|
|
7
|
-
See [`Bun.serve`](https://bun.
|
|
7
|
+
See [`Bun.serve`](https://bun.com/docs/api/http) for details.
|
|
8
8
|
|
|
9
9
|
```ts
|
|
10
10
|
const server = Bun.serve({
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: Stream a file as an HTTP Response
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
This snippet reads a file from disk using [`Bun.file()`](https://bun.
|
|
5
|
+
This snippet reads a file from disk using [`Bun.file()`](https://bun.com/docs/api/file-io#reading-files-bun-file). This returns a `BunFile` instance, which can be passed directly into the `new Response` constructor.
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
8
|
const path = "/path/to/file.txt";
|
|
@@ -30,7 +30,7 @@ new Response(Bun.file("./img.png")).headers.get("Content-Type");
|
|
|
30
30
|
|
|
31
31
|
---
|
|
32
32
|
|
|
33
|
-
Putting it all together with [`Bun.serve()`](https://bun.
|
|
33
|
+
Putting it all together with [`Bun.serve()`](https://bun.com/docs/api/http#bun-serve).
|
|
34
34
|
|
|
35
35
|
```ts
|
|
36
36
|
// static file server
|
|
@@ -45,4 +45,4 @@ Bun.serve({
|
|
|
45
45
|
|
|
46
46
|
---
|
|
47
47
|
|
|
48
|
-
See [Docs > API > File I/O](https://bun.
|
|
48
|
+
See [Docs > API > File I/O](https://bun.com/docs/api/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`.
|
package/docs/guides/http/tls.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name: Configure TLS on an HTTP server
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
Set the `tls` key to configure TLS. Both `key` and `cert` are required. The `key` should be the contents of your private key; `cert` should be the contents of your issued certificate. Use [`Bun.file()`](https://bun.
|
|
5
|
+
Set the `tls` key to configure TLS. Both `key` and `cert` are required. The `key` should be the contents of your private key; `cert` should be the contents of your issued certificate. Use [`Bun.file()`](https://bun.com/docs/api/file-io#reading-files-bun-file) to read the contents.
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
8
|
const server = Bun.serve({
|
|
@@ -23,4 +23,4 @@ This will add the package to `devDependencies` in `package.json`.
|
|
|
23
23
|
|
|
24
24
|
---
|
|
25
25
|
|
|
26
|
-
See [Docs > Package manager](https://bun.
|
|
26
|
+
See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager.
|
|
@@ -33,4 +33,4 @@ $ bun add github:colinhacks/zod
|
|
|
33
33
|
|
|
34
34
|
---
|
|
35
35
|
|
|
36
|
-
See [Docs > Package manager](https://bun.
|
|
36
|
+
See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager.
|
|
@@ -22,4 +22,4 @@ This will add the package to `optionalDependencies` in `package.json`.
|
|
|
22
22
|
|
|
23
23
|
---
|
|
24
24
|
|
|
25
|
-
See [Docs > Package manager](https://bun.
|
|
25
|
+
See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager.
|
|
@@ -15,7 +15,7 @@ This will add the package to `peerDependencies` in `package.json`.
|
|
|
15
15
|
```json-diff
|
|
16
16
|
{
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
+ "@types/bun": "^1.2.19-canary.
|
|
18
|
+
+ "@types/bun": "^1.2.19-canary.20250710T140803"
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
```
|
|
@@ -27,7 +27,7 @@ Running `bun install` will install peer dependencies by default, unless marked o
|
|
|
27
27
|
```json-diff
|
|
28
28
|
{
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@types/bun": "^1.2.19-canary.
|
|
30
|
+
"@types/bun": "^1.2.19-canary.20250710T140803"
|
|
31
31
|
},
|
|
32
32
|
"peerDependenciesMeta": {
|
|
33
33
|
+ "@types/bun": {
|
|
@@ -40,4 +40,4 @@ Running `bun install` will install peer dependencies by default, unless marked o
|
|
|
40
40
|
|
|
41
41
|
---
|
|
42
42
|
|
|
43
|
-
See [Docs > Package manager](https://bun.
|
|
43
|
+
See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager.
|
|
@@ -30,4 +30,4 @@ import { z } from "zod";
|
|
|
30
30
|
|
|
31
31
|
---
|
|
32
32
|
|
|
33
|
-
See [Docs > Package manager](https://bun.
|
|
33
|
+
See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager.
|
|
@@ -26,7 +26,7 @@ password = "$NPM_PASSWORD"
|
|
|
26
26
|
|
|
27
27
|
---
|
|
28
28
|
|
|
29
|
-
Then assign your Azure Personal Access Token to the `NPM_PASSWORD` environment variable. Bun [automatically reads](https://bun.
|
|
29
|
+
Then assign your Azure Personal Access Token to the `NPM_PASSWORD` environment variable. Bun [automatically reads](https://bun.com/docs/runtime/env) `.env` files, so create a file called `.env` in your project root. There is no need to base-64 encode this token! Bun will do this for you.
|
|
30
30
|
|
|
31
31
|
```txt#.env
|
|
32
32
|
NPM_PASSWORD=<paste token here>
|