m06_task3.js 1.0.0

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