m06_task3.js 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.idea/.name +1 -0
- package/.idea/inspectionProfiles/Project_Default.xml +10 -0
- package/.idea/jsLibraryMappings.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/node_lab_6.iml +12 -0
- package/06_task2.html +73 -0
- package/06_task2.js +52 -0
- package/06_task3.js +3 -0
- package/06_task4.js +3 -0
- package/m06_task3.js +28 -0
- package/package/index.js +28 -0
- package/package/node_modules/.package-lock.json +31 -0
- package/package/node_modules/@types/node/LICENSE +21 -0
- package/package/node_modules/@types/node/README.md +16 -0
- package/package/node_modules/@types/node/assert/strict.d.ts +8 -0
- package/package/node_modules/@types/node/assert.d.ts +961 -0
- package/package/node_modules/@types/node/async_hooks.d.ts +501 -0
- package/package/node_modules/@types/node/buffer.d.ts +2258 -0
- package/package/node_modules/@types/node/child_process.d.ts +1369 -0
- package/package/node_modules/@types/node/cluster.d.ts +410 -0
- package/package/node_modules/@types/node/console.d.ts +412 -0
- package/package/node_modules/@types/node/constants.d.ts +18 -0
- package/package/node_modules/@types/node/crypto.d.ts +3964 -0
- package/package/node_modules/@types/node/dgram.d.ts +545 -0
- package/package/node_modules/@types/node/diagnostics_channel.d.ts +153 -0
- package/package/node_modules/@types/node/dns/promises.d.ts +370 -0
- package/package/node_modules/@types/node/dns.d.ts +659 -0
- package/package/node_modules/@types/node/dom-events.d.ts +126 -0
- package/package/node_modules/@types/node/domain.d.ts +170 -0
- package/package/node_modules/@types/node/events.d.ts +678 -0
- package/package/node_modules/@types/node/fs/promises.d.ts +1138 -0
- package/package/node_modules/@types/node/fs.d.ts +3872 -0
- package/package/node_modules/@types/node/globals.d.ts +300 -0
- package/package/node_modules/@types/node/globals.global.d.ts +1 -0
- package/package/node_modules/@types/node/http.d.ts +1614 -0
- package/package/node_modules/@types/node/http2.d.ts +2134 -0
- package/package/node_modules/@types/node/https.d.ts +541 -0
- package/package/node_modules/@types/node/index.d.ts +133 -0
- package/package/node_modules/@types/node/inspector.d.ts +2741 -0
- package/package/node_modules/@types/node/module.d.ts +114 -0
- package/package/node_modules/@types/node/net.d.ts +869 -0
- package/package/node_modules/@types/node/os.d.ts +466 -0
- package/package/node_modules/@types/node/package.json +232 -0
- package/package/node_modules/@types/node/path.d.ts +191 -0
- package/package/node_modules/@types/node/perf_hooks.d.ts +625 -0
- package/package/node_modules/@types/node/process.d.ts +1482 -0
- package/package/node_modules/@types/node/punycode.d.ts +117 -0
- package/package/node_modules/@types/node/querystring.d.ts +131 -0
- package/package/node_modules/@types/node/readline/promises.d.ts +143 -0
- package/package/node_modules/@types/node/readline.d.ts +653 -0
- package/package/node_modules/@types/node/repl.d.ts +424 -0
- package/package/node_modules/@types/node/stream/consumers.d.ts +12 -0
- package/package/node_modules/@types/node/stream/promises.d.ts +42 -0
- package/package/node_modules/@types/node/stream/web.d.ts +330 -0
- package/package/node_modules/@types/node/stream.d.ts +1340 -0
- package/package/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/package/node_modules/@types/node/test.d.ts +314 -0
- package/package/node_modules/@types/node/timers/promises.d.ts +68 -0
- package/package/node_modules/@types/node/timers.d.ts +94 -0
- package/package/node_modules/@types/node/tls.d.ts +1028 -0
- package/package/node_modules/@types/node/trace_events.d.ts +171 -0
- package/package/node_modules/@types/node/ts4.8/assert/strict.d.ts +8 -0
- package/package/node_modules/@types/node/ts4.8/assert.d.ts +961 -0
- package/package/node_modules/@types/node/ts4.8/async_hooks.d.ts +501 -0
- package/package/node_modules/@types/node/ts4.8/buffer.d.ts +2259 -0
- package/package/node_modules/@types/node/ts4.8/child_process.d.ts +1369 -0
- package/package/node_modules/@types/node/ts4.8/cluster.d.ts +410 -0
- package/package/node_modules/@types/node/ts4.8/console.d.ts +412 -0
- package/package/node_modules/@types/node/ts4.8/constants.d.ts +18 -0
- package/package/node_modules/@types/node/ts4.8/crypto.d.ts +3964 -0
- package/package/node_modules/@types/node/ts4.8/dgram.d.ts +545 -0
- package/package/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts +153 -0
- package/package/node_modules/@types/node/ts4.8/dns/promises.d.ts +370 -0
- package/package/node_modules/@types/node/ts4.8/dns.d.ts +659 -0
- package/package/node_modules/@types/node/ts4.8/dom-events.d.ts +126 -0
- package/package/node_modules/@types/node/ts4.8/domain.d.ts +170 -0
- package/package/node_modules/@types/node/ts4.8/events.d.ts +678 -0
- package/package/node_modules/@types/node/ts4.8/fs/promises.d.ts +1138 -0
- package/package/node_modules/@types/node/ts4.8/fs.d.ts +3872 -0
- package/package/node_modules/@types/node/ts4.8/globals.d.ts +294 -0
- package/package/node_modules/@types/node/ts4.8/globals.global.d.ts +1 -0
- package/package/node_modules/@types/node/ts4.8/http.d.ts +1614 -0
- package/package/node_modules/@types/node/ts4.8/http2.d.ts +2134 -0
- package/package/node_modules/@types/node/ts4.8/https.d.ts +541 -0
- package/package/node_modules/@types/node/ts4.8/index.d.ts +88 -0
- package/package/node_modules/@types/node/ts4.8/inspector.d.ts +2741 -0
- package/package/node_modules/@types/node/ts4.8/module.d.ts +114 -0
- package/package/node_modules/@types/node/ts4.8/net.d.ts +869 -0
- package/package/node_modules/@types/node/ts4.8/os.d.ts +466 -0
- package/package/node_modules/@types/node/ts4.8/path.d.ts +191 -0
- package/package/node_modules/@types/node/ts4.8/perf_hooks.d.ts +625 -0
- package/package/node_modules/@types/node/ts4.8/process.d.ts +1482 -0
- package/package/node_modules/@types/node/ts4.8/punycode.d.ts +117 -0
- package/package/node_modules/@types/node/ts4.8/querystring.d.ts +131 -0
- package/package/node_modules/@types/node/ts4.8/readline/promises.d.ts +143 -0
- package/package/node_modules/@types/node/ts4.8/readline.d.ts +653 -0
- package/package/node_modules/@types/node/ts4.8/repl.d.ts +424 -0
- package/package/node_modules/@types/node/ts4.8/stream/consumers.d.ts +12 -0
- package/package/node_modules/@types/node/ts4.8/stream/promises.d.ts +42 -0
- package/package/node_modules/@types/node/ts4.8/stream/web.d.ts +330 -0
- package/package/node_modules/@types/node/ts4.8/stream.d.ts +1340 -0
- package/package/node_modules/@types/node/ts4.8/string_decoder.d.ts +67 -0
- package/package/node_modules/@types/node/ts4.8/test.d.ts +314 -0
- package/package/node_modules/@types/node/ts4.8/timers/promises.d.ts +68 -0
- package/package/node_modules/@types/node/ts4.8/timers.d.ts +94 -0
- package/package/node_modules/@types/node/ts4.8/tls.d.ts +1028 -0
- package/package/node_modules/@types/node/ts4.8/trace_events.d.ts +171 -0
- package/package/node_modules/@types/node/ts4.8/tty.d.ts +206 -0
- package/package/node_modules/@types/node/ts4.8/url.d.ts +897 -0
- package/package/node_modules/@types/node/ts4.8/util.d.ts +1850 -0
- package/package/node_modules/@types/node/ts4.8/v8.d.ts +396 -0
- package/package/node_modules/@types/node/ts4.8/vm.d.ts +509 -0
- package/package/node_modules/@types/node/ts4.8/wasi.d.ts +158 -0
- package/package/node_modules/@types/node/ts4.8/worker_threads.d.ts +689 -0
- package/package/node_modules/@types/node/ts4.8/zlib.d.ts +517 -0
- package/package/node_modules/@types/node/tty.d.ts +206 -0
- package/package/node_modules/@types/node/url.d.ts +897 -0
- package/package/node_modules/@types/node/util.d.ts +1850 -0
- package/package/node_modules/@types/node/v8.d.ts +396 -0
- package/package/node_modules/@types/node/vm.d.ts +509 -0
- package/package/node_modules/@types/node/wasi.d.ts +158 -0
- package/package/node_modules/@types/node/worker_threads.d.ts +689 -0
- package/package/node_modules/@types/node/zlib.d.ts +517 -0
- package/package/node_modules/@types/nodemailer/LICENSE +21 -0
- package/package/node_modules/@types/nodemailer/README.md +16 -0
- package/package/node_modules/@types/nodemailer/index.d.ts +83 -0
- package/package/node_modules/@types/nodemailer/lib/addressparser/index.d.ts +31 -0
- package/package/node_modules/@types/nodemailer/lib/base64/index.d.ts +22 -0
- package/package/node_modules/@types/nodemailer/lib/dkim/index.d.ts +45 -0
- package/package/node_modules/@types/nodemailer/lib/dkim/message-parser.d.ts +75 -0
- package/package/node_modules/@types/nodemailer/lib/dkim/relaxed-body.d.ts +75 -0
- package/package/node_modules/@types/nodemailer/lib/dkim/sign.d.ts +11 -0
- package/package/node_modules/@types/nodemailer/lib/fetch/cookies.d.ts +54 -0
- package/package/node_modules/@types/nodemailer/lib/fetch/index.d.ts +38 -0
- package/package/node_modules/@types/nodemailer/lib/json-transport/index.d.ts +50 -0
- package/package/node_modules/@types/nodemailer/lib/mail-composer/index.d.ts +25 -0
- package/package/node_modules/@types/nodemailer/lib/mailer/index.d.ts +230 -0
- package/package/node_modules/@types/nodemailer/lib/mailer/mail-message.d.ts +28 -0
- package/package/node_modules/@types/nodemailer/lib/mime-funcs/index.d.ts +87 -0
- package/package/node_modules/@types/nodemailer/lib/mime-funcs/mime-types.d.ts +2 -0
- package/package/node_modules/@types/nodemailer/lib/mime-node/index.d.ts +137 -0
- package/package/node_modules/@types/nodemailer/lib/mime-node/last-newline.d.ts +9 -0
- package/package/node_modules/@types/nodemailer/lib/qp/index.d.ts +23 -0
- package/package/node_modules/@types/nodemailer/lib/sendmail-transport/index.d.ts +53 -0
- package/package/node_modules/@types/nodemailer/lib/sendmail-transport/le-unix.d.ts +7 -0
- package/package/node_modules/@types/nodemailer/lib/sendmail-transport/le-windows.d.ts +7 -0
- package/package/node_modules/@types/nodemailer/lib/ses-transport/index.d.ts +136 -0
- package/package/node_modules/@types/nodemailer/lib/shared/index.d.ts +51 -0
- package/package/node_modules/@types/nodemailer/lib/smtp-connection/data-stream.d.ts +11 -0
- package/package/node_modules/@types/nodemailer/lib/smtp-connection/http-proxy-client.d.ts +11 -0
- package/package/node_modules/@types/nodemailer/lib/smtp-connection/index.d.ts +254 -0
- package/package/node_modules/@types/nodemailer/lib/smtp-pool/index.d.ts +90 -0
- package/package/node_modules/@types/nodemailer/lib/smtp-pool/pool-resource.d.ts +66 -0
- package/package/node_modules/@types/nodemailer/lib/smtp-transport/index.d.ts +115 -0
- package/package/node_modules/@types/nodemailer/lib/stream-transport/index.d.ts +56 -0
- package/package/node_modules/@types/nodemailer/lib/well-known/index.d.ts +6 -0
- package/package/node_modules/@types/nodemailer/lib/xoauth2/index.d.ts +110 -0
- package/package/node_modules/@types/nodemailer/package.json +37 -0
- package/package/node_modules/nodemailer/.gitattributes +6 -0
- package/package/node_modules/nodemailer/.prettierrc.js +8 -0
- package/package/node_modules/nodemailer/CHANGELOG.md +715 -0
- package/package/node_modules/nodemailer/CODE_OF_CONDUCT.md +76 -0
- package/package/node_modules/nodemailer/CONTRIBUTING.md +67 -0
- package/package/node_modules/nodemailer/LICENSE +16 -0
- package/package/node_modules/nodemailer/README.md +93 -0
- package/package/node_modules/nodemailer/SECURITY.txt +22 -0
- package/package/node_modules/nodemailer/lib/addressparser/index.js +313 -0
- package/package/node_modules/nodemailer/lib/base64/index.js +142 -0
- package/package/node_modules/nodemailer/lib/dkim/index.js +251 -0
- package/package/node_modules/nodemailer/lib/dkim/message-parser.js +155 -0
- package/package/node_modules/nodemailer/lib/dkim/relaxed-body.js +154 -0
- package/package/node_modules/nodemailer/lib/dkim/sign.js +117 -0
- package/package/node_modules/nodemailer/lib/fetch/cookies.js +281 -0
- package/package/node_modules/nodemailer/lib/fetch/index.js +269 -0
- package/package/node_modules/nodemailer/lib/json-transport/index.js +82 -0
- package/package/node_modules/nodemailer/lib/mail-composer/index.js +558 -0
- package/package/node_modules/nodemailer/lib/mailer/index.js +427 -0
- package/package/node_modules/nodemailer/lib/mailer/mail-message.js +315 -0
- package/package/node_modules/nodemailer/lib/mime-funcs/index.js +619 -0
- package/package/node_modules/nodemailer/lib/mime-funcs/mime-types.js +2102 -0
- package/package/node_modules/nodemailer/lib/mime-node/index.js +1290 -0
- package/package/node_modules/nodemailer/lib/mime-node/last-newline.js +33 -0
- package/package/node_modules/nodemailer/lib/mime-node/le-unix.js +43 -0
- package/package/node_modules/nodemailer/lib/mime-node/le-windows.js +52 -0
- package/package/node_modules/nodemailer/lib/nodemailer.js +143 -0
- package/package/node_modules/nodemailer/lib/qp/index.js +219 -0
- package/package/node_modules/nodemailer/lib/sendmail-transport/index.js +210 -0
- package/package/node_modules/nodemailer/lib/ses-transport/index.js +349 -0
- package/package/node_modules/nodemailer/lib/shared/index.js +639 -0
- package/package/node_modules/nodemailer/lib/smtp-connection/data-stream.js +108 -0
- package/package/node_modules/nodemailer/lib/smtp-connection/http-proxy-client.js +143 -0
- package/package/node_modules/nodemailer/lib/smtp-connection/index.js +1786 -0
- package/package/node_modules/nodemailer/lib/smtp-pool/index.js +648 -0
- package/package/node_modules/nodemailer/lib/smtp-pool/pool-resource.js +253 -0
- package/package/node_modules/nodemailer/lib/smtp-transport/index.js +416 -0
- package/package/node_modules/nodemailer/lib/stream-transport/index.js +135 -0
- package/package/node_modules/nodemailer/lib/well-known/index.js +47 -0
- package/package/node_modules/nodemailer/lib/well-known/services.json +286 -0
- package/package/node_modules/nodemailer/lib/xoauth2/index.js +376 -0
- package/package/node_modules/nodemailer/package.json +46 -0
- package/package/node_modules/nodemailer/postinstall.js +101 -0
- package/package/package-lock.json +60 -0
- package/package/package.json +6 -0
- package/package.json +19 -0
@@ -0,0 +1,396 @@
|
|
1
|
+
/**
|
2
|
+
* The `v8` module exposes APIs that are specific to the version of [V8](https://developers.google.com/v8/) built into the Node.js binary. It can be accessed using:
|
3
|
+
*
|
4
|
+
* ```js
|
5
|
+
* const v8 = require('v8');
|
6
|
+
* ```
|
7
|
+
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/v8.js)
|
8
|
+
*/
|
9
|
+
declare module 'v8' {
|
10
|
+
import { Readable } from 'node:stream';
|
11
|
+
interface HeapSpaceInfo {
|
12
|
+
space_name: string;
|
13
|
+
space_size: number;
|
14
|
+
space_used_size: number;
|
15
|
+
space_available_size: number;
|
16
|
+
physical_space_size: number;
|
17
|
+
}
|
18
|
+
// ** Signifies if the --zap_code_space option is enabled or not. 1 == enabled, 0 == disabled. */
|
19
|
+
type DoesZapCodeSpaceFlag = 0 | 1;
|
20
|
+
interface HeapInfo {
|
21
|
+
total_heap_size: number;
|
22
|
+
total_heap_size_executable: number;
|
23
|
+
total_physical_size: number;
|
24
|
+
total_available_size: number;
|
25
|
+
used_heap_size: number;
|
26
|
+
heap_size_limit: number;
|
27
|
+
malloced_memory: number;
|
28
|
+
peak_malloced_memory: number;
|
29
|
+
does_zap_garbage: DoesZapCodeSpaceFlag;
|
30
|
+
number_of_native_contexts: number;
|
31
|
+
number_of_detached_contexts: number;
|
32
|
+
}
|
33
|
+
interface HeapCodeStatistics {
|
34
|
+
code_and_metadata_size: number;
|
35
|
+
bytecode_and_metadata_size: number;
|
36
|
+
external_script_source_size: number;
|
37
|
+
}
|
38
|
+
/**
|
39
|
+
* Returns an integer representing a version tag derived from the V8 version,
|
40
|
+
* command-line flags, and detected CPU features. This is useful for determining
|
41
|
+
* whether a `vm.Script` `cachedData` buffer is compatible with this instance
|
42
|
+
* of V8.
|
43
|
+
*
|
44
|
+
* ```js
|
45
|
+
* console.log(v8.cachedDataVersionTag()); // 3947234607
|
46
|
+
* // The value returned by v8.cachedDataVersionTag() is derived from the V8
|
47
|
+
* // version, command-line flags, and detected CPU features. Test that the value
|
48
|
+
* // does indeed update when flags are toggled.
|
49
|
+
* v8.setFlagsFromString('--allow_natives_syntax');
|
50
|
+
* console.log(v8.cachedDataVersionTag()); // 183726201
|
51
|
+
* ```
|
52
|
+
* @since v8.0.0
|
53
|
+
*/
|
54
|
+
function cachedDataVersionTag(): number;
|
55
|
+
/**
|
56
|
+
* Returns an object with the following properties:
|
57
|
+
*
|
58
|
+
* `does_zap_garbage` is a 0/1 boolean, which signifies whether the`--zap_code_space` option is enabled or not. This makes V8 overwrite heap
|
59
|
+
* garbage with a bit pattern. The RSS footprint (resident set size) gets bigger
|
60
|
+
* because it continuously touches all heap pages and that makes them less likely
|
61
|
+
* to get swapped out by the operating system.
|
62
|
+
*
|
63
|
+
* `number_of_native_contexts` The value of native\_context is the number of the
|
64
|
+
* top-level contexts currently active. Increase of this number over time indicates
|
65
|
+
* a memory leak.
|
66
|
+
*
|
67
|
+
* `number_of_detached_contexts` The value of detached\_context is the number
|
68
|
+
* of contexts that were detached and not yet garbage collected. This number
|
69
|
+
* being non-zero indicates a potential memory leak.
|
70
|
+
*
|
71
|
+
* ```js
|
72
|
+
* {
|
73
|
+
* total_heap_size: 7326976,
|
74
|
+
* total_heap_size_executable: 4194304,
|
75
|
+
* total_physical_size: 7326976,
|
76
|
+
* total_available_size: 1152656,
|
77
|
+
* used_heap_size: 3476208,
|
78
|
+
* heap_size_limit: 1535115264,
|
79
|
+
* malloced_memory: 16384,
|
80
|
+
* peak_malloced_memory: 1127496,
|
81
|
+
* does_zap_garbage: 0,
|
82
|
+
* number_of_native_contexts: 1,
|
83
|
+
* number_of_detached_contexts: 0
|
84
|
+
* }
|
85
|
+
* ```
|
86
|
+
* @since v1.0.0
|
87
|
+
*/
|
88
|
+
function getHeapStatistics(): HeapInfo;
|
89
|
+
/**
|
90
|
+
* Returns statistics about the V8 heap spaces, i.e. the segments which make up
|
91
|
+
* the V8 heap. Neither the ordering of heap spaces, nor the availability of a
|
92
|
+
* heap space can be guaranteed as the statistics are provided via the
|
93
|
+
* V8[`GetHeapSpaceStatistics`](https://v8docs.nodesource.com/node-13.2/d5/dda/classv8_1_1_isolate.html#ac673576f24fdc7a33378f8f57e1d13a4) function and may change from one V8 version to the
|
94
|
+
* next.
|
95
|
+
*
|
96
|
+
* The value returned is an array of objects containing the following properties:
|
97
|
+
*
|
98
|
+
* ```json
|
99
|
+
* [
|
100
|
+
* {
|
101
|
+
* "space_name": "new_space",
|
102
|
+
* "space_size": 2063872,
|
103
|
+
* "space_used_size": 951112,
|
104
|
+
* "space_available_size": 80824,
|
105
|
+
* "physical_space_size": 2063872
|
106
|
+
* },
|
107
|
+
* {
|
108
|
+
* "space_name": "old_space",
|
109
|
+
* "space_size": 3090560,
|
110
|
+
* "space_used_size": 2493792,
|
111
|
+
* "space_available_size": 0,
|
112
|
+
* "physical_space_size": 3090560
|
113
|
+
* },
|
114
|
+
* {
|
115
|
+
* "space_name": "code_space",
|
116
|
+
* "space_size": 1260160,
|
117
|
+
* "space_used_size": 644256,
|
118
|
+
* "space_available_size": 960,
|
119
|
+
* "physical_space_size": 1260160
|
120
|
+
* },
|
121
|
+
* {
|
122
|
+
* "space_name": "map_space",
|
123
|
+
* "space_size": 1094160,
|
124
|
+
* "space_used_size": 201608,
|
125
|
+
* "space_available_size": 0,
|
126
|
+
* "physical_space_size": 1094160
|
127
|
+
* },
|
128
|
+
* {
|
129
|
+
* "space_name": "large_object_space",
|
130
|
+
* "space_size": 0,
|
131
|
+
* "space_used_size": 0,
|
132
|
+
* "space_available_size": 1490980608,
|
133
|
+
* "physical_space_size": 0
|
134
|
+
* }
|
135
|
+
* ]
|
136
|
+
* ```
|
137
|
+
* @since v6.0.0
|
138
|
+
*/
|
139
|
+
function getHeapSpaceStatistics(): HeapSpaceInfo[];
|
140
|
+
/**
|
141
|
+
* The `v8.setFlagsFromString()` method can be used to programmatically set
|
142
|
+
* V8 command-line flags. This method should be used with care. Changing settings
|
143
|
+
* after the VM has started may result in unpredictable behavior, including
|
144
|
+
* crashes and data loss; or it may simply do nothing.
|
145
|
+
*
|
146
|
+
* The V8 options available for a version of Node.js may be determined by running`node --v8-options`.
|
147
|
+
*
|
148
|
+
* Usage:
|
149
|
+
*
|
150
|
+
* ```js
|
151
|
+
* // Print GC events to stdout for one minute.
|
152
|
+
* const v8 = require('v8');
|
153
|
+
* v8.setFlagsFromString('--trace_gc');
|
154
|
+
* setTimeout(() => { v8.setFlagsFromString('--notrace_gc'); }, 60e3);
|
155
|
+
* ```
|
156
|
+
* @since v1.0.0
|
157
|
+
*/
|
158
|
+
function setFlagsFromString(flags: string): void;
|
159
|
+
/**
|
160
|
+
* Generates a snapshot of the current V8 heap and returns a Readable
|
161
|
+
* Stream that may be used to read the JSON serialized representation.
|
162
|
+
* This JSON stream format is intended to be used with tools such as
|
163
|
+
* Chrome DevTools. The JSON schema is undocumented and specific to the
|
164
|
+
* V8 engine. Therefore, the schema may change from one version of V8 to the next.
|
165
|
+
*
|
166
|
+
* Creating a heap snapshot requires memory about twice the size of the heap at
|
167
|
+
* the time the snapshot is created. This results in the risk of OOM killers
|
168
|
+
* terminating the process.
|
169
|
+
*
|
170
|
+
* Generating a snapshot is a synchronous operation which blocks the event loop
|
171
|
+
* for a duration depending on the heap size.
|
172
|
+
*
|
173
|
+
* ```js
|
174
|
+
* // Print heap snapshot to the console
|
175
|
+
* const v8 = require('v8');
|
176
|
+
* const stream = v8.getHeapSnapshot();
|
177
|
+
* stream.pipe(process.stdout);
|
178
|
+
* ```
|
179
|
+
* @since v11.13.0
|
180
|
+
* @return A Readable Stream containing the V8 heap snapshot
|
181
|
+
*/
|
182
|
+
function getHeapSnapshot(): Readable;
|
183
|
+
/**
|
184
|
+
* Generates a snapshot of the current V8 heap and writes it to a JSON
|
185
|
+
* file. This file is intended to be used with tools such as Chrome
|
186
|
+
* DevTools. The JSON schema is undocumented and specific to the V8
|
187
|
+
* engine, and may change from one version of V8 to the next.
|
188
|
+
*
|
189
|
+
* A heap snapshot is specific to a single V8 isolate. When using `worker threads`, a heap snapshot generated from the main thread will
|
190
|
+
* not contain any information about the workers, and vice versa.
|
191
|
+
*
|
192
|
+
* Creating a heap snapshot requires memory about twice the size of the heap at
|
193
|
+
* the time the snapshot is created. This results in the risk of OOM killers
|
194
|
+
* terminating the process.
|
195
|
+
*
|
196
|
+
* Generating a snapshot is a synchronous operation which blocks the event loop
|
197
|
+
* for a duration depending on the heap size.
|
198
|
+
*
|
199
|
+
* ```js
|
200
|
+
* const { writeHeapSnapshot } = require('v8');
|
201
|
+
* const {
|
202
|
+
* Worker,
|
203
|
+
* isMainThread,
|
204
|
+
* parentPort
|
205
|
+
* } = require('worker_threads');
|
206
|
+
*
|
207
|
+
* if (isMainThread) {
|
208
|
+
* const worker = new Worker(__filename);
|
209
|
+
*
|
210
|
+
* worker.once('message', (filename) => {
|
211
|
+
* console.log(`worker heapdump: ${filename}`);
|
212
|
+
* // Now get a heapdump for the main thread.
|
213
|
+
* console.log(`main thread heapdump: ${writeHeapSnapshot()}`);
|
214
|
+
* });
|
215
|
+
*
|
216
|
+
* // Tell the worker to create a heapdump.
|
217
|
+
* worker.postMessage('heapdump');
|
218
|
+
* } else {
|
219
|
+
* parentPort.once('message', (message) => {
|
220
|
+
* if (message === 'heapdump') {
|
221
|
+
* // Generate a heapdump for the worker
|
222
|
+
* // and return the filename to the parent.
|
223
|
+
* parentPort.postMessage(writeHeapSnapshot());
|
224
|
+
* }
|
225
|
+
* });
|
226
|
+
* }
|
227
|
+
* ```
|
228
|
+
* @since v11.13.0
|
229
|
+
* @param filename The file path where the V8 heap snapshot is to be saved. If not specified, a file name with the pattern `'Heap-${yyyymmdd}-${hhmmss}-${pid}-${thread_id}.heapsnapshot'` will be
|
230
|
+
* generated, where `{pid}` will be the PID of the Node.js process, `{thread_id}` will be `0` when `writeHeapSnapshot()` is called from the main Node.js thread or the id of a
|
231
|
+
* worker thread.
|
232
|
+
* @return The filename where the snapshot was saved.
|
233
|
+
*/
|
234
|
+
function writeHeapSnapshot(filename?: string): string;
|
235
|
+
/**
|
236
|
+
* Returns an object with the following properties:
|
237
|
+
*
|
238
|
+
* ```js
|
239
|
+
* {
|
240
|
+
* code_and_metadata_size: 212208,
|
241
|
+
* bytecode_and_metadata_size: 161368,
|
242
|
+
* external_script_source_size: 1410794
|
243
|
+
* }
|
244
|
+
* ```
|
245
|
+
* @since v12.8.0
|
246
|
+
*/
|
247
|
+
function getHeapCodeStatistics(): HeapCodeStatistics;
|
248
|
+
/**
|
249
|
+
* @since v8.0.0
|
250
|
+
*/
|
251
|
+
class Serializer {
|
252
|
+
/**
|
253
|
+
* Writes out a header, which includes the serialization format version.
|
254
|
+
*/
|
255
|
+
writeHeader(): void;
|
256
|
+
/**
|
257
|
+
* Serializes a JavaScript value and adds the serialized representation to the
|
258
|
+
* internal buffer.
|
259
|
+
*
|
260
|
+
* This throws an error if `value` cannot be serialized.
|
261
|
+
*/
|
262
|
+
writeValue(val: any): boolean;
|
263
|
+
/**
|
264
|
+
* Returns the stored internal buffer. This serializer should not be used once
|
265
|
+
* the buffer is released. Calling this method results in undefined behavior
|
266
|
+
* if a previous write has failed.
|
267
|
+
*/
|
268
|
+
releaseBuffer(): Buffer;
|
269
|
+
/**
|
270
|
+
* Marks an `ArrayBuffer` as having its contents transferred out of band.
|
271
|
+
* Pass the corresponding `ArrayBuffer` in the deserializing context to `deserializer.transferArrayBuffer()`.
|
272
|
+
* @param id A 32-bit unsigned integer.
|
273
|
+
* @param arrayBuffer An `ArrayBuffer` instance.
|
274
|
+
*/
|
275
|
+
transferArrayBuffer(id: number, arrayBuffer: ArrayBuffer): void;
|
276
|
+
/**
|
277
|
+
* Write a raw 32-bit unsigned integer.
|
278
|
+
* For use inside of a custom `serializer._writeHostObject()`.
|
279
|
+
*/
|
280
|
+
writeUint32(value: number): void;
|
281
|
+
/**
|
282
|
+
* Write a raw 64-bit unsigned integer, split into high and low 32-bit parts.
|
283
|
+
* For use inside of a custom `serializer._writeHostObject()`.
|
284
|
+
*/
|
285
|
+
writeUint64(hi: number, lo: number): void;
|
286
|
+
/**
|
287
|
+
* Write a JS `number` value.
|
288
|
+
* For use inside of a custom `serializer._writeHostObject()`.
|
289
|
+
*/
|
290
|
+
writeDouble(value: number): void;
|
291
|
+
/**
|
292
|
+
* Write raw bytes into the serializer’s internal buffer. The deserializer
|
293
|
+
* will require a way to compute the length of the buffer.
|
294
|
+
* For use inside of a custom `serializer._writeHostObject()`.
|
295
|
+
*/
|
296
|
+
writeRawBytes(buffer: NodeJS.TypedArray): void;
|
297
|
+
}
|
298
|
+
/**
|
299
|
+
* A subclass of `Serializer` that serializes `TypedArray`(in particular `Buffer`) and `DataView` objects as host objects, and only
|
300
|
+
* stores the part of their underlying `ArrayBuffer`s that they are referring to.
|
301
|
+
* @since v8.0.0
|
302
|
+
*/
|
303
|
+
class DefaultSerializer extends Serializer {}
|
304
|
+
/**
|
305
|
+
* @since v8.0.0
|
306
|
+
*/
|
307
|
+
class Deserializer {
|
308
|
+
constructor(data: NodeJS.TypedArray);
|
309
|
+
/**
|
310
|
+
* Reads and validates a header (including the format version).
|
311
|
+
* May, for example, reject an invalid or unsupported wire format. In that case,
|
312
|
+
* an `Error` is thrown.
|
313
|
+
*/
|
314
|
+
readHeader(): boolean;
|
315
|
+
/**
|
316
|
+
* Deserializes a JavaScript value from the buffer and returns it.
|
317
|
+
*/
|
318
|
+
readValue(): any;
|
319
|
+
/**
|
320
|
+
* Marks an `ArrayBuffer` as having its contents transferred out of band.
|
321
|
+
* Pass the corresponding `ArrayBuffer` in the serializing context to `serializer.transferArrayBuffer()` (or return the `id` from `serializer._getSharedArrayBufferId()` in the case of
|
322
|
+
* `SharedArrayBuffer`s).
|
323
|
+
* @param id A 32-bit unsigned integer.
|
324
|
+
* @param arrayBuffer An `ArrayBuffer` instance.
|
325
|
+
*/
|
326
|
+
transferArrayBuffer(id: number, arrayBuffer: ArrayBuffer): void;
|
327
|
+
/**
|
328
|
+
* Reads the underlying wire format version. Likely mostly to be useful to
|
329
|
+
* legacy code reading old wire format versions. May not be called before`.readHeader()`.
|
330
|
+
*/
|
331
|
+
getWireFormatVersion(): number;
|
332
|
+
/**
|
333
|
+
* Read a raw 32-bit unsigned integer and return it.
|
334
|
+
* For use inside of a custom `deserializer._readHostObject()`.
|
335
|
+
*/
|
336
|
+
readUint32(): number;
|
337
|
+
/**
|
338
|
+
* Read a raw 64-bit unsigned integer and return it as an array `[hi, lo]`with two 32-bit unsigned integer entries.
|
339
|
+
* For use inside of a custom `deserializer._readHostObject()`.
|
340
|
+
*/
|
341
|
+
readUint64(): [number, number];
|
342
|
+
/**
|
343
|
+
* Read a JS `number` value.
|
344
|
+
* For use inside of a custom `deserializer._readHostObject()`.
|
345
|
+
*/
|
346
|
+
readDouble(): number;
|
347
|
+
/**
|
348
|
+
* Read raw bytes from the deserializer’s internal buffer. The `length` parameter
|
349
|
+
* must correspond to the length of the buffer that was passed to `serializer.writeRawBytes()`.
|
350
|
+
* For use inside of a custom `deserializer._readHostObject()`.
|
351
|
+
*/
|
352
|
+
readRawBytes(length: number): Buffer;
|
353
|
+
}
|
354
|
+
/**
|
355
|
+
* A subclass of `Deserializer` corresponding to the format written by `DefaultSerializer`.
|
356
|
+
* @since v8.0.0
|
357
|
+
*/
|
358
|
+
class DefaultDeserializer extends Deserializer {}
|
359
|
+
/**
|
360
|
+
* Uses a `DefaultSerializer` to serialize `value` into a buffer.
|
361
|
+
*
|
362
|
+
* `ERR_BUFFER_TOO_LARGE` will be thrown when trying to
|
363
|
+
* serialize a huge object which requires buffer
|
364
|
+
* larger than `buffer.constants.MAX_LENGTH`.
|
365
|
+
* @since v8.0.0
|
366
|
+
*/
|
367
|
+
function serialize(value: any): Buffer;
|
368
|
+
/**
|
369
|
+
* Uses a `DefaultDeserializer` with default options to read a JS value
|
370
|
+
* from a buffer.
|
371
|
+
* @since v8.0.0
|
372
|
+
* @param buffer A buffer returned by {@link serialize}.
|
373
|
+
*/
|
374
|
+
function deserialize(buffer: NodeJS.TypedArray): any;
|
375
|
+
/**
|
376
|
+
* The `v8.takeCoverage()` method allows the user to write the coverage started by `NODE_V8_COVERAGE` to disk on demand. This method can be invoked multiple
|
377
|
+
* times during the lifetime of the process. Each time the execution counter will
|
378
|
+
* be reset and a new coverage report will be written to the directory specified
|
379
|
+
* by `NODE_V8_COVERAGE`.
|
380
|
+
*
|
381
|
+
* When the process is about to exit, one last coverage will still be written to
|
382
|
+
* disk unless {@link stopCoverage} is invoked before the process exits.
|
383
|
+
* @since v15.1.0, v14.18.0, v12.22.0
|
384
|
+
*/
|
385
|
+
function takeCoverage(): void;
|
386
|
+
/**
|
387
|
+
* The `v8.stopCoverage()` method allows the user to stop the coverage collection
|
388
|
+
* started by `NODE_V8_COVERAGE`, so that V8 can release the execution count
|
389
|
+
* records and optimize code. This can be used in conjunction with {@link takeCoverage} if the user wants to collect the coverage on demand.
|
390
|
+
* @since v15.1.0, v14.18.0, v12.22.0
|
391
|
+
*/
|
392
|
+
function stopCoverage(): void;
|
393
|
+
}
|
394
|
+
declare module 'node:v8' {
|
395
|
+
export * from 'v8';
|
396
|
+
}
|