Skip to content

Commit 5f3abcd

Browse files
Merge branch 'main' into pfg/event-target
2 parents 544e649 + 64ed68c commit 5f3abcd

File tree

375 files changed

+3261
-2732
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

375 files changed

+3261
-2732
lines changed

.github/workflows/clang-format.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

.github/workflows/clang-tidy.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

.github/workflows/format.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: format
2+
3+
permissions:
4+
contents: write
5+
6+
on:
7+
workflow_call:
8+
workflow_dispatch:
9+
pull_request:
10+
merge_group:
11+
12+
env:
13+
BUN_VERSION: "1.2.11"
14+
LLVM_VERSION: "19.1.7"
15+
LLVM_VERSION_MAJOR: "19"
16+
17+
jobs:
18+
format:
19+
name: Format
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
- name: Configure Git
27+
run: |
28+
git config --global core.autocrlf true
29+
git config --global core.ignorecase true
30+
git config --global core.precomposeUnicode true
31+
- name: Setup Bun
32+
uses: ./.github/actions/setup-bun
33+
with:
34+
bun-version: ${{ env.BUN_VERSION }}
35+
- name: Setup Dependencies
36+
run: |
37+
bun install
38+
- name: Install LLVM
39+
run: |
40+
curl -fsSL https://apt.llvm.org/llvm.sh | sudo bash -s -- ${{ env.LLVM_VERSION_MAJOR }} all
41+
- name: Setup Zig
42+
uses: mlugg/setup-zig@v1
43+
with:
44+
version: 0.14.0
45+
- name: Zig Format
46+
run: |
47+
zig fmt src/**.zig
48+
- name: Commit
49+
uses: stefanzweifel/git-auto-commit-action@v5
50+
with:
51+
commit_message: "`bun run zig-format`"
52+
- name: Prettier Format
53+
run: |
54+
bun run prettier
55+
- name: Commit
56+
uses: stefanzweifel/git-auto-commit-action@v5
57+
with:
58+
commit_message: "`bun run prettier`"
59+
- name: Clang Format
60+
run: |
61+
bun run clang-format
62+
- name: Commit
63+
uses: stefanzweifel/git-auto-commit-action@v5
64+
with:
65+
commit_message: "`bun run clang-format`"

.github/workflows/prettier-format.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.

.github/workflows/zig-format.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
"editor.tabSize": 4,
4444
"editor.useTabStops": false,
4545
"editor.defaultFormatter": "ziglang.vscode-zig",
46+
"editor.codeActionsOnSave": {
47+
"source.organizeImports": "never",
48+
},
4649
},
4750

4851
// lldb

bun.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/api/binary-data.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ Buffer.from(buf, 0, 10);
557557
#### To `string`
558558

559559
As UTF-8:
560+
560561
```ts
561562
new TextDecoder().decode(buf);
562563
```
@@ -638,6 +639,7 @@ Buffer.from(arr);
638639
#### To `string`
639640

640641
As UTF-8:
642+
641643
```ts
642644
new TextDecoder().decode(arr);
643645
```
@@ -716,6 +718,7 @@ Buffer.from(view.buffer, view.byteOffset, view.byteLength);
716718
#### To `string`
717719

718720
As UTF-8:
721+
719722
```ts
720723
new TextDecoder().decode(view);
721724
```
@@ -788,16 +791,21 @@ new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
788791
#### To `string`
789792

790793
As UTF-8:
794+
791795
```ts
792796
buf.toString();
793797
```
798+
794799
As base64:
800+
795801
```ts
796-
buf.toString('base64');
802+
buf.toString("base64");
797803
```
804+
798805
As hex:
806+
799807
```ts
800-
buf.toString('hex');
808+
buf.toString("hex");
801809
```
802810

803811
#### To `number[]`
@@ -876,6 +884,7 @@ Buffer.from(await blob.arrayBuffer());
876884
#### To `string`
877885

878886
As UTF-8:
887+
879888
```ts
880889
await blob.text();
881890
```
@@ -962,6 +971,7 @@ Buffer.from(Bun.readableStreamToArrayBuffer(stream));
962971
#### To `string`
963972

964973
As UTF-8:
974+
965975
```ts
966976
// with Response
967977
await new Response(stream).text();

docs/api/dns.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ console.log(addrs);
1010

1111
## DNS caching in Bun
1212

13-
In Bun v1.1.9, we added support for DNS caching. This cache makes repeated connections to the same hosts faster.
13+
In Bun v1.1.9, we added support for DNS caching. This cache makes repeated connections to the same hosts faster.
1414

1515
At the time of writing, we cache up to 255 entries for a maximum of 30 seconds (each). If any connections to a host fail, we remove the entry from the cache. When multiple connections are made to the same host simultaneously, DNS lookups are deduplicated to avoid making multiple requests for the same host.
1616

@@ -27,10 +27,10 @@ This cache is automatically used by:
2727

2828
Web browsers expose [`<link rel="dns-prefetch">`](https://developer.mozilla.org/en-US/docs/Web/Performance/dns-prefetch) to allow developers to prefetch DNS entries. This is useful when you know you'll need to connect to a host in the near future and want to avoid the initial DNS lookup.
2929

30-
In Bun, you can use the `dns.prefetch` API to achieve the same effect.
30+
In Bun, you can use the `dns.prefetch` API to achieve the same effect.
3131

3232
```ts
33-
import {dns} from "bun";
33+
import { dns } from "bun";
3434

3535
dns.prefetch("my.database-host.com", 5432);
3636
```
@@ -52,7 +52,7 @@ dns.prefetch(hostname: string, port: number): void;
5252
Here's an example:
5353

5454
```ts
55-
import {dns} from "bun";
55+
import { dns } from "bun";
5656

5757
dns.prefetch("bun.sh", 443);
5858
//
@@ -66,13 +66,13 @@ await fetch("https://bun.sh");
6666
**🚧** — This API is experimental and may change in the future.
6767
{% /callout %}
6868

69-
To get the current cache stats, you can use the `dns.getCacheStats` API.
69+
To get the current cache stats, you can use the `dns.getCacheStats` API.
7070

7171
This API returns an object with the following properties:
7272

7373
```ts
7474
{
75-
// Cache hits
75+
// Cache hits
7676
cacheHitsCompleted: number;
7777
cacheHitsInflight: number;
7878
cacheMisses: number;
@@ -90,7 +90,7 @@ This API returns an object with the following properties:
9090
Example:
9191

9292
```ts
93-
import {dns} from "bun";
93+
import { dns } from "bun";
9494

9595
const stats = dns.getCacheStats();
9696
console.log(stats);
@@ -107,7 +107,4 @@ BUN_CONFIG_DNS_TIME_TO_LIVE_SECONDS=5 bun run my-script.ts
107107

108108
#### Why is 30 seconds the default?
109109

110-
Unfortunately, the system API underneath (`getaddrinfo`) does not provide a way to get the TTL of a DNS entry. This means we have to pick a number arbitrarily. We chose 30 seconds because it's long enough to see the benefits of caching, and short enough to be unlikely to cause issues if a DNS entry changes. [Amazon Web Services recommends 5 seconds](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/jvm-ttl-dns.html) for the Java Virtual Machine, however the JVM defaults to cache indefinitely.
111-
112-
113-
110+
Unfortunately, the system API underneath (`getaddrinfo`) does not provide a way to get the TTL of a DNS entry. This means we have to pick a number arbitrarily. We chose 30 seconds because it's long enough to see the benefits of caching, and short enough to be unlikely to cause issues if a DNS entry changes. [Amazon Web Services recommends 5 seconds](https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/jvm-ttl-dns.html) for the Java Virtual Machine, however the JVM defaults to cache indefinitely.

docs/api/file-io.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Bun.stderr;
6767
You can delete a file by calling the `.delete()` function.
6868

6969
```ts
70-
await Bun.file("logs.json").delete()
70+
await Bun.file("logs.json").delete();
7171
```
7272

7373
## Writing files (`Bun.write()`)

0 commit comments

Comments
 (0)