mcpbrowser 0.2.2 → 0.2.4

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 (126) hide show
  1. package/README.md +36 -21
  2. package/package.json +2 -3
  3. package/server.json +2 -2
  4. package/src/mcp-browser.js +42 -6
  5. package/.mcpregistry_github_token +0 -1
  6. package/.mcpregistry_registry_token +0 -1
  7. package/extension/mcpbrowser-0.1.1.vsix +0 -0
  8. package/extension/mcpbrowser-0.1.2.vsix +0 -0
  9. package/extension/mcpbrowser-0.1.3.vsix +0 -0
  10. package/extension/mcpbrowser-0.1.4.vsix +0 -0
  11. package/extension/mcpbrowser-config-0.1.0.vsix +0 -0
  12. package/extension/node_modules/.package-lock.json +0 -32
  13. package/extension/node_modules/@types/node/LICENSE +0 -21
  14. package/extension/node_modules/@types/node/README.md +0 -15
  15. package/extension/node_modules/@types/node/assert/strict.d.ts +0 -8
  16. package/extension/node_modules/@types/node/assert.d.ts +0 -1062
  17. package/extension/node_modules/@types/node/async_hooks.d.ts +0 -605
  18. package/extension/node_modules/@types/node/buffer.buffer.d.ts +0 -471
  19. package/extension/node_modules/@types/node/buffer.d.ts +0 -1936
  20. package/extension/node_modules/@types/node/child_process.d.ts +0 -1475
  21. package/extension/node_modules/@types/node/cluster.d.ts +0 -577
  22. package/extension/node_modules/@types/node/compatibility/disposable.d.ts +0 -16
  23. package/extension/node_modules/@types/node/compatibility/index.d.ts +0 -9
  24. package/extension/node_modules/@types/node/compatibility/indexable.d.ts +0 -20
  25. package/extension/node_modules/@types/node/compatibility/iterators.d.ts +0 -21
  26. package/extension/node_modules/@types/node/console.d.ts +0 -452
  27. package/extension/node_modules/@types/node/constants.d.ts +0 -21
  28. package/extension/node_modules/@types/node/crypto.d.ts +0 -4590
  29. package/extension/node_modules/@types/node/dgram.d.ts +0 -597
  30. package/extension/node_modules/@types/node/diagnostics_channel.d.ts +0 -578
  31. package/extension/node_modules/@types/node/dns/promises.d.ts +0 -479
  32. package/extension/node_modules/@types/node/dns.d.ts +0 -871
  33. package/extension/node_modules/@types/node/domain.d.ts +0 -170
  34. package/extension/node_modules/@types/node/events.d.ts +0 -977
  35. package/extension/node_modules/@types/node/fs/promises.d.ts +0 -1270
  36. package/extension/node_modules/@types/node/fs.d.ts +0 -4375
  37. package/extension/node_modules/@types/node/globals.d.ts +0 -172
  38. package/extension/node_modules/@types/node/globals.typedarray.d.ts +0 -38
  39. package/extension/node_modules/@types/node/http.d.ts +0 -2049
  40. package/extension/node_modules/@types/node/http2.d.ts +0 -2631
  41. package/extension/node_modules/@types/node/https.d.ts +0 -578
  42. package/extension/node_modules/@types/node/index.d.ts +0 -93
  43. package/extension/node_modules/@types/node/inspector.generated.d.ts +0 -3966
  44. package/extension/node_modules/@types/node/module.d.ts +0 -539
  45. package/extension/node_modules/@types/node/net.d.ts +0 -1012
  46. package/extension/node_modules/@types/node/os.d.ts +0 -506
  47. package/extension/node_modules/@types/node/package.json +0 -140
  48. package/extension/node_modules/@types/node/path.d.ts +0 -200
  49. package/extension/node_modules/@types/node/perf_hooks.d.ts +0 -961
  50. package/extension/node_modules/@types/node/process.d.ts +0 -1957
  51. package/extension/node_modules/@types/node/punycode.d.ts +0 -117
  52. package/extension/node_modules/@types/node/querystring.d.ts +0 -152
  53. package/extension/node_modules/@types/node/readline/promises.d.ts +0 -162
  54. package/extension/node_modules/@types/node/readline.d.ts +0 -589
  55. package/extension/node_modules/@types/node/repl.d.ts +0 -430
  56. package/extension/node_modules/@types/node/sea.d.ts +0 -153
  57. package/extension/node_modules/@types/node/stream/consumers.d.ts +0 -38
  58. package/extension/node_modules/@types/node/stream/promises.d.ts +0 -90
  59. package/extension/node_modules/@types/node/stream/web.d.ts +0 -533
  60. package/extension/node_modules/@types/node/stream.d.ts +0 -1675
  61. package/extension/node_modules/@types/node/string_decoder.d.ts +0 -67
  62. package/extension/node_modules/@types/node/test.d.ts +0 -1787
  63. package/extension/node_modules/@types/node/timers/promises.d.ts +0 -108
  64. package/extension/node_modules/@types/node/timers.d.ts +0 -286
  65. package/extension/node_modules/@types/node/tls.d.ts +0 -1255
  66. package/extension/node_modules/@types/node/trace_events.d.ts +0 -197
  67. package/extension/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +0 -468
  68. package/extension/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +0 -34
  69. package/extension/node_modules/@types/node/ts5.6/index.d.ts +0 -93
  70. package/extension/node_modules/@types/node/tty.d.ts +0 -208
  71. package/extension/node_modules/@types/node/url.d.ts +0 -964
  72. package/extension/node_modules/@types/node/util.d.ts +0 -2331
  73. package/extension/node_modules/@types/node/v8.d.ts +0 -809
  74. package/extension/node_modules/@types/node/vm.d.ts +0 -1001
  75. package/extension/node_modules/@types/node/wasi.d.ts +0 -181
  76. package/extension/node_modules/@types/node/web-globals/abortcontroller.d.ts +0 -34
  77. package/extension/node_modules/@types/node/web-globals/domexception.d.ts +0 -68
  78. package/extension/node_modules/@types/node/web-globals/events.d.ts +0 -97
  79. package/extension/node_modules/@types/node/web-globals/fetch.d.ts +0 -46
  80. package/extension/node_modules/@types/node/worker_threads.d.ts +0 -715
  81. package/extension/node_modules/@types/node/zlib.d.ts +0 -540
  82. package/extension/node_modules/@types/vscode/LICENSE +0 -21
  83. package/extension/node_modules/@types/vscode/README.md +0 -15
  84. package/extension/node_modules/@types/vscode/index.d.ts +0 -21153
  85. package/extension/node_modules/@types/vscode/package.json +0 -26
  86. package/extension/node_modules/undici-types/LICENSE +0 -21
  87. package/extension/node_modules/undici-types/README.md +0 -6
  88. package/extension/node_modules/undici-types/agent.d.ts +0 -31
  89. package/extension/node_modules/undici-types/api.d.ts +0 -43
  90. package/extension/node_modules/undici-types/balanced-pool.d.ts +0 -29
  91. package/extension/node_modules/undici-types/cache.d.ts +0 -36
  92. package/extension/node_modules/undici-types/client.d.ts +0 -108
  93. package/extension/node_modules/undici-types/connector.d.ts +0 -34
  94. package/extension/node_modules/undici-types/content-type.d.ts +0 -21
  95. package/extension/node_modules/undici-types/cookies.d.ts +0 -28
  96. package/extension/node_modules/undici-types/diagnostics-channel.d.ts +0 -66
  97. package/extension/node_modules/undici-types/dispatcher.d.ts +0 -256
  98. package/extension/node_modules/undici-types/env-http-proxy-agent.d.ts +0 -21
  99. package/extension/node_modules/undici-types/errors.d.ts +0 -149
  100. package/extension/node_modules/undici-types/eventsource.d.ts +0 -61
  101. package/extension/node_modules/undici-types/fetch.d.ts +0 -209
  102. package/extension/node_modules/undici-types/file.d.ts +0 -39
  103. package/extension/node_modules/undici-types/filereader.d.ts +0 -54
  104. package/extension/node_modules/undici-types/formdata.d.ts +0 -108
  105. package/extension/node_modules/undici-types/global-dispatcher.d.ts +0 -9
  106. package/extension/node_modules/undici-types/global-origin.d.ts +0 -7
  107. package/extension/node_modules/undici-types/handlers.d.ts +0 -15
  108. package/extension/node_modules/undici-types/header.d.ts +0 -4
  109. package/extension/node_modules/undici-types/index.d.ts +0 -71
  110. package/extension/node_modules/undici-types/interceptors.d.ts +0 -17
  111. package/extension/node_modules/undici-types/mock-agent.d.ts +0 -50
  112. package/extension/node_modules/undici-types/mock-client.d.ts +0 -25
  113. package/extension/node_modules/undici-types/mock-errors.d.ts +0 -12
  114. package/extension/node_modules/undici-types/mock-interceptor.d.ts +0 -93
  115. package/extension/node_modules/undici-types/mock-pool.d.ts +0 -25
  116. package/extension/node_modules/undici-types/package.json +0 -55
  117. package/extension/node_modules/undici-types/patch.d.ts +0 -33
  118. package/extension/node_modules/undici-types/pool-stats.d.ts +0 -19
  119. package/extension/node_modules/undici-types/pool.d.ts +0 -39
  120. package/extension/node_modules/undici-types/proxy-agent.d.ts +0 -28
  121. package/extension/node_modules/undici-types/readable.d.ts +0 -65
  122. package/extension/node_modules/undici-types/retry-agent.d.ts +0 -8
  123. package/extension/node_modules/undici-types/retry-handler.d.ts +0 -116
  124. package/extension/node_modules/undici-types/util.d.ts +0 -18
  125. package/extension/node_modules/undici-types/webidl.d.ts +0 -228
  126. package/extension/node_modules/undici-types/websocket.d.ts +0 -150
@@ -1,1270 +0,0 @@
1
- /**
2
- * The `fs/promises` API provides asynchronous file system methods that return
3
- * promises.
4
- *
5
- * The promise APIs use the underlying Node.js threadpool to perform file
6
- * system operations off the event loop thread. These operations are not
7
- * synchronized or threadsafe. Care must be taken when performing multiple
8
- * concurrent modifications on the same file or data corruption may occur.
9
- * @since v10.0.0
10
- */
11
- declare module "fs/promises" {
12
- import { NonSharedBuffer } from "node:buffer";
13
- import { Abortable } from "node:events";
14
- import { Stream } from "node:stream";
15
- import { ReadableStream } from "node:stream/web";
16
- import {
17
- BigIntStats,
18
- BigIntStatsFs,
19
- BufferEncodingOption,
20
- constants as fsConstants,
21
- CopyOptions,
22
- Dir,
23
- Dirent,
24
- MakeDirectoryOptions,
25
- Mode,
26
- ObjectEncodingOptions,
27
- OpenDirOptions,
28
- OpenMode,
29
- PathLike,
30
- ReadOptions,
31
- ReadOptionsWithBuffer,
32
- ReadStream,
33
- ReadVResult,
34
- RmDirOptions,
35
- RmOptions,
36
- StatFsOptions,
37
- StatOptions,
38
- Stats,
39
- StatsFs,
40
- TimeLike,
41
- WatchEventType,
42
- WatchOptions,
43
- WriteStream,
44
- WriteVResult,
45
- } from "node:fs";
46
- import { Interface as ReadlineInterface } from "node:readline";
47
- interface FileChangeInfo<T extends string | Buffer> {
48
- eventType: WatchEventType;
49
- filename: T | null;
50
- }
51
- interface FlagAndOpenMode {
52
- mode?: Mode | undefined;
53
- flag?: OpenMode | undefined;
54
- }
55
- interface FileReadResult<T extends NodeJS.ArrayBufferView> {
56
- bytesRead: number;
57
- buffer: T;
58
- }
59
- /** @deprecated This interface will be removed in a future version. Use `import { ReadOptionsWithBuffer } from "node:fs"` instead. */
60
- interface FileReadOptions<T extends NodeJS.ArrayBufferView = Buffer> {
61
- /**
62
- * @default `Buffer.alloc(0xffff)`
63
- */
64
- buffer?: T;
65
- /**
66
- * @default 0
67
- */
68
- offset?: number | null;
69
- /**
70
- * @default `buffer.byteLength`
71
- */
72
- length?: number | null;
73
- position?: number | null;
74
- }
75
- interface CreateReadStreamOptions extends Abortable {
76
- encoding?: BufferEncoding | null | undefined;
77
- autoClose?: boolean | undefined;
78
- emitClose?: boolean | undefined;
79
- start?: number | undefined;
80
- end?: number | undefined;
81
- highWaterMark?: number | undefined;
82
- }
83
- interface CreateWriteStreamOptions {
84
- encoding?: BufferEncoding | null | undefined;
85
- autoClose?: boolean | undefined;
86
- emitClose?: boolean | undefined;
87
- start?: number | undefined;
88
- highWaterMark?: number | undefined;
89
- flush?: boolean | undefined;
90
- }
91
- interface ReadableWebStreamOptions {
92
- /**
93
- * Whether to open a normal or a `'bytes'` stream.
94
- * @since v20.0.0
95
- */
96
- type?: "bytes" | undefined;
97
- }
98
- // TODO: Add `EventEmitter` close
99
- interface FileHandle {
100
- /**
101
- * The numeric file descriptor managed by the {FileHandle} object.
102
- * @since v10.0.0
103
- */
104
- readonly fd: number;
105
- /**
106
- * Alias of `filehandle.writeFile()`.
107
- *
108
- * When operating on file handles, the mode cannot be changed from what it was set
109
- * to with `fsPromises.open()`. Therefore, this is equivalent to `filehandle.writeFile()`.
110
- * @since v10.0.0
111
- * @return Fulfills with `undefined` upon success.
112
- */
113
- appendFile(
114
- data: string | Uint8Array,
115
- options?:
116
- | (ObjectEncodingOptions & Abortable)
117
- | BufferEncoding
118
- | null,
119
- ): Promise<void>;
120
- /**
121
- * Changes the ownership of the file. A wrapper for [`chown(2)`](http://man7.org/linux/man-pages/man2/chown.2.html).
122
- * @since v10.0.0
123
- * @param uid The file's new owner's user id.
124
- * @param gid The file's new group's group id.
125
- * @return Fulfills with `undefined` upon success.
126
- */
127
- chown(uid: number, gid: number): Promise<void>;
128
- /**
129
- * Modifies the permissions on the file. See [`chmod(2)`](http://man7.org/linux/man-pages/man2/chmod.2.html).
130
- * @since v10.0.0
131
- * @param mode the file mode bit mask.
132
- * @return Fulfills with `undefined` upon success.
133
- */
134
- chmod(mode: Mode): Promise<void>;
135
- /**
136
- * Unlike the 16 KiB default `highWaterMark` for a `stream.Readable`, the stream
137
- * returned by this method has a default `highWaterMark` of 64 KiB.
138
- *
139
- * `options` can include `start` and `end` values to read a range of bytes from
140
- * the file instead of the entire file. Both `start` and `end` are inclusive and
141
- * start counting at 0, allowed values are in the
142
- * \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. If `start` is
143
- * omitted or `undefined`, `filehandle.createReadStream()` reads sequentially from
144
- * the current file position. The `encoding` can be any one of those accepted by `Buffer`.
145
- *
146
- * If the `FileHandle` points to a character device that only supports blocking
147
- * reads (such as keyboard or sound card), read operations do not finish until data
148
- * is available. This can prevent the process from exiting and the stream from
149
- * closing naturally.
150
- *
151
- * By default, the stream will emit a `'close'` event after it has been
152
- * destroyed. Set the `emitClose` option to `false` to change this behavior.
153
- *
154
- * ```js
155
- * import { open } from 'node:fs/promises';
156
- *
157
- * const fd = await open('/dev/input/event0');
158
- * // Create a stream from some character device.
159
- * const stream = fd.createReadStream();
160
- * setTimeout(() => {
161
- * stream.close(); // This may not close the stream.
162
- * // Artificially marking end-of-stream, as if the underlying resource had
163
- * // indicated end-of-file by itself, allows the stream to close.
164
- * // This does not cancel pending read operations, and if there is such an
165
- * // operation, the process may still not be able to exit successfully
166
- * // until it finishes.
167
- * stream.push(null);
168
- * stream.read(0);
169
- * }, 100);
170
- * ```
171
- *
172
- * If `autoClose` is false, then the file descriptor won't be closed, even if
173
- * there's an error. It is the application's responsibility to close it and make
174
- * sure there's no file descriptor leak. If `autoClose` is set to true (default
175
- * behavior), on `'error'` or `'end'` the file descriptor will be closed
176
- * automatically.
177
- *
178
- * An example to read the last 10 bytes of a file which is 100 bytes long:
179
- *
180
- * ```js
181
- * import { open } from 'node:fs/promises';
182
- *
183
- * const fd = await open('sample.txt');
184
- * fd.createReadStream({ start: 90, end: 99 });
185
- * ```
186
- * @since v16.11.0
187
- */
188
- createReadStream(options?: CreateReadStreamOptions): ReadStream;
189
- /**
190
- * `options` may also include a `start` option to allow writing data at some
191
- * position past the beginning of the file, allowed values are in the
192
- * \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. Modifying a file rather than
193
- * replacing it may require the `flags` `open` option to be set to `r+` rather than
194
- * the default `r`. The `encoding` can be any one of those accepted by `Buffer`.
195
- *
196
- * If `autoClose` is set to true (default behavior) on `'error'` or `'finish'` the file descriptor will be closed automatically. If `autoClose` is false,
197
- * then the file descriptor won't be closed, even if there's an error.
198
- * It is the application's responsibility to close it and make sure there's no
199
- * file descriptor leak.
200
- *
201
- * By default, the stream will emit a `'close'` event after it has been
202
- * destroyed. Set the `emitClose` option to `false` to change this behavior.
203
- * @since v16.11.0
204
- */
205
- createWriteStream(options?: CreateWriteStreamOptions): WriteStream;
206
- /**
207
- * Forces all currently queued I/O operations associated with the file to the
208
- * operating system's synchronized I/O completion state. Refer to the POSIX [`fdatasync(2)`](http://man7.org/linux/man-pages/man2/fdatasync.2.html) documentation for details.
209
- *
210
- * Unlike `filehandle.sync` this method does not flush modified metadata.
211
- * @since v10.0.0
212
- * @return Fulfills with `undefined` upon success.
213
- */
214
- datasync(): Promise<void>;
215
- /**
216
- * Request that all data for the open file descriptor is flushed to the storage
217
- * device. The specific implementation is operating system and device specific.
218
- * Refer to the POSIX [`fsync(2)`](http://man7.org/linux/man-pages/man2/fsync.2.html) documentation for more detail.
219
- * @since v10.0.0
220
- * @return Fulfills with `undefined` upon success.
221
- */
222
- sync(): Promise<void>;
223
- /**
224
- * Reads data from the file and stores that in the given buffer.
225
- *
226
- * If the file is not modified concurrently, the end-of-file is reached when the
227
- * number of bytes read is zero.
228
- * @since v10.0.0
229
- * @param buffer A buffer that will be filled with the file data read.
230
- * @param offset The location in the buffer at which to start filling.
231
- * @param length The number of bytes to read.
232
- * @param position The location where to begin reading data from the file. If `null`, data will be read from the current file position, and the position will be updated. If `position` is an
233
- * integer, the current file position will remain unchanged.
234
- * @return Fulfills upon success with an object with two properties:
235
- */
236
- read<T extends NodeJS.ArrayBufferView>(
237
- buffer: T,
238
- offset?: number | null,
239
- length?: number | null,
240
- position?: number | null,
241
- ): Promise<FileReadResult<T>>;
242
- read<T extends NodeJS.ArrayBufferView>(
243
- buffer: T,
244
- options?: ReadOptions,
245
- ): Promise<FileReadResult<T>>;
246
- read<T extends NodeJS.ArrayBufferView = NonSharedBuffer>(
247
- options?: ReadOptionsWithBuffer<T>,
248
- ): Promise<FileReadResult<T>>;
249
- /**
250
- * Returns a `ReadableStream` that may be used to read the files data.
251
- *
252
- * An error will be thrown if this method is called more than once or is called
253
- * after the `FileHandle` is closed or closing.
254
- *
255
- * ```js
256
- * import {
257
- * open,
258
- * } from 'node:fs/promises';
259
- *
260
- * const file = await open('./some/file/to/read');
261
- *
262
- * for await (const chunk of file.readableWebStream())
263
- * console.log(chunk);
264
- *
265
- * await file.close();
266
- * ```
267
- *
268
- * While the `ReadableStream` will read the file to completion, it will not
269
- * close the `FileHandle` automatically. User code must still call the`fileHandle.close()` method.
270
- * @since v17.0.0
271
- * @experimental
272
- */
273
- readableWebStream(options?: ReadableWebStreamOptions): ReadableStream;
274
- /**
275
- * Asynchronously reads the entire contents of a file.
276
- *
277
- * If `options` is a string, then it specifies the `encoding`.
278
- *
279
- * The `FileHandle` has to support reading.
280
- *
281
- * If one or more `filehandle.read()` calls are made on a file handle and then a `filehandle.readFile()` call is made, the data will be read from the current
282
- * position till the end of the file. It doesn't always read from the beginning
283
- * of the file.
284
- * @since v10.0.0
285
- * @return Fulfills upon a successful read with the contents of the file. If no encoding is specified (using `options.encoding`), the data is returned as a {Buffer} object. Otherwise, the
286
- * data will be a string.
287
- */
288
- readFile(
289
- options?:
290
- | ({ encoding?: null | undefined } & Abortable)
291
- | null,
292
- ): Promise<NonSharedBuffer>;
293
- /**
294
- * Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
295
- * The `FileHandle` must have been opened for reading.
296
- */
297
- readFile(
298
- options:
299
- | ({ encoding: BufferEncoding } & Abortable)
300
- | BufferEncoding,
301
- ): Promise<string>;
302
- /**
303
- * Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
304
- * The `FileHandle` must have been opened for reading.
305
- */
306
- readFile(
307
- options?:
308
- | (ObjectEncodingOptions & Abortable)
309
- | BufferEncoding
310
- | null,
311
- ): Promise<string | NonSharedBuffer>;
312
- /**
313
- * Convenience method to create a `readline` interface and stream over the file.
314
- * See `filehandle.createReadStream()` for the options.
315
- *
316
- * ```js
317
- * import { open } from 'node:fs/promises';
318
- *
319
- * const file = await open('./some/file/to/read');
320
- *
321
- * for await (const line of file.readLines()) {
322
- * console.log(line);
323
- * }
324
- * ```
325
- * @since v18.11.0
326
- */
327
- readLines(options?: CreateReadStreamOptions): ReadlineInterface;
328
- /**
329
- * @since v10.0.0
330
- * @return Fulfills with an {fs.Stats} for the file.
331
- */
332
- stat(
333
- opts?: StatOptions & {
334
- bigint?: false | undefined;
335
- },
336
- ): Promise<Stats>;
337
- stat(
338
- opts: StatOptions & {
339
- bigint: true;
340
- },
341
- ): Promise<BigIntStats>;
342
- stat(opts?: StatOptions): Promise<Stats | BigIntStats>;
343
- /**
344
- * Truncates the file.
345
- *
346
- * If the file was larger than `len` bytes, only the first `len` bytes will be
347
- * retained in the file.
348
- *
349
- * The following example retains only the first four bytes of the file:
350
- *
351
- * ```js
352
- * import { open } from 'node:fs/promises';
353
- *
354
- * let filehandle = null;
355
- * try {
356
- * filehandle = await open('temp.txt', 'r+');
357
- * await filehandle.truncate(4);
358
- * } finally {
359
- * await filehandle?.close();
360
- * }
361
- * ```
362
- *
363
- * If the file previously was shorter than `len` bytes, it is extended, and the
364
- * extended part is filled with null bytes (`'\0'`):
365
- *
366
- * If `len` is negative then `0` will be used.
367
- * @since v10.0.0
368
- * @param [len=0]
369
- * @return Fulfills with `undefined` upon success.
370
- */
371
- truncate(len?: number): Promise<void>;
372
- /**
373
- * Change the file system timestamps of the object referenced by the `FileHandle` then fulfills the promise with no arguments upon success.
374
- * @since v10.0.0
375
- */
376
- utimes(atime: TimeLike, mtime: TimeLike): Promise<void>;
377
- /**
378
- * Asynchronously writes data to a file, replacing the file if it already exists. `data` can be a string, a buffer, an
379
- * [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface), or an
380
- * [Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol) object.
381
- * The promise is fulfilled with no arguments upon success.
382
- *
383
- * If `options` is a string, then it specifies the `encoding`.
384
- *
385
- * The `FileHandle` has to support writing.
386
- *
387
- * It is unsafe to use `filehandle.writeFile()` multiple times on the same file
388
- * without waiting for the promise to be fulfilled (or rejected).
389
- *
390
- * If one or more `filehandle.write()` calls are made on a file handle and then a`filehandle.writeFile()` call is made, the data will be written from the
391
- * current position till the end of the file. It doesn't always write from the
392
- * beginning of the file.
393
- * @since v10.0.0
394
- */
395
- writeFile(
396
- data: string | Uint8Array,
397
- options?:
398
- | (ObjectEncodingOptions & Abortable)
399
- | BufferEncoding
400
- | null,
401
- ): Promise<void>;
402
- /**
403
- * Write `buffer` to the file.
404
- *
405
- * The promise is fulfilled with an object containing two properties:
406
- *
407
- * It is unsafe to use `filehandle.write()` multiple times on the same file
408
- * without waiting for the promise to be fulfilled (or rejected). For this
409
- * scenario, use `filehandle.createWriteStream()`.
410
- *
411
- * On Linux, positional writes do not work when the file is opened in append mode.
412
- * The kernel ignores the position argument and always appends the data to
413
- * the end of the file.
414
- * @since v10.0.0
415
- * @param offset The start position from within `buffer` where the data to write begins.
416
- * @param [length=buffer.byteLength - offset] The number of bytes from `buffer` to write.
417
- * @param [position='null'] The offset from the beginning of the file where the data from `buffer` should be written. If `position` is not a `number`, the data will be written at the current
418
- * position. See the POSIX pwrite(2) documentation for more detail.
419
- */
420
- write<TBuffer extends NodeJS.ArrayBufferView>(
421
- buffer: TBuffer,
422
- offset?: number | null,
423
- length?: number | null,
424
- position?: number | null,
425
- ): Promise<{
426
- bytesWritten: number;
427
- buffer: TBuffer;
428
- }>;
429
- write(
430
- data: string,
431
- position?: number | null,
432
- encoding?: BufferEncoding | null,
433
- ): Promise<{
434
- bytesWritten: number;
435
- buffer: string;
436
- }>;
437
- /**
438
- * Write an array of [ArrayBufferView](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView) s to the file.
439
- *
440
- * The promise is fulfilled with an object containing a two properties:
441
- *
442
- * It is unsafe to call `writev()` multiple times on the same file without waiting
443
- * for the promise to be fulfilled (or rejected).
444
- *
445
- * On Linux, positional writes don't work when the file is opened in append mode.
446
- * The kernel ignores the position argument and always appends the data to
447
- * the end of the file.
448
- * @since v12.9.0
449
- * @param [position='null'] The offset from the beginning of the file where the data from `buffers` should be written. If `position` is not a `number`, the data will be written at the current
450
- * position.
451
- */
452
- writev<TBuffers extends readonly NodeJS.ArrayBufferView[]>(
453
- buffers: TBuffers,
454
- position?: number,
455
- ): Promise<WriteVResult<TBuffers>>;
456
- /**
457
- * Read from a file and write to an array of [ArrayBufferView](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView) s
458
- * @since v13.13.0, v12.17.0
459
- * @param [position='null'] The offset from the beginning of the file where the data should be read from. If `position` is not a `number`, the data will be read from the current position.
460
- * @return Fulfills upon success an object containing two properties:
461
- */
462
- readv<TBuffers extends readonly NodeJS.ArrayBufferView[]>(
463
- buffers: TBuffers,
464
- position?: number,
465
- ): Promise<ReadVResult<TBuffers>>;
466
- /**
467
- * Closes the file handle after waiting for any pending operation on the handle to
468
- * complete.
469
- *
470
- * ```js
471
- * import { open } from 'node:fs/promises';
472
- *
473
- * let filehandle;
474
- * try {
475
- * filehandle = await open('thefile.txt', 'r');
476
- * } finally {
477
- * await filehandle?.close();
478
- * }
479
- * ```
480
- * @since v10.0.0
481
- * @return Fulfills with `undefined` upon success.
482
- */
483
- close(): Promise<void>;
484
- /**
485
- * An alias for {@link FileHandle.close()}.
486
- * @since v20.4.0
487
- */
488
- [Symbol.asyncDispose](): Promise<void>;
489
- }
490
- const constants: typeof fsConstants;
491
- /**
492
- * Tests a user's permissions for the file or directory specified by `path`.
493
- * The `mode` argument is an optional integer that specifies the accessibility
494
- * checks to be performed. `mode` should be either the value `fs.constants.F_OK` or a mask consisting of the bitwise OR of any of `fs.constants.R_OK`, `fs.constants.W_OK`, and `fs.constants.X_OK`
495
- * (e.g.`fs.constants.W_OK | fs.constants.R_OK`). Check `File access constants` for
496
- * possible values of `mode`.
497
- *
498
- * If the accessibility check is successful, the promise is fulfilled with no
499
- * value. If any of the accessibility checks fail, the promise is rejected
500
- * with an [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) object. The following example checks if the file`/etc/passwd` can be read and
501
- * written by the current process.
502
- *
503
- * ```js
504
- * import { access, constants } from 'node:fs/promises';
505
- *
506
- * try {
507
- * await access('/etc/passwd', constants.R_OK | constants.W_OK);
508
- * console.log('can access');
509
- * } catch {
510
- * console.error('cannot access');
511
- * }
512
- * ```
513
- *
514
- * Using `fsPromises.access()` to check for the accessibility of a file before
515
- * calling `fsPromises.open()` is not recommended. Doing so introduces a race
516
- * condition, since other processes may change the file's state between the two
517
- * calls. Instead, user code should open/read/write the file directly and handle
518
- * the error raised if the file is not accessible.
519
- * @since v10.0.0
520
- * @param [mode=fs.constants.F_OK]
521
- * @return Fulfills with `undefined` upon success.
522
- */
523
- function access(path: PathLike, mode?: number): Promise<void>;
524
- /**
525
- * Asynchronously copies `src` to `dest`. By default, `dest` is overwritten if it
526
- * already exists.
527
- *
528
- * No guarantees are made about the atomicity of the copy operation. If an
529
- * error occurs after the destination file has been opened for writing, an attempt
530
- * will be made to remove the destination.
531
- *
532
- * ```js
533
- * import { copyFile, constants } from 'node:fs/promises';
534
- *
535
- * try {
536
- * await copyFile('source.txt', 'destination.txt');
537
- * console.log('source.txt was copied to destination.txt');
538
- * } catch {
539
- * console.error('The file could not be copied');
540
- * }
541
- *
542
- * // By using COPYFILE_EXCL, the operation will fail if destination.txt exists.
543
- * try {
544
- * await copyFile('source.txt', 'destination.txt', constants.COPYFILE_EXCL);
545
- * console.log('source.txt was copied to destination.txt');
546
- * } catch {
547
- * console.error('The file could not be copied');
548
- * }
549
- * ```
550
- * @since v10.0.0
551
- * @param src source filename to copy
552
- * @param dest destination filename of the copy operation
553
- * @param [mode=0] Optional modifiers that specify the behavior of the copy operation. It is possible to create a mask consisting of the bitwise OR of two or more values (e.g.
554
- * `fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE`)
555
- * @return Fulfills with `undefined` upon success.
556
- */
557
- function copyFile(src: PathLike, dest: PathLike, mode?: number): Promise<void>;
558
- /**
559
- * Opens a `FileHandle`.
560
- *
561
- * Refer to the POSIX [`open(2)`](http://man7.org/linux/man-pages/man2/open.2.html) documentation for more detail.
562
- *
563
- * Some characters (`< > : " / \ | ? *`) are reserved under Windows as documented
564
- * by [Naming Files, Paths, and Namespaces](https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file). Under NTFS, if the filename contains
565
- * a colon, Node.js will open a file system stream, as described by [this MSDN page](https://docs.microsoft.com/en-us/windows/desktop/FileIO/using-streams).
566
- * @since v10.0.0
567
- * @param [flags='r'] See `support of file system `flags``.
568
- * @param [mode=0o666] Sets the file mode (permission and sticky bits) if the file is created.
569
- * @return Fulfills with a {FileHandle} object.
570
- */
571
- function open(path: PathLike, flags?: string | number, mode?: Mode): Promise<FileHandle>;
572
- /**
573
- * Renames `oldPath` to `newPath`.
574
- * @since v10.0.0
575
- * @return Fulfills with `undefined` upon success.
576
- */
577
- function rename(oldPath: PathLike, newPath: PathLike): Promise<void>;
578
- /**
579
- * Truncates (shortens or extends the length) of the content at `path` to `len` bytes.
580
- * @since v10.0.0
581
- * @param [len=0]
582
- * @return Fulfills with `undefined` upon success.
583
- */
584
- function truncate(path: PathLike, len?: number): Promise<void>;
585
- /**
586
- * Removes the directory identified by `path`.
587
- *
588
- * Using `fsPromises.rmdir()` on a file (not a directory) results in the
589
- * promise being rejected with an `ENOENT` error on Windows and an `ENOTDIR` error on POSIX.
590
- *
591
- * To get a behavior similar to the `rm -rf` Unix command, use `fsPromises.rm()` with options `{ recursive: true, force: true }`.
592
- * @since v10.0.0
593
- * @return Fulfills with `undefined` upon success.
594
- */
595
- function rmdir(path: PathLike, options?: RmDirOptions): Promise<void>;
596
- /**
597
- * Removes files and directories (modeled on the standard POSIX `rm` utility).
598
- * @since v14.14.0
599
- * @return Fulfills with `undefined` upon success.
600
- */
601
- function rm(path: PathLike, options?: RmOptions): Promise<void>;
602
- /**
603
- * Asynchronously creates a directory.
604
- *
605
- * The optional `options` argument can be an integer specifying `mode` (permission
606
- * and sticky bits), or an object with a `mode` property and a `recursive` property indicating whether parent directories should be created. Calling `fsPromises.mkdir()` when `path` is a directory
607
- * that exists results in a
608
- * rejection only when `recursive` is false.
609
- *
610
- * ```js
611
- * import { mkdir } from 'node:fs/promises';
612
- *
613
- * try {
614
- * const projectFolder = new URL('./test/project/', import.meta.url);
615
- * const createDir = await mkdir(projectFolder, { recursive: true });
616
- *
617
- * console.log(`created ${createDir}`);
618
- * } catch (err) {
619
- * console.error(err.message);
620
- * }
621
- * ```
622
- * @since v10.0.0
623
- * @return Upon success, fulfills with `undefined` if `recursive` is `false`, or the first directory path created if `recursive` is `true`.
624
- */
625
- function mkdir(
626
- path: PathLike,
627
- options: MakeDirectoryOptions & {
628
- recursive: true;
629
- },
630
- ): Promise<string | undefined>;
631
- /**
632
- * Asynchronous mkdir(2) - create a directory.
633
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
634
- * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
635
- * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
636
- */
637
- function mkdir(
638
- path: PathLike,
639
- options?:
640
- | Mode
641
- | (MakeDirectoryOptions & {
642
- recursive?: false | undefined;
643
- })
644
- | null,
645
- ): Promise<void>;
646
- /**
647
- * Asynchronous mkdir(2) - create a directory.
648
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
649
- * @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
650
- * should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
651
- */
652
- function mkdir(path: PathLike, options?: Mode | MakeDirectoryOptions | null): Promise<string | undefined>;
653
- /**
654
- * Reads the contents of a directory.
655
- *
656
- * The optional `options` argument can be a string specifying an encoding, or an
657
- * object with an `encoding` property specifying the character encoding to use for
658
- * the filenames. If the `encoding` is set to `'buffer'`, the filenames returned
659
- * will be passed as `Buffer` objects.
660
- *
661
- * If `options.withFileTypes` is set to `true`, the returned array will contain `fs.Dirent` objects.
662
- *
663
- * ```js
664
- * import { readdir } from 'node:fs/promises';
665
- *
666
- * try {
667
- * const files = await readdir(path);
668
- * for (const file of files)
669
- * console.log(file);
670
- * } catch (err) {
671
- * console.error(err);
672
- * }
673
- * ```
674
- * @since v10.0.0
675
- * @return Fulfills with an array of the names of the files in the directory excluding `'.'` and `'..'`.
676
- */
677
- function readdir(
678
- path: PathLike,
679
- options?:
680
- | (ObjectEncodingOptions & {
681
- withFileTypes?: false | undefined;
682
- recursive?: boolean | undefined;
683
- })
684
- | BufferEncoding
685
- | null,
686
- ): Promise<string[]>;
687
- /**
688
- * Asynchronous readdir(3) - read a directory.
689
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
690
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
691
- */
692
- function readdir(
693
- path: PathLike,
694
- options:
695
- | {
696
- encoding: "buffer";
697
- withFileTypes?: false | undefined;
698
- recursive?: boolean | undefined;
699
- }
700
- | "buffer",
701
- ): Promise<NonSharedBuffer[]>;
702
- /**
703
- * Asynchronous readdir(3) - read a directory.
704
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
705
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
706
- */
707
- function readdir(
708
- path: PathLike,
709
- options?:
710
- | (ObjectEncodingOptions & {
711
- withFileTypes?: false | undefined;
712
- recursive?: boolean | undefined;
713
- })
714
- | BufferEncoding
715
- | null,
716
- ): Promise<string[] | NonSharedBuffer[]>;
717
- /**
718
- * Asynchronous readdir(3) - read a directory.
719
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
720
- * @param options If called with `withFileTypes: true` the result data will be an array of Dirent.
721
- */
722
- function readdir(
723
- path: PathLike,
724
- options: ObjectEncodingOptions & {
725
- withFileTypes: true;
726
- recursive?: boolean | undefined;
727
- },
728
- ): Promise<Dirent[]>;
729
- /**
730
- * Asynchronous readdir(3) - read a directory.
731
- * @param path A path to a directory. If a URL is provided, it must use the `file:` protocol.
732
- * @param options Must include `withFileTypes: true` and `encoding: 'buffer'`.
733
- */
734
- function readdir(
735
- path: PathLike,
736
- options: {
737
- encoding: "buffer";
738
- withFileTypes: true;
739
- recursive?: boolean | undefined;
740
- },
741
- ): Promise<Dirent<NonSharedBuffer>[]>;
742
- /**
743
- * Reads the contents of the symbolic link referred to by `path`. See the POSIX [`readlink(2)`](http://man7.org/linux/man-pages/man2/readlink.2.html) documentation for more detail. The promise is
744
- * fulfilled with the`linkString` upon success.
745
- *
746
- * The optional `options` argument can be a string specifying an encoding, or an
747
- * object with an `encoding` property specifying the character encoding to use for
748
- * the link path returned. If the `encoding` is set to `'buffer'`, the link path
749
- * returned will be passed as a `Buffer` object.
750
- * @since v10.0.0
751
- * @return Fulfills with the `linkString` upon success.
752
- */
753
- function readlink(path: PathLike, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string>;
754
- /**
755
- * Asynchronous readlink(2) - read value of a symbolic link.
756
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
757
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
758
- */
759
- function readlink(path: PathLike, options: BufferEncodingOption): Promise<NonSharedBuffer>;
760
- /**
761
- * Asynchronous readlink(2) - read value of a symbolic link.
762
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
763
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
764
- */
765
- function readlink(
766
- path: PathLike,
767
- options?: ObjectEncodingOptions | string | null,
768
- ): Promise<string | NonSharedBuffer>;
769
- /**
770
- * Creates a symbolic link.
771
- *
772
- * The `type` argument is only used on Windows platforms and can be one of `'dir'`, `'file'`, or `'junction'`. If the `type` argument is not a string, Node.js will
773
- * autodetect `target` type and use `'file'` or `'dir'`. If the `target` does not
774
- * exist, `'file'` will be used. Windows junction points require the destination
775
- * path to be absolute. When using `'junction'`, the `target` argument will
776
- * automatically be normalized to absolute path. Junction points on NTFS volumes
777
- * can only point to directories.
778
- * @since v10.0.0
779
- * @param [type='null']
780
- * @return Fulfills with `undefined` upon success.
781
- */
782
- function symlink(target: PathLike, path: PathLike, type?: string | null): Promise<void>;
783
- /**
784
- * Equivalent to `fsPromises.stat()` unless `path` refers to a symbolic link,
785
- * in which case the link itself is stat-ed, not the file that it refers to.
786
- * Refer to the POSIX [`lstat(2)`](http://man7.org/linux/man-pages/man2/lstat.2.html) document for more detail.
787
- * @since v10.0.0
788
- * @return Fulfills with the {fs.Stats} object for the given symbolic link `path`.
789
- */
790
- function lstat(
791
- path: PathLike,
792
- opts?: StatOptions & {
793
- bigint?: false | undefined;
794
- },
795
- ): Promise<Stats>;
796
- function lstat(
797
- path: PathLike,
798
- opts: StatOptions & {
799
- bigint: true;
800
- },
801
- ): Promise<BigIntStats>;
802
- function lstat(path: PathLike, opts?: StatOptions): Promise<Stats | BigIntStats>;
803
- /**
804
- * @since v10.0.0
805
- * @return Fulfills with the {fs.Stats} object for the given `path`.
806
- */
807
- function stat(
808
- path: PathLike,
809
- opts?: StatOptions & {
810
- bigint?: false | undefined;
811
- },
812
- ): Promise<Stats>;
813
- function stat(
814
- path: PathLike,
815
- opts: StatOptions & {
816
- bigint: true;
817
- },
818
- ): Promise<BigIntStats>;
819
- function stat(path: PathLike, opts?: StatOptions): Promise<Stats | BigIntStats>;
820
- /**
821
- * @since v19.6.0, v18.15.0
822
- * @return Fulfills with the {fs.StatFs} object for the given `path`.
823
- */
824
- function statfs(
825
- path: PathLike,
826
- opts?: StatFsOptions & {
827
- bigint?: false | undefined;
828
- },
829
- ): Promise<StatsFs>;
830
- function statfs(
831
- path: PathLike,
832
- opts: StatFsOptions & {
833
- bigint: true;
834
- },
835
- ): Promise<BigIntStatsFs>;
836
- function statfs(path: PathLike, opts?: StatFsOptions): Promise<StatsFs | BigIntStatsFs>;
837
- /**
838
- * Creates a new link from the `existingPath` to the `newPath`. See the POSIX [`link(2)`](http://man7.org/linux/man-pages/man2/link.2.html) documentation for more detail.
839
- * @since v10.0.0
840
- * @return Fulfills with `undefined` upon success.
841
- */
842
- function link(existingPath: PathLike, newPath: PathLike): Promise<void>;
843
- /**
844
- * If `path` refers to a symbolic link, then the link is removed without affecting
845
- * the file or directory to which that link refers. If the `path` refers to a file
846
- * path that is not a symbolic link, the file is deleted. See the POSIX [`unlink(2)`](http://man7.org/linux/man-pages/man2/unlink.2.html) documentation for more detail.
847
- * @since v10.0.0
848
- * @return Fulfills with `undefined` upon success.
849
- */
850
- function unlink(path: PathLike): Promise<void>;
851
- /**
852
- * Changes the permissions of a file.
853
- * @since v10.0.0
854
- * @return Fulfills with `undefined` upon success.
855
- */
856
- function chmod(path: PathLike, mode: Mode): Promise<void>;
857
- /**
858
- * Changes the permissions on a symbolic link.
859
- *
860
- * This method is only implemented on macOS.
861
- * @deprecated Since v10.0.0
862
- * @return Fulfills with `undefined` upon success.
863
- */
864
- function lchmod(path: PathLike, mode: Mode): Promise<void>;
865
- /**
866
- * Changes the ownership on a symbolic link.
867
- * @since v10.0.0
868
- * @return Fulfills with `undefined` upon success.
869
- */
870
- function lchown(path: PathLike, uid: number, gid: number): Promise<void>;
871
- /**
872
- * Changes the access and modification times of a file in the same way as `fsPromises.utimes()`, with the difference that if the path refers to a
873
- * symbolic link, then the link is not dereferenced: instead, the timestamps of
874
- * the symbolic link itself are changed.
875
- * @since v14.5.0, v12.19.0
876
- * @return Fulfills with `undefined` upon success.
877
- */
878
- function lutimes(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise<void>;
879
- /**
880
- * Changes the ownership of a file.
881
- * @since v10.0.0
882
- * @return Fulfills with `undefined` upon success.
883
- */
884
- function chown(path: PathLike, uid: number, gid: number): Promise<void>;
885
- /**
886
- * Change the file system timestamps of the object referenced by `path`.
887
- *
888
- * The `atime` and `mtime` arguments follow these rules:
889
- *
890
- * * Values can be either numbers representing Unix epoch time, `Date`s, or a
891
- * numeric string like `'123456789.0'`.
892
- * * If the value can not be converted to a number, or is `NaN`, `Infinity`, or `-Infinity`, an `Error` will be thrown.
893
- * @since v10.0.0
894
- * @return Fulfills with `undefined` upon success.
895
- */
896
- function utimes(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise<void>;
897
- /**
898
- * Determines the actual location of `path` using the same semantics as the `fs.realpath.native()` function.
899
- *
900
- * Only paths that can be converted to UTF8 strings are supported.
901
- *
902
- * The optional `options` argument can be a string specifying an encoding, or an
903
- * object with an `encoding` property specifying the character encoding to use for
904
- * the path. If the `encoding` is set to `'buffer'`, the path returned will be
905
- * passed as a `Buffer` object.
906
- *
907
- * On Linux, when Node.js is linked against musl libc, the procfs file system must
908
- * be mounted on `/proc` in order for this function to work. Glibc does not have
909
- * this restriction.
910
- * @since v10.0.0
911
- * @return Fulfills with the resolved path upon success.
912
- */
913
- function realpath(path: PathLike, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string>;
914
- /**
915
- * Asynchronous realpath(3) - return the canonicalized absolute pathname.
916
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
917
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
918
- */
919
- function realpath(path: PathLike, options: BufferEncodingOption): Promise<NonSharedBuffer>;
920
- /**
921
- * Asynchronous realpath(3) - return the canonicalized absolute pathname.
922
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
923
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
924
- */
925
- function realpath(
926
- path: PathLike,
927
- options?: ObjectEncodingOptions | BufferEncoding | null,
928
- ): Promise<string | NonSharedBuffer>;
929
- /**
930
- * Creates a unique temporary directory. A unique directory name is generated by
931
- * appending six random characters to the end of the provided `prefix`. Due to
932
- * platform inconsistencies, avoid trailing `X` characters in `prefix`. Some
933
- * platforms, notably the BSDs, can return more than six random characters, and
934
- * replace trailing `X` characters in `prefix` with random characters.
935
- *
936
- * The optional `options` argument can be a string specifying an encoding, or an
937
- * object with an `encoding` property specifying the character encoding to use.
938
- *
939
- * ```js
940
- * import { mkdtemp } from 'node:fs/promises';
941
- * import { join } from 'node:path';
942
- * import { tmpdir } from 'node:os';
943
- *
944
- * try {
945
- * await mkdtemp(join(tmpdir(), 'foo-'));
946
- * } catch (err) {
947
- * console.error(err);
948
- * }
949
- * ```
950
- *
951
- * The `fsPromises.mkdtemp()` method will append the six randomly selected
952
- * characters directly to the `prefix` string. For instance, given a directory `/tmp`, if the intention is to create a temporary directory _within_ `/tmp`, the `prefix` must end with a trailing
953
- * platform-specific path separator
954
- * (`import { sep } from 'node:node:path'`).
955
- * @since v10.0.0
956
- * @return Fulfills with a string containing the file system path of the newly created temporary directory.
957
- */
958
- function mkdtemp(prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string>;
959
- /**
960
- * Asynchronously creates a unique temporary directory.
961
- * Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
962
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
963
- */
964
- function mkdtemp(prefix: string, options: BufferEncodingOption): Promise<NonSharedBuffer>;
965
- /**
966
- * Asynchronously creates a unique temporary directory.
967
- * Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
968
- * @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
969
- */
970
- function mkdtemp(
971
- prefix: string,
972
- options?: ObjectEncodingOptions | BufferEncoding | null,
973
- ): Promise<string | NonSharedBuffer>;
974
- /**
975
- * Asynchronously writes data to a file, replacing the file if it already exists. `data` can be a string, a buffer, an
976
- * [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface), or an
977
- * [Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol) object.
978
- *
979
- * The `encoding` option is ignored if `data` is a buffer.
980
- *
981
- * If `options` is a string, then it specifies the encoding.
982
- *
983
- * The `mode` option only affects the newly created file. See `fs.open()` for more details.
984
- *
985
- * Any specified `FileHandle` has to support writing.
986
- *
987
- * It is unsafe to use `fsPromises.writeFile()` multiple times on the same file
988
- * without waiting for the promise to be settled.
989
- *
990
- * Similarly to `fsPromises.readFile` \- `fsPromises.writeFile` is a convenience
991
- * method that performs multiple `write` calls internally to write the buffer
992
- * passed to it. For performance sensitive code consider using `fs.createWriteStream()` or `filehandle.createWriteStream()`.
993
- *
994
- * It is possible to use an `AbortSignal` to cancel an `fsPromises.writeFile()`.
995
- * Cancelation is "best effort", and some amount of data is likely still
996
- * to be written.
997
- *
998
- * ```js
999
- * import { writeFile } from 'node:fs/promises';
1000
- * import { Buffer } from 'node:buffer';
1001
- *
1002
- * try {
1003
- * const controller = new AbortController();
1004
- * const { signal } = controller;
1005
- * const data = new Uint8Array(Buffer.from('Hello Node.js'));
1006
- * const promise = writeFile('message.txt', data, { signal });
1007
- *
1008
- * // Abort the request before the promise settles.
1009
- * controller.abort();
1010
- *
1011
- * await promise;
1012
- * } catch (err) {
1013
- * // When a request is aborted - err is an AbortError
1014
- * console.error(err);
1015
- * }
1016
- * ```
1017
- *
1018
- * Aborting an ongoing request does not abort individual operating
1019
- * system requests but rather the internal buffering `fs.writeFile` performs.
1020
- * @since v10.0.0
1021
- * @param file filename or `FileHandle`
1022
- * @return Fulfills with `undefined` upon success.
1023
- */
1024
- function writeFile(
1025
- file: PathLike | FileHandle,
1026
- data:
1027
- | string
1028
- | NodeJS.ArrayBufferView
1029
- | Iterable<string | NodeJS.ArrayBufferView>
1030
- | AsyncIterable<string | NodeJS.ArrayBufferView>
1031
- | Stream,
1032
- options?:
1033
- | (ObjectEncodingOptions & {
1034
- mode?: Mode | undefined;
1035
- flag?: OpenMode | undefined;
1036
- /**
1037
- * If all data is successfully written to the file, and `flush`
1038
- * is `true`, `filehandle.sync()` is used to flush the data.
1039
- * @default false
1040
- */
1041
- flush?: boolean | undefined;
1042
- } & Abortable)
1043
- | BufferEncoding
1044
- | null,
1045
- ): Promise<void>;
1046
- /**
1047
- * Asynchronously append data to a file, creating the file if it does not yet
1048
- * exist. `data` can be a string or a `Buffer`.
1049
- *
1050
- * If `options` is a string, then it specifies the `encoding`.
1051
- *
1052
- * The `mode` option only affects the newly created file. See `fs.open()` for more details.
1053
- *
1054
- * The `path` may be specified as a `FileHandle` that has been opened
1055
- * for appending (using `fsPromises.open()`).
1056
- * @since v10.0.0
1057
- * @param path filename or {FileHandle}
1058
- * @return Fulfills with `undefined` upon success.
1059
- */
1060
- function appendFile(
1061
- path: PathLike | FileHandle,
1062
- data: string | Uint8Array,
1063
- options?: (ObjectEncodingOptions & FlagAndOpenMode & { flush?: boolean | undefined }) | BufferEncoding | null,
1064
- ): Promise<void>;
1065
- /**
1066
- * Asynchronously reads the entire contents of a file.
1067
- *
1068
- * If no encoding is specified (using `options.encoding`), the data is returned
1069
- * as a `Buffer` object. Otherwise, the data will be a string.
1070
- *
1071
- * If `options` is a string, then it specifies the encoding.
1072
- *
1073
- * When the `path` is a directory, the behavior of `fsPromises.readFile()` is
1074
- * platform-specific. On macOS, Linux, and Windows, the promise will be rejected
1075
- * with an error. On FreeBSD, a representation of the directory's contents will be
1076
- * returned.
1077
- *
1078
- * An example of reading a `package.json` file located in the same directory of the
1079
- * running code:
1080
- *
1081
- * ```js
1082
- * import { readFile } from 'node:fs/promises';
1083
- * try {
1084
- * const filePath = new URL('./package.json', import.meta.url);
1085
- * const contents = await readFile(filePath, { encoding: 'utf8' });
1086
- * console.log(contents);
1087
- * } catch (err) {
1088
- * console.error(err.message);
1089
- * }
1090
- * ```
1091
- *
1092
- * It is possible to abort an ongoing `readFile` using an `AbortSignal`. If a
1093
- * request is aborted the promise returned is rejected with an `AbortError`:
1094
- *
1095
- * ```js
1096
- * import { readFile } from 'node:fs/promises';
1097
- *
1098
- * try {
1099
- * const controller = new AbortController();
1100
- * const { signal } = controller;
1101
- * const promise = readFile(fileName, { signal });
1102
- *
1103
- * // Abort the request before the promise settles.
1104
- * controller.abort();
1105
- *
1106
- * await promise;
1107
- * } catch (err) {
1108
- * // When a request is aborted - err is an AbortError
1109
- * console.error(err);
1110
- * }
1111
- * ```
1112
- *
1113
- * Aborting an ongoing request does not abort individual operating
1114
- * system requests but rather the internal buffering `fs.readFile` performs.
1115
- *
1116
- * Any specified `FileHandle` has to support reading.
1117
- * @since v10.0.0
1118
- * @param path filename or `FileHandle`
1119
- * @return Fulfills with the contents of the file.
1120
- */
1121
- function readFile(
1122
- path: PathLike | FileHandle,
1123
- options?:
1124
- | ({
1125
- encoding?: null | undefined;
1126
- flag?: OpenMode | undefined;
1127
- } & Abortable)
1128
- | null,
1129
- ): Promise<NonSharedBuffer>;
1130
- /**
1131
- * Asynchronously reads the entire contents of a file.
1132
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1133
- * If a `FileHandle` is provided, the underlying file will _not_ be closed automatically.
1134
- * @param options An object that may contain an optional flag.
1135
- * If a flag is not provided, it defaults to `'r'`.
1136
- */
1137
- function readFile(
1138
- path: PathLike | FileHandle,
1139
- options:
1140
- | ({
1141
- encoding: BufferEncoding;
1142
- flag?: OpenMode | undefined;
1143
- } & Abortable)
1144
- | BufferEncoding,
1145
- ): Promise<string>;
1146
- /**
1147
- * Asynchronously reads the entire contents of a file.
1148
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1149
- * If a `FileHandle` is provided, the underlying file will _not_ be closed automatically.
1150
- * @param options An object that may contain an optional flag.
1151
- * If a flag is not provided, it defaults to `'r'`.
1152
- */
1153
- function readFile(
1154
- path: PathLike | FileHandle,
1155
- options?:
1156
- | (
1157
- & ObjectEncodingOptions
1158
- & Abortable
1159
- & {
1160
- flag?: OpenMode | undefined;
1161
- }
1162
- )
1163
- | BufferEncoding
1164
- | null,
1165
- ): Promise<string | NonSharedBuffer>;
1166
- /**
1167
- * Asynchronously open a directory for iterative scanning. See the POSIX [`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html) documentation for more detail.
1168
- *
1169
- * Creates an `fs.Dir`, which contains all further functions for reading from
1170
- * and cleaning up the directory.
1171
- *
1172
- * The `encoding` option sets the encoding for the `path` while opening the
1173
- * directory and subsequent read operations.
1174
- *
1175
- * Example using async iteration:
1176
- *
1177
- * ```js
1178
- * import { opendir } from 'node:fs/promises';
1179
- *
1180
- * try {
1181
- * const dir = await opendir('./');
1182
- * for await (const dirent of dir)
1183
- * console.log(dirent.name);
1184
- * } catch (err) {
1185
- * console.error(err);
1186
- * }
1187
- * ```
1188
- *
1189
- * When using the async iterator, the `fs.Dir` object will be automatically
1190
- * closed after the iterator exits.
1191
- * @since v12.12.0
1192
- * @return Fulfills with an {fs.Dir}.
1193
- */
1194
- function opendir(path: PathLike, options?: OpenDirOptions): Promise<Dir>;
1195
- /**
1196
- * Returns an async iterator that watches for changes on `filename`, where `filename`is either a file or a directory.
1197
- *
1198
- * ```js
1199
- * import { watch } from 'node:fs/promises';
1200
- *
1201
- * const ac = new AbortController();
1202
- * const { signal } = ac;
1203
- * setTimeout(() => ac.abort(), 10000);
1204
- *
1205
- * (async () => {
1206
- * try {
1207
- * const watcher = watch(__filename, { signal });
1208
- * for await (const event of watcher)
1209
- * console.log(event);
1210
- * } catch (err) {
1211
- * if (err.name === 'AbortError')
1212
- * return;
1213
- * throw err;
1214
- * }
1215
- * })();
1216
- * ```
1217
- *
1218
- * On most platforms, `'rename'` is emitted whenever a filename appears or
1219
- * disappears in the directory.
1220
- *
1221
- * All the `caveats` for `fs.watch()` also apply to `fsPromises.watch()`.
1222
- * @since v15.9.0, v14.18.0
1223
- * @return of objects with the properties:
1224
- */
1225
- function watch(
1226
- filename: PathLike,
1227
- options:
1228
- | (WatchOptions & {
1229
- encoding: "buffer";
1230
- })
1231
- | "buffer",
1232
- ): AsyncIterable<FileChangeInfo<NonSharedBuffer>>;
1233
- /**
1234
- * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
1235
- * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
1236
- * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
1237
- * If `encoding` is not supplied, the default of `'utf8'` is used.
1238
- * If `persistent` is not supplied, the default of `true` is used.
1239
- * If `recursive` is not supplied, the default of `false` is used.
1240
- */
1241
- function watch(filename: PathLike, options?: WatchOptions | BufferEncoding): AsyncIterable<FileChangeInfo<string>>;
1242
- /**
1243
- * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
1244
- * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
1245
- * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
1246
- * If `encoding` is not supplied, the default of `'utf8'` is used.
1247
- * If `persistent` is not supplied, the default of `true` is used.
1248
- * If `recursive` is not supplied, the default of `false` is used.
1249
- */
1250
- function watch(
1251
- filename: PathLike,
1252
- options: WatchOptions | string,
1253
- ): AsyncIterable<FileChangeInfo<string>> | AsyncIterable<FileChangeInfo<NonSharedBuffer>>;
1254
- /**
1255
- * Asynchronously copies the entire directory structure from `src` to `dest`,
1256
- * including subdirectories and files.
1257
- *
1258
- * When copying a directory to another directory, globs are not supported and
1259
- * behavior is similar to `cp dir1/ dir2/`.
1260
- * @since v16.7.0
1261
- * @experimental
1262
- * @param src source path to copy.
1263
- * @param dest destination path to copy to.
1264
- * @return Fulfills with `undefined` upon success.
1265
- */
1266
- function cp(source: string | URL, destination: string | URL, opts?: CopyOptions): Promise<void>;
1267
- }
1268
- declare module "node:fs/promises" {
1269
- export * from "fs/promises";
1270
- }