bun-types 1.2.10 → 1.2.11-canary.20250418T140557
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/bun.d.ts +119 -15
- package/docs/api/fetch.md +1 -1
- package/docs/api/redis.md +0 -22
- package/docs/api/spawn.md +1 -1
- package/docs/cli/publish.md +1 -1
- package/docs/guides/ecosystem/nuxt.md +1 -1
- package/docs/guides/install/add-peer.md +2 -2
- package/docs/guides/install/from-npm-install-to-bun-install.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/version.md +1 -1
- package/docs/installation.md +4 -4
- package/docs/project/bindgen.md +1 -1
- package/docs/runtime/debugger.md +3 -3
- package/docs/test/dom.md +1 -1
- package/globals.d.ts +26 -0
- package/jsc.d.ts +22 -18
- package/package.json +1 -1
package/bun.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ declare module "bun" {
|
|
|
27
27
|
| ReadableStreamDefaultReadValueResult<T>
|
|
28
28
|
| ReadableStreamDefaultReadDoneResult;
|
|
29
29
|
type ReadableStreamReader<T> = ReadableStreamDefaultReader<T>;
|
|
30
|
-
type Transferable = ArrayBuffer |
|
|
30
|
+
type Transferable = ArrayBuffer | MessagePort;
|
|
31
31
|
type MessageEventSource = Bun.__internal.UseLibDomIfAvailable<"MessageEventSource", undefined>;
|
|
32
32
|
type Encoding = "utf-8" | "windows-1252" | "utf-16";
|
|
33
33
|
type UncaughtExceptionOrigin = "uncaughtException" | "unhandledRejection";
|
|
@@ -581,7 +581,10 @@ declare module "bun" {
|
|
|
581
581
|
},
|
|
582
582
|
): number;
|
|
583
583
|
|
|
584
|
-
|
|
584
|
+
/**
|
|
585
|
+
* TOML related APIs
|
|
586
|
+
*/
|
|
587
|
+
namespace TOML {
|
|
585
588
|
/**
|
|
586
589
|
* Parse a TOML string into a JavaScript object.
|
|
587
590
|
*
|
|
@@ -590,8 +593,8 @@ declare module "bun" {
|
|
|
590
593
|
* @param input The TOML string to parse
|
|
591
594
|
* @returns A JavaScript object
|
|
592
595
|
*/
|
|
593
|
-
parse(input: string): object;
|
|
594
|
-
}
|
|
596
|
+
export function parse(input: string): object;
|
|
597
|
+
}
|
|
595
598
|
|
|
596
599
|
/**
|
|
597
600
|
* Synchronously resolve a `moduleId` as though it were imported from `parent`
|
|
@@ -1001,7 +1004,8 @@ declare module "bun" {
|
|
|
1001
1004
|
end(): ArrayBuffer | Uint8Array;
|
|
1002
1005
|
}
|
|
1003
1006
|
|
|
1004
|
-
|
|
1007
|
+
/** DNS Related APIs */
|
|
1008
|
+
namespace dns {
|
|
1005
1009
|
/**
|
|
1006
1010
|
* Lookup the IP address for a hostname
|
|
1007
1011
|
*
|
|
@@ -1046,7 +1050,7 @@ declare module "bun" {
|
|
|
1046
1050
|
* console.log(address); // "19.42.52.62"
|
|
1047
1051
|
* ```
|
|
1048
1052
|
*/
|
|
1049
|
-
lookup(
|
|
1053
|
+
function lookup(
|
|
1050
1054
|
hostname: string,
|
|
1051
1055
|
options?: {
|
|
1052
1056
|
/**
|
|
@@ -1115,12 +1119,12 @@ declare module "bun" {
|
|
|
1115
1119
|
* await fetch('https://example.com');
|
|
1116
1120
|
* ```
|
|
1117
1121
|
*/
|
|
1118
|
-
prefetch(hostname: string): void;
|
|
1122
|
+
function prefetch(hostname: string): void;
|
|
1119
1123
|
|
|
1120
1124
|
/**
|
|
1121
1125
|
* **Experimental API**
|
|
1122
1126
|
*/
|
|
1123
|
-
getCacheStats(): {
|
|
1127
|
+
function getCacheStats(): {
|
|
1124
1128
|
/**
|
|
1125
1129
|
* The number of times a cached DNS entry that was already resolved was used.
|
|
1126
1130
|
*/
|
|
@@ -1132,10 +1136,10 @@ declare module "bun" {
|
|
|
1132
1136
|
totalCount: number;
|
|
1133
1137
|
};
|
|
1134
1138
|
|
|
1135
|
-
ADDRCONFIG: number;
|
|
1136
|
-
ALL: number;
|
|
1137
|
-
V4MAPPED: number;
|
|
1138
|
-
}
|
|
1139
|
+
const ADDRCONFIG: number;
|
|
1140
|
+
const ALL: number;
|
|
1141
|
+
const V4MAPPED: number;
|
|
1142
|
+
}
|
|
1139
1143
|
|
|
1140
1144
|
interface DNSLookup {
|
|
1141
1145
|
/**
|
|
@@ -1184,7 +1188,7 @@ declare module "bun" {
|
|
|
1184
1188
|
* ```
|
|
1185
1189
|
*/
|
|
1186
1190
|
interface BunFile extends Blob {
|
|
1187
|
-
|
|
1191
|
+
/**
|
|
1188
1192
|
* Offset any operation on the file starting at `begin` and ending at `end`. `end` is relative to 0
|
|
1189
1193
|
*
|
|
1190
1194
|
* Similar to [`TypedArray.subarray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray). Does not copy the file, open the file, or modify the file.
|
|
@@ -1197,7 +1201,6 @@ declare module "bun" {
|
|
|
1197
1201
|
*/
|
|
1198
1202
|
slice(begin?: number, end?: number, contentType?: string): BunFile;
|
|
1199
1203
|
|
|
1200
|
-
/** */
|
|
1201
1204
|
/**
|
|
1202
1205
|
* Offset any operation on the file starting at `begin`
|
|
1203
1206
|
*
|
|
@@ -1211,6 +1214,8 @@ declare module "bun" {
|
|
|
1211
1214
|
slice(begin?: number, contentType?: string): BunFile;
|
|
1212
1215
|
|
|
1213
1216
|
/**
|
|
1217
|
+
* Slice the file from the beginning to the end, optionally with a new MIME type.
|
|
1218
|
+
*
|
|
1214
1219
|
* @param contentType - MIME type for the new BunFile
|
|
1215
1220
|
*/
|
|
1216
1221
|
slice(contentType?: string): BunFile;
|
|
@@ -1271,7 +1276,7 @@ declare module "bun" {
|
|
|
1271
1276
|
unlink(): Promise<void>;
|
|
1272
1277
|
|
|
1273
1278
|
/**
|
|
1274
|
-
* Deletes the file
|
|
1279
|
+
* Deletes the file (same as unlink)
|
|
1275
1280
|
*/
|
|
1276
1281
|
delete(): Promise<void>;
|
|
1277
1282
|
|
|
@@ -7366,34 +7371,133 @@ declare module "bun" {
|
|
|
7366
7371
|
|
|
7367
7372
|
type CookieSameSite = "strict" | "lax" | "none";
|
|
7368
7373
|
|
|
7374
|
+
/**
|
|
7375
|
+
* A class for working with a single cookie
|
|
7376
|
+
*
|
|
7377
|
+
* @example
|
|
7378
|
+
* ```js
|
|
7379
|
+
* const cookie = new Bun.Cookie("name", "value");
|
|
7380
|
+
* console.log(cookie.toString()); // "name=value; Path=/; SameSite=Lax"
|
|
7381
|
+
* ```
|
|
7382
|
+
*/
|
|
7369
7383
|
class Cookie {
|
|
7384
|
+
/**
|
|
7385
|
+
* Create a new cookie
|
|
7386
|
+
* @param name - The name of the cookie
|
|
7387
|
+
* @param value - The value of the cookie
|
|
7388
|
+
* @param options - Optional cookie attributes
|
|
7389
|
+
*/
|
|
7370
7390
|
constructor(name: string, value: string, options?: CookieInit);
|
|
7391
|
+
|
|
7392
|
+
/**
|
|
7393
|
+
* Create a new cookie from a cookie string
|
|
7394
|
+
* @param cookieString - The cookie string
|
|
7395
|
+
*/
|
|
7371
7396
|
constructor(cookieString: string);
|
|
7397
|
+
|
|
7398
|
+
/**
|
|
7399
|
+
* Create a new cookie from a cookie object
|
|
7400
|
+
* @param cookieObject - The cookie object
|
|
7401
|
+
*/
|
|
7372
7402
|
constructor(cookieObject?: CookieInit);
|
|
7373
7403
|
|
|
7404
|
+
/**
|
|
7405
|
+
* The name of the cookie
|
|
7406
|
+
*/
|
|
7374
7407
|
readonly name: string;
|
|
7408
|
+
|
|
7409
|
+
/**
|
|
7410
|
+
* The value of the cookie
|
|
7411
|
+
*/
|
|
7375
7412
|
value: string;
|
|
7413
|
+
|
|
7414
|
+
/**
|
|
7415
|
+
* The domain of the cookie
|
|
7416
|
+
*/
|
|
7376
7417
|
domain?: string;
|
|
7418
|
+
|
|
7419
|
+
/**
|
|
7420
|
+
* The path of the cookie
|
|
7421
|
+
*/
|
|
7377
7422
|
path: string;
|
|
7423
|
+
|
|
7424
|
+
/**
|
|
7425
|
+
* The expiration date of the cookie
|
|
7426
|
+
*/
|
|
7378
7427
|
expires?: Date;
|
|
7428
|
+
|
|
7429
|
+
/**
|
|
7430
|
+
* Whether the cookie is secure
|
|
7431
|
+
*/
|
|
7379
7432
|
secure: boolean;
|
|
7433
|
+
|
|
7434
|
+
/**
|
|
7435
|
+
* The same-site attribute of the cookie
|
|
7436
|
+
*/
|
|
7380
7437
|
sameSite: CookieSameSite;
|
|
7438
|
+
|
|
7439
|
+
/**
|
|
7440
|
+
* Whether the cookie is partitioned
|
|
7441
|
+
*/
|
|
7381
7442
|
partitioned: boolean;
|
|
7443
|
+
|
|
7444
|
+
/**
|
|
7445
|
+
* The maximum age of the cookie in seconds
|
|
7446
|
+
*/
|
|
7382
7447
|
maxAge?: number;
|
|
7448
|
+
|
|
7449
|
+
/**
|
|
7450
|
+
* Whether the cookie is HTTP-only
|
|
7451
|
+
*/
|
|
7383
7452
|
httpOnly: boolean;
|
|
7384
7453
|
|
|
7454
|
+
/**
|
|
7455
|
+
* Whether the cookie is expired
|
|
7456
|
+
*/
|
|
7385
7457
|
isExpired(): boolean;
|
|
7386
7458
|
|
|
7459
|
+
/**
|
|
7460
|
+
* Serialize the cookie to a string
|
|
7461
|
+
*
|
|
7462
|
+
* @example
|
|
7463
|
+
* ```ts
|
|
7464
|
+
* const cookie = Bun.Cookie.from("session", "abc123", {
|
|
7465
|
+
* domain: "example.com",
|
|
7466
|
+
* path: "/",
|
|
7467
|
+
* secure: true,
|
|
7468
|
+
* httpOnly: true
|
|
7469
|
+
* }).serialize(); // "session=abc123; Domain=example.com; Path=/; Secure; HttpOnly; SameSite=Lax"
|
|
7470
|
+
* ```
|
|
7471
|
+
*/
|
|
7387
7472
|
serialize(): string;
|
|
7473
|
+
|
|
7474
|
+
/**
|
|
7475
|
+
* Serialize the cookie to a string
|
|
7476
|
+
*
|
|
7477
|
+
* Alias of {@link Cookie.serialize}
|
|
7478
|
+
*/
|
|
7388
7479
|
toString(): string;
|
|
7480
|
+
|
|
7481
|
+
/**
|
|
7482
|
+
* Serialize the cookie to a JSON object
|
|
7483
|
+
*/
|
|
7389
7484
|
toJSON(): CookieInit;
|
|
7390
7485
|
|
|
7486
|
+
/**
|
|
7487
|
+
* Parse a cookie string into a Cookie object
|
|
7488
|
+
* @param cookieString - The cookie string
|
|
7489
|
+
*/
|
|
7391
7490
|
static parse(cookieString: string): Cookie;
|
|
7491
|
+
|
|
7492
|
+
/**
|
|
7493
|
+
* Create a new cookie from a name and value and optional options
|
|
7494
|
+
*/
|
|
7392
7495
|
static from(name: string, value: string, options?: CookieInit): Cookie;
|
|
7393
7496
|
}
|
|
7394
7497
|
|
|
7395
7498
|
/**
|
|
7396
7499
|
* A Map-like interface for working with collections of cookies.
|
|
7500
|
+
*
|
|
7397
7501
|
* Implements the `Iterable` interface, allowing use with `for...of` loops.
|
|
7398
7502
|
*/
|
|
7399
7503
|
class CookieMap implements Iterable<[string, string]> {
|
package/docs/api/fetch.md
CHANGED
|
@@ -337,7 +337,7 @@ This will print the request and response headers to your terminal:
|
|
|
337
337
|
```sh
|
|
338
338
|
[fetch] > HTTP/1.1 GET http://example.com/
|
|
339
339
|
[fetch] > Connection: keep-alive
|
|
340
|
-
[fetch] > User-Agent: Bun/1.2.
|
|
340
|
+
[fetch] > User-Agent: Bun/1.2.11-canary.20250418T140557
|
|
341
341
|
[fetch] > Accept: */*
|
|
342
342
|
[fetch] > Host: example.com
|
|
343
343
|
[fetch] > Accept-Encoding: gzip, deflate, br
|
package/docs/api/redis.md
CHANGED
|
@@ -21,28 +21,6 @@ const exists = await redis.exists("greeting");
|
|
|
21
21
|
await redis.del("greeting");
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
{% features title="Features" %}
|
|
25
|
-
|
|
26
|
-
{% icon size=20 name="Bolt" /%} Fast native implementation using Zig and JavaScriptCore
|
|
27
|
-
|
|
28
|
-
{% icon size=20 name="Link" /%} Automatic pipelining for better performance
|
|
29
|
-
|
|
30
|
-
{% icon size=20 name="EthernetPort" /%} Auto-reconnect with exponential backoff
|
|
31
|
-
|
|
32
|
-
{% icon size=20 name="Omega" /%} Support for RESP3 protocol
|
|
33
|
-
|
|
34
|
-
{% icon size=20 name="Lock" /%} TLS support
|
|
35
|
-
|
|
36
|
-
{% icon size=20 name="Clock" /%} Connection management with configurable timeouts
|
|
37
|
-
|
|
38
|
-
{% icon size=20 name="IndentDecrease" /%} Offline command queue
|
|
39
|
-
|
|
40
|
-
{% icon size=20 name="Settings" /%} Automatic configuration with environment variables
|
|
41
|
-
|
|
42
|
-
{% icon size=20 name="Hash" /%} Support for hash, set, and other Redis data structures
|
|
43
|
-
|
|
44
|
-
{% /features %}
|
|
45
|
-
|
|
46
24
|
## Getting Started
|
|
47
25
|
|
|
48
26
|
To use the Redis client, you first need to create a connection:
|
package/docs/api/spawn.md
CHANGED
|
@@ -120,7 +120,7 @@ You can read results from the subprocess via the `stdout` and `stderr` propertie
|
|
|
120
120
|
```ts
|
|
121
121
|
const proc = Bun.spawn(["bun", "--version"]);
|
|
122
122
|
const text = await new Response(proc.stdout).text();
|
|
123
|
-
console.log(text); // => "1.2.
|
|
123
|
+
console.log(text); // => "1.2.11-canary.20250418T140557"
|
|
124
124
|
```
|
|
125
125
|
|
|
126
126
|
Configure the output stream by passing one of the following values to `stdout/stderr`:
|
package/docs/cli/publish.md
CHANGED
|
@@ -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.
|
|
12
|
+
bun install v1.2.11-canary.20250418T140557 (16b4bf34)
|
|
13
13
|
+ @nuxt/devtools@0.8.2
|
|
14
14
|
+ nuxt@3.7.0
|
|
15
15
|
785 packages installed [2.67s]
|
|
@@ -16,7 +16,7 @@ This will add the package to `peerDependencies` in `package.json`.
|
|
|
16
16
|
```json-diff
|
|
17
17
|
{
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
+ "@types/bun": "^1.2.
|
|
19
|
+
+ "@types/bun": "^1.2.11-canary.20250418T140557"
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
```
|
|
@@ -28,7 +28,7 @@ Running `bun install` will install peer dependencies by default, unless marked o
|
|
|
28
28
|
```json-diff
|
|
29
29
|
{
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@types/bun": "^1.2.
|
|
31
|
+
"@types/bun": "^1.2.11-canary.20250418T140557"
|
|
32
32
|
},
|
|
33
33
|
"peerDependenciesMeta": {
|
|
34
34
|
+ "@types/bun": {
|
|
@@ -97,7 +97,7 @@ $ bun update
|
|
|
97
97
|
$ bun update @types/bun --latest
|
|
98
98
|
|
|
99
99
|
# Update a dependency to a specific version
|
|
100
|
-
$ bun update @types/bun@1.2.
|
|
100
|
+
$ bun update @types/bun@1.2.11-canary.20250418T140557
|
|
101
101
|
|
|
102
102
|
# Update all dependencies to the latest versions
|
|
103
103
|
$ bun update --latest
|
|
@@ -21,7 +21,7 @@ Here's what the output of a typical test run looks like. In this case, there are
|
|
|
21
21
|
|
|
22
22
|
```sh
|
|
23
23
|
$ bun test
|
|
24
|
-
bun test v1.2.
|
|
24
|
+
bun test v1.2.11-canary.20250418T140557 (9c68abdb)
|
|
25
25
|
|
|
26
26
|
test.test.js:
|
|
27
27
|
✓ add [0.87ms]
|
|
@@ -47,7 +47,7 @@ To only run certain test files, pass a positional argument to `bun test`. The ru
|
|
|
47
47
|
|
|
48
48
|
```sh
|
|
49
49
|
$ bun test test3
|
|
50
|
-
bun test v1.2.
|
|
50
|
+
bun test v1.2.11-canary.20250418T140557 (9c68abdb)
|
|
51
51
|
|
|
52
52
|
test3.test.js:
|
|
53
53
|
✓ add [1.40ms]
|
|
@@ -85,7 +85,7 @@ Adding `-t add` will only run tests with "add" in the name. This works with test
|
|
|
85
85
|
|
|
86
86
|
```sh
|
|
87
87
|
$ bun test -t add
|
|
88
|
-
bun test v1.2.
|
|
88
|
+
bun test v1.2.11-canary.20250418T140557 (9c68abdb)
|
|
89
89
|
|
|
90
90
|
test.test.js:
|
|
91
91
|
✓ add [1.79ms]
|
|
@@ -18,7 +18,7 @@ The first time this test is executed, Bun will evaluate the value passed into `e
|
|
|
18
18
|
|
|
19
19
|
```sh
|
|
20
20
|
$ bun test test/snap
|
|
21
|
-
bun test v1.2.
|
|
21
|
+
bun test v1.2.11-canary.20250418T140557 (9c68abdb)
|
|
22
22
|
|
|
23
23
|
test/snap.test.ts:
|
|
24
24
|
✓ snapshot [1.48ms]
|
|
@@ -61,7 +61,7 @@ Later, when this test file is executed again, Bun will read the snapshot file an
|
|
|
61
61
|
|
|
62
62
|
```sh
|
|
63
63
|
$ bun test
|
|
64
|
-
bun test v1.2.
|
|
64
|
+
bun test v1.2.11-canary.20250418T140557 (9c68abdb)
|
|
65
65
|
|
|
66
66
|
test/snap.test.ts:
|
|
67
67
|
✓ snapshot [1.05ms]
|
|
@@ -78,7 +78,7 @@ To update snapshots, use the `--update-snapshots` flag.
|
|
|
78
78
|
|
|
79
79
|
```sh
|
|
80
80
|
$ bun test --update-snapshots
|
|
81
|
-
bun test v1.2.
|
|
81
|
+
bun test v1.2.11-canary.20250418T140557 (9c68abdb)
|
|
82
82
|
|
|
83
83
|
test/snap.test.ts:
|
|
84
84
|
✓ snapshot [0.86ms]
|
package/docs/installation.md
CHANGED
|
@@ -14,7 +14,7 @@ Kernel version 5.6 or higher is strongly recommended, but the minimum is 5.1. Us
|
|
|
14
14
|
```bash#macOS/Linux_(curl)
|
|
15
15
|
$ curl -fsSL https://bun.sh/install | bash # for macOS, Linux, and WSL
|
|
16
16
|
# to install a specific version
|
|
17
|
-
$ curl -fsSL https://bun.sh/install | bash -s "bun-v1.2.
|
|
17
|
+
$ curl -fsSL https://bun.sh/install | bash -s "bun-v1.2.11-canary.20250418T140557"
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
```bash#npm
|
|
@@ -189,10 +189,10 @@ Since Bun is a single binary, you can install older versions of Bun by re-runnin
|
|
|
189
189
|
|
|
190
190
|
### Installing a specific version of Bun on Linux/Mac
|
|
191
191
|
|
|
192
|
-
To install a specific version of Bun, you can pass the git tag of the version you want to install to the install script, such as `bun-v1.2.0` or `bun-v1.2.
|
|
192
|
+
To install a specific version of Bun, you can pass the git tag of the version you want to install to the install script, such as `bun-v1.2.0` or `bun-v1.2.11-canary.20250418T140557`.
|
|
193
193
|
|
|
194
194
|
```sh
|
|
195
|
-
$ curl -fsSL https://bun.sh/install | bash -s "bun-v1.2.
|
|
195
|
+
$ curl -fsSL https://bun.sh/install | bash -s "bun-v1.2.11-canary.20250418T140557"
|
|
196
196
|
```
|
|
197
197
|
|
|
198
198
|
### Installing a specific version of Bun on Windows
|
|
@@ -201,7 +201,7 @@ On Windows, you can install a specific version of Bun by passing the version num
|
|
|
201
201
|
|
|
202
202
|
```sh
|
|
203
203
|
# PowerShell:
|
|
204
|
-
$ iex "& {$(irm https://bun.sh/install.ps1)} -Version 1.2.
|
|
204
|
+
$ iex "& {$(irm https://bun.sh/install.ps1)} -Version 1.2.11-canary.20250418T140557"
|
|
205
205
|
```
|
|
206
206
|
|
|
207
207
|
## Downloading Bun binaries directly
|
package/docs/project/bindgen.md
CHANGED
|
@@ -32,7 +32,7 @@ pub fn add(global: *JSC.JSGlobalObject, a: i32, b: i32) !i32 {
|
|
|
32
32
|
const gen = bun.gen.math; // "math" being this file's basename
|
|
33
33
|
|
|
34
34
|
const std = @import("std");
|
|
35
|
-
const bun = @import("
|
|
35
|
+
const bun = @import("bun");
|
|
36
36
|
const JSC = bun.JSC;
|
|
37
37
|
```
|
|
38
38
|
|
package/docs/runtime/debugger.md
CHANGED
|
@@ -124,11 +124,11 @@ await fetch("https://example.com", {
|
|
|
124
124
|
This prints the `fetch` request as a single-line `curl` command to let you copy-paste into your terminal to replicate the request.
|
|
125
125
|
|
|
126
126
|
```sh
|
|
127
|
-
[fetch] $ curl --http1.1 "https://example.com/" -X POST -H "content-type: application/json" -H "Connection: keep-alive" -H "User-Agent: Bun/1.2.
|
|
127
|
+
[fetch] $ curl --http1.1 "https://example.com/" -X POST -H "content-type: application/json" -H "Connection: keep-alive" -H "User-Agent: Bun/1.2.11-canary.20250418T140557" -H "Accept: */*" -H "Host: example.com" -H "Accept-Encoding: gzip, deflate, br" --compressed -H "Content-Length: 13" --data-raw "{\"foo\":\"bar\"}"
|
|
128
128
|
[fetch] > HTTP/1.1 POST https://example.com/
|
|
129
129
|
[fetch] > content-type: application/json
|
|
130
130
|
[fetch] > Connection: keep-alive
|
|
131
|
-
[fetch] > User-Agent: Bun/1.2.
|
|
131
|
+
[fetch] > User-Agent: Bun/1.2.11-canary.20250418T140557
|
|
132
132
|
[fetch] > Accept: */*
|
|
133
133
|
[fetch] > Host: example.com
|
|
134
134
|
[fetch] > Accept-Encoding: gzip, deflate, br
|
|
@@ -170,7 +170,7 @@ This prints the following to the console:
|
|
|
170
170
|
[fetch] > HTTP/1.1 POST https://example.com/
|
|
171
171
|
[fetch] > content-type: application/json
|
|
172
172
|
[fetch] > Connection: keep-alive
|
|
173
|
-
[fetch] > User-Agent: Bun/1.2.
|
|
173
|
+
[fetch] > User-Agent: Bun/1.2.11-canary.20250418T140557
|
|
174
174
|
[fetch] > Accept: */*
|
|
175
175
|
[fetch] > Host: example.com
|
|
176
176
|
[fetch] > Accept-Encoding: gzip, deflate, br
|
package/docs/test/dom.md
CHANGED
package/globals.d.ts
CHANGED
|
@@ -1832,14 +1832,40 @@ interface BunFetchRequestInit extends RequestInit {
|
|
|
1832
1832
|
/**
|
|
1833
1833
|
* Override http_proxy or HTTPS_PROXY
|
|
1834
1834
|
* This is a custom property that is not part of the Fetch API specification.
|
|
1835
|
+
*
|
|
1836
|
+
* @example
|
|
1837
|
+
* ```js
|
|
1838
|
+
* const response = await fetch("http://example.com", {
|
|
1839
|
+
* proxy: "https://username:password@127.0.0.1:8080"
|
|
1840
|
+
* });
|
|
1841
|
+
* ```
|
|
1835
1842
|
*/
|
|
1836
1843
|
proxy?: string;
|
|
1837
1844
|
|
|
1838
1845
|
/**
|
|
1839
1846
|
* Override the default S3 options
|
|
1847
|
+
*
|
|
1848
|
+
* @example
|
|
1849
|
+
* ```js
|
|
1850
|
+
* const response = await fetch("s3://bucket/key", {
|
|
1851
|
+
* s3: {
|
|
1852
|
+
* accessKeyId: "AKIAIOSFODNN7EXAMPLE",
|
|
1853
|
+
* secretAccessKey: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
|
|
1854
|
+
* region: "us-east-1",
|
|
1855
|
+
* }
|
|
1856
|
+
* });
|
|
1857
|
+
* ```
|
|
1840
1858
|
*/
|
|
1841
1859
|
s3?: Bun.S3Options;
|
|
1842
1860
|
|
|
1861
|
+
/**
|
|
1862
|
+
* Make the request over a Unix socket
|
|
1863
|
+
*
|
|
1864
|
+
* @example
|
|
1865
|
+
* ```js
|
|
1866
|
+
* const response = await fetch("http://example.com", { unix: "/path/to/socket" });
|
|
1867
|
+
* ```
|
|
1868
|
+
*/
|
|
1843
1869
|
unix?: string;
|
|
1844
1870
|
}
|
|
1845
1871
|
|
package/jsc.d.ts
CHANGED
|
@@ -8,24 +8,8 @@ declare module "bun:jsc" {
|
|
|
8
8
|
function fullGC(): number;
|
|
9
9
|
function edenGC(): number;
|
|
10
10
|
function heapSize(): number;
|
|
11
|
-
function heapStats():
|
|
12
|
-
|
|
13
|
-
heapCapacity: number;
|
|
14
|
-
extraMemorySize: number;
|
|
15
|
-
objectCount: number;
|
|
16
|
-
protectedObjectCount: number;
|
|
17
|
-
globalObjectCount: number;
|
|
18
|
-
protectedGlobalObjectCount: number;
|
|
19
|
-
objectTypeCounts: Record<string, number>;
|
|
20
|
-
protectedObjectTypeCounts: Record<string, number>;
|
|
21
|
-
};
|
|
22
|
-
function memoryUsage(): {
|
|
23
|
-
current: number;
|
|
24
|
-
peak: number;
|
|
25
|
-
currentCommit: number;
|
|
26
|
-
peakCommit: number;
|
|
27
|
-
pageFaults: number;
|
|
28
|
-
};
|
|
11
|
+
function heapStats(): HeapStats;
|
|
12
|
+
function memoryUsage(): MemoryUsage;
|
|
29
13
|
function getRandomSeed(): number;
|
|
30
14
|
function setRandomSeed(value: number): void;
|
|
31
15
|
function isRope(input: string): boolean;
|
|
@@ -78,6 +62,26 @@ declare module "bun:jsc" {
|
|
|
78
62
|
*/
|
|
79
63
|
function setTimeZone(timeZone: string): string;
|
|
80
64
|
|
|
65
|
+
interface HeapStats {
|
|
66
|
+
heapSize: number;
|
|
67
|
+
heapCapacity: number;
|
|
68
|
+
extraMemorySize: number;
|
|
69
|
+
objectCount: number;
|
|
70
|
+
protectedObjectCount: number;
|
|
71
|
+
globalObjectCount: number;
|
|
72
|
+
protectedGlobalObjectCount: number;
|
|
73
|
+
objectTypeCounts: Record<string, number>;
|
|
74
|
+
protectedObjectTypeCounts: Record<string, number>;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
interface MemoryUsage {
|
|
78
|
+
current: number;
|
|
79
|
+
peak: number;
|
|
80
|
+
currentCommit: number;
|
|
81
|
+
peakCommit: number;
|
|
82
|
+
pageFaults: number;
|
|
83
|
+
}
|
|
84
|
+
|
|
81
85
|
interface SamplingProfile {
|
|
82
86
|
/**
|
|
83
87
|
* A formatted summary of the top functions
|
package/package.json
CHANGED