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