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,67 @@
1
+ /**
2
+ * The `string_decoder` module provides an API for decoding `Buffer` objects into
3
+ * strings in a manner that preserves encoded multi-byte UTF-8 and UTF-16
4
+ * characters. It can be accessed using:
5
+ *
6
+ * ```js
7
+ * const { StringDecoder } = require('string_decoder');
8
+ * ```
9
+ *
10
+ * The following example shows the basic use of the `StringDecoder` class.
11
+ *
12
+ * ```js
13
+ * const { StringDecoder } = require('string_decoder');
14
+ * const decoder = new StringDecoder('utf8');
15
+ *
16
+ * const cent = Buffer.from([0xC2, 0xA2]);
17
+ * console.log(decoder.write(cent));
18
+ *
19
+ * const euro = Buffer.from([0xE2, 0x82, 0xAC]);
20
+ * console.log(decoder.write(euro));
21
+ * ```
22
+ *
23
+ * When a `Buffer` instance is written to the `StringDecoder` instance, an
24
+ * internal buffer is used to ensure that the decoded string does not contain
25
+ * any incomplete multibyte characters. These are held in the buffer until the
26
+ * next call to `stringDecoder.write()` or until `stringDecoder.end()` is called.
27
+ *
28
+ * In the following example, the three UTF-8 encoded bytes of the European Euro
29
+ * symbol (`€`) are written over three separate operations:
30
+ *
31
+ * ```js
32
+ * const { StringDecoder } = require('string_decoder');
33
+ * const decoder = new StringDecoder('utf8');
34
+ *
35
+ * decoder.write(Buffer.from([0xE2]));
36
+ * decoder.write(Buffer.from([0x82]));
37
+ * console.log(decoder.end(Buffer.from([0xAC])));
38
+ * ```
39
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/string_decoder.js)
40
+ */
41
+ declare module 'string_decoder' {
42
+ class StringDecoder {
43
+ constructor(encoding?: BufferEncoding);
44
+ /**
45
+ * Returns a decoded string, ensuring that any incomplete multibyte characters at
46
+ * the end of the `Buffer`, or `TypedArray`, or `DataView` are omitted from the
47
+ * returned string and stored in an internal buffer for the next call to`stringDecoder.write()` or `stringDecoder.end()`.
48
+ * @since v0.1.99
49
+ * @param buffer A `Buffer`, or `TypedArray`, or `DataView` containing the bytes to decode.
50
+ */
51
+ write(buffer: Buffer): string;
52
+ /**
53
+ * Returns any remaining input stored in the internal buffer as a string. Bytes
54
+ * representing incomplete UTF-8 and UTF-16 characters will be replaced with
55
+ * substitution characters appropriate for the character encoding.
56
+ *
57
+ * If the `buffer` argument is provided, one final call to `stringDecoder.write()`is performed before returning the remaining input.
58
+ * After `end()` is called, the `stringDecoder` object can be reused for new input.
59
+ * @since v0.9.3
60
+ * @param buffer A `Buffer`, or `TypedArray`, or `DataView` containing the bytes to decode.
61
+ */
62
+ end(buffer?: Buffer): string;
63
+ }
64
+ }
65
+ declare module 'node:string_decoder' {
66
+ export * from 'string_decoder';
67
+ }
@@ -0,0 +1,314 @@
1
+ /**
2
+ * The `node:test` module provides a standalone testing module.
3
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/test.js)
4
+ */
5
+ declare module 'node:test' {
6
+ /**
7
+ * Programmatically start the test runner.
8
+ * @since v18.9.0
9
+ * @param options Configuration options for running tests.
10
+ * @returns A {@link TapStream} that emits events about the test execution.
11
+ */
12
+ function run(options?: RunOptions): TapStream;
13
+
14
+ /**
15
+ * The `test()` function is the value imported from the test module. Each invocation of this
16
+ * function results in the creation of a test point in the TAP output.
17
+ *
18
+ * The {@link TestContext} object passed to the fn argument can be used to perform actions
19
+ * related to the current test. Examples include skipping the test, adding additional TAP
20
+ * diagnostic information, or creating subtests.
21
+ *
22
+ * `test()` returns a {@link Promise} that resolves once the test completes. The return value
23
+ * can usually be discarded for top level tests. However, the return value from subtests should
24
+ * be used to prevent the parent test from finishing first and cancelling the subtest as shown
25
+ * in the following example.
26
+ *
27
+ * ```js
28
+ * test('top level test', async (t) => {
29
+ * // The setTimeout() in the following subtest would cause it to outlive its
30
+ * // parent test if 'await' is removed on the next line. Once the parent test
31
+ * // completes, it will cancel any outstanding subtests.
32
+ * await t.test('longer running subtest', async (t) => {
33
+ * return new Promise((resolve, reject) => {
34
+ * setTimeout(resolve, 1000);
35
+ * });
36
+ * });
37
+ * });
38
+ * ```
39
+ * @since v18.0.0
40
+ * @param name The name of the test, which is displayed when reporting test results.
41
+ * Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
42
+ * @param options Configuration options for the test
43
+ * @param fn The function under test. The first argument to this function is a
44
+ * {@link TestContext} object. If the test uses callbacks, the callback function is
45
+ * passed as the second argument. Default: A no-op function.
46
+ * @returns A {@link Promise} resolved with `undefined` once the test completes.
47
+ */
48
+ function test(name?: string, fn?: TestFn): Promise<void>;
49
+ function test(name?: string, options?: TestOptions, fn?: TestFn): Promise<void>;
50
+ function test(options?: TestOptions, fn?: TestFn): Promise<void>;
51
+ function test(fn?: TestFn): Promise<void>;
52
+
53
+ /**
54
+ * @since v18.6.0
55
+ * @param name The name of the suite, which is displayed when reporting suite results.
56
+ * Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
57
+ * @param options Configuration options for the suite
58
+ * @param fn The function under suite. Default: A no-op function.
59
+ */
60
+ function describe(name?: string, options?: TestOptions, fn?: SuiteFn): void;
61
+ function describe(name?: string, fn?: SuiteFn): void;
62
+ function describe(options?: TestOptions, fn?: SuiteFn): void;
63
+ function describe(fn?: SuiteFn): void;
64
+
65
+ /**
66
+ * @since v18.6.0
67
+ * @param name The name of the test, which is displayed when reporting test results.
68
+ * Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
69
+ * @param options Configuration options for the test
70
+ * @param fn The function under test. If the test uses callbacks, the callback function is
71
+ * passed as the second argument. Default: A no-op function.
72
+ */
73
+ function it(name?: string, options?: TestOptions, fn?: ItFn): void;
74
+ function it(name?: string, fn?: ItFn): void;
75
+ function it(options?: TestOptions, fn?: ItFn): void;
76
+ function it(fn?: ItFn): void;
77
+
78
+ /**
79
+ * The type of a function under test. The first argument to this function is a
80
+ * {@link TestContext} object. If the test uses callbacks, the callback function is passed as
81
+ * the second argument.
82
+ */
83
+ type TestFn = (t: TestContext, done: (result?: any) => void) => any;
84
+
85
+ /**
86
+ * The type of a function under Suite.
87
+ * If the test uses callbacks, the callback function is passed as an argument
88
+ */
89
+ type SuiteFn = (done: (result?: any) => void) => void;
90
+
91
+ /**
92
+ * The type of a function under test.
93
+ * If the test uses callbacks, the callback function is passed as an argument
94
+ */
95
+ type ItFn = (done: (result?: any) => void) => any;
96
+
97
+ interface RunOptions {
98
+ /**
99
+ * @default false
100
+ */
101
+ concurrency?: number | boolean;
102
+
103
+ /**
104
+ * An array containing the list of files to run. If unspecified, the test runner execution model will be used.
105
+ */
106
+ files?: readonly string[];
107
+
108
+ /**
109
+ * Allows aborting an in-progress test.
110
+ * @default undefined
111
+ */
112
+ signal?: AbortSignal;
113
+
114
+ /**
115
+ * A number of milliseconds the test will fail after. If unspecified, subtests inherit this
116
+ * value from their parent.
117
+ * @default Infinity
118
+ */
119
+ timeout?: number;
120
+ }
121
+
122
+ /**
123
+ * A successful call of the run() method will return a new TapStream object, streaming a TAP output.
124
+ * TapStream will emit events in the order of the tests' definitions.
125
+ * @since v18.9.0
126
+ */
127
+ interface TapStream extends NodeJS.ReadableStream {
128
+ addListener(event: 'test:diagnostic', listener: (message: string) => void): this;
129
+ addListener(event: 'test:fail', listener: (data: TestFail) => void): this;
130
+ addListener(event: 'test:pass', listener: (data: TestPass) => void): this;
131
+ addListener(event: string, listener: (...args: any[]) => void): this;
132
+ emit(event: 'test:diagnostic', message: string): boolean;
133
+ emit(event: 'test:fail', data: TestFail): boolean;
134
+ emit(event: 'test:pass', data: TestPass): boolean;
135
+ emit(event: string | symbol, ...args: any[]): boolean;
136
+ on(event: 'test:diagnostic', listener: (message: string) => void): this;
137
+ on(event: 'test:fail', listener: (data: TestFail) => void): this;
138
+ on(event: 'test:pass', listener: (data: TestPass) => void): this;
139
+ on(event: string, listener: (...args: any[]) => void): this;
140
+ once(event: 'test:diagnostic', listener: (message: string) => void): this;
141
+ once(event: 'test:fail', listener: (data: TestFail) => void): this;
142
+ once(event: 'test:pass', listener: (data: TestPass) => void): this;
143
+ once(event: string, listener: (...args: any[]) => void): this;
144
+ prependListener(event: 'test:diagnostic', listener: (message: string) => void): this;
145
+ prependListener(event: 'test:fail', listener: (data: TestFail) => void): this;
146
+ prependListener(event: 'test:pass', listener: (data: TestPass) => void): this;
147
+ prependListener(event: string, listener: (...args: any[]) => void): this;
148
+ prependOnceListener(event: 'test:diagnostic', listener: (message: string) => void): this;
149
+ prependOnceListener(event: 'test:fail', listener: (data: TestFail) => void): this;
150
+ prependOnceListener(event: 'test:pass', listener: (data: TestPass) => void): this;
151
+ prependOnceListener(event: string, listener: (...args: any[]) => void): this;
152
+ }
153
+
154
+ interface TestFail {
155
+ /**
156
+ * The test duration.
157
+ */
158
+ duration: number;
159
+
160
+ /**
161
+ * The failure casing test to fail.
162
+ */
163
+ error: Error;
164
+
165
+ /**
166
+ * The test name.
167
+ */
168
+ name: string;
169
+
170
+ /**
171
+ * The ordinal number of the test.
172
+ */
173
+ testNumber: number;
174
+
175
+ /**
176
+ * Present if `context.todo` is called.
177
+ */
178
+ todo?: string;
179
+
180
+ /**
181
+ * Present if `context.skip` is called.
182
+ */
183
+ skip?: string;
184
+ }
185
+
186
+ interface TestPass {
187
+ /**
188
+ * The test duration.
189
+ */
190
+ duration: number;
191
+
192
+ /**
193
+ * The test name.
194
+ */
195
+ name: string;
196
+
197
+ /**
198
+ * The ordinal number of the test.
199
+ */
200
+ testNumber: number;
201
+
202
+ /**
203
+ * Present if `context.todo` is called.
204
+ */
205
+ todo?: string;
206
+
207
+ /**
208
+ * Present if `context.skip` is called.
209
+ */
210
+ skip?: string;
211
+ }
212
+
213
+ /**
214
+ * An instance of `TestContext` is passed to each test function in order to interact with the
215
+ * test runner. However, the `TestContext` constructor is not exposed as part of the API.
216
+ * @since v18.0.0
217
+ */
218
+ interface TestContext {
219
+ /**
220
+ * This function is used to write TAP diagnostics to the output. Any diagnostic information is
221
+ * included at the end of the test's results. This function does not return a value.
222
+ * @param message Message to be displayed as a TAP diagnostic.
223
+ * @since v18.0.0
224
+ */
225
+ diagnostic(message: string): void;
226
+
227
+ /**
228
+ * If `shouldRunOnlyTests` is truthy, the test context will only run tests that have the `only`
229
+ * option set. Otherwise, all tests are run. If Node.js was not started with the `--test-only`
230
+ * command-line option, this function is a no-op.
231
+ * @param shouldRunOnlyTests Whether or not to run `only` tests.
232
+ * @since v18.0.0
233
+ */
234
+ runOnly(shouldRunOnlyTests: boolean): void;
235
+
236
+ /**
237
+ * This function causes the test's output to indicate the test as skipped. If `message` is
238
+ * provided, it is included in the TAP output. Calling `skip()` does not terminate execution of
239
+ * the test function. This function does not return a value.
240
+ * @param message Optional skip message to be displayed in TAP output.
241
+ * @since v18.0.0
242
+ */
243
+ skip(message?: string): void;
244
+
245
+ /**
246
+ * This function adds a `TODO` directive to the test's output. If `message` is provided, it is
247
+ * included in the TAP output. Calling `todo()` does not terminate execution of the test
248
+ * function. This function does not return a value.
249
+ * @param message Optional `TODO` message to be displayed in TAP output.
250
+ * @since v18.0.0
251
+ */
252
+ todo(message?: string): void;
253
+
254
+ /**
255
+ * This function is used to create subtests under the current test. This function behaves in
256
+ * the same fashion as the top level {@link test} function.
257
+ * @since v18.0.0
258
+ * @param name The name of the test, which is displayed when reporting test results.
259
+ * Default: The `name` property of fn, or `'<anonymous>'` if `fn` does not have a name.
260
+ * @param options Configuration options for the test
261
+ * @param fn The function under test. This first argument to this function is a
262
+ * {@link TestContext} object. If the test uses callbacks, the callback function is
263
+ * passed as the second argument. Default: A no-op function.
264
+ * @returns A {@link Promise} resolved with `undefined` once the test completes.
265
+ */
266
+ test: typeof test;
267
+ }
268
+
269
+ interface TestOptions {
270
+ /**
271
+ * The number of tests that can be run at the same time. If unspecified, subtests inherit this
272
+ * value from their parent.
273
+ * @default 1
274
+ */
275
+ concurrency?: number;
276
+
277
+ /**
278
+ * If truthy, and the test context is configured to run `only` tests, then this test will be
279
+ * run. Otherwise, the test is skipped.
280
+ * @default false
281
+ */
282
+ only?: boolean;
283
+
284
+ /**
285
+ * Allows aborting an in-progress test.
286
+ * @since v18.8.0
287
+ */
288
+ signal?: AbortSignal;
289
+
290
+ /**
291
+ * If truthy, the test is skipped. If a string is provided, that string is displayed in the
292
+ * test results as the reason for skipping the test.
293
+ * @default false
294
+ */
295
+ skip?: boolean | string;
296
+
297
+ /**
298
+ * A number of milliseconds the test will fail after. If unspecified, subtests inherit this
299
+ * value from their parent.
300
+ * @default Infinity
301
+ * @since v18.7.0
302
+ */
303
+ timeout?: number;
304
+
305
+ /**
306
+ * If truthy, the test marked as `TODO`. If a string is provided, that string is displayed in
307
+ * the test results as the reason why the test is `TODO`.
308
+ * @default false
309
+ */
310
+ todo?: boolean | string;
311
+ }
312
+
313
+ export { test as default, run, test, describe, it };
314
+ }
@@ -0,0 +1,68 @@
1
+ /**
2
+ * The `timers/promises` API provides an alternative set of timer functions
3
+ * that return `Promise` objects. The API is accessible via`require('timers/promises')`.
4
+ *
5
+ * ```js
6
+ * import {
7
+ * setTimeout,
8
+ * setImmediate,
9
+ * setInterval,
10
+ * } from 'timers/promises';
11
+ * ```
12
+ * @since v15.0.0
13
+ */
14
+ declare module 'timers/promises' {
15
+ import { TimerOptions } from 'node:timers';
16
+ /**
17
+ * ```js
18
+ * import {
19
+ * setTimeout,
20
+ * } from 'timers/promises';
21
+ *
22
+ * const res = await setTimeout(100, 'result');
23
+ *
24
+ * console.log(res); // Prints 'result'
25
+ * ```
26
+ * @since v15.0.0
27
+ * @param [delay=1] The number of milliseconds to wait before fulfilling the promise.
28
+ * @param value A value with which the promise is fulfilled.
29
+ */
30
+ function setTimeout<T = void>(delay?: number, value?: T, options?: TimerOptions): Promise<T>;
31
+ /**
32
+ * ```js
33
+ * import {
34
+ * setImmediate,
35
+ * } from 'timers/promises';
36
+ *
37
+ * const res = await setImmediate('result');
38
+ *
39
+ * console.log(res); // Prints 'result'
40
+ * ```
41
+ * @since v15.0.0
42
+ * @param value A value with which the promise is fulfilled.
43
+ */
44
+ function setImmediate<T = void>(value?: T, options?: TimerOptions): Promise<T>;
45
+ /**
46
+ * Returns an async iterator that generates values in an interval of `delay` ms.
47
+ *
48
+ * ```js
49
+ * import {
50
+ * setInterval,
51
+ * } from 'timers/promises';
52
+ *
53
+ * const interval = 100;
54
+ * for await (const startTime of setInterval(interval, Date.now())) {
55
+ * const now = Date.now();
56
+ * console.log(now);
57
+ * if ((now - startTime) > 1000)
58
+ * break;
59
+ * }
60
+ * console.log(Date.now());
61
+ * ```
62
+ * @since v15.9.0
63
+ */
64
+ function setInterval<T = void>(delay?: number, value?: T, options?: TimerOptions): AsyncIterable<T>;
65
+ }
66
+ declare module 'node:timers/promises' {
67
+ export * from 'timers/promises';
68
+ }
@@ -0,0 +1,94 @@
1
+ /**
2
+ * The `timer` module exposes a global API for scheduling functions to
3
+ * be called at some future period of time. Because the timer functions are
4
+ * globals, there is no need to call `require('timers')` to use the API.
5
+ *
6
+ * The timer functions within Node.js implement a similar API as the timers API
7
+ * provided by Web Browsers but use a different internal implementation that is
8
+ * built around the Node.js [Event Loop](https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/#setimmediate-vs-settimeout).
9
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/timers.js)
10
+ */
11
+ declare module 'timers' {
12
+ import { Abortable } from 'node:events';
13
+ import { setTimeout as setTimeoutPromise, setImmediate as setImmediatePromise, setInterval as setIntervalPromise } from 'node:timers/promises';
14
+ interface TimerOptions extends Abortable {
15
+ /**
16
+ * Set to `false` to indicate that the scheduled `Timeout`
17
+ * should not require the Node.js event loop to remain active.
18
+ * @default true
19
+ */
20
+ ref?: boolean | undefined;
21
+ }
22
+ let setTimeout: typeof global.setTimeout;
23
+ let clearTimeout: typeof global.clearTimeout;
24
+ let setInterval: typeof global.setInterval;
25
+ let clearInterval: typeof global.clearInterval;
26
+ let setImmediate: typeof global.setImmediate;
27
+ let clearImmediate: typeof global.clearImmediate;
28
+ global {
29
+ namespace NodeJS {
30
+ // compatibility with older typings
31
+ interface Timer extends RefCounted {
32
+ hasRef(): boolean;
33
+ refresh(): this;
34
+ [Symbol.toPrimitive](): number;
35
+ }
36
+ interface Immediate extends RefCounted {
37
+ /**
38
+ * If true, the `Immediate` object will keep the Node.js event loop active.
39
+ * @since v11.0.0
40
+ */
41
+ hasRef(): boolean;
42
+ _onImmediate: Function; // to distinguish it from the Timeout class
43
+ }
44
+ interface Timeout extends Timer {
45
+ /**
46
+ * If true, the `Timeout` object will keep the Node.js event loop active.
47
+ * @since v11.0.0
48
+ */
49
+ hasRef(): boolean;
50
+ /**
51
+ * Sets the timer's start time to the current time, and reschedules the timer to
52
+ * call its callback at the previously specified duration adjusted to the current
53
+ * time. This is useful for refreshing a timer without allocating a new
54
+ * JavaScript object.
55
+ *
56
+ * Using this on a timer that has already called its callback will reactivate the
57
+ * timer.
58
+ * @since v10.2.0
59
+ * @return a reference to `timeout`
60
+ */
61
+ refresh(): this;
62
+ [Symbol.toPrimitive](): number;
63
+ }
64
+ }
65
+ function setTimeout<TArgs extends any[]>(callback: (...args: TArgs) => void, ms?: number, ...args: TArgs): NodeJS.Timeout;
66
+ // util.promisify no rest args compability
67
+ // tslint:disable-next-line void-return
68
+ function setTimeout(callback: (args: void) => void, ms?: number): NodeJS.Timeout;
69
+ namespace setTimeout {
70
+ const __promisify__: typeof setTimeoutPromise;
71
+ }
72
+ function clearTimeout(timeoutId: NodeJS.Timeout | string | number | undefined): void;
73
+ function setInterval<TArgs extends any[]>(callback: (...args: TArgs) => void, ms?: number, ...args: TArgs): NodeJS.Timer;
74
+ // util.promisify no rest args compability
75
+ // tslint:disable-next-line void-return
76
+ function setInterval(callback: (args: void) => void, ms?: number): NodeJS.Timer;
77
+ namespace setInterval {
78
+ const __promisify__: typeof setIntervalPromise;
79
+ }
80
+ function clearInterval(intervalId: NodeJS.Timeout | string | number | undefined): void;
81
+ function setImmediate<TArgs extends any[]>(callback: (...args: TArgs) => void, ...args: TArgs): NodeJS.Immediate;
82
+ // util.promisify no rest args compability
83
+ // tslint:disable-next-line void-return
84
+ function setImmediate(callback: (args: void) => void): NodeJS.Immediate;
85
+ namespace setImmediate {
86
+ const __promisify__: typeof setImmediatePromise;
87
+ }
88
+ function clearImmediate(immediateId: NodeJS.Immediate | undefined): void;
89
+ function queueMicrotask(callback: () => void): void;
90
+ }
91
+ }
92
+ declare module 'node:timers' {
93
+ export * from 'timers';
94
+ }