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,126 @@
1
+ export {}; // Don't export anything!
2
+
3
+ //// DOM-like Events
4
+ // NB: The Event / EventTarget / EventListener implementations below were copied
5
+ // from lib.dom.d.ts, then edited to reflect Node's documentation at
6
+ // https://nodejs.org/api/events.html#class-eventtarget.
7
+ // Please read that link to understand important implementation differences.
8
+
9
+ // This conditional type will be the existing global Event in a browser, or
10
+ // the copy below in a Node environment.
11
+ type __Event = typeof globalThis extends { onmessage: any, Event: any }
12
+ ? {}
13
+ : {
14
+ /** This is not used in Node.js and is provided purely for completeness. */
15
+ readonly bubbles: boolean;
16
+ /** Alias for event.stopPropagation(). This is not used in Node.js and is provided purely for completeness. */
17
+ cancelBubble: () => void;
18
+ /** True if the event was created with the cancelable option */
19
+ readonly cancelable: boolean;
20
+ /** This is not used in Node.js and is provided purely for completeness. */
21
+ readonly composed: boolean;
22
+ /** Returns an array containing the current EventTarget as the only entry or empty if the event is not being dispatched. This is not used in Node.js and is provided purely for completeness. */
23
+ composedPath(): [EventTarget?]
24
+ /** Alias for event.target. */
25
+ readonly currentTarget: EventTarget | null;
26
+ /** Is true if cancelable is true and event.preventDefault() has been called. */
27
+ readonly defaultPrevented: boolean;
28
+ /** This is not used in Node.js and is provided purely for completeness. */
29
+ readonly eventPhase: 0 | 2;
30
+ /** The `AbortSignal` "abort" event is emitted with `isTrusted` set to `true`. The value is `false` in all other cases. */
31
+ readonly isTrusted: boolean;
32
+ /** Sets the `defaultPrevented` property to `true` if `cancelable` is `true`. */
33
+ preventDefault(): void;
34
+ /** This is not used in Node.js and is provided purely for completeness. */
35
+ returnValue: boolean;
36
+ /** Alias for event.target. */
37
+ readonly srcElement: EventTarget | null;
38
+ /** Stops the invocation of event listeners after the current one completes. */
39
+ stopImmediatePropagation(): void;
40
+ /** This is not used in Node.js and is provided purely for completeness. */
41
+ stopPropagation(): void;
42
+ /** The `EventTarget` dispatching the event */
43
+ readonly target: EventTarget | null;
44
+ /** The millisecond timestamp when the Event object was created. */
45
+ readonly timeStamp: number;
46
+ /** Returns the type of event, e.g. "click", "hashchange", or "submit". */
47
+ readonly type: string;
48
+ };
49
+
50
+ // See comment above explaining conditional type
51
+ type __EventTarget = typeof globalThis extends { onmessage: any, EventTarget: any }
52
+ ? {}
53
+ : {
54
+ /**
55
+ * Adds a new handler for the `type` event. Any given `listener` is added only once per `type` and per `capture` option value.
56
+ *
57
+ * If the `once` option is true, the `listener` is removed after the next time a `type` event is dispatched.
58
+ *
59
+ * The `capture` option is not used by Node.js in any functional way other than tracking registered event listeners per the `EventTarget` specification.
60
+ * Specifically, the `capture` option is used as part of the key when registering a `listener`.
61
+ * Any individual `listener` may be added once with `capture = false`, and once with `capture = true`.
62
+ */
63
+ addEventListener(
64
+ type: string,
65
+ listener: EventListener | EventListenerObject,
66
+ options?: AddEventListenerOptions | boolean,
67
+ ): void;
68
+ /** Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise. */
69
+ dispatchEvent(event: Event): boolean;
70
+ /** Removes the event listener in target's event listener list with the same type, callback, and options. */
71
+ removeEventListener(
72
+ type: string,
73
+ listener: EventListener | EventListenerObject,
74
+ options?: EventListenerOptions | boolean,
75
+ ): void;
76
+ };
77
+
78
+ interface EventInit {
79
+ bubbles?: boolean;
80
+ cancelable?: boolean;
81
+ composed?: boolean;
82
+ }
83
+
84
+ interface EventListenerOptions {
85
+ /** Not directly used by Node.js. Added for API completeness. Default: `false`. */
86
+ capture?: boolean;
87
+ }
88
+
89
+ interface AddEventListenerOptions extends EventListenerOptions {
90
+ /** When `true`, the listener is automatically removed when it is first invoked. Default: `false`. */
91
+ once?: boolean;
92
+ /** When `true`, serves as a hint that the listener will not call the `Event` object's `preventDefault()` method. Default: false. */
93
+ passive?: boolean;
94
+ }
95
+
96
+ interface EventListener {
97
+ (evt: Event): void;
98
+ }
99
+
100
+ interface EventListenerObject {
101
+ handleEvent(object: Event): void;
102
+ }
103
+
104
+ import {} from 'events'; // Make this an ambient declaration
105
+ declare global {
106
+ /** An event which takes place in the DOM. */
107
+ interface Event extends __Event {}
108
+ var Event: typeof globalThis extends { onmessage: any, Event: infer T }
109
+ ? T
110
+ : {
111
+ prototype: __Event;
112
+ new (type: string, eventInitDict?: EventInit): __Event;
113
+ };
114
+
115
+ /**
116
+ * EventTarget is a DOM interface implemented by objects that can
117
+ * receive events and may have listeners for them.
118
+ */
119
+ interface EventTarget extends __EventTarget {}
120
+ var EventTarget: typeof globalThis extends { onmessage: any, EventTarget: infer T }
121
+ ? T
122
+ : {
123
+ prototype: __EventTarget;
124
+ new (): __EventTarget;
125
+ };
126
+ }
@@ -0,0 +1,170 @@
1
+ /**
2
+ * **This module is pending deprecation.** Once a replacement API has been
3
+ * finalized, this module will be fully deprecated. Most developers should
4
+ * **not** have cause to use this module. Users who absolutely must have
5
+ * the functionality that domains provide may rely on it for the time being
6
+ * but should expect to have to migrate to a different solution
7
+ * in the future.
8
+ *
9
+ * Domains provide a way to handle multiple different IO operations as a
10
+ * single group. If any of the event emitters or callbacks registered to a
11
+ * domain emit an `'error'` event, or throw an error, then the domain object
12
+ * will be notified, rather than losing the context of the error in the`process.on('uncaughtException')` handler, or causing the program to
13
+ * exit immediately with an error code.
14
+ * @deprecated Since v1.4.2 - Deprecated
15
+ * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/domain.js)
16
+ */
17
+ declare module 'domain' {
18
+ import EventEmitter = require('node:events');
19
+ /**
20
+ * The `Domain` class encapsulates the functionality of routing errors and
21
+ * uncaught exceptions to the active `Domain` object.
22
+ *
23
+ * To handle the errors that it catches, listen to its `'error'` event.
24
+ */
25
+ class Domain extends EventEmitter {
26
+ /**
27
+ * An array of timers and event emitters that have been explicitly added
28
+ * to the domain.
29
+ */
30
+ members: Array<EventEmitter | NodeJS.Timer>;
31
+ /**
32
+ * The `enter()` method is plumbing used by the `run()`, `bind()`, and`intercept()` methods to set the active domain. It sets `domain.active` and`process.domain` to the domain, and implicitly
33
+ * pushes the domain onto the domain
34
+ * stack managed by the domain module (see {@link exit} for details on the
35
+ * domain stack). The call to `enter()` delimits the beginning of a chain of
36
+ * asynchronous calls and I/O operations bound to a domain.
37
+ *
38
+ * Calling `enter()` changes only the active domain, and does not alter the domain
39
+ * itself. `enter()` and `exit()` can be called an arbitrary number of times on a
40
+ * single domain.
41
+ */
42
+ enter(): void;
43
+ /**
44
+ * The `exit()` method exits the current domain, popping it off the domain stack.
45
+ * Any time execution is going to switch to the context of a different chain of
46
+ * asynchronous calls, it's important to ensure that the current domain is exited.
47
+ * The call to `exit()` delimits either the end of or an interruption to the chain
48
+ * of asynchronous calls and I/O operations bound to a domain.
49
+ *
50
+ * If there are multiple, nested domains bound to the current execution context,`exit()` will exit any domains nested within this domain.
51
+ *
52
+ * Calling `exit()` changes only the active domain, and does not alter the domain
53
+ * itself. `enter()` and `exit()` can be called an arbitrary number of times on a
54
+ * single domain.
55
+ */
56
+ exit(): void;
57
+ /**
58
+ * Run the supplied function in the context of the domain, implicitly
59
+ * binding all event emitters, timers, and lowlevel requests that are
60
+ * created in that context. Optionally, arguments can be passed to
61
+ * the function.
62
+ *
63
+ * This is the most basic way to use a domain.
64
+ *
65
+ * ```js
66
+ * const domain = require('domain');
67
+ * const fs = require('fs');
68
+ * const d = domain.create();
69
+ * d.on('error', (er) => {
70
+ * console.error('Caught error!', er);
71
+ * });
72
+ * d.run(() => {
73
+ * process.nextTick(() => {
74
+ * setTimeout(() => { // Simulating some various async stuff
75
+ * fs.open('non-existent file', 'r', (er, fd) => {
76
+ * if (er) throw er;
77
+ * // proceed...
78
+ * });
79
+ * }, 100);
80
+ * });
81
+ * });
82
+ * ```
83
+ *
84
+ * In this example, the `d.on('error')` handler will be triggered, rather
85
+ * than crashing the program.
86
+ */
87
+ run<T>(fn: (...args: any[]) => T, ...args: any[]): T;
88
+ /**
89
+ * Explicitly adds an emitter to the domain. If any event handlers called by
90
+ * the emitter throw an error, or if the emitter emits an `'error'` event, it
91
+ * will be routed to the domain's `'error'` event, just like with implicit
92
+ * binding.
93
+ *
94
+ * This also works with timers that are returned from `setInterval()` and `setTimeout()`. If their callback function throws, it will be caught by
95
+ * the domain `'error'` handler.
96
+ *
97
+ * If the Timer or `EventEmitter` was already bound to a domain, it is removed
98
+ * from that one, and bound to this one instead.
99
+ * @param emitter emitter or timer to be added to the domain
100
+ */
101
+ add(emitter: EventEmitter | NodeJS.Timer): void;
102
+ /**
103
+ * The opposite of {@link add}. Removes domain handling from the
104
+ * specified emitter.
105
+ * @param emitter emitter or timer to be removed from the domain
106
+ */
107
+ remove(emitter: EventEmitter | NodeJS.Timer): void;
108
+ /**
109
+ * The returned function will be a wrapper around the supplied callback
110
+ * function. When the returned function is called, any errors that are
111
+ * thrown will be routed to the domain's `'error'` event.
112
+ *
113
+ * ```js
114
+ * const d = domain.create();
115
+ *
116
+ * function readSomeFile(filename, cb) {
117
+ * fs.readFile(filename, 'utf8', d.bind((er, data) => {
118
+ * // If this throws, it will also be passed to the domain.
119
+ * return cb(er, data ? JSON.parse(data) : null);
120
+ * }));
121
+ * }
122
+ *
123
+ * d.on('error', (er) => {
124
+ * // An error occurred somewhere. If we throw it now, it will crash the program
125
+ * // with the normal line number and stack message.
126
+ * });
127
+ * ```
128
+ * @param callback The callback function
129
+ * @return The bound function
130
+ */
131
+ bind<T extends Function>(callback: T): T;
132
+ /**
133
+ * This method is almost identical to {@link bind}. However, in
134
+ * addition to catching thrown errors, it will also intercept `Error` objects sent as the first argument to the function.
135
+ *
136
+ * In this way, the common `if (err) return callback(err);` pattern can be replaced
137
+ * with a single error handler in a single place.
138
+ *
139
+ * ```js
140
+ * const d = domain.create();
141
+ *
142
+ * function readSomeFile(filename, cb) {
143
+ * fs.readFile(filename, 'utf8', d.intercept((data) => {
144
+ * // Note, the first argument is never passed to the
145
+ * // callback since it is assumed to be the 'Error' argument
146
+ * // and thus intercepted by the domain.
147
+ *
148
+ * // If this throws, it will also be passed to the domain
149
+ * // so the error-handling logic can be moved to the 'error'
150
+ * // event on the domain instead of being repeated throughout
151
+ * // the program.
152
+ * return cb(null, JSON.parse(data));
153
+ * }));
154
+ * }
155
+ *
156
+ * d.on('error', (er) => {
157
+ * // An error occurred somewhere. If we throw it now, it will crash the program
158
+ * // with the normal line number and stack message.
159
+ * });
160
+ * ```
161
+ * @param callback The callback function
162
+ * @return The intercepted function
163
+ */
164
+ intercept<T extends Function>(callback: T): T;
165
+ }
166
+ function create(): Domain;
167
+ }
168
+ declare module 'node:domain' {
169
+ export * from 'domain';
170
+ }