@types/node 24.13.6 → 24.19.1
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.
- {node v24.13 → node v24.19}/README.md +1 -1
- {node v24.13 → node v24.19}/async_hooks.d.ts +18 -22
- {node v24.13 → node v24.19}/buffer.buffer.d.ts +10 -5
- {node v24.13 → node v24.19}/buffer.d.ts +7 -0
- {node v24.13 → node v24.19}/child_process.d.ts +5 -1
- {node v24.13 → node v24.19}/crypto.d.ts +114 -47
- {node v24.13 → node v24.19}/dgram.d.ts +119 -4
- {node v24.13 → node v24.19}/dns/promises.d.ts +5 -5
- {node v24.13 → node v24.19}/dns.d.ts +6 -6
- {node v24.13 → node v24.19}/events.d.ts +13 -22
- {node v24.13 → node v24.19}/fs/promises.d.ts +79 -66
- {node v24.13 → node v24.19}/fs.d.ts +153 -90
- {node v24.13 → node v24.19}/http.d.ts +94 -2
- {node v24.13 → node v24.19}/http2.d.ts +65 -18
- {node v24.13 → node v24.19}/inspector.d.ts +47 -1
- {node v24.13 → node v24.19}/inspector.generated.d.ts +167 -0
- {node v24.13 → node v24.19}/module.d.ts +1 -0
- {node v24.13 → node v24.19}/net.d.ts +139 -15
- {node v24.13 → node v24.19}/os.d.ts +30 -30
- {node v24.13 → node v24.19}/package.json +3 -3
- {node v24.13 → node v24.19}/perf_hooks.d.ts +31 -19
- {node v24.13 → node v24.19}/process.d.ts +42 -43
- {node v24.13 → node v24.19}/sqlite.d.ts +153 -11
- {node v24.13 → node v24.19}/stream/consumers.d.ts +7 -0
- {node v24.13 → node v24.19}/stream/web.d.ts +19 -0
- {node v24.13 → node v24.19}/stream.d.ts +2 -1
- {node v24.13 → node v24.19}/test.d.ts +320 -13
- {node v24.13 → node v24.19}/tls.d.ts +50 -15
- {node v24.13 → node v24.19}/ts5.6/buffer.buffer.d.ts +5 -0
- {node v24.13 → node v24.19}/tty.d.ts +4 -3
- {node v24.13 → node v24.19}/url.d.ts +27 -3
- {node v24.13 → node v24.19}/util.d.ts +42 -2
- {node v24.13 → node v24.19}/v8.d.ts +51 -23
- {node v24.13 → node v24.19}/vm.d.ts +52 -87
- {node v24.13 → node v24.19}/zlib.d.ts +23 -0
- {node v24.13 → node v24.19}/LICENSE +0 -0
- {node v24.13 → node v24.19}/assert/strict.d.ts +0 -0
- {node v24.13 → node v24.19}/assert.d.ts +0 -0
- {node v24.13 → node v24.19}/cluster.d.ts +0 -0
- {node v24.13 → node v24.19}/compatibility/iterators.d.ts +0 -0
- {node v24.13 → node v24.19}/console.d.ts +0 -0
- {node v24.13 → node v24.19}/constants.d.ts +0 -0
- {node v24.13 → node v24.19}/diagnostics_channel.d.ts +0 -0
- {node v24.13 → node v24.19}/domain.d.ts +0 -0
- {node v24.13 → node v24.19}/globals.d.ts +0 -0
- {node v24.13 → node v24.19}/globals.typedarray.d.ts +0 -0
- {node v24.13 → node v24.19}/https.d.ts +0 -0
- {node v24.13 → node v24.19}/index.d.ts +0 -0
- {node v24.13 → node v24.19}/path.d.ts +0 -0
- {node v24.13 → node v24.19}/punycode.d.ts +0 -0
- {node v24.13 → node v24.19}/querystring.d.ts +0 -0
- {node v24.13 → node v24.19}/readline/promises.d.ts +0 -0
- {node v24.13 → node v24.19}/readline.d.ts +0 -0
- {node v24.13 → node v24.19}/repl.d.ts +0 -0
- {node v24.13 → node v24.19}/sea.d.ts +0 -0
- {node v24.13 → node v24.19}/stream/promises.d.ts +0 -0
- {node v24.13 → node v24.19}/string_decoder.d.ts +0 -0
- {node v24.13 → node v24.19}/timers/promises.d.ts +0 -0
- {node v24.13 → node v24.19}/timers.d.ts +0 -0
- {node v24.13 → node v24.19}/trace_events.d.ts +0 -0
- {node v24.13 → node v24.19}/ts5.6/compatibility/float16array.d.ts +0 -0
- {node v24.13 → node v24.19}/ts5.6/globals.typedarray.d.ts +0 -0
- {node v24.13 → node v24.19}/ts5.6/index.d.ts +0 -0
- {node v24.13 → node v24.19}/ts5.7/compatibility/float16array.d.ts +0 -0
- {node v24.13 → node v24.19}/ts5.7/index.d.ts +0 -0
- {node v24.13 → node v24.19}/wasi.d.ts +0 -0
- {node v24.13 → node v24.19}/web-globals/abortcontroller.d.ts +0 -0
- {node v24.13 → node v24.19}/web-globals/crypto.d.ts +0 -0
- {node v24.13 → node v24.19}/web-globals/domexception.d.ts +0 -0
- {node v24.13 → node v24.19}/web-globals/events.d.ts +0 -0
- {node v24.13 → node v24.19}/web-globals/fetch.d.ts +0 -0
- {node v24.13 → node v24.19}/web-globals/navigator.d.ts +0 -0
- {node v24.13 → node v24.19}/web-globals/storage.d.ts +0 -0
- {node v24.13 → node v24.19}/web-globals/streams.d.ts +0 -0
- {node v24.13 → node v24.19}/worker_threads.d.ts +0 -0
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* @see [source](https://github.com/nodejs/node/blob/v24.x/lib/fs.js)
|
|
20
20
|
*/
|
|
21
21
|
declare module "fs" {
|
|
22
|
-
import { NonSharedBuffer } from "node:buffer";
|
|
22
|
+
import { BufferView, NonSharedBuffer } from "node:buffer";
|
|
23
23
|
import * as stream from "node:stream";
|
|
24
24
|
import { Abortable, EventEmitter } from "node:events";
|
|
25
25
|
import { URL } from "node:url";
|
|
@@ -147,6 +147,8 @@ declare module "fs" {
|
|
|
147
147
|
bavail: T;
|
|
148
148
|
/** Total file nodes in file system. */
|
|
149
149
|
files: T;
|
|
150
|
+
/** Fundamental file system block size. */
|
|
151
|
+
frsize: T;
|
|
150
152
|
/** Free file nodes in file system. */
|
|
151
153
|
ffree: T;
|
|
152
154
|
}
|
|
@@ -422,7 +424,8 @@ declare module "fs" {
|
|
|
422
424
|
prependOnceListener(event: "error", listener: (error: Error) => void): this;
|
|
423
425
|
}
|
|
424
426
|
/**
|
|
425
|
-
* Instances of `fs.ReadStream`
|
|
427
|
+
* Instances of `fs.ReadStream` cannot be constructed directly. They are created and
|
|
428
|
+
* returned using the `fs.createReadStream()` function.
|
|
426
429
|
* @since v0.1.93
|
|
427
430
|
*/
|
|
428
431
|
export class ReadStream extends stream.Readable {
|
|
@@ -717,9 +720,8 @@ declare module "fs" {
|
|
|
717
720
|
unpipe: (src: stream.Readable) => void;
|
|
718
721
|
} & CustomEvents;
|
|
719
722
|
/**
|
|
720
|
-
*
|
|
721
|
-
*
|
|
722
|
-
* Instances of `fs.WriteStream` are created and returned using the {@link createWriteStream} function.
|
|
723
|
+
* Instances of `fs.WriteStream` cannot be constructed directly. They are created and
|
|
724
|
+
* returned using the `fs.createWriteStream()` function.
|
|
723
725
|
* @since v0.1.93
|
|
724
726
|
*/
|
|
725
727
|
export class WriteStream extends stream.Writable {
|
|
@@ -1180,6 +1182,7 @@ declare module "fs" {
|
|
|
1180
1182
|
options:
|
|
1181
1183
|
| (StatOptions & {
|
|
1182
1184
|
bigint?: false | undefined;
|
|
1185
|
+
throwIfNoEntry?: true | undefined;
|
|
1183
1186
|
})
|
|
1184
1187
|
| undefined,
|
|
1185
1188
|
callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void,
|
|
@@ -1188,13 +1191,32 @@ declare module "fs" {
|
|
|
1188
1191
|
path: PathLike,
|
|
1189
1192
|
options: StatOptions & {
|
|
1190
1193
|
bigint: true;
|
|
1194
|
+
throwIfNoEntry?: true | undefined;
|
|
1191
1195
|
},
|
|
1192
1196
|
callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats) => void,
|
|
1193
1197
|
): void;
|
|
1198
|
+
export function stat(
|
|
1199
|
+
path: PathLike,
|
|
1200
|
+
options:
|
|
1201
|
+
| (StatOptions & {
|
|
1202
|
+
bigint?: false | undefined;
|
|
1203
|
+
throwIfNoEntry: false;
|
|
1204
|
+
})
|
|
1205
|
+
| undefined,
|
|
1206
|
+
callback: (err: NodeJS.ErrnoException | null, stats: Stats | undefined) => void,
|
|
1207
|
+
): void;
|
|
1208
|
+
export function stat(
|
|
1209
|
+
path: PathLike,
|
|
1210
|
+
options: StatOptions & {
|
|
1211
|
+
bigint: true;
|
|
1212
|
+
throwIfNoEntry: false;
|
|
1213
|
+
},
|
|
1214
|
+
callback: (err: NodeJS.ErrnoException | null, stats: BigIntStats | undefined) => void,
|
|
1215
|
+
): void;
|
|
1194
1216
|
export function stat(
|
|
1195
1217
|
path: PathLike,
|
|
1196
1218
|
options: StatOptions | undefined,
|
|
1197
|
-
callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats) => void,
|
|
1219
|
+
callback: (err: NodeJS.ErrnoException | null, stats: Stats | BigIntStats | undefined) => void,
|
|
1198
1220
|
): void;
|
|
1199
1221
|
export namespace stat {
|
|
1200
1222
|
/**
|
|
@@ -1205,15 +1227,31 @@ declare module "fs" {
|
|
|
1205
1227
|
path: PathLike,
|
|
1206
1228
|
options?: StatOptions & {
|
|
1207
1229
|
bigint?: false | undefined;
|
|
1230
|
+
throwIfNoEntry?: true | undefined;
|
|
1208
1231
|
},
|
|
1209
1232
|
): Promise<Stats>;
|
|
1210
1233
|
function __promisify__(
|
|
1211
1234
|
path: PathLike,
|
|
1212
1235
|
options: StatOptions & {
|
|
1213
1236
|
bigint: true;
|
|
1237
|
+
throwIfNoEntry?: true | undefined;
|
|
1214
1238
|
},
|
|
1215
1239
|
): Promise<BigIntStats>;
|
|
1216
|
-
function __promisify__(
|
|
1240
|
+
function __promisify__(
|
|
1241
|
+
path: PathLike,
|
|
1242
|
+
options?: StatOptions & {
|
|
1243
|
+
bigint?: false | undefined;
|
|
1244
|
+
throwIfNoEntry: false;
|
|
1245
|
+
},
|
|
1246
|
+
): Promise<Stats | undefined>;
|
|
1247
|
+
function __promisify__(
|
|
1248
|
+
path: PathLike,
|
|
1249
|
+
options: StatOptions & {
|
|
1250
|
+
bigint: true;
|
|
1251
|
+
throwIfNoEntry: false;
|
|
1252
|
+
},
|
|
1253
|
+
): Promise<BigIntStats | undefined>;
|
|
1254
|
+
function __promisify__(path: PathLike, options?: StatOptions): Promise<Stats | BigIntStats | undefined>;
|
|
1217
1255
|
}
|
|
1218
1256
|
export interface StatSyncFn extends Function {
|
|
1219
1257
|
(path: PathLike, options?: undefined): Stats;
|
|
@@ -2965,6 +3003,21 @@ declare module "fs" {
|
|
|
2965
3003
|
* If no `options` object is specified, it will default with the above values.
|
|
2966
3004
|
*/
|
|
2967
3005
|
export function readSync(fd: number, buffer: NodeJS.ArrayBufferView, opts?: ReadOptions): number;
|
|
3006
|
+
export interface ReadFileOptions extends Abortable {
|
|
3007
|
+
encoding?: BufferEncoding | null | undefined;
|
|
3008
|
+
flag?: OpenMode | undefined;
|
|
3009
|
+
}
|
|
3010
|
+
export interface ReadFileOptionsWithStringEncoding extends ReadFileOptions {
|
|
3011
|
+
encoding: BufferEncoding;
|
|
3012
|
+
}
|
|
3013
|
+
export interface ReadFileOptionsWithBufferEncoding extends ReadFileOptions {
|
|
3014
|
+
encoding?: null | undefined;
|
|
3015
|
+
}
|
|
3016
|
+
export interface ReadFileOptionsWithBuffer<T extends NodeJS.ArrayBufferView>
|
|
3017
|
+
extends ReadFileOptionsWithBufferEncoding
|
|
3018
|
+
{
|
|
3019
|
+
buffer: T | ((size: number) => T);
|
|
3020
|
+
}
|
|
2968
3021
|
/**
|
|
2969
3022
|
* Asynchronously reads the entire contents of a file.
|
|
2970
3023
|
*
|
|
@@ -2982,6 +3035,11 @@ declare module "fs" {
|
|
|
2982
3035
|
*
|
|
2983
3036
|
* If no encoding is specified, then the raw buffer is returned.
|
|
2984
3037
|
*
|
|
3038
|
+
* If `buffer` is provided and no encoding is specified, the returned `Buffer` is
|
|
3039
|
+
* a view over the supplied buffer containing only the bytes read. If the
|
|
3040
|
+
* supplied buffer is too small to contain the entire file, the callback is
|
|
3041
|
+
* called with an error.
|
|
3042
|
+
*
|
|
2985
3043
|
* If `options` is a string, then it specifies the encoding:
|
|
2986
3044
|
*
|
|
2987
3045
|
* ```js
|
|
@@ -2990,7 +3048,8 @@ declare module "fs" {
|
|
|
2990
3048
|
* readFile('/etc/passwd', 'utf8', callback);
|
|
2991
3049
|
* ```
|
|
2992
3050
|
*
|
|
2993
|
-
* When the path is a directory, the behavior of `fs.readFile()` and
|
|
3051
|
+
* When the path is a directory, the behavior of `fs.readFile()` and
|
|
3052
|
+
* `fs.readFileSync()` is platform-specific. On macOS, Linux, and Windows, an
|
|
2994
3053
|
* error will be returned. On FreeBSD, a representation of the directory's contents
|
|
2995
3054
|
* will be returned.
|
|
2996
3055
|
*
|
|
@@ -3028,60 +3087,56 @@ declare module "fs" {
|
|
|
3028
3087
|
*
|
|
3029
3088
|
* Aborting an ongoing request does not abort individual operating
|
|
3030
3089
|
* system requests but rather the internal buffering `fs.readFile` performs.
|
|
3090
|
+
*
|
|
3091
|
+
* An example using the `buffer` option with a pre-allocated buffer:
|
|
3092
|
+
*
|
|
3093
|
+
* ```js
|
|
3094
|
+
* import { Buffer } from 'node:buffer';
|
|
3095
|
+
* import { readFile } from 'node:fs';
|
|
3096
|
+
*
|
|
3097
|
+
* const buf = Buffer.alloc(16384);
|
|
3098
|
+
* readFile('/path/to/file', { buffer: buf }, (err, data) => {
|
|
3099
|
+
* if (err) throw err;
|
|
3100
|
+
* console.log(data); // A view over `buf` containing only the bytes read
|
|
3101
|
+
* });
|
|
3102
|
+
* ```
|
|
3103
|
+
*
|
|
3104
|
+
* An example using the `buffer` option with a function returning a buffer:
|
|
3105
|
+
*
|
|
3106
|
+
* ```js
|
|
3107
|
+
* import { Buffer } from 'node:buffer';
|
|
3108
|
+
* import { readFile } from 'node:fs';
|
|
3109
|
+
*
|
|
3110
|
+
* readFile('/path/to/file', {
|
|
3111
|
+
* buffer: (size) => Buffer.alloc(size),
|
|
3112
|
+
* }, (err, data) => {
|
|
3113
|
+
* if (err) throw err;
|
|
3114
|
+
* console.log(data);
|
|
3115
|
+
* });
|
|
3116
|
+
* ```
|
|
3031
3117
|
* @since v0.1.29
|
|
3032
3118
|
* @param path filename or file descriptor
|
|
3033
3119
|
*/
|
|
3120
|
+
export function readFile<T extends NodeJS.ArrayBufferView>(
|
|
3121
|
+
path: PathOrFileDescriptor,
|
|
3122
|
+
options: ReadFileOptionsWithBuffer<T>,
|
|
3123
|
+
callback: (err: NodeJS.ErrnoException | null, data: BufferView<T>) => void,
|
|
3124
|
+
): void;
|
|
3034
3125
|
export function readFile(
|
|
3035
3126
|
path: PathOrFileDescriptor,
|
|
3036
|
-
options:
|
|
3037
|
-
| ({
|
|
3038
|
-
encoding?: null | undefined;
|
|
3039
|
-
flag?: string | undefined;
|
|
3040
|
-
} & Abortable)
|
|
3041
|
-
| undefined
|
|
3042
|
-
| null,
|
|
3127
|
+
options: ReadFileOptionsWithBufferEncoding | null | undefined,
|
|
3043
3128
|
callback: (err: NodeJS.ErrnoException | null, data: NonSharedBuffer) => void,
|
|
3044
3129
|
): void;
|
|
3045
|
-
/**
|
|
3046
|
-
* Asynchronously reads the entire contents of a file.
|
|
3047
|
-
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
3048
|
-
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
|
3049
|
-
* @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
|
|
3050
|
-
* If a flag is not provided, it defaults to `'r'`.
|
|
3051
|
-
*/
|
|
3052
3130
|
export function readFile(
|
|
3053
3131
|
path: PathOrFileDescriptor,
|
|
3054
|
-
options:
|
|
3055
|
-
| ({
|
|
3056
|
-
encoding: BufferEncoding;
|
|
3057
|
-
flag?: string | undefined;
|
|
3058
|
-
} & Abortable)
|
|
3059
|
-
| BufferEncoding,
|
|
3132
|
+
options: ReadFileOptionsWithStringEncoding | BufferEncoding,
|
|
3060
3133
|
callback: (err: NodeJS.ErrnoException | null, data: string) => void,
|
|
3061
3134
|
): void;
|
|
3062
|
-
/**
|
|
3063
|
-
* Asynchronously reads the entire contents of a file.
|
|
3064
|
-
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
3065
|
-
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
|
3066
|
-
* @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
|
|
3067
|
-
* If a flag is not provided, it defaults to `'r'`.
|
|
3068
|
-
*/
|
|
3069
3135
|
export function readFile(
|
|
3070
3136
|
path: PathOrFileDescriptor,
|
|
3071
|
-
options:
|
|
3072
|
-
| (ObjectEncodingOptions & {
|
|
3073
|
-
flag?: string | undefined;
|
|
3074
|
-
} & Abortable)
|
|
3075
|
-
| BufferEncoding
|
|
3076
|
-
| undefined
|
|
3077
|
-
| null,
|
|
3137
|
+
options: ReadFileOptions | BufferEncoding | null | undefined,
|
|
3078
3138
|
callback: (err: NodeJS.ErrnoException | null, data: string | NonSharedBuffer) => void,
|
|
3079
3139
|
): void;
|
|
3080
|
-
/**
|
|
3081
|
-
* Asynchronously reads the entire contents of a file.
|
|
3082
|
-
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
3083
|
-
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
|
3084
|
-
*/
|
|
3085
3140
|
export function readFile(
|
|
3086
3141
|
path: PathOrFileDescriptor,
|
|
3087
3142
|
callback: (err: NodeJS.ErrnoException | null, data: NonSharedBuffer) => void,
|
|
@@ -3136,16 +3191,37 @@ declare module "fs" {
|
|
|
3136
3191
|
| null,
|
|
3137
3192
|
): Promise<string | NonSharedBuffer>;
|
|
3138
3193
|
}
|
|
3194
|
+
export interface ReadFileSyncOptions {
|
|
3195
|
+
encoding?: BufferEncoding | null | undefined;
|
|
3196
|
+
flag?: OpenMode | undefined;
|
|
3197
|
+
}
|
|
3198
|
+
export interface ReadFileSyncOptionsWithStringEncoding extends ReadFileSyncOptions {
|
|
3199
|
+
encoding: BufferEncoding;
|
|
3200
|
+
}
|
|
3201
|
+
export interface ReadFileSyncOptionsWithBufferEncoding extends ReadFileSyncOptions {
|
|
3202
|
+
encoding?: null | undefined;
|
|
3203
|
+
}
|
|
3204
|
+
export interface ReadFileSyncOptionsWithBuffer<T extends NodeJS.ArrayBufferView>
|
|
3205
|
+
extends ReadFileSyncOptionsWithBufferEncoding
|
|
3206
|
+
{
|
|
3207
|
+
buffer: T | ((size: number) => T);
|
|
3208
|
+
}
|
|
3139
3209
|
/**
|
|
3140
3210
|
* Returns the contents of the `path`.
|
|
3141
3211
|
*
|
|
3142
3212
|
* For detailed information, see the documentation of the asynchronous version of
|
|
3143
|
-
* this API:
|
|
3213
|
+
* this API: `fs.readFile()`.
|
|
3144
3214
|
*
|
|
3145
3215
|
* If the `encoding` option is specified then this function returns a
|
|
3146
3216
|
* string. Otherwise it returns a buffer.
|
|
3147
3217
|
*
|
|
3148
|
-
*
|
|
3218
|
+
* If `buffer` is provided and no encoding is specified, the returned {Buffer} is
|
|
3219
|
+
* a view over the supplied buffer containing only the bytes read. If the
|
|
3220
|
+
* supplied buffer is too small to contain the entire file, an error will be
|
|
3221
|
+
* thrown.
|
|
3222
|
+
*
|
|
3223
|
+
* Similar to `fs.readFile()`, when the path is a directory, the behavior of
|
|
3224
|
+
* `fs.readFileSync()` is platform-specific.
|
|
3149
3225
|
*
|
|
3150
3226
|
* ```js
|
|
3151
3227
|
* import { readFileSync } from 'node:fs';
|
|
@@ -3160,45 +3236,19 @@ declare module "fs" {
|
|
|
3160
3236
|
* @since v0.1.8
|
|
3161
3237
|
* @param path filename or file descriptor
|
|
3162
3238
|
*/
|
|
3239
|
+
export function readFileSync<T extends NodeJS.ArrayBufferView>(
|
|
3240
|
+
path: PathOrFileDescriptor,
|
|
3241
|
+
options: ReadFileSyncOptionsWithBuffer<T>,
|
|
3242
|
+
): BufferView<T>;
|
|
3163
3243
|
export function readFileSync(
|
|
3164
3244
|
path: PathOrFileDescriptor,
|
|
3165
|
-
options?:
|
|
3166
|
-
encoding?: null | undefined;
|
|
3167
|
-
flag?: string | undefined;
|
|
3168
|
-
} | null,
|
|
3245
|
+
options?: ReadFileSyncOptionsWithBufferEncoding | null,
|
|
3169
3246
|
): NonSharedBuffer;
|
|
3170
|
-
/**
|
|
3171
|
-
* Synchronously reads the entire contents of a file.
|
|
3172
|
-
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
3173
|
-
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
|
3174
|
-
* @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
|
|
3175
|
-
* If a flag is not provided, it defaults to `'r'`.
|
|
3176
|
-
*/
|
|
3177
3247
|
export function readFileSync(
|
|
3178
3248
|
path: PathOrFileDescriptor,
|
|
3179
|
-
options:
|
|
3180
|
-
| {
|
|
3181
|
-
encoding: BufferEncoding;
|
|
3182
|
-
flag?: string | undefined;
|
|
3183
|
-
}
|
|
3184
|
-
| BufferEncoding,
|
|
3249
|
+
options: ReadFileSyncOptionsWithStringEncoding | BufferEncoding,
|
|
3185
3250
|
): string;
|
|
3186
|
-
|
|
3187
|
-
* Synchronously reads the entire contents of a file.
|
|
3188
|
-
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
|
3189
|
-
* If a file descriptor is provided, the underlying file will _not_ be closed automatically.
|
|
3190
|
-
* @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
|
|
3191
|
-
* If a flag is not provided, it defaults to `'r'`.
|
|
3192
|
-
*/
|
|
3193
|
-
export function readFileSync(
|
|
3194
|
-
path: PathOrFileDescriptor,
|
|
3195
|
-
options?:
|
|
3196
|
-
| (ObjectEncodingOptions & {
|
|
3197
|
-
flag?: string | undefined;
|
|
3198
|
-
})
|
|
3199
|
-
| BufferEncoding
|
|
3200
|
-
| null,
|
|
3201
|
-
): string | NonSharedBuffer;
|
|
3251
|
+
export function readFileSync(path: PathOrFileDescriptor, options: ReadFileSyncOptions): string | NonSharedBuffer;
|
|
3202
3252
|
export type WriteFileOptions =
|
|
3203
3253
|
| (
|
|
3204
3254
|
& ObjectEncodingOptions
|
|
@@ -3594,10 +3644,12 @@ declare module "fs" {
|
|
|
3594
3644
|
*/
|
|
3595
3645
|
export function unwatchFile(filename: PathLike, listener?: StatsListener): void;
|
|
3596
3646
|
export function unwatchFile(filename: PathLike, listener?: BigIntStatsListener): void;
|
|
3647
|
+
type WatchIgnorePredicate = string | RegExp | ((filename: string) => boolean);
|
|
3597
3648
|
export interface WatchOptions extends Abortable {
|
|
3598
3649
|
encoding?: BufferEncoding | "buffer" | undefined;
|
|
3599
3650
|
persistent?: boolean | undefined;
|
|
3600
3651
|
recursive?: boolean | undefined;
|
|
3652
|
+
ignore?: WatchIgnorePredicate | readonly WatchIgnorePredicate[] | undefined;
|
|
3601
3653
|
}
|
|
3602
3654
|
export interface WatchOptionsWithBufferEncoding extends WatchOptions {
|
|
3603
3655
|
encoding: "buffer";
|
|
@@ -4520,10 +4572,9 @@ declare module "fs" {
|
|
|
4520
4572
|
}
|
|
4521
4573
|
export interface StatOptions {
|
|
4522
4574
|
bigint?: boolean | undefined;
|
|
4523
|
-
}
|
|
4524
|
-
export interface StatSyncOptions extends StatOptions {
|
|
4525
4575
|
throwIfNoEntry?: boolean | undefined;
|
|
4526
4576
|
}
|
|
4577
|
+
export interface StatSyncOptions extends StatOptions {}
|
|
4527
4578
|
interface CopyOptionsBase {
|
|
4528
4579
|
/**
|
|
4529
4580
|
* Dereference symlinks
|
|
@@ -4620,12 +4671,6 @@ declare module "fs" {
|
|
|
4620
4671
|
* @default process.cwd()
|
|
4621
4672
|
*/
|
|
4622
4673
|
cwd?: string | URL | undefined;
|
|
4623
|
-
/**
|
|
4624
|
-
* `true` if the glob should return paths as `Dirent`s, `false` otherwise.
|
|
4625
|
-
* @default false
|
|
4626
|
-
* @since v22.2.0
|
|
4627
|
-
*/
|
|
4628
|
-
withFileTypes?: boolean | undefined;
|
|
4629
4674
|
/**
|
|
4630
4675
|
* Function to filter out files/directories or a
|
|
4631
4676
|
* list of glob patterns to be excluded. If a function is provided, return
|
|
@@ -4636,6 +4681,18 @@ declare module "fs" {
|
|
|
4636
4681
|
* @default undefined
|
|
4637
4682
|
*/
|
|
4638
4683
|
exclude?: ((fileName: T) => boolean) | readonly string[] | undefined;
|
|
4684
|
+
/**
|
|
4685
|
+
* When `true`, symbolic links to directories are
|
|
4686
|
+
* followed while expanding `**` patterns.
|
|
4687
|
+
* @default false
|
|
4688
|
+
*/
|
|
4689
|
+
followSymlinks?: boolean | undefined;
|
|
4690
|
+
/**
|
|
4691
|
+
* `true` if the glob should return paths as `Dirent`s, `false` otherwise.
|
|
4692
|
+
* @default false
|
|
4693
|
+
* @since v22.2.0
|
|
4694
|
+
*/
|
|
4695
|
+
withFileTypes?: boolean | undefined;
|
|
4639
4696
|
}
|
|
4640
4697
|
export interface GlobOptions extends _GlobOptions<Dirent | string> {}
|
|
4641
4698
|
export interface GlobOptionsWithFileTypes extends _GlobOptions<Dirent> {
|
|
@@ -4648,6 +4705,9 @@ declare module "fs" {
|
|
|
4648
4705
|
/**
|
|
4649
4706
|
* Retrieves the files matching the specified pattern.
|
|
4650
4707
|
*
|
|
4708
|
+
* When `followSymlinks` is enabled, detected symbolic link cycles are not
|
|
4709
|
+
* traversed recursively.
|
|
4710
|
+
*
|
|
4651
4711
|
* ```js
|
|
4652
4712
|
* import { glob } from 'node:fs';
|
|
4653
4713
|
*
|
|
@@ -4687,6 +4747,9 @@ declare module "fs" {
|
|
|
4687
4747
|
) => void,
|
|
4688
4748
|
): void;
|
|
4689
4749
|
/**
|
|
4750
|
+
* When `followSymlinks` is enabled, detected symbolic link cycles are not
|
|
4751
|
+
* traversed recursively.
|
|
4752
|
+
*
|
|
4690
4753
|
* ```js
|
|
4691
4754
|
* import { globSync } from 'node:fs';
|
|
4692
4755
|
*
|
|
@@ -216,6 +216,7 @@ declare module "http" {
|
|
|
216
216
|
headers?: OutgoingHttpHeaders | readonly string[] | undefined;
|
|
217
217
|
host?: string | null | undefined;
|
|
218
218
|
hostname?: string | null | undefined;
|
|
219
|
+
httpValidation?: "strict" | "relaxed" | "insecure" | undefined;
|
|
219
220
|
insecureHTTPParser?: boolean | undefined;
|
|
220
221
|
localAddress?: string | undefined;
|
|
221
222
|
localPort?: number | undefined;
|
|
@@ -265,7 +266,7 @@ declare module "http" {
|
|
|
265
266
|
* The number of milliseconds of inactivity a server needs to wait for additional incoming data,
|
|
266
267
|
* after it has finished writing the last response, before a socket will be destroyed.
|
|
267
268
|
* @see Server.keepAliveTimeout for more information.
|
|
268
|
-
* @default
|
|
269
|
+
* @default 65000
|
|
269
270
|
* @since v18.0.0
|
|
270
271
|
*/
|
|
271
272
|
keepAliveTimeout?: number | undefined;
|
|
@@ -295,6 +296,21 @@ declare module "http" {
|
|
|
295
296
|
* @since v20.1.0
|
|
296
297
|
*/
|
|
297
298
|
highWaterMark?: number | undefined;
|
|
299
|
+
/**
|
|
300
|
+
* Controls HTTP header value validation strictness
|
|
301
|
+
* for incoming requests. Accepted values are:
|
|
302
|
+
* * `'strict'`: Strictest validation; rejects any non-ASCII or control
|
|
303
|
+
* characters in header values.
|
|
304
|
+
* * `'relaxed'`: Allows a limited set of non-ASCII characters in header
|
|
305
|
+
* values, aligning with the
|
|
306
|
+
* [Fetch specification](https://fetch.spec.whatwg.org/).
|
|
307
|
+
* * `'insecure'`: Disables all header value validation (equivalent to
|
|
308
|
+
* `insecureHTTPParser: true`).
|
|
309
|
+
*
|
|
310
|
+
* Cannot be used together with `insecureHTTPParser`. **Default:** `'strict'`.
|
|
311
|
+
* @since v24.19.0
|
|
312
|
+
*/
|
|
313
|
+
httpValidation?: "strict" | "relaxed" | "insecure" | undefined;
|
|
298
314
|
/**
|
|
299
315
|
* Use an insecure HTTP parser that accepts invalid HTTP headers when `true`.
|
|
300
316
|
* Using the insecure parser should be avoided.
|
|
@@ -324,7 +340,7 @@ declare module "http" {
|
|
|
324
340
|
requireHostHeader?: boolean | undefined;
|
|
325
341
|
/**
|
|
326
342
|
* If set to `true`, it enables keep-alive functionality on the socket immediately after a new incoming connection is received,
|
|
327
|
-
* similarly on what is done in `socket.setKeepAlive(
|
|
343
|
+
* similarly on what is done in `socket.setKeepAlive()`.
|
|
328
344
|
* @default false
|
|
329
345
|
* @since v16.5.0
|
|
330
346
|
*/
|
|
@@ -956,6 +972,36 @@ declare module "http" {
|
|
|
956
972
|
headers?: OutgoingHttpHeaders | OutgoingHttpHeader[],
|
|
957
973
|
): this;
|
|
958
974
|
writeHead(statusCode: number, headers?: OutgoingHttpHeaders | OutgoingHttpHeader[]): this;
|
|
975
|
+
/**
|
|
976
|
+
* Sends an arbitrary HTTP/1.1 1xx informational response to the client. This
|
|
977
|
+
* is a generic equivalent of `response.writeContinue()`,
|
|
978
|
+
* `response.writeProcessing()` and `response.writeEarlyHints()`, and
|
|
979
|
+
* can be called multiple times before the final response. After the final
|
|
980
|
+
* response headers have been sent (via `response.writeHead()` or an
|
|
981
|
+
* implicit header), calling this method throws `ERR_HTTP_HEADERS_SENT`.
|
|
982
|
+
*
|
|
983
|
+
* Clients receive these responses via the [`'information'`](https://nodejs.org/docs/latest-v24.x/api/http.html#event-information)
|
|
984
|
+
* event on `http.ClientRequest`.
|
|
985
|
+
*
|
|
986
|
+
* ```js
|
|
987
|
+
* response.writeInformation(110, { 'X-Progress': '50%' });
|
|
988
|
+
* ```
|
|
989
|
+
* @since v24.18.0
|
|
990
|
+
* @param statusCode An HTTP 1xx informational status code, between `100`
|
|
991
|
+
* and `199` inclusive, excluding `101` (Switching Protocols) which is only
|
|
992
|
+
* available through the [`'upgrade'`](https://nodejs.org/docs/latest-v24.x/api/http.html#event-upgrade) event.
|
|
993
|
+
* @param headers An optional set of headers to send with the
|
|
994
|
+
* informational response. Accepts the same shapes as
|
|
995
|
+
* `response.writeHead()`.
|
|
996
|
+
* @param callback Optional, called once the message has been written
|
|
997
|
+
* to the socket.
|
|
998
|
+
*/
|
|
999
|
+
writeInformation(
|
|
1000
|
+
statusCode: number,
|
|
1001
|
+
headers?: OutgoingHttpHeaders | readonly string[],
|
|
1002
|
+
callback?: () => void,
|
|
1003
|
+
): void;
|
|
1004
|
+
writeInformation(statusCode: number, callback: () => void): void;
|
|
959
1005
|
/**
|
|
960
1006
|
* Sends a HTTP/1.1 102 Processing message to the client, indicating that
|
|
961
1007
|
* the request body should be sent.
|
|
@@ -1411,6 +1457,31 @@ declare module "http" {
|
|
|
1411
1457
|
* @since v0.5.9
|
|
1412
1458
|
*/
|
|
1413
1459
|
setTimeout(msecs: number, callback?: () => void): this;
|
|
1460
|
+
/**
|
|
1461
|
+
* An `AbortSignal` that is aborted when the underlying socket closes or the
|
|
1462
|
+
* request is destroyed. The signal is created lazily on first access — no
|
|
1463
|
+
* `AbortController` is allocated for requests that never use this property.
|
|
1464
|
+
*
|
|
1465
|
+
* This is useful for cancelling downstream asynchronous work such as database
|
|
1466
|
+
* queries or `fetch` calls when a client disconnects mid-request.
|
|
1467
|
+
*
|
|
1468
|
+
* ```js
|
|
1469
|
+
* import http from 'node:http';
|
|
1470
|
+
*
|
|
1471
|
+
* http.createServer(async (req, res) => {
|
|
1472
|
+
* try {
|
|
1473
|
+
* const data = await fetch('https://example.com/api', { signal: req.signal });
|
|
1474
|
+
* res.end(JSON.stringify(await data.json()));
|
|
1475
|
+
* } catch (err) {
|
|
1476
|
+
* if (err.name === 'AbortError') return;
|
|
1477
|
+
* res.statusCode = 500;
|
|
1478
|
+
* res.end('Internal Server Error');
|
|
1479
|
+
* }
|
|
1480
|
+
* }).listen(3000);
|
|
1481
|
+
* ```
|
|
1482
|
+
* @since v24.16.0
|
|
1483
|
+
*/
|
|
1484
|
+
readonly signal: AbortSignal;
|
|
1414
1485
|
/**
|
|
1415
1486
|
* **Only valid for request obtained from {@link Server}.**
|
|
1416
1487
|
*
|
|
@@ -2123,6 +2194,27 @@ declare module "http" {
|
|
|
2123
2194
|
* @param [max=1000]
|
|
2124
2195
|
*/
|
|
2125
2196
|
function setMaxIdleHTTPParsers(max: number): void;
|
|
2197
|
+
/**
|
|
2198
|
+
* Dynamically resets the global configurations to enable built-in proxy support for
|
|
2199
|
+
* `fetch()` and `http.request()`/`https.request()` at runtime, as an alternative
|
|
2200
|
+
* to using the `--use-env-proxy` flag or `NODE_USE_ENV_PROXY` environment variable.
|
|
2201
|
+
* It can also be used to override settings configured from the environment variables.
|
|
2202
|
+
*
|
|
2203
|
+
* As this function resets the global configurations, any previously configured
|
|
2204
|
+
* `http.globalAgent`, `https.globalAgent` or undici global dispatcher would be
|
|
2205
|
+
* overridden after this function is invoked. It's recommended to invoke it before any
|
|
2206
|
+
* requests are made and avoid invoking it in the middle of any requests.
|
|
2207
|
+
*
|
|
2208
|
+
* See [Built-in Proxy Support](https://nodejs.org/docs/latest-v24.x/api/http.html#built-in-proxy-support) for details on proxy URL formats and `NO_PROXY`
|
|
2209
|
+
* syntax.
|
|
2210
|
+
* @since v24.14.0
|
|
2211
|
+
* @param proxyEnv An object containing proxy configuration. This accepts the
|
|
2212
|
+
* same options as the `proxyEnv` option accepted by {@link Agent}. **Default:**
|
|
2213
|
+
* `process.env`.
|
|
2214
|
+
* @returns A function that restores the original agent and dispatcher
|
|
2215
|
+
* settings to the state before this `http.setGlobalProxyFromEnv()` is invoked.
|
|
2216
|
+
*/
|
|
2217
|
+
function setGlobalProxyFromEnv(proxyEnv?: ProxyEnv): () => void;
|
|
2126
2218
|
/**
|
|
2127
2219
|
* Global instance of `Agent` which is used as the default for all HTTP client
|
|
2128
2220
|
* requests. Diverges from a default `Agent` configuration by having `keepAlive`
|