bun-types 1.3.3 → 1.3.4-canary.20251123T140630
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/CLAUDE.md +3 -3
- package/docs/bundler/css.mdx +1 -1
- package/docs/bundler/executables.mdx +33 -4
- package/docs/bundler/fullstack.mdx +3 -3
- package/docs/bundler/hot-reloading.mdx +2 -2
- package/docs/bundler/html-static.mdx +10 -9
- package/docs/bundler/index.mdx +27 -18
- package/docs/bundler/loaders.mdx +2 -2
- package/docs/bundler/macros.mdx +1 -1
- package/docs/feedback.mdx +2 -12
- package/docs/guides/binary/arraybuffer-to-array.mdx +1 -1
- package/docs/guides/binary/arraybuffer-to-blob.mdx +1 -1
- package/docs/guides/binary/arraybuffer-to-buffer.mdx +1 -1
- package/docs/guides/binary/arraybuffer-to-string.mdx +1 -1
- package/docs/guides/binary/arraybuffer-to-typedarray.mdx +1 -1
- package/docs/guides/binary/blob-to-arraybuffer.mdx +1 -1
- package/docs/guides/binary/blob-to-dataview.mdx +1 -1
- package/docs/guides/binary/blob-to-stream.mdx +1 -1
- package/docs/guides/binary/blob-to-string.mdx +1 -1
- package/docs/guides/binary/blob-to-typedarray.mdx +1 -1
- package/docs/guides/binary/buffer-to-arraybuffer.mdx +1 -1
- package/docs/guides/binary/buffer-to-blob.mdx +1 -1
- package/docs/guides/binary/buffer-to-readablestream.mdx +1 -1
- package/docs/guides/binary/buffer-to-string.mdx +1 -1
- package/docs/guides/binary/buffer-to-typedarray.mdx +1 -1
- package/docs/guides/binary/dataview-to-string.mdx +1 -1
- package/docs/guides/binary/typedarray-to-arraybuffer.mdx +1 -1
- package/docs/guides/binary/typedarray-to-blob.mdx +1 -1
- package/docs/guides/binary/typedarray-to-buffer.mdx +1 -1
- package/docs/guides/binary/typedarray-to-dataview.mdx +1 -1
- package/docs/guides/binary/typedarray-to-readablestream.mdx +1 -1
- package/docs/guides/binary/typedarray-to-string.mdx +1 -1
- package/docs/guides/deployment/aws-lambda.mdx +6 -6
- package/docs/guides/deployment/digital-ocean.mdx +7 -7
- package/docs/guides/deployment/vercel.mdx +1 -3
- package/docs/guides/ecosystem/discordjs.mdx +2 -2
- package/docs/guides/ecosystem/express.mdx +2 -2
- package/docs/guides/ecosystem/mongoose.mdx +1 -1
- package/docs/guides/ecosystem/neon-drizzle.mdx +2 -2
- package/docs/guides/ecosystem/neon-serverless-postgres.mdx +2 -2
- package/docs/guides/ecosystem/nuxt.mdx +1 -1
- package/docs/guides/ecosystem/prisma-postgres.mdx +1 -1
- package/docs/guides/ecosystem/prisma.mdx +1 -1
- package/docs/guides/ecosystem/qwik.mdx +4 -4
- package/docs/guides/ecosystem/sentry.mdx +2 -2
- package/docs/guides/ecosystem/sveltekit.mdx +1 -1
- package/docs/guides/ecosystem/tanstack-start.mdx +0 -1
- package/docs/guides/ecosystem/upstash.mdx +2 -2
- package/docs/guides/ecosystem/vite.mdx +2 -2
- package/docs/guides/html-rewriter/extract-links.mdx +2 -2
- package/docs/guides/html-rewriter/extract-social-meta.mdx +1 -1
- package/docs/guides/http/file-uploads.mdx +1 -1
- package/docs/guides/http/hot.mdx +1 -1
- package/docs/guides/http/server.mdx +1 -1
- package/docs/guides/http/simple.mdx +1 -1
- package/docs/guides/http/stream-file.mdx +3 -3
- package/docs/guides/http/tls.mdx +1 -1
- package/docs/guides/install/add-dev.mdx +1 -1
- package/docs/guides/install/add-git.mdx +1 -1
- package/docs/guides/install/add-optional.mdx +1 -1
- package/docs/guides/install/add-peer.mdx +3 -3
- package/docs/guides/install/add-tarball.mdx +1 -1
- package/docs/guides/install/add.mdx +1 -1
- package/docs/guides/install/azure-artifacts.mdx +3 -3
- package/docs/guides/install/custom-registry.mdx +2 -2
- package/docs/guides/install/from-npm-install-to-bun-install.mdx +1 -1
- package/docs/guides/install/git-diff-bun-lockfile.mdx +2 -1
- package/docs/guides/install/npm-alias.mdx +1 -1
- package/docs/guides/install/registry-scope.mdx +3 -3
- package/docs/guides/install/trusted.mdx +1 -1
- package/docs/guides/install/workspaces.mdx +1 -1
- package/docs/guides/install/yarnlock.mdx +4 -3
- package/docs/guides/process/ctrl-c.mdx +1 -1
- package/docs/guides/process/ipc.mdx +2 -2
- package/docs/guides/process/nanoseconds.mdx +1 -1
- package/docs/guides/process/os-signals.mdx +1 -1
- package/docs/guides/process/spawn-stderr.mdx +2 -2
- package/docs/guides/process/spawn-stdout.mdx +2 -2
- package/docs/guides/process/spawn.mdx +2 -2
- package/docs/guides/process/stdin.mdx +1 -1
- package/docs/guides/read-file/arraybuffer.mdx +2 -2
- package/docs/guides/read-file/buffer.mdx +1 -1
- package/docs/guides/read-file/exists.mdx +1 -1
- package/docs/guides/read-file/mime.mdx +1 -1
- package/docs/guides/read-file/stream.mdx +1 -1
- package/docs/guides/read-file/uint8array.mdx +1 -1
- package/docs/guides/read-file/watch.mdx +1 -1
- package/docs/guides/runtime/build-time-constants.mdx +3 -3
- package/docs/guides/runtime/cicd.mdx +1 -1
- package/docs/guides/runtime/codesign-macos-executable.mdx +1 -1
- package/docs/guides/runtime/delete-directory.mdx +1 -1
- package/docs/guides/runtime/delete-file.mdx +1 -1
- package/docs/guides/runtime/heap-snapshot.mdx +1 -1
- package/docs/guides/runtime/import-json.mdx +1 -1
- package/docs/guides/runtime/import-toml.mdx +1 -1
- package/docs/guides/runtime/import-yaml.mdx +1 -1
- package/docs/guides/runtime/read-env.mdx +1 -1
- package/docs/guides/runtime/set-env.mdx +2 -2
- package/docs/guides/runtime/shell.mdx +1 -1
- package/docs/guides/runtime/tsconfig-paths.mdx +1 -1
- package/docs/guides/runtime/typescript.mdx +1 -1
- package/docs/guides/runtime/vscode-debugger.mdx +1 -2
- package/docs/guides/runtime/web-debugger.mdx +1 -1
- package/docs/guides/streams/to-array.mdx +1 -1
- package/docs/guides/streams/to-arraybuffer.mdx +1 -1
- package/docs/guides/streams/to-blob.mdx +1 -1
- package/docs/guides/streams/to-buffer.mdx +1 -1
- package/docs/guides/streams/to-json.mdx +1 -1
- package/docs/guides/streams/to-string.mdx +1 -1
- package/docs/guides/streams/to-typedarray.mdx +1 -1
- package/docs/guides/test/bail.mdx +1 -1
- package/docs/guides/test/concurrent-test-glob.mdx +5 -2
- package/docs/guides/test/coverage-threshold.mdx +1 -1
- package/docs/guides/test/coverage.mdx +1 -1
- package/docs/guides/test/happy-dom.mdx +1 -1
- package/docs/guides/test/migrate-from-jest.mdx +7 -7
- package/docs/guides/test/mock-clock.mdx +2 -2
- package/docs/guides/test/mock-functions.mdx +1 -1
- package/docs/guides/test/rerun-each.mdx +1 -1
- package/docs/guides/test/run-tests.mdx +2 -2
- package/docs/guides/test/skip-tests.mdx +2 -2
- package/docs/guides/test/snapshot.mdx +4 -4
- package/docs/guides/test/spy-on.mdx +1 -1
- package/docs/guides/test/svelte-test.mdx +4 -4
- package/docs/guides/test/testing-library.mdx +3 -3
- package/docs/guides/test/timeout.mdx +1 -1
- package/docs/guides/test/todo-tests.mdx +2 -2
- package/docs/guides/test/update-snapshots.mdx +1 -1
- package/docs/guides/test/watch-mode.mdx +1 -1
- package/docs/guides/util/base64.mdx +1 -1
- package/docs/guides/util/deep-equals.mdx +3 -3
- package/docs/guides/util/deflate.mdx +1 -1
- package/docs/guides/util/entrypoint.mdx +2 -2
- package/docs/guides/util/escape-html.mdx +1 -1
- package/docs/guides/util/file-url-to-path.mdx +1 -1
- package/docs/guides/util/gzip.mdx +1 -1
- package/docs/guides/util/hash-a-password.mdx +1 -1
- package/docs/guides/util/import-meta-dir.mdx +2 -2
- package/docs/guides/util/import-meta-file.mdx +2 -2
- package/docs/guides/util/import-meta-path.mdx +2 -2
- package/docs/guides/util/javascript-uuid.mdx +2 -2
- package/docs/guides/util/main.mdx +1 -1
- package/docs/guides/util/path-to-file-url.mdx +1 -1
- package/docs/guides/util/sleep.mdx +1 -1
- package/docs/guides/util/version.mdx +2 -2
- package/docs/guides/util/which-path-to-executable-bin.mdx +1 -1
- package/docs/guides/websocket/context.mdx +1 -1
- package/docs/guides/websocket/simple.mdx +1 -1
- package/docs/guides/write-file/basic.mdx +2 -2
- package/docs/guides/write-file/blob.mdx +2 -2
- package/docs/guides/write-file/cat.mdx +2 -2
- package/docs/guides/write-file/file-cp.mdx +2 -2
- package/docs/guides/write-file/filesink.mdx +1 -1
- package/docs/guides/write-file/response.mdx +2 -2
- package/docs/guides/write-file/stdout.mdx +2 -2
- package/docs/guides/write-file/stream.mdx +2 -2
- package/docs/guides/write-file/unlink.mdx +1 -1
- package/docs/index.mdx +2 -2
- package/docs/installation.mdx +3 -3
- package/docs/pm/bunx.mdx +2 -2
- package/docs/pm/cli/install.mdx +8 -8
- package/docs/pm/cli/link.mdx +2 -2
- package/docs/pm/cli/outdated.mdx +3 -3
- package/docs/pm/cli/patch.mdx +2 -2
- package/docs/pm/cli/pm.mdx +1 -1
- package/docs/pm/cli/publish.mdx +1 -1
- package/docs/pm/filter.mdx +2 -2
- package/docs/pm/isolated-installs.mdx +3 -3
- package/docs/pm/npmrc.mdx +6 -6
- package/docs/pm/scopes-registries.mdx +1 -1
- package/docs/pm/security-scanner-api.mdx +2 -2
- package/docs/pm/workspaces.mdx +3 -4
- package/docs/project/benchmarking.mdx +1 -1
- package/docs/project/building-windows.mdx +1 -1
- package/docs/project/contributing.mdx +1 -1
- package/docs/project/license.mdx +1 -1
- package/docs/quickstart.mdx +3 -3
- package/docs/runtime/auto-install.mdx +1 -1
- package/docs/runtime/binary-data.mdx +1 -1
- package/docs/runtime/bun-apis.mdx +35 -35
- package/docs/runtime/bunfig.mdx +29 -3
- package/docs/runtime/c-compiler.mdx +3 -3
- package/docs/runtime/child-process.mdx +2 -2
- package/docs/runtime/cookies.mdx +19 -19
- package/docs/runtime/debugger.mdx +4 -4
- package/docs/runtime/environment-variables.mdx +24 -7
- package/docs/runtime/ffi.mdx +2 -2
- package/docs/runtime/file-io.mdx +2 -2
- package/docs/runtime/file-types.mdx +5 -5
- package/docs/runtime/globals.mdx +4 -4
- package/docs/runtime/http/error-handling.mdx +2 -2
- package/docs/runtime/http/routing.mdx +1 -1
- package/docs/runtime/http/server.mdx +5 -9
- package/docs/runtime/http/websockets.mdx +1 -1
- package/docs/runtime/index.mdx +2 -2
- package/docs/runtime/jsx.mdx +1 -1
- package/docs/runtime/module-resolution.mdx +2 -2
- package/docs/runtime/networking/fetch.mdx +4 -4
- package/docs/runtime/nodejs-compat.mdx +3 -3
- package/docs/runtime/plugins.mdx +1 -1
- package/docs/runtime/s3.mdx +4 -4
- package/docs/runtime/secrets.mdx +10 -7
- package/docs/runtime/sql.mdx +10 -10
- package/docs/runtime/sqlite.mdx +15 -4
- package/docs/runtime/templating/create.mdx +4 -4
- package/docs/runtime/transpiler.mdx +1 -1
- package/docs/runtime/utils.mdx +3 -3
- package/docs/runtime/watch-mode.mdx +1 -1
- package/docs/runtime/workers.mdx +5 -17
- package/docs/snippets/cli/publish.mdx +2 -2
- package/docs/test/configuration.mdx +1 -1
- package/docs/test/dom.mdx +1 -1
- package/docs/test/index.mdx +8 -8
- package/docs/test/reporters.mdx +1 -1
- package/docs/test/snapshots.mdx +3 -3
- package/docs/test/writing-tests.mdx +37 -0
- package/docs/typescript.mdx +2 -2
- package/package.json +3 -4
- package/docs/snippets/product-card.mdx +0 -32
- package/docs/snippets/product-tiles.mdx +0 -94
|
@@ -46,4 +46,4 @@ Ran 1 tests across 1 files. [102.00ms]
|
|
|
46
46
|
|
|
47
47
|
---
|
|
48
48
|
|
|
49
|
-
See [Docs > Test Runner > Snapshots](
|
|
49
|
+
See [Docs > Test Runner > Snapshots](/docs/test/snapshots) for complete documentation on snapshots with the Bun test runner.
|
|
@@ -21,4 +21,4 @@ This will restart the running Bun process whenever a file change is detected. It
|
|
|
21
21
|
|
|
22
22
|
---
|
|
23
23
|
|
|
24
|
-
See [Docs > Test Runner](
|
|
24
|
+
See [Docs > Test Runner](/docs/test) for complete documentation on the test runner.
|
|
@@ -14,4 +14,4 @@ const decoded = atob(encoded); // => "hello world"
|
|
|
14
14
|
|
|
15
15
|
---
|
|
16
16
|
|
|
17
|
-
See [Docs > Web APIs](
|
|
17
|
+
See [Docs > Web APIs](/docs/runtime/web-apis) for a complete breakdown of the Web APIs implemented in Bun.
|
|
@@ -4,7 +4,7 @@ sidebarTitle: Deep equality
|
|
|
4
4
|
mode: center
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
Check if two objects are deeply equal. This is used internally by `expect().toEqual()` in Bun's [test runner](
|
|
7
|
+
Check if two objects are deeply equal. This is used internally by `expect().toEqual()` in Bun's [test runner](/docs/test/writing-tests).
|
|
8
8
|
|
|
9
9
|
```ts index.ts icon="/icons/typescript.svg"
|
|
10
10
|
const a = { a: 1, b: 2, c: { d: 3 } };
|
|
@@ -15,7 +15,7 @@ Bun.deepEquals(a, b); // true
|
|
|
15
15
|
|
|
16
16
|
---
|
|
17
17
|
|
|
18
|
-
Pass `true` as a third argument to enable strict mode. This is used internally by `expect().toStrictEqual()` in Bun's [test runner](
|
|
18
|
+
Pass `true` as a third argument to enable strict mode. This is used internally by `expect().toStrictEqual()` in Bun's [test runner](/docs/test/writing-tests).
|
|
19
19
|
|
|
20
20
|
The following examples would return `true` in non-strict mode but `false` in strict mode.
|
|
21
21
|
|
|
@@ -38,4 +38,4 @@ Bun.deepEquals(new Foo(), { a: 1 }, true); // false
|
|
|
38
38
|
|
|
39
39
|
---
|
|
40
40
|
|
|
41
|
-
See [Docs > API > Utils](
|
|
41
|
+
See [Docs > API > Utils](/docs/runtime/utils) for more useful utilities.
|
|
@@ -4,7 +4,7 @@ sidebarTitle: Check entrypoint
|
|
|
4
4
|
mode: center
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
Bun provides a handful of module-specific utilities on the [`import.meta`](
|
|
7
|
+
Bun provides a handful of module-specific utilities on the [`import.meta`](/docs/runtime/module-resolution#import-meta) object. Use `import.meta.main` to check if the current file is the entrypoint of the current process.
|
|
8
8
|
|
|
9
9
|
```ts index.ts icon="/icons/typescript.svg"
|
|
10
10
|
if (import.meta.main) {
|
|
@@ -16,4 +16,4 @@ if (import.meta.main) {
|
|
|
16
16
|
|
|
17
17
|
---
|
|
18
18
|
|
|
19
|
-
See [Docs > API > import.meta](
|
|
19
|
+
See [Docs > API > import.meta](/docs/runtime/module-resolution#import-meta) for complete documentation.
|
|
@@ -53,4 +53,4 @@ const isMatch = await Bun.password.verify(password, hash);
|
|
|
53
53
|
|
|
54
54
|
---
|
|
55
55
|
|
|
56
|
-
See [Docs > API > Hashing](
|
|
56
|
+
See [Docs > API > Hashing](/docs/runtime/hashing#bun-password) for complete documentation.
|
|
@@ -4,7 +4,7 @@ sidebarTitle: import.meta.dir
|
|
|
4
4
|
mode: center
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
Bun provides a handful of module-specific utilities on the [`import.meta`](
|
|
7
|
+
Bun provides a handful of module-specific utilities on the [`import.meta`](/docs/runtime/module-resolution#import-meta) object.
|
|
8
8
|
|
|
9
9
|
```ts /a/b/c.ts icon="/icons/typescript.svg"
|
|
10
10
|
import.meta.dir; // => "/a/b"
|
|
@@ -12,4 +12,4 @@ import.meta.dir; // => "/a/b"
|
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
|
-
See [Docs > API > import.meta](
|
|
15
|
+
See [Docs > API > import.meta](/docs/runtime/module-resolution#import-meta) for complete documentation.
|
|
@@ -4,7 +4,7 @@ sidebarTitle: import.meta.file
|
|
|
4
4
|
mode: center
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
Bun provides a handful of module-specific utilities on the [`import.meta`](
|
|
7
|
+
Bun provides a handful of module-specific utilities on the [`import.meta`](/docs/runtime/module-resolution#import-meta) object. Use `import.meta.file` to retrieve the name of the current file.
|
|
8
8
|
|
|
9
9
|
```ts /a/b/c.ts icon="/icons/typescript.svg"
|
|
10
10
|
import.meta.file; // => "c.ts"
|
|
@@ -12,4 +12,4 @@ import.meta.file; // => "c.ts"
|
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
|
-
See [Docs > API > import.meta](
|
|
15
|
+
See [Docs > API > import.meta](/docs/runtime/module-resolution#import-meta) for complete documentation.
|
|
@@ -4,7 +4,7 @@ sidebarTitle: import.meta.path
|
|
|
4
4
|
mode: center
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
Bun provides a handful of module-specific utilities on the [`import.meta`](
|
|
7
|
+
Bun provides a handful of module-specific utilities on the [`import.meta`](/docs/runtime/module-resolution#import-meta) object. Use `import.meta.path` to retrieve the absolute path of the current file.
|
|
8
8
|
|
|
9
9
|
```ts /a/b/c.ts icon="/icons/typescript.svg"
|
|
10
10
|
import.meta.path; // => "/a/b/c.ts"
|
|
@@ -12,4 +12,4 @@ import.meta.path; // => "/a/b/c.ts"
|
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
|
-
See [Docs > API > import.meta](
|
|
15
|
+
See [Docs > API > import.meta](/docs/runtime/module-resolution#import-meta) for complete documentation.
|
|
@@ -8,7 +8,7 @@ Use `crypto.randomUUID()` to generate a UUID v4. This API works in Bun, Node.js,
|
|
|
8
8
|
|
|
9
9
|
```ts
|
|
10
10
|
crypto.randomUUID();
|
|
11
|
-
// => "123e4567-e89b-
|
|
11
|
+
// => "123e4567-e89b-42d3-a456-426614174000"
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
---
|
|
@@ -22,4 +22,4 @@ Bun.randomUUIDv7();
|
|
|
22
22
|
|
|
23
23
|
---
|
|
24
24
|
|
|
25
|
-
See [Docs > API > Utils](
|
|
25
|
+
See [Docs > API > Utils](/docs/runtime/utils) for more useful utilities.
|
|
@@ -7,7 +7,7 @@ mode: center
|
|
|
7
7
|
Get the current version of Bun in a semver format.
|
|
8
8
|
|
|
9
9
|
```ts index.ts icon="/icons/typescript.svg"
|
|
10
|
-
Bun.version; // => "1.3.
|
|
10
|
+
Bun.version; // => "1.3.3"
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
---
|
|
@@ -20,4 +20,4 @@ Bun.revision; // => "49231b2cb9aa48497ab966fc0bb6b742dacc4994"
|
|
|
20
20
|
|
|
21
21
|
---
|
|
22
22
|
|
|
23
|
-
See [Docs > API > Utils](
|
|
23
|
+
See [Docs > API > Utils](/docs/runtime/utils) for more useful utilities.
|
|
@@ -6,7 +6,7 @@ mode: center
|
|
|
6
6
|
|
|
7
7
|
When building a WebSocket server, it's typically necessary to store some identifying information or context associated with each connected client.
|
|
8
8
|
|
|
9
|
-
With [Bun.serve()](
|
|
9
|
+
With [Bun.serve()](/docs/runtime/http/websockets#contextual-data), this "contextual data" is set when the connection is initially upgraded by passing a `data` parameter in the `server.upgrade()` call.
|
|
10
10
|
|
|
11
11
|
```ts server.ts icon="/icons/typescript.svg"
|
|
12
12
|
Bun.serve({
|
|
@@ -4,7 +4,7 @@ sidebarTitle: Simple server
|
|
|
4
4
|
mode: center
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
Start a simple WebSocket server using [`Bun.serve`](
|
|
7
|
+
Start a simple WebSocket server using [`Bun.serve`](/docs/runtime/http/server).
|
|
8
8
|
|
|
9
9
|
Inside `fetch`, we attempt to upgrade incoming `ws:` or `wss:` requests to WebSocket connections.
|
|
10
10
|
|
|
@@ -6,7 +6,7 @@ mode: center
|
|
|
6
6
|
|
|
7
7
|
This code snippet writes a string to disk at a particular _absolute path_.
|
|
8
8
|
|
|
9
|
-
It uses the fast [`Bun.write()`](
|
|
9
|
+
It uses the fast [`Bun.write()`](/docs/runtime/file-io#writing-files-bun-write) API to efficiently write data to disk. The first argument is a _destination_; the second is the _data_ to write.
|
|
10
10
|
|
|
11
11
|
```ts
|
|
12
12
|
const path = "/path/to/file.txt";
|
|
@@ -43,4 +43,4 @@ const bytes = await Bun.write(path, "Lorem ipsum");
|
|
|
43
43
|
|
|
44
44
|
---
|
|
45
45
|
|
|
46
|
-
See [Docs > API > File I/O](
|
|
46
|
+
See [Docs > API > File I/O](/docs/runtime/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`.
|
|
@@ -6,7 +6,7 @@ mode: center
|
|
|
6
6
|
|
|
7
7
|
This code snippet writes a `Blob` to disk at a particular path.
|
|
8
8
|
|
|
9
|
-
It uses the fast [`Bun.write()`](
|
|
9
|
+
It uses the fast [`Bun.write()`](/docs/runtime/file-io#writing-files-bun-write) API to efficiently write data to disk. The first argument is a _destination_, like an absolute path or `BunFile` instance. The second argument is the _data_ to write.
|
|
10
10
|
|
|
11
11
|
```ts
|
|
12
12
|
const path = "/path/to/file.txt";
|
|
@@ -27,4 +27,4 @@ await Bun.write(path, data);
|
|
|
27
27
|
|
|
28
28
|
---
|
|
29
29
|
|
|
30
|
-
See [Docs > API > File I/O](
|
|
30
|
+
See [Docs > API > File I/O](/docs/runtime/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`.
|
|
@@ -4,7 +4,7 @@ sidebarTitle: Write file to stdout
|
|
|
4
4
|
mode: center
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
Bun exposes `stdout` as a `BunFile` with the `Bun.stdout` property. This can be used as a destination for [`Bun.write()`](
|
|
7
|
+
Bun exposes `stdout` as a `BunFile` with the `Bun.stdout` property. This can be used as a destination for [`Bun.write()`](/docs/runtime/file-io#writing-files-bun-write).
|
|
8
8
|
|
|
9
9
|
This code writes a file to `stdout` similar to the `cat` command in Unix.
|
|
10
10
|
|
|
@@ -16,4 +16,4 @@ await Bun.write(Bun.stdout, file);
|
|
|
16
16
|
|
|
17
17
|
---
|
|
18
18
|
|
|
19
|
-
See [Docs > API > File I/O](
|
|
19
|
+
See [Docs > API > File I/O](/docs/runtime/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`.
|
|
@@ -6,7 +6,7 @@ mode: center
|
|
|
6
6
|
|
|
7
7
|
This code snippet copies a file to another location on disk.
|
|
8
8
|
|
|
9
|
-
It uses the fast [`Bun.write()`](
|
|
9
|
+
It uses the fast [`Bun.write()`](/docs/runtime/file-io#writing-files-bun-write) API to efficiently write data to disk. The first argument is a _destination_, like an absolute path or `BunFile` instance. The second argument is the _data_ to write.
|
|
10
10
|
|
|
11
11
|
```ts
|
|
12
12
|
const file = Bun.file("/path/to/original.txt");
|
|
@@ -15,4 +15,4 @@ await Bun.write("/path/to/copy.txt", file);
|
|
|
15
15
|
|
|
16
16
|
---
|
|
17
17
|
|
|
18
|
-
See [Docs > API > File I/O](
|
|
18
|
+
See [Docs > API > File I/O](/docs/runtime/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`.
|
|
@@ -6,7 +6,7 @@ mode: center
|
|
|
6
6
|
|
|
7
7
|
This code snippet writes a `Response` to disk at a particular path. Bun will consume the `Response` body according to its `Content-Type` header.
|
|
8
8
|
|
|
9
|
-
It uses the fast [`Bun.write()`](
|
|
9
|
+
It uses the fast [`Bun.write()`](/docs/runtime/file-io#writing-files-bun-write) API to efficiently write data to disk. The first argument is a _destination_, like an absolute path or `BunFile` instance. The second argument is the _data_ to write.
|
|
10
10
|
|
|
11
11
|
```ts
|
|
12
12
|
const result = await fetch("https://bun.com");
|
|
@@ -16,4 +16,4 @@ await Bun.write(path, result);
|
|
|
16
16
|
|
|
17
17
|
---
|
|
18
18
|
|
|
19
|
-
See [Docs > API > File I/O](
|
|
19
|
+
See [Docs > API > File I/O](/docs/runtime/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`.
|
|
@@ -12,7 +12,7 @@ console.log("Lorem ipsum");
|
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
|
-
For more advanced use cases, Bun exposes `stdout` as a `BunFile` via the `Bun.stdout` property. This can be used as a destination for [`Bun.write()`](
|
|
15
|
+
For more advanced use cases, Bun exposes `stdout` as a `BunFile` via the `Bun.stdout` property. This can be used as a destination for [`Bun.write()`](/docs/runtime/file-io#writing-files-bun-write).
|
|
16
16
|
|
|
17
17
|
```ts
|
|
18
18
|
await Bun.write(Bun.stdout, "Lorem ipsum");
|
|
@@ -20,4 +20,4 @@ await Bun.write(Bun.stdout, "Lorem ipsum");
|
|
|
20
20
|
|
|
21
21
|
---
|
|
22
22
|
|
|
23
|
-
See [Docs > API > File I/O](
|
|
23
|
+
See [Docs > API > File I/O](/docs/runtime/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`.
|
|
@@ -4,7 +4,7 @@ sidebarTitle: Write stream
|
|
|
4
4
|
mode: center
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
To write a `ReadableStream` to disk, first create a `Response` instance from the stream. This `Response` can then be written to disk using [`Bun.write()`](
|
|
7
|
+
To write a `ReadableStream` to disk, first create a `Response` instance from the stream. This `Response` can then be written to disk using [`Bun.write()`](/docs/runtime/file-io#writing-files-bun-write).
|
|
8
8
|
|
|
9
9
|
```ts
|
|
10
10
|
const stream: ReadableStream = ...;
|
|
@@ -16,4 +16,4 @@ await Bun.write(path, response);
|
|
|
16
16
|
|
|
17
17
|
---
|
|
18
18
|
|
|
19
|
-
See [Docs > API > File I/O](
|
|
19
|
+
See [Docs > API > File I/O](/docs/runtime/file-io#writing-files-bun-write) for complete documentation of `Bun.write()`.
|
|
@@ -15,4 +15,4 @@ await file.delete();
|
|
|
15
15
|
|
|
16
16
|
---
|
|
17
17
|
|
|
18
|
-
See [Docs > API > File I/O](
|
|
18
|
+
See [Docs > API > File I/O](/docs/runtime/file-io#reading-files-bun-file) for complete documentation of `Bun.file()`.
|
package/docs/index.mdx
CHANGED
|
@@ -127,7 +127,7 @@ Bun is designed from the ground-up with today's JavaScript ecosystem in mind.
|
|
|
127
127
|
- **Speed**. Bun processes start [4x faster than Node.js](https://twitter.com/jarredsumner/status/1499225725492076544) currently (try it yourself!)
|
|
128
128
|
- **TypeScript & JSX support**. You can directly execute `.jsx`, `.ts`, and `.tsx` files; Bun's transpiler converts these to vanilla JavaScript before execution.
|
|
129
129
|
- **ESM & CommonJS compatibility**. The world is moving towards ES modules (ESM), but millions of packages on npm still require CommonJS. Bun recommends ES modules, but supports CommonJS.
|
|
130
|
-
- **Web-standard APIs**. Bun implements standard Web APIs like `fetch`, `WebSocket`, and `ReadableStream`. Bun is powered by the JavaScriptCore engine, which is developed by Apple for Safari, so some APIs like [`Headers`](https://developer.mozilla.org/en-US/Web/API/Headers) and [`URL`](https://developer.mozilla.org/en-US/Web/API/URL) directly use [Safari's implementation](https://github.com/oven-sh/bun/blob/HEAD/src/bun.js/bindings/webcore/JSFetchHeaders.cpp).
|
|
131
|
-
- **Node.js compatibility**. In addition to supporting Node-style module resolution, Bun aims for full compatibility with built-in Node.js globals (`process`, `Buffer`) and modules (`path`, `fs`, `http`, etc.) _This is an ongoing effort that is not complete._ Refer to the [compatibility page](/runtime/nodejs-compat) for the current status.
|
|
130
|
+
- **Web-standard APIs**. Bun implements standard Web APIs like `fetch`, `WebSocket`, and `ReadableStream`. Bun is powered by the JavaScriptCore engine, which is developed by Apple for Safari, so some APIs like [`Headers`](https://developer.mozilla.org/en-US/docs/Web/API/Headers) and [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL) directly use [Safari's implementation](https://github.com/oven-sh/bun/blob/HEAD/src/bun.js/bindings/webcore/JSFetchHeaders.cpp).
|
|
131
|
+
- **Node.js compatibility**. In addition to supporting Node-style module resolution, Bun aims for full compatibility with built-in Node.js globals (`process`, `Buffer`) and modules (`path`, `fs`, `http`, etc.) _This is an ongoing effort that is not complete._ Refer to the [compatibility page](/docs/runtime/nodejs-compat) for the current status.
|
|
132
132
|
|
|
133
133
|
Bun is more than a runtime. The long-term goal is to be a cohesive, infrastructural toolkit for building apps with JavaScript/TypeScript, including a package manager, transpiler, bundler, script runner, test runner, and more.
|
package/docs/installation.mdx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Installation
|
|
3
|
-
description: Install Bun
|
|
3
|
+
description: Install Bun with npm, Homebrew, Docker, or the official script.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
## Overview
|
|
@@ -209,7 +209,7 @@ Since Bun is a single binary, you can install older versions by re-running the i
|
|
|
209
209
|
To install a specific version, pass the git tag to the install script:
|
|
210
210
|
|
|
211
211
|
```bash terminal icon="terminal"
|
|
212
|
-
curl -fsSL https://bun.com/install | bash -s "bun-v1.3.
|
|
212
|
+
curl -fsSL https://bun.com/install | bash -s "bun-v1.3.3"
|
|
213
213
|
```
|
|
214
214
|
|
|
215
215
|
</Tab>
|
|
@@ -217,7 +217,7 @@ Since Bun is a single binary, you can install older versions by re-running the i
|
|
|
217
217
|
On Windows, pass the version number to the PowerShell install script:
|
|
218
218
|
|
|
219
219
|
```powershell PowerShell icon="windows"
|
|
220
|
-
iex "& {$(irm https://bun.com/install.ps1)} -Version 1.3.
|
|
220
|
+
iex "& {$(irm https://bun.com/install.ps1)} -Version 1.3.3"
|
|
221
221
|
```
|
|
222
222
|
|
|
223
223
|
</Tab>
|
package/docs/pm/bunx.mdx
CHANGED
|
@@ -30,7 +30,7 @@ Packages can declare executables in the `"bin"` field of their `package.json`. T
|
|
|
30
30
|
|
|
31
31
|
These executables are commonly plain JavaScript files marked with a [shebang line](<https://en.wikipedia.org/wiki/Shebang_(Unix)>) to indicate which program should be used to execute them. The following file indicates that it should be executed with `node`.
|
|
32
32
|
|
|
33
|
-
```
|
|
33
|
+
```js dist/index.js icon="/icons/javascript.svg"
|
|
34
34
|
#!/usr/bin/env node
|
|
35
35
|
|
|
36
36
|
console.log("Hello world!");
|
|
@@ -78,6 +78,6 @@ bunx --package @angular/cli ng
|
|
|
78
78
|
|
|
79
79
|
To force bun to always be used with a script, use a shebang.
|
|
80
80
|
|
|
81
|
-
```
|
|
81
|
+
```js dist/index.js icon="/icons/javascript.svg"
|
|
82
82
|
#!/usr/bin/env bun
|
|
83
83
|
```
|
package/docs/pm/cli/install.mdx
CHANGED
|
@@ -99,7 +99,7 @@ BUN_FEATURE_FLAG_DISABLE_IGNORE_SCRIPTS=1 bun install
|
|
|
99
99
|
|
|
100
100
|
## Workspaces
|
|
101
101
|
|
|
102
|
-
Bun supports `"workspaces"` in package.json. For complete documentation refer to [Package manager > Workspaces](/pm/workspaces).
|
|
102
|
+
Bun supports `"workspaces"` in package.json. For complete documentation refer to [Package manager > Workspaces](/docs/pm/workspaces).
|
|
103
103
|
|
|
104
104
|
```json package.json icon="file-json"
|
|
105
105
|
{
|
|
@@ -126,16 +126,16 @@ bun install --filter '!pkg-c'
|
|
|
126
126
|
bun install --filter './packages/pkg-a'
|
|
127
127
|
```
|
|
128
128
|
|
|
129
|
-
For more information on filtering with `bun install`, refer to [Package Manager > Filtering](/pm/filter#bun-install-and-bun-outdated)
|
|
129
|
+
For more information on filtering with `bun install`, refer to [Package Manager > Filtering](/docs/pm/filter#bun-install-and-bun-outdated)
|
|
130
130
|
|
|
131
131
|
---
|
|
132
132
|
|
|
133
133
|
## Overrides and resolutions
|
|
134
134
|
|
|
135
|
-
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](/pm/overrides) for complete documentation.
|
|
135
|
+
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](/docs/pm/overrides) for complete documentation.
|
|
136
136
|
|
|
137
137
|
{/* prettier-ignore */}
|
|
138
|
-
```json package.json
|
|
138
|
+
```json package.json icon="file-json"
|
|
139
139
|
{
|
|
140
140
|
"name": "my-app",
|
|
141
141
|
"dependencies": {
|
|
@@ -185,7 +185,7 @@ For reproducible installs, use `--frozen-lockfile`. This will install the exact
|
|
|
185
185
|
bun install --frozen-lockfile
|
|
186
186
|
```
|
|
187
187
|
|
|
188
|
-
For more information on Bun's lockfile `bun.lock`, refer to [Package manager > Lockfile](/pm/lockfile).
|
|
188
|
+
For more information on Bun's lockfile `bun.lock`, refer to [Package manager > Lockfile](/docs/pm/lockfile).
|
|
189
189
|
|
|
190
190
|
---
|
|
191
191
|
|
|
@@ -217,7 +217,7 @@ bun install --dry-run
|
|
|
217
217
|
|
|
218
218
|
## Non-npm dependencies
|
|
219
219
|
|
|
220
|
-
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](/pm/cli/add).
|
|
220
|
+
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](/docs/pm/cli/add).
|
|
221
221
|
|
|
222
222
|
```json package.json icon="file-json"
|
|
223
223
|
{
|
|
@@ -264,7 +264,7 @@ The default linker strategy depends on whether you're starting fresh or have an
|
|
|
264
264
|
- **New single-package projects**: `hoisted` (traditional npm behavior)
|
|
265
265
|
- **Existing projects (made pre-v1.3.2)**: `hoisted` (preserves backward compatibility)
|
|
266
266
|
|
|
267
|
-
The default is controlled by a `configVersion` field in your lockfile. For a detailed explanation, see [Package manager > Isolated installs](/pm/isolated-installs).
|
|
267
|
+
The default is controlled by a `configVersion` field in your lockfile. For a detailed explanation, see [Package manager > Isolated installs](/docs/pm/isolated-installs).
|
|
268
268
|
|
|
269
269
|
---
|
|
270
270
|
|
|
@@ -298,7 +298,7 @@ When the minimum age filter is active:
|
|
|
298
298
|
- Exact version requests (like `package@1.1.1`) still respect the age gate but bypass the stability check
|
|
299
299
|
- Versions without a `time` field are treated as passing the age check (npm registry should always provide timestamps)
|
|
300
300
|
|
|
301
|
-
For more advanced security scanning, including integration with services & custom filtering, see [Package manager > Security Scanner API](/pm/security-scanner-api).
|
|
301
|
+
For more advanced security scanning, including integration with services & custom filtering, see [Package manager > Security Scanner API](/docs/pm/security-scanner-api).
|
|
302
302
|
|
|
303
303
|
---
|
|
304
304
|
|
package/docs/pm/cli/link.mdx
CHANGED
|
@@ -14,7 +14,7 @@ bun link
|
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
```txt
|
|
17
|
-
bun link v1.
|
|
17
|
+
bun link v1.3.3 (7416672e)
|
|
18
18
|
Success! Registered "cool-pkg"
|
|
19
19
|
|
|
20
20
|
To use cool-pkg in a project, run:
|
|
@@ -53,7 +53,7 @@ bun unlink
|
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
```txt
|
|
56
|
-
bun unlink v1.
|
|
56
|
+
bun unlink v1.3.3 (7416672e)
|
|
57
57
|
```
|
|
58
58
|
|
|
59
59
|
---
|
package/docs/pm/cli/outdated.mdx
CHANGED
|
@@ -15,7 +15,7 @@ bun outdated
|
|
|
15
15
|
| Package | Current | Update | Latest |
|
|
16
16
|
| ------------------------------ | ------- | --------- | ---------- |
|
|
17
17
|
| @sinclair/typebox | 0.34.15 | 0.34.16 | 0.34.16 |
|
|
18
|
-
| @types/bun (dev) | 1.
|
|
18
|
+
| @types/bun (dev) | 1.3.0 | 1.3.3 | 1.3.3 |
|
|
19
19
|
| eslint (dev) | 8.57.1 | 8.57.1 | 9.20.0 |
|
|
20
20
|
| eslint-plugin-security (dev) | 2.1.1 | 2.1.1 | 3.0.1 |
|
|
21
21
|
| eslint-plugin-sonarjs (dev) | 0.23.0 | 0.23.0 | 3.0.1 |
|
|
@@ -55,7 +55,7 @@ bun outdated eslint-plugin-security eslint-plugin-sonarjs
|
|
|
55
55
|
You can also pass glob patterns to check for outdated packages:
|
|
56
56
|
|
|
57
57
|
```sh terminal icon="terminal"
|
|
58
|
-
bun outdated eslint*
|
|
58
|
+
bun outdated 'eslint*'
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
```txt
|
|
@@ -75,7 +75,7 @@ bun outdated '@types/*'
|
|
|
75
75
|
```txt
|
|
76
76
|
| Package | Current | Update | Latest |
|
|
77
77
|
| ------------------ | ------- | ------ | ------ |
|
|
78
|
-
| @types/bun (dev) | 1.
|
|
78
|
+
| @types/bun (dev) | 1.3.0 | 1.3.3 | 1.3.3 |
|
|
79
79
|
```
|
|
80
80
|
|
|
81
81
|
Or to exclude all `@types/*` packages:
|
package/docs/pm/cli/patch.mdx
CHANGED
|
@@ -14,7 +14,7 @@ Features:
|
|
|
14
14
|
- Generates `.patch` files applied to dependencies in `node_modules` on install
|
|
15
15
|
- `.patch` files can be committed to your repository, reused across multiple installs, projects, and machines
|
|
16
16
|
- `"patchedDependencies"` in `package.json` keeps track of patched packages
|
|
17
|
-
- `bun patch` lets you patch packages in `node_modules/` while preserving the integrity of Bun's [Global Cache](/pm/global-cache)
|
|
17
|
+
- `bun patch` lets you patch packages in `node_modules/` while preserving the integrity of Bun's [Global Cache](/docs/pm/global-cache)
|
|
18
18
|
- Test your changes locally before committing them with `bun patch --commit <pkg>`
|
|
19
19
|
- To preserve disk space and keep `bun install` fast, patched packages are committed to the Global Cache and shared across projects where possible
|
|
20
20
|
|
|
@@ -42,7 +42,7 @@ If you forget to do this, you might end up editing the package globally in the c
|
|
|
42
42
|
|
|
43
43
|
#### Step 2. Test your changes locally
|
|
44
44
|
|
|
45
|
-
`bun patch <pkg>` makes it safe to edit the `<pkg>` in `node_modules/` directly, while preserving the integrity of Bun's [Global Cache](/pm/global-cache). This works by re-creating an unlinked clone of the package in `node_modules/` and diffing it against the original package in the Global Cache.
|
|
45
|
+
`bun patch <pkg>` makes it safe to edit the `<pkg>` in `node_modules/` directly, while preserving the integrity of Bun's [Global Cache](/docs/pm/global-cache). This works by re-creating an unlinked clone of the package in `node_modules/` and diffing it against the original package in the Global Cache.
|
|
46
46
|
|
|
47
47
|
#### Step 3. Commit your changes
|
|
48
48
|
|
package/docs/pm/cli/pm.mdx
CHANGED
package/docs/pm/cli/publish.mdx
CHANGED
package/docs/pm/filter.mdx
CHANGED
|
@@ -50,7 +50,7 @@ bun outdated --filter 'pkg-*'
|
|
|
50
50
|
bun outdated --filter './'
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
For more information on both these commands, see [`bun install`](/pm/cli/install) and [`bun outdated`](/pm/cli/outdated).
|
|
53
|
+
For more information on both these commands, see [`bun install`](/docs/pm/cli/install) and [`bun outdated`](/docs/pm/cli/outdated).
|
|
54
54
|
|
|
55
55
|
---
|
|
56
56
|
|
|
@@ -85,7 +85,7 @@ Both commands will be run in parallel, and you will see a nice terminal UI showi
|
|
|
85
85
|
|
|
86
86
|
### Running scripts in workspaces
|
|
87
87
|
|
|
88
|
-
Filters respect your [workspace configuration](/pm/workspaces): If you have a `package.json` file that specifies which packages are part of the workspace,
|
|
88
|
+
Filters respect your [workspace configuration](/docs/pm/workspaces): If you have a `package.json` file that specifies which packages are part of the workspace,
|
|
89
89
|
`--filter` will be restricted to only these packages. Also, in a workspace you can use `--filter` to run scripts in packages that are located anywhere in the workspace:
|
|
90
90
|
|
|
91
91
|
```bash terminal icon="terminal"
|
|
@@ -215,6 +215,6 @@ The main difference is that Bun uses symlinks in `node_modules` while pnpm uses
|
|
|
215
215
|
|
|
216
216
|
## Related documentation
|
|
217
217
|
|
|
218
|
-
- [Package manager > Workspaces](/pm/workspaces) — Monorepo workspace management
|
|
219
|
-
- [Package manager > Lockfile](/pm/lockfile) — Understanding Bun's lockfile format
|
|
220
|
-
- [CLI > install](/pm/cli/install) — Complete `bun install` command reference
|
|
218
|
+
- [Package manager > Workspaces](/docs/pm/workspaces) — Monorepo workspace management
|
|
219
|
+
- [Package manager > Lockfile](/docs/pm/lockfile) — Understanding Bun's lockfile format
|
|
220
|
+
- [CLI > install](/docs/pm/cli/install) — Complete `bun install` command reference
|