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.
Files changed (220) hide show
  1. package/CLAUDE.md +3 -3
  2. package/docs/bundler/css.mdx +1 -1
  3. package/docs/bundler/executables.mdx +33 -4
  4. package/docs/bundler/fullstack.mdx +3 -3
  5. package/docs/bundler/hot-reloading.mdx +2 -2
  6. package/docs/bundler/html-static.mdx +10 -9
  7. package/docs/bundler/index.mdx +27 -18
  8. package/docs/bundler/loaders.mdx +2 -2
  9. package/docs/bundler/macros.mdx +1 -1
  10. package/docs/feedback.mdx +2 -12
  11. package/docs/guides/binary/arraybuffer-to-array.mdx +1 -1
  12. package/docs/guides/binary/arraybuffer-to-blob.mdx +1 -1
  13. package/docs/guides/binary/arraybuffer-to-buffer.mdx +1 -1
  14. package/docs/guides/binary/arraybuffer-to-string.mdx +1 -1
  15. package/docs/guides/binary/arraybuffer-to-typedarray.mdx +1 -1
  16. package/docs/guides/binary/blob-to-arraybuffer.mdx +1 -1
  17. package/docs/guides/binary/blob-to-dataview.mdx +1 -1
  18. package/docs/guides/binary/blob-to-stream.mdx +1 -1
  19. package/docs/guides/binary/blob-to-string.mdx +1 -1
  20. package/docs/guides/binary/blob-to-typedarray.mdx +1 -1
  21. package/docs/guides/binary/buffer-to-arraybuffer.mdx +1 -1
  22. package/docs/guides/binary/buffer-to-blob.mdx +1 -1
  23. package/docs/guides/binary/buffer-to-readablestream.mdx +1 -1
  24. package/docs/guides/binary/buffer-to-string.mdx +1 -1
  25. package/docs/guides/binary/buffer-to-typedarray.mdx +1 -1
  26. package/docs/guides/binary/dataview-to-string.mdx +1 -1
  27. package/docs/guides/binary/typedarray-to-arraybuffer.mdx +1 -1
  28. package/docs/guides/binary/typedarray-to-blob.mdx +1 -1
  29. package/docs/guides/binary/typedarray-to-buffer.mdx +1 -1
  30. package/docs/guides/binary/typedarray-to-dataview.mdx +1 -1
  31. package/docs/guides/binary/typedarray-to-readablestream.mdx +1 -1
  32. package/docs/guides/binary/typedarray-to-string.mdx +1 -1
  33. package/docs/guides/deployment/aws-lambda.mdx +6 -6
  34. package/docs/guides/deployment/digital-ocean.mdx +7 -7
  35. package/docs/guides/deployment/vercel.mdx +1 -3
  36. package/docs/guides/ecosystem/discordjs.mdx +2 -2
  37. package/docs/guides/ecosystem/express.mdx +2 -2
  38. package/docs/guides/ecosystem/mongoose.mdx +1 -1
  39. package/docs/guides/ecosystem/neon-drizzle.mdx +2 -2
  40. package/docs/guides/ecosystem/neon-serverless-postgres.mdx +2 -2
  41. package/docs/guides/ecosystem/nuxt.mdx +1 -1
  42. package/docs/guides/ecosystem/prisma-postgres.mdx +1 -1
  43. package/docs/guides/ecosystem/prisma.mdx +1 -1
  44. package/docs/guides/ecosystem/qwik.mdx +4 -4
  45. package/docs/guides/ecosystem/sentry.mdx +2 -2
  46. package/docs/guides/ecosystem/sveltekit.mdx +1 -1
  47. package/docs/guides/ecosystem/tanstack-start.mdx +0 -1
  48. package/docs/guides/ecosystem/upstash.mdx +2 -2
  49. package/docs/guides/ecosystem/vite.mdx +2 -2
  50. package/docs/guides/html-rewriter/extract-links.mdx +2 -2
  51. package/docs/guides/html-rewriter/extract-social-meta.mdx +1 -1
  52. package/docs/guides/http/file-uploads.mdx +1 -1
  53. package/docs/guides/http/hot.mdx +1 -1
  54. package/docs/guides/http/server.mdx +1 -1
  55. package/docs/guides/http/simple.mdx +1 -1
  56. package/docs/guides/http/stream-file.mdx +3 -3
  57. package/docs/guides/http/tls.mdx +1 -1
  58. package/docs/guides/install/add-dev.mdx +1 -1
  59. package/docs/guides/install/add-git.mdx +1 -1
  60. package/docs/guides/install/add-optional.mdx +1 -1
  61. package/docs/guides/install/add-peer.mdx +3 -3
  62. package/docs/guides/install/add-tarball.mdx +1 -1
  63. package/docs/guides/install/add.mdx +1 -1
  64. package/docs/guides/install/azure-artifacts.mdx +3 -3
  65. package/docs/guides/install/custom-registry.mdx +2 -2
  66. package/docs/guides/install/from-npm-install-to-bun-install.mdx +1 -1
  67. package/docs/guides/install/git-diff-bun-lockfile.mdx +2 -1
  68. package/docs/guides/install/npm-alias.mdx +1 -1
  69. package/docs/guides/install/registry-scope.mdx +3 -3
  70. package/docs/guides/install/trusted.mdx +1 -1
  71. package/docs/guides/install/workspaces.mdx +1 -1
  72. package/docs/guides/install/yarnlock.mdx +4 -3
  73. package/docs/guides/process/ctrl-c.mdx +1 -1
  74. package/docs/guides/process/ipc.mdx +2 -2
  75. package/docs/guides/process/nanoseconds.mdx +1 -1
  76. package/docs/guides/process/os-signals.mdx +1 -1
  77. package/docs/guides/process/spawn-stderr.mdx +2 -2
  78. package/docs/guides/process/spawn-stdout.mdx +2 -2
  79. package/docs/guides/process/spawn.mdx +2 -2
  80. package/docs/guides/process/stdin.mdx +1 -1
  81. package/docs/guides/read-file/arraybuffer.mdx +2 -2
  82. package/docs/guides/read-file/buffer.mdx +1 -1
  83. package/docs/guides/read-file/exists.mdx +1 -1
  84. package/docs/guides/read-file/mime.mdx +1 -1
  85. package/docs/guides/read-file/stream.mdx +1 -1
  86. package/docs/guides/read-file/uint8array.mdx +1 -1
  87. package/docs/guides/read-file/watch.mdx +1 -1
  88. package/docs/guides/runtime/build-time-constants.mdx +3 -3
  89. package/docs/guides/runtime/cicd.mdx +1 -1
  90. package/docs/guides/runtime/codesign-macos-executable.mdx +1 -1
  91. package/docs/guides/runtime/delete-directory.mdx +1 -1
  92. package/docs/guides/runtime/delete-file.mdx +1 -1
  93. package/docs/guides/runtime/heap-snapshot.mdx +1 -1
  94. package/docs/guides/runtime/import-json.mdx +1 -1
  95. package/docs/guides/runtime/import-toml.mdx +1 -1
  96. package/docs/guides/runtime/import-yaml.mdx +1 -1
  97. package/docs/guides/runtime/read-env.mdx +1 -1
  98. package/docs/guides/runtime/set-env.mdx +2 -2
  99. package/docs/guides/runtime/shell.mdx +1 -1
  100. package/docs/guides/runtime/tsconfig-paths.mdx +1 -1
  101. package/docs/guides/runtime/typescript.mdx +1 -1
  102. package/docs/guides/runtime/vscode-debugger.mdx +1 -2
  103. package/docs/guides/runtime/web-debugger.mdx +1 -1
  104. package/docs/guides/streams/to-array.mdx +1 -1
  105. package/docs/guides/streams/to-arraybuffer.mdx +1 -1
  106. package/docs/guides/streams/to-blob.mdx +1 -1
  107. package/docs/guides/streams/to-buffer.mdx +1 -1
  108. package/docs/guides/streams/to-json.mdx +1 -1
  109. package/docs/guides/streams/to-string.mdx +1 -1
  110. package/docs/guides/streams/to-typedarray.mdx +1 -1
  111. package/docs/guides/test/bail.mdx +1 -1
  112. package/docs/guides/test/concurrent-test-glob.mdx +5 -2
  113. package/docs/guides/test/coverage-threshold.mdx +1 -1
  114. package/docs/guides/test/coverage.mdx +1 -1
  115. package/docs/guides/test/happy-dom.mdx +1 -1
  116. package/docs/guides/test/migrate-from-jest.mdx +7 -7
  117. package/docs/guides/test/mock-clock.mdx +2 -2
  118. package/docs/guides/test/mock-functions.mdx +1 -1
  119. package/docs/guides/test/rerun-each.mdx +1 -1
  120. package/docs/guides/test/run-tests.mdx +2 -2
  121. package/docs/guides/test/skip-tests.mdx +2 -2
  122. package/docs/guides/test/snapshot.mdx +4 -4
  123. package/docs/guides/test/spy-on.mdx +1 -1
  124. package/docs/guides/test/svelte-test.mdx +4 -4
  125. package/docs/guides/test/testing-library.mdx +3 -3
  126. package/docs/guides/test/timeout.mdx +1 -1
  127. package/docs/guides/test/todo-tests.mdx +2 -2
  128. package/docs/guides/test/update-snapshots.mdx +1 -1
  129. package/docs/guides/test/watch-mode.mdx +1 -1
  130. package/docs/guides/util/base64.mdx +1 -1
  131. package/docs/guides/util/deep-equals.mdx +3 -3
  132. package/docs/guides/util/deflate.mdx +1 -1
  133. package/docs/guides/util/entrypoint.mdx +2 -2
  134. package/docs/guides/util/escape-html.mdx +1 -1
  135. package/docs/guides/util/file-url-to-path.mdx +1 -1
  136. package/docs/guides/util/gzip.mdx +1 -1
  137. package/docs/guides/util/hash-a-password.mdx +1 -1
  138. package/docs/guides/util/import-meta-dir.mdx +2 -2
  139. package/docs/guides/util/import-meta-file.mdx +2 -2
  140. package/docs/guides/util/import-meta-path.mdx +2 -2
  141. package/docs/guides/util/javascript-uuid.mdx +2 -2
  142. package/docs/guides/util/main.mdx +1 -1
  143. package/docs/guides/util/path-to-file-url.mdx +1 -1
  144. package/docs/guides/util/sleep.mdx +1 -1
  145. package/docs/guides/util/version.mdx +2 -2
  146. package/docs/guides/util/which-path-to-executable-bin.mdx +1 -1
  147. package/docs/guides/websocket/context.mdx +1 -1
  148. package/docs/guides/websocket/simple.mdx +1 -1
  149. package/docs/guides/write-file/basic.mdx +2 -2
  150. package/docs/guides/write-file/blob.mdx +2 -2
  151. package/docs/guides/write-file/cat.mdx +2 -2
  152. package/docs/guides/write-file/file-cp.mdx +2 -2
  153. package/docs/guides/write-file/filesink.mdx +1 -1
  154. package/docs/guides/write-file/response.mdx +2 -2
  155. package/docs/guides/write-file/stdout.mdx +2 -2
  156. package/docs/guides/write-file/stream.mdx +2 -2
  157. package/docs/guides/write-file/unlink.mdx +1 -1
  158. package/docs/index.mdx +2 -2
  159. package/docs/installation.mdx +3 -3
  160. package/docs/pm/bunx.mdx +2 -2
  161. package/docs/pm/cli/install.mdx +8 -8
  162. package/docs/pm/cli/link.mdx +2 -2
  163. package/docs/pm/cli/outdated.mdx +3 -3
  164. package/docs/pm/cli/patch.mdx +2 -2
  165. package/docs/pm/cli/pm.mdx +1 -1
  166. package/docs/pm/cli/publish.mdx +1 -1
  167. package/docs/pm/filter.mdx +2 -2
  168. package/docs/pm/isolated-installs.mdx +3 -3
  169. package/docs/pm/npmrc.mdx +6 -6
  170. package/docs/pm/scopes-registries.mdx +1 -1
  171. package/docs/pm/security-scanner-api.mdx +2 -2
  172. package/docs/pm/workspaces.mdx +3 -4
  173. package/docs/project/benchmarking.mdx +1 -1
  174. package/docs/project/building-windows.mdx +1 -1
  175. package/docs/project/contributing.mdx +1 -1
  176. package/docs/project/license.mdx +1 -1
  177. package/docs/quickstart.mdx +3 -3
  178. package/docs/runtime/auto-install.mdx +1 -1
  179. package/docs/runtime/binary-data.mdx +1 -1
  180. package/docs/runtime/bun-apis.mdx +35 -35
  181. package/docs/runtime/bunfig.mdx +29 -3
  182. package/docs/runtime/c-compiler.mdx +3 -3
  183. package/docs/runtime/child-process.mdx +2 -2
  184. package/docs/runtime/cookies.mdx +19 -19
  185. package/docs/runtime/debugger.mdx +4 -4
  186. package/docs/runtime/environment-variables.mdx +24 -7
  187. package/docs/runtime/ffi.mdx +2 -2
  188. package/docs/runtime/file-io.mdx +2 -2
  189. package/docs/runtime/file-types.mdx +5 -5
  190. package/docs/runtime/globals.mdx +4 -4
  191. package/docs/runtime/http/error-handling.mdx +2 -2
  192. package/docs/runtime/http/routing.mdx +1 -1
  193. package/docs/runtime/http/server.mdx +5 -9
  194. package/docs/runtime/http/websockets.mdx +1 -1
  195. package/docs/runtime/index.mdx +2 -2
  196. package/docs/runtime/jsx.mdx +1 -1
  197. package/docs/runtime/module-resolution.mdx +2 -2
  198. package/docs/runtime/networking/fetch.mdx +4 -4
  199. package/docs/runtime/nodejs-compat.mdx +3 -3
  200. package/docs/runtime/plugins.mdx +1 -1
  201. package/docs/runtime/s3.mdx +4 -4
  202. package/docs/runtime/secrets.mdx +10 -7
  203. package/docs/runtime/sql.mdx +10 -10
  204. package/docs/runtime/sqlite.mdx +15 -4
  205. package/docs/runtime/templating/create.mdx +4 -4
  206. package/docs/runtime/transpiler.mdx +1 -1
  207. package/docs/runtime/utils.mdx +3 -3
  208. package/docs/runtime/watch-mode.mdx +1 -1
  209. package/docs/runtime/workers.mdx +5 -17
  210. package/docs/snippets/cli/publish.mdx +2 -2
  211. package/docs/test/configuration.mdx +1 -1
  212. package/docs/test/dom.mdx +1 -1
  213. package/docs/test/index.mdx +8 -8
  214. package/docs/test/reporters.mdx +1 -1
  215. package/docs/test/snapshots.mdx +3 -3
  216. package/docs/test/writing-tests.mdx +37 -0
  217. package/docs/typescript.mdx +2 -2
  218. package/package.json +3 -4
  219. package/docs/snippets/product-card.mdx +0 -32
  220. package/docs/snippets/product-tiles.mdx +0 -94
@@ -9,7 +9,7 @@ A `string` containing the version of the `bun` CLI that is currently running.
9
9
 
10
10
  ```ts terminal icon="terminal"
11
11
  Bun.version;
12
- // => "0.6.4"
12
+ // => "1.3.3"
13
13
  ```
14
14
 
15
15
  ## `Bun.revision`
@@ -231,9 +231,9 @@ const currentFile = import.meta.url;
231
231
  Bun.openInEditor(currentFile);
232
232
  ```
233
233
 
234
- You can override this via the `debug.editor` setting in your [`bunfig.toml`](/runtime/bunfig).
234
+ You can override this via the `debug.editor` setting in your [`bunfig.toml`](/docs/runtime/bunfig).
235
235
 
236
- ```toml bunfig.toml
236
+ ```toml bunfig.toml icon="settings"
237
237
  [debug] # [!code ++]
238
238
  editor = "code" # [!code ++]
239
239
  ```
@@ -89,7 +89,7 @@ Use `bun --hot` to enable hot reloading when executing code with Bun. This is di
89
89
  This is not the same as hot reloading in the browser! Many frameworks provide a "hot reloading" experience, where you
90
90
  can edit & save your frontend code (say, a React component) and see the changes reflected in the browser without
91
91
  refreshing the page. Bun's `--hot` is the server-side equivalent of this experience. To get hot reloading in the
92
- browser, use a framework like [Vite](https://vitejs.dev).
92
+ browser, use a framework like [Vite](https://vite.dev).
93
93
  </Note>
94
94
 
95
95
  ```bash terminal icon="terminal"
@@ -29,7 +29,7 @@ worker.onmessage = event => {
29
29
 
30
30
  ### Worker thread
31
31
 
32
- ```ts worker.ts icon="file-code"
32
+ ```ts worker.ts icon="file-code"
33
33
  // prevents TS errors
34
34
  declare var self: Worker;
35
35
 
@@ -81,15 +81,9 @@ const worker = new Worker("./worker.ts", {
81
81
  You can also pass a `blob:` URL to `Worker`. This is useful for creating workers from strings or other sources.
82
82
 
83
83
  ```js
84
- const blob = new Blob(
85
- [
86
- `
87
- self.onmessage = (event: MessageEvent) => postMessage(event.data)`,
88
- ],
89
- {
90
- type: "application/typescript",
91
- },
92
- );
84
+ const blob = new Blob([`self.onmessage = (event: MessageEvent) => postMessage(event.data)`], {
85
+ type: "application/typescript",
86
+ });
93
87
  const url = URL.createObjectURL(blob);
94
88
  const worker = new Worker(url);
95
89
  ```
@@ -97,13 +91,7 @@ const worker = new Worker(url);
97
91
  Like the rest of Bun, workers created from `blob:` URLs support TypeScript, JSX, and other file types out of the box. You can communicate it should be loaded via typescript either via `type` or by passing a `filename` to the `File` constructor.
98
92
 
99
93
  ```ts
100
- const file = new File(
101
- [
102
- `
103
- self.onmessage = (event: MessageEvent) => postMessage(event.data)`,
104
- ],
105
- "worker.ts",
106
- );
94
+ const file = new File([`self.onmessage = (event: MessageEvent) => postMessage(event.data)`], "worker.ts");
107
95
  const url = URL.createObjectURL(file);
108
96
  const worker = new Worker(url);
109
97
  ```
@@ -25,7 +25,7 @@ bun publish --access public
25
25
 
26
26
  </ParamField>
27
27
 
28
- <ParamField path="--tag" type="string" default="latest">
28
+ <ParamField path="--tag" type="string" default="latest">
29
29
  Set the tag of the package version being published. By default, the tag is `latest`. The initial version of a package is always given the `latest` tag in addition to the specified tag.
30
30
 
31
31
  ```sh terminal icon="terminal"
@@ -34,7 +34,7 @@ bun publish --tag alpha
34
34
 
35
35
  `--tag` can also be set in the `publishConfig` field of your `package.json`.
36
36
 
37
- ```json package.json file="file-json"
37
+ ```json package.json icon="file-json"
38
38
  {
39
39
  "publishConfig": {
40
40
  "tag": "next" // [!code ++]
@@ -306,7 +306,7 @@ coveragePathIgnorePatterns = [
306
306
  ]
307
307
  ```
308
308
 
309
- Files matching any of these patterns will be excluded from coverage calculation and reporting. See the [coverage documentation](/test/code-coverage) for more details and examples.
309
+ Files matching any of these patterns will be excluded from coverage calculation and reporting. See the [coverage documentation](/docs/test/code-coverage) for more details and examples.
310
310
 
311
311
  #### Common Ignore Patterns
312
312
 
package/docs/test/dom.mdx CHANGED
@@ -65,7 +65,7 @@ bun test
65
65
  ```
66
66
 
67
67
  ```
68
- bun test v1.3.2
68
+ bun test v1.3.3
69
69
 
70
70
  dom.test.ts:
71
71
  ✓ dom test [0.82ms]
@@ -25,7 +25,7 @@ Bun ships with a fast, built-in, Jest-compatible test runner. Tests are executed
25
25
  bun test
26
26
  ```
27
27
 
28
- Tests are written in JavaScript or TypeScript with a Jest-like API. Refer to [Writing tests](/test/writing-tests) for full documentation.
28
+ Tests are written in JavaScript or TypeScript with a Jest-like API. Refer to [Writing tests](/docs/test/writing-tests) for full documentation.
29
29
 
30
30
  ```ts math.test.ts icon="/icons/typescript.svg"
31
31
  import { expect, test } from "bun:test";
@@ -61,7 +61,7 @@ To run a specific file in the test runner, make sure the path starts with `./` o
61
61
  bun test ./test/specific-file.test.ts
62
62
  ```
63
63
 
64
- The test runner runs all tests in a single process. It loads all `--preload` scripts (see [Lifecycle](/test/lifecycle) for details), then runs all tests. If a test fails, the test runner will exit with a non-zero exit code.
64
+ The test runner runs all tests in a single process. It loads all `--preload` scripts (see [Lifecycle](/docs/test/lifecycle) for details), then runs all tests. If a test fails, the test runner will exit with a non-zero exit code.
65
65
 
66
66
  ## CI/CD integration
67
67
 
@@ -275,11 +275,11 @@ Bun supports the following lifecycle hooks:
275
275
 
276
276
  These hooks can be defined inside test files, or in a separate file that is preloaded with the `--preload` flag.
277
277
 
278
- ```ts terminal icon="terminal"
278
+ ```sh terminal icon="terminal"
279
279
  bun test --preload ./setup.ts
280
280
  ```
281
281
 
282
- See [Test > Lifecycle](/test/lifecycle) for complete documentation.
282
+ See [Test > Lifecycle](/docs/test/lifecycle) for complete documentation.
283
283
 
284
284
  ## Mocks
285
285
 
@@ -307,7 +307,7 @@ const random = mock(() => Math.random()); // [!code --]
307
307
  const random = jest.fn(() => Math.random()); // [!code ++]
308
308
  ```
309
309
 
310
- See [Test > Mocks](/test/mocks) for complete documentation.
310
+ See [Test > Mocks](/docs/test/mocks) for complete documentation.
311
311
 
312
312
  ## Snapshot testing
313
313
 
@@ -328,7 +328,7 @@ To update snapshots, use the `--update-snapshots` flag.
328
328
  bun test --update-snapshots
329
329
  ```
330
330
 
331
- See [Test > Snapshots](/test/snapshots) for complete documentation.
331
+ See [Test > Snapshots](/docs/test/snapshots) for complete documentation.
332
332
 
333
333
  ## UI & DOM testing
334
334
 
@@ -338,13 +338,13 @@ Bun is compatible with popular UI testing libraries:
338
338
  - [DOM Testing Library](https://testing-library.com/docs/dom-testing-library/intro/)
339
339
  - [React Testing Library](https://testing-library.com/docs/react-testing-library/intro)
340
340
 
341
- See [Test > DOM Testing](/test/dom) for complete documentation.
341
+ See [Test > DOM Testing](/docs/test/dom) for complete documentation.
342
342
 
343
343
  ## Performance
344
344
 
345
345
  Bun's test runner is fast.
346
346
 
347
- <Frame>![Running 266 React SSR tests faster than Jest can print its version number.](/images/buntest.jpeg)</Frame>
347
+ <Frame>![Running 266 React SSR tests faster than Jest can print its version number.](https://bun.com/images/buntest.jpeg)</Frame>
348
348
 
349
349
  ## AI Agent Integration
350
350
 
@@ -98,7 +98,7 @@ The JUnit reporter currently has a few limitations that will be addressed in fut
98
98
 
99
99
  Bun test automatically detects when it's running inside GitHub Actions and emits GitHub Actions annotations to the console directly. No special configuration is needed beyond installing Bun and running `bun test`.
100
100
 
101
- For a GitHub Actions workflow configuration example, see the [CI/CD integration](/pm/cli/install#ci%2Fcd) section of the CLI documentation.
101
+ For a GitHub Actions workflow configuration example, see the [CI/CD integration](/docs/pm/cli/install#ci%2Fcd) section of the CLI documentation.
102
102
 
103
103
  ---
104
104
 
@@ -32,8 +32,8 @@ your-project/
32
32
 
33
33
  The snapshot file contains:
34
34
 
35
- ```txt title="snapshot file" icon="file-code"
36
- // Bun Snapshot v1, https://goo.gl/fbAQLP
35
+ ```ts title="__snapshots__/snap.test.ts.snap" icon="file-code"
36
+ // Bun Snapshot v1, https://bun.com/docs/test/snapshots
37
37
 
38
38
  exports[`snap 1`] = `"foo"`;
39
39
  ```
@@ -400,7 +400,7 @@ tests/
400
400
 
401
401
  When snapshots fail, you'll see a diff:
402
402
 
403
- ```text title="diff" icon="file-code"
403
+ ```diff title="diff" icon="file-code"
404
404
  - Expected
405
405
  + Received
406
406
 
@@ -78,6 +78,43 @@ In `bun:test`, test timeouts throw an uncatchable exception to force the test to
78
78
 
79
79
  The default timeout for each test is 5000ms (5 seconds) if not overridden by this timeout option or `jest.setDefaultTimeout()`.
80
80
 
81
+ ## Retries and Repeats
82
+
83
+ ### test.retry
84
+
85
+ Use the `retry` option to automatically retry a test if it fails. The test passes if it succeeds within the specified number of attempts. This is useful for flaky tests that may fail intermittently.
86
+
87
+ ```ts title="example.test.ts" icon="/icons/typescript.svg"
88
+ import { test } from "bun:test";
89
+
90
+ test(
91
+ "flaky network request",
92
+ async () => {
93
+ const response = await fetch("https://example.com/api");
94
+ expect(response.ok).toBe(true);
95
+ },
96
+ { retry: 3 }, // Retry up to 3 times if the test fails
97
+ );
98
+ ```
99
+
100
+ ### test.repeats
101
+
102
+ Use the `repeats` option to run a test multiple times regardless of pass/fail status. The test fails if any iteration fails. This is useful for detecting flaky tests or stress testing. Note that `repeats: N` runs the test N+1 times total (1 initial run + N repeats).
103
+
104
+ ```ts title="example.test.ts" icon="/icons/typescript.svg"
105
+ import { test } from "bun:test";
106
+
107
+ test(
108
+ "ensure test is stable",
109
+ () => {
110
+ expect(Math.random()).toBeLessThan(1);
111
+ },
112
+ { repeats: 20 }, // Runs 21 times total (1 initial + 20 repeats)
113
+ );
114
+ ```
115
+
116
+ <Note>You cannot use both `retry` and `repeats` on the same test.</Note>
117
+
81
118
  ### 🧟 Zombie Process Killer
82
119
 
83
120
  When a test times out and processes spawned in the test via `Bun.spawn`, `Bun.spawnSync`, or `node:child_process` are not killed, they will be automatically killed and a message will be logged to the console. This prevents zombie processes from lingering in the background after timed-out tests.
@@ -15,7 +15,7 @@ At this point, you should be able to reference the `Bun` global in your TypeScri
15
15
 
16
16
  Bun supports things like top-level await, JSX, and extensioned `.ts` imports, which TypeScript doesn't allow by default. Below is a set of recommended `compilerOptions` for a Bun project, so you can use these features without seeing compiler warnings from TypeScript.
17
17
 
18
- ```json tsconfig.json icon="file-code"
18
+ ```json tsconfig.json icon="file-json"
19
19
  {
20
20
  "compilerOptions": {
21
21
  // Environment setup & latest features
@@ -49,6 +49,6 @@ Bun supports things like top-level await, JSX, and extensioned `.ts` imports, wh
49
49
 
50
50
  If you run `bun init` in a new directory, this `tsconfig.json` will be generated for you. (The stricter flags are disabled by default.)
51
51
 
52
- ```sh terminal icon="terminal"
52
+ ```sh terminal icon="terminal"
53
53
  bun init
54
54
  ```
package/package.json CHANGED
@@ -1,5 +1,4 @@
1
1
  {
2
- "version": "1.3.3",
3
2
  "name": "bun-types",
4
3
  "license": "MIT",
5
4
  "types": "./index.d.ts",
@@ -25,8 +24,7 @@
25
24
  },
26
25
  "scripts": {
27
26
  "prebuild": "echo $(pwd)",
28
- "copy-docs": "rm -rf docs && cp -rL ../../docs/ ./docs && find ./docs -type f -name '*.{md,mdx}' -exec sed -i 's/\\$BUN_LATEST_VERSION/'\"${BUN_VERSION#bun-v}\"'/g' {} +",
29
- "build": "bun run copy-docs && cp ../../src/init/rule.md CLAUDE.md && bun scripts/build.ts",
27
+ "build": "bun scripts/build.ts",
30
28
  "test": "tsc",
31
29
  "fmt": "echo $(which biome) && biome format --write ."
32
30
  },
@@ -34,5 +32,6 @@
34
32
  "bun",
35
33
  "bun.js",
36
34
  "types"
37
- ]
35
+ ],
36
+ "version": "1.3.4-canary.20251123T140630"
38
37
  }
@@ -1,32 +0,0 @@
1
- export const ProductCard = ({ img, href, title, description, model, type }) => {
2
- return (
3
- <a href={href} target="_blank" rel="noopener noreferrer" className="group">
4
- <div className="flex flex-col gap-4 rounded-xl md:p-1">
5
- <div className="w-full h-32 overflow-hidden rounded-xl bg-gray-100 dark:bg-gray-800">
6
- <img
7
- src={img}
8
- className="w-full h-full object-cover transition-transform duration-300 group-hover:scale-105"
9
- alt={title}
10
- loading="lazy"
11
- />
12
- </div>
13
- <div className="flex flex-col gap-3 pb-2">
14
- <h2 className="text-md font-medium text-gray-900 dark:text-gray-200 group-hover:text-gray-600 dark:group-hover:text-gray-400 transition-colors mb-[-8px]">
15
- {title}
16
- </h2>
17
- <p className="text-gray-500 dark:text-gray-400 text-sm font-medium">{description}</p>
18
- <div className="flex gap-2 mt-2 mb-1">
19
- <span className="bg-gray-100 dark:bg-[#181817] text-gray-600 dark:text-white rounded-lg px-2 py-1 text-sm font-medium">
20
- {model}
21
- </span>
22
- <span className="bg-primary-light dark:bg-primary-dark text-white dark:text-white rounded-lg px-2 py-1 text-sm font-medium">
23
- {type}
24
- </span>
25
- </div>
26
- </div>
27
- </div>
28
- </a>
29
- );
30
- };
31
-
32
- ;
@@ -1,94 +0,0 @@
1
- export const ProductTiles = ({ categories, hideButtons = false }) => {
2
- const [activeCategory, setActiveCategory] = useState(categories[0].id)
3
- const [activeSubTab, setActiveSubTab] = useState(
4
- categories[0].items[0]?.id ?? null
5
- )
6
-
7
- const currentCategory = categories.find((cat) => cat.id === activeCategory)
8
- const currentSub = currentCategory?.items.find(
9
- (item) => item.id === activeSubTab
10
- )
11
-
12
- return (
13
-
14
- <div className="not-prose space-y-6">
15
- {!hideButtons && (
16
- <div className="flex flex-wrap gap-2">
17
- {categories.map((cat) => (
18
- <button
19
- key={cat.id}
20
- onClick={() => {
21
- setActiveCategory(cat.id)
22
- setActiveSubTab(cat.items[0]?.id ?? null)
23
- }}
24
- className={`px-4 py-2 text-sm rounded-full font-medium transition-colors ${activeCategory === cat.id
25
- ? 'bg-[#0A0B0D] text-white dark:bg-white dark:text-[#0A0B0D] border-black'
26
- : 'bg-gray-100 dark:bg-white/10 text-black dark:text-white'
27
- }`} >
28
- {cat.label}
29
- </button>
30
- ))}
31
- </div>
32
- )}
33
-
34
- <div>
35
- {currentCategory?.items?.length ? (
36
- <div className="flex flex-col lg:flex-row gap-6 bg-gray-100 dark:bg-[#141414] rounded-2xl">
37
- <div className="flex flex-col w-full lg:w-1/2 space-y-2 p-4">
38
- {currentCategory.items.map((item) => (
39
- <a
40
- key={item.id}
41
- href={item.href}
42
- onMouseOver={() => setActiveSubTab(item.id)}
43
- className={`flex items-start gap-1.5 text-left px-5 py-3 rounded-2xl transition-all ${activeSubTab === item.id
44
- ? 'bg-white dark:bg-white/5'
45
- : ''
46
- }`}
47
- >
48
- <div className="text-xl mr-3 mt-1"><img src={item.icon} alt={item.title} className="w-8 h-8" /></div>
49
- <div className="flex-1">
50
- <h3 className="font-medium text-base text-black dark:text-white">
51
- {item.title}
52
- </h3>
53
- <p className="text-sm text-gray-600 dark:text-gray-400">{item.desc}</p>
54
- </div>
55
- <div className={`flex items-center justify-center min-w-[24px] self-center ${activeSubTab === item.id ? 'opacity-100' : 'opacity-0'}`}>
56
- <div className="hidden dark:block">
57
- <Icon icon="chevron-right" size="14" color="#FFF" />
58
- </div>
59
- <div className="block dark:hidden">
60
- <Icon icon="chevron-right" size="14" color="#0A0B0D" />
61
- </div>
62
- </div>
63
- </a>
64
- ))}
65
- </div>
66
- <div className="group w-full h-fit lg:w-1/2 rounded-2xl flex items-center justify-center overflow-hidden min-h-[320px] p-4">
67
- {currentSub?.image ? (
68
- <>
69
- <img
70
- src={currentSub.image.light}
71
- alt={currentSub.title}
72
- className="block dark:hidden w-full h-full object-cover rounded-xl"
73
- />
74
- <img
75
- src={currentSub.image.dark}
76
- alt={currentSub.title}
77
- className="hidden dark:block w-full h-full object-cover rounded-xl"
78
- />
79
- </>
80
- ) : (
81
- <p className="text-gray-400 dark:text-gray-500 p-8">No preview available</p>
82
- )}
83
- </div>
84
- </div>
85
- ) : (
86
- <p className="text-sm text-gray-500 dark:text-gray-400">
87
- No features available for this category.
88
- </p>
89
- )}
90
- </div>
91
- </div>
92
-
93
- )
94
- }