rahad-all-downloader 2.1.16 → 2.1.17
Sign up to get free protection for your applications and to get access to all the features.
- package/.github/workflows/Run.yml +20 -0
- package/README.md +0 -1
- package/index.js +1 -1
- package/package.json +4 -2
- package/.cache/nix/binary-cache-v6.sqlite +0 -0
- package/.cache/nix/binary-cache-v6.sqlite-journal +0 -0
- package/.cache/replit/env/latest +0 -123
- package/.cache/replit/env/latest.json +0 -1
- package/.cache/replit/modules/nix.res +0 -1
- package/.cache/replit/modules/nodejs-20.res +0 -1
- package/.cache/replit/modules/replit.res +0 -1
- package/.cache/replit/modules.stamp +0 -0
- package/.cache/replit/nix/env.json +0 -1
- package/.cache/typescript/5.4/node_modules/.package-lock.json +0 -137
- package/.cache/typescript/5.4/node_modules/@types/caseless/LICENSE +0 -21
- package/.cache/typescript/5.4/node_modules/@types/caseless/README.md +0 -48
- package/.cache/typescript/5.4/node_modules/@types/caseless/index.d.ts +0 -29
- package/.cache/typescript/5.4/node_modules/@types/caseless/package.json +0 -35
- package/.cache/typescript/5.4/node_modules/@types/node/LICENSE +0 -21
- package/.cache/typescript/5.4/node_modules/@types/node/README.md +0 -15
- package/.cache/typescript/5.4/node_modules/@types/node/assert/strict.d.ts +0 -8
- package/.cache/typescript/5.4/node_modules/@types/node/assert.d.ts +0 -1040
- package/.cache/typescript/5.4/node_modules/@types/node/async_hooks.d.ts +0 -541
- package/.cache/typescript/5.4/node_modules/@types/node/buffer.d.ts +0 -2363
- package/.cache/typescript/5.4/node_modules/@types/node/child_process.d.ts +0 -1544
- package/.cache/typescript/5.4/node_modules/@types/node/cluster.d.ts +0 -578
- package/.cache/typescript/5.4/node_modules/@types/node/console.d.ts +0 -452
- package/.cache/typescript/5.4/node_modules/@types/node/constants.d.ts +0 -19
- package/.cache/typescript/5.4/node_modules/@types/node/crypto.d.ts +0 -4523
- package/.cache/typescript/5.4/node_modules/@types/node/dgram.d.ts +0 -596
- package/.cache/typescript/5.4/node_modules/@types/node/diagnostics_channel.d.ts +0 -554
- package/.cache/typescript/5.4/node_modules/@types/node/dns/promises.d.ts +0 -474
- package/.cache/typescript/5.4/node_modules/@types/node/dns.d.ts +0 -864
- package/.cache/typescript/5.4/node_modules/@types/node/dom-events.d.ts +0 -124
- package/.cache/typescript/5.4/node_modules/@types/node/domain.d.ts +0 -170
- package/.cache/typescript/5.4/node_modules/@types/node/events.d.ts +0 -909
- package/.cache/typescript/5.4/node_modules/@types/node/fs/promises.d.ts +0 -1245
- package/.cache/typescript/5.4/node_modules/@types/node/fs.d.ts +0 -4317
- package/.cache/typescript/5.4/node_modules/@types/node/globals.d.ts +0 -411
- package/.cache/typescript/5.4/node_modules/@types/node/globals.global.d.ts +0 -1
- package/.cache/typescript/5.4/node_modules/@types/node/http.d.ts +0 -1908
- package/.cache/typescript/5.4/node_modules/@types/node/http2.d.ts +0 -2418
- package/.cache/typescript/5.4/node_modules/@types/node/https.d.ts +0 -550
- package/.cache/typescript/5.4/node_modules/@types/node/index.d.ts +0 -89
- package/.cache/typescript/5.4/node_modules/@types/node/inspector.d.ts +0 -2746
- package/.cache/typescript/5.4/node_modules/@types/node/module.d.ts +0 -315
- package/.cache/typescript/5.4/node_modules/@types/node/net.d.ts +0 -999
- package/.cache/typescript/5.4/node_modules/@types/node/os.d.ts +0 -495
- package/.cache/typescript/5.4/node_modules/@types/node/package.json +0 -217
- package/.cache/typescript/5.4/node_modules/@types/node/path.d.ts +0 -191
- package/.cache/typescript/5.4/node_modules/@types/node/perf_hooks.d.ts +0 -905
- package/.cache/typescript/5.4/node_modules/@types/node/process.d.ts +0 -1754
- package/.cache/typescript/5.4/node_modules/@types/node/punycode.d.ts +0 -117
- package/.cache/typescript/5.4/node_modules/@types/node/querystring.d.ts +0 -153
- package/.cache/typescript/5.4/node_modules/@types/node/readline/promises.d.ts +0 -150
- package/.cache/typescript/5.4/node_modules/@types/node/readline.d.ts +0 -540
- package/.cache/typescript/5.4/node_modules/@types/node/repl.d.ts +0 -430
- package/.cache/typescript/5.4/node_modules/@types/node/sea.d.ts +0 -153
- package/.cache/typescript/5.4/node_modules/@types/node/stream/consumers.d.ts +0 -12
- package/.cache/typescript/5.4/node_modules/@types/node/stream/promises.d.ts +0 -83
- package/.cache/typescript/5.4/node_modules/@types/node/stream/web.d.ts +0 -367
- package/.cache/typescript/5.4/node_modules/@types/node/stream.d.ts +0 -1707
- package/.cache/typescript/5.4/node_modules/@types/node/string_decoder.d.ts +0 -67
- package/.cache/typescript/5.4/node_modules/@types/node/test.d.ts +0 -1718
- package/.cache/typescript/5.4/node_modules/@types/node/timers/promises.d.ts +0 -97
- package/.cache/typescript/5.4/node_modules/@types/node/timers.d.ts +0 -240
- package/.cache/typescript/5.4/node_modules/@types/node/tls.d.ts +0 -1217
- package/.cache/typescript/5.4/node_modules/@types/node/trace_events.d.ts +0 -197
- package/.cache/typescript/5.4/node_modules/@types/node/tty.d.ts +0 -208
- package/.cache/typescript/5.4/node_modules/@types/node/url.d.ts +0 -952
- package/.cache/typescript/5.4/node_modules/@types/node/util.d.ts +0 -2292
- package/.cache/typescript/5.4/node_modules/@types/node/v8.d.ts +0 -808
- package/.cache/typescript/5.4/node_modules/@types/node/vm.d.ts +0 -924
- package/.cache/typescript/5.4/node_modules/@types/node/wasi.d.ts +0 -181
- package/.cache/typescript/5.4/node_modules/@types/node/worker_threads.d.ts +0 -691
- package/.cache/typescript/5.4/node_modules/@types/node/zlib.d.ts +0 -530
- package/.cache/typescript/5.4/node_modules/@types/node-fetch/LICENSE +0 -21
- package/.cache/typescript/5.4/node_modules/@types/node-fetch/README.md +0 -15
- package/.cache/typescript/5.4/node_modules/@types/node-fetch/externals.d.ts +0 -32
- package/.cache/typescript/5.4/node_modules/@types/node-fetch/index.d.ts +0 -238
- package/.cache/typescript/5.4/node_modules/@types/node-fetch/package.json +0 -83
- package/.cache/typescript/5.4/node_modules/@types/request/LICENSE +0 -21
- package/.cache/typescript/5.4/node_modules/@types/request/README.md +0 -15
- package/.cache/typescript/5.4/node_modules/@types/request/index.d.ts +0 -395
- package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/License +0 -19
- package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/README.md +0 -350
- package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/README.md.bak +0 -350
- package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/index.d.ts +0 -51
- package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/lib/browser.js +0 -2
- package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/lib/form_data.js +0 -483
- package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/lib/populate.js +0 -10
- package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/package.json +0 -68
- package/.cache/typescript/5.4/node_modules/@types/request/package.json +0 -70
- package/.cache/typescript/5.4/node_modules/@types/tough-cookie/LICENSE +0 -21
- package/.cache/typescript/5.4/node_modules/@types/tough-cookie/README.md +0 -15
- package/.cache/typescript/5.4/node_modules/@types/tough-cookie/index.d.ts +0 -321
- package/.cache/typescript/5.4/node_modules/@types/tough-cookie/package.json +0 -35
- package/.cache/typescript/5.4/node_modules/asynckit/LICENSE +0 -21
- package/.cache/typescript/5.4/node_modules/asynckit/README.md +0 -233
- package/.cache/typescript/5.4/node_modules/asynckit/bench.js +0 -76
- package/.cache/typescript/5.4/node_modules/asynckit/index.js +0 -6
- package/.cache/typescript/5.4/node_modules/asynckit/lib/abort.js +0 -29
- package/.cache/typescript/5.4/node_modules/asynckit/lib/async.js +0 -34
- package/.cache/typescript/5.4/node_modules/asynckit/lib/defer.js +0 -26
- package/.cache/typescript/5.4/node_modules/asynckit/lib/iterate.js +0 -75
- package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_asynckit.js +0 -91
- package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_parallel.js +0 -25
- package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_serial.js +0 -25
- package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_serial_ordered.js +0 -29
- package/.cache/typescript/5.4/node_modules/asynckit/lib/state.js +0 -37
- package/.cache/typescript/5.4/node_modules/asynckit/lib/streamify.js +0 -141
- package/.cache/typescript/5.4/node_modules/asynckit/lib/terminator.js +0 -29
- package/.cache/typescript/5.4/node_modules/asynckit/package.json +0 -63
- package/.cache/typescript/5.4/node_modules/asynckit/parallel.js +0 -43
- package/.cache/typescript/5.4/node_modules/asynckit/serial.js +0 -17
- package/.cache/typescript/5.4/node_modules/asynckit/serialOrdered.js +0 -75
- package/.cache/typescript/5.4/node_modules/asynckit/stream.js +0 -21
- package/.cache/typescript/5.4/node_modules/combined-stream/License +0 -19
- package/.cache/typescript/5.4/node_modules/combined-stream/Readme.md +0 -138
- package/.cache/typescript/5.4/node_modules/combined-stream/lib/combined_stream.js +0 -208
- package/.cache/typescript/5.4/node_modules/combined-stream/package.json +0 -25
- package/.cache/typescript/5.4/node_modules/combined-stream/yarn.lock +0 -17
- package/.cache/typescript/5.4/node_modules/delayed-stream/License +0 -19
- package/.cache/typescript/5.4/node_modules/delayed-stream/Makefile +0 -7
- package/.cache/typescript/5.4/node_modules/delayed-stream/Readme.md +0 -141
- package/.cache/typescript/5.4/node_modules/delayed-stream/lib/delayed_stream.js +0 -107
- package/.cache/typescript/5.4/node_modules/delayed-stream/package.json +0 -27
- package/.cache/typescript/5.4/node_modules/form-data/License +0 -19
- package/.cache/typescript/5.4/node_modules/form-data/README.md.bak +0 -358
- package/.cache/typescript/5.4/node_modules/form-data/Readme.md +0 -358
- package/.cache/typescript/5.4/node_modules/form-data/index.d.ts +0 -62
- package/.cache/typescript/5.4/node_modules/form-data/lib/browser.js +0 -2
- package/.cache/typescript/5.4/node_modules/form-data/lib/form_data.js +0 -501
- package/.cache/typescript/5.4/node_modules/form-data/lib/populate.js +0 -10
- package/.cache/typescript/5.4/node_modules/form-data/package.json +0 -68
- package/.cache/typescript/5.4/node_modules/mime-db/HISTORY.md +0 -507
- package/.cache/typescript/5.4/node_modules/mime-db/LICENSE +0 -23
- package/.cache/typescript/5.4/node_modules/mime-db/README.md +0 -100
- package/.cache/typescript/5.4/node_modules/mime-db/db.json +0 -8519
- package/.cache/typescript/5.4/node_modules/mime-db/index.js +0 -12
- package/.cache/typescript/5.4/node_modules/mime-db/package.json +0 -60
- package/.cache/typescript/5.4/node_modules/mime-types/HISTORY.md +0 -397
- package/.cache/typescript/5.4/node_modules/mime-types/LICENSE +0 -23
- package/.cache/typescript/5.4/node_modules/mime-types/README.md +0 -113
- package/.cache/typescript/5.4/node_modules/mime-types/index.js +0 -188
- package/.cache/typescript/5.4/node_modules/mime-types/package.json +0 -44
- package/.cache/typescript/5.4/node_modules/types-registry/README.md +0 -2
- package/.cache/typescript/5.4/node_modules/types-registry/index.json +0 -1
- package/.cache/typescript/5.4/node_modules/types-registry/package.json +0 -20
- package/.cache/typescript/5.4/node_modules/undici-types/README.md +0 -6
- package/.cache/typescript/5.4/node_modules/undici-types/agent.d.ts +0 -31
- package/.cache/typescript/5.4/node_modules/undici-types/api.d.ts +0 -43
- package/.cache/typescript/5.4/node_modules/undici-types/balanced-pool.d.ts +0 -18
- package/.cache/typescript/5.4/node_modules/undici-types/cache.d.ts +0 -36
- package/.cache/typescript/5.4/node_modules/undici-types/client.d.ts +0 -97
- package/.cache/typescript/5.4/node_modules/undici-types/connector.d.ts +0 -34
- package/.cache/typescript/5.4/node_modules/undici-types/content-type.d.ts +0 -21
- package/.cache/typescript/5.4/node_modules/undici-types/cookies.d.ts +0 -28
- package/.cache/typescript/5.4/node_modules/undici-types/diagnostics-channel.d.ts +0 -67
- package/.cache/typescript/5.4/node_modules/undici-types/dispatcher.d.ts +0 -241
- package/.cache/typescript/5.4/node_modules/undici-types/errors.d.ts +0 -128
- package/.cache/typescript/5.4/node_modules/undici-types/fetch.d.ts +0 -209
- package/.cache/typescript/5.4/node_modules/undici-types/file.d.ts +0 -39
- package/.cache/typescript/5.4/node_modules/undici-types/filereader.d.ts +0 -54
- package/.cache/typescript/5.4/node_modules/undici-types/formdata.d.ts +0 -108
- package/.cache/typescript/5.4/node_modules/undici-types/global-dispatcher.d.ts +0 -9
- package/.cache/typescript/5.4/node_modules/undici-types/global-origin.d.ts +0 -7
- package/.cache/typescript/5.4/node_modules/undici-types/handlers.d.ts +0 -9
- package/.cache/typescript/5.4/node_modules/undici-types/header.d.ts +0 -4
- package/.cache/typescript/5.4/node_modules/undici-types/index.d.ts +0 -63
- package/.cache/typescript/5.4/node_modules/undici-types/interceptors.d.ts +0 -5
- package/.cache/typescript/5.4/node_modules/undici-types/mock-agent.d.ts +0 -50
- package/.cache/typescript/5.4/node_modules/undici-types/mock-client.d.ts +0 -25
- package/.cache/typescript/5.4/node_modules/undici-types/mock-errors.d.ts +0 -12
- package/.cache/typescript/5.4/node_modules/undici-types/mock-interceptor.d.ts +0 -93
- package/.cache/typescript/5.4/node_modules/undici-types/mock-pool.d.ts +0 -25
- package/.cache/typescript/5.4/node_modules/undici-types/package.json +0 -55
- package/.cache/typescript/5.4/node_modules/undici-types/patch.d.ts +0 -71
- package/.cache/typescript/5.4/node_modules/undici-types/pool-stats.d.ts +0 -19
- package/.cache/typescript/5.4/node_modules/undici-types/pool.d.ts +0 -28
- package/.cache/typescript/5.4/node_modules/undici-types/proxy-agent.d.ts +0 -30
- package/.cache/typescript/5.4/node_modules/undici-types/readable.d.ts +0 -61
- package/.cache/typescript/5.4/node_modules/undici-types/webidl.d.ts +0 -220
- package/.cache/typescript/5.4/node_modules/undici-types/websocket.d.ts +0 -131
- package/.cache/typescript/5.4/package-lock.json +0 -146
- package/.cache/typescript/5.4/package.json +0 -1
- package/.replit +0 -21
- package/replit.nix +0 -3
@@ -1,808 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* The `node: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('node:v8');
|
6
|
-
* ```
|
7
|
-
* @see [source](https://github.com/nodejs/node/blob/v20.13.1/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
|
-
total_global_handles_size: number;
|
33
|
-
used_global_handles_size: number;
|
34
|
-
external_memory: number;
|
35
|
-
}
|
36
|
-
interface HeapCodeStatistics {
|
37
|
-
code_and_metadata_size: number;
|
38
|
-
bytecode_and_metadata_size: number;
|
39
|
-
external_script_source_size: number;
|
40
|
-
}
|
41
|
-
interface HeapSnapshotOptions {
|
42
|
-
/**
|
43
|
-
* If true, expose internals in the heap snapshot.
|
44
|
-
* @default false
|
45
|
-
*/
|
46
|
-
exposeInternals?: boolean;
|
47
|
-
/**
|
48
|
-
* If true, expose numeric values in artificial fields.
|
49
|
-
* @default false
|
50
|
-
*/
|
51
|
-
exposeNumericValues?: boolean;
|
52
|
-
}
|
53
|
-
/**
|
54
|
-
* Returns an integer representing a version tag derived from the V8 version,
|
55
|
-
* command-line flags, and detected CPU features. This is useful for determining
|
56
|
-
* whether a `vm.Script` `cachedData` buffer is compatible with this instance
|
57
|
-
* of V8.
|
58
|
-
*
|
59
|
-
* ```js
|
60
|
-
* console.log(v8.cachedDataVersionTag()); // 3947234607
|
61
|
-
* // The value returned by v8.cachedDataVersionTag() is derived from the V8
|
62
|
-
* // version, command-line flags, and detected CPU features. Test that the value
|
63
|
-
* // does indeed update when flags are toggled.
|
64
|
-
* v8.setFlagsFromString('--allow_natives_syntax');
|
65
|
-
* console.log(v8.cachedDataVersionTag()); // 183726201
|
66
|
-
* ```
|
67
|
-
* @since v8.0.0
|
68
|
-
*/
|
69
|
-
function cachedDataVersionTag(): number;
|
70
|
-
/**
|
71
|
-
* Returns an object with the following properties:
|
72
|
-
*
|
73
|
-
* `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
|
74
|
-
* garbage with a bit pattern. The RSS footprint (resident set size) gets bigger
|
75
|
-
* because it continuously touches all heap pages and that makes them less likely
|
76
|
-
* to get swapped out by the operating system.
|
77
|
-
*
|
78
|
-
* `number_of_native_contexts` The value of native\_context is the number of the
|
79
|
-
* top-level contexts currently active. Increase of this number over time indicates
|
80
|
-
* a memory leak.
|
81
|
-
*
|
82
|
-
* `number_of_detached_contexts` The value of detached\_context is the number
|
83
|
-
* of contexts that were detached and not yet garbage collected. This number
|
84
|
-
* being non-zero indicates a potential memory leak.
|
85
|
-
*
|
86
|
-
* `total_global_handles_size` The value of total\_global\_handles\_size is the
|
87
|
-
* total memory size of V8 global handles.
|
88
|
-
*
|
89
|
-
* `used_global_handles_size` The value of used\_global\_handles\_size is the
|
90
|
-
* used memory size of V8 global handles.
|
91
|
-
*
|
92
|
-
* `external_memory` The value of external\_memory is the memory size of array
|
93
|
-
* buffers and external strings.
|
94
|
-
*
|
95
|
-
* ```js
|
96
|
-
* {
|
97
|
-
* total_heap_size: 7326976,
|
98
|
-
* total_heap_size_executable: 4194304,
|
99
|
-
* total_physical_size: 7326976,
|
100
|
-
* total_available_size: 1152656,
|
101
|
-
* used_heap_size: 3476208,
|
102
|
-
* heap_size_limit: 1535115264,
|
103
|
-
* malloced_memory: 16384,
|
104
|
-
* peak_malloced_memory: 1127496,
|
105
|
-
* does_zap_garbage: 0,
|
106
|
-
* number_of_native_contexts: 1,
|
107
|
-
* number_of_detached_contexts: 0,
|
108
|
-
* total_global_handles_size: 8192,
|
109
|
-
* used_global_handles_size: 3296,
|
110
|
-
* external_memory: 318824
|
111
|
-
* }
|
112
|
-
* ```
|
113
|
-
* @since v1.0.0
|
114
|
-
*/
|
115
|
-
function getHeapStatistics(): HeapInfo;
|
116
|
-
/**
|
117
|
-
* Returns statistics about the V8 heap spaces, i.e. the segments which make up
|
118
|
-
* the V8 heap. Neither the ordering of heap spaces, nor the availability of a
|
119
|
-
* heap space can be guaranteed as the statistics are provided via the
|
120
|
-
* 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
|
121
|
-
* next.
|
122
|
-
*
|
123
|
-
* The value returned is an array of objects containing the following properties:
|
124
|
-
*
|
125
|
-
* ```json
|
126
|
-
* [
|
127
|
-
* {
|
128
|
-
* "space_name": "new_space",
|
129
|
-
* "space_size": 2063872,
|
130
|
-
* "space_used_size": 951112,
|
131
|
-
* "space_available_size": 80824,
|
132
|
-
* "physical_space_size": 2063872
|
133
|
-
* },
|
134
|
-
* {
|
135
|
-
* "space_name": "old_space",
|
136
|
-
* "space_size": 3090560,
|
137
|
-
* "space_used_size": 2493792,
|
138
|
-
* "space_available_size": 0,
|
139
|
-
* "physical_space_size": 3090560
|
140
|
-
* },
|
141
|
-
* {
|
142
|
-
* "space_name": "code_space",
|
143
|
-
* "space_size": 1260160,
|
144
|
-
* "space_used_size": 644256,
|
145
|
-
* "space_available_size": 960,
|
146
|
-
* "physical_space_size": 1260160
|
147
|
-
* },
|
148
|
-
* {
|
149
|
-
* "space_name": "map_space",
|
150
|
-
* "space_size": 1094160,
|
151
|
-
* "space_used_size": 201608,
|
152
|
-
* "space_available_size": 0,
|
153
|
-
* "physical_space_size": 1094160
|
154
|
-
* },
|
155
|
-
* {
|
156
|
-
* "space_name": "large_object_space",
|
157
|
-
* "space_size": 0,
|
158
|
-
* "space_used_size": 0,
|
159
|
-
* "space_available_size": 1490980608,
|
160
|
-
* "physical_space_size": 0
|
161
|
-
* }
|
162
|
-
* ]
|
163
|
-
* ```
|
164
|
-
* @since v6.0.0
|
165
|
-
*/
|
166
|
-
function getHeapSpaceStatistics(): HeapSpaceInfo[];
|
167
|
-
/**
|
168
|
-
* The `v8.setFlagsFromString()` method can be used to programmatically set
|
169
|
-
* V8 command-line flags. This method should be used with care. Changing settings
|
170
|
-
* after the VM has started may result in unpredictable behavior, including
|
171
|
-
* crashes and data loss; or it may simply do nothing.
|
172
|
-
*
|
173
|
-
* The V8 options available for a version of Node.js may be determined by running `node --v8-options`.
|
174
|
-
*
|
175
|
-
* Usage:
|
176
|
-
*
|
177
|
-
* ```js
|
178
|
-
* // Print GC events to stdout for one minute.
|
179
|
-
* const v8 = require('node:v8');
|
180
|
-
* v8.setFlagsFromString('--trace_gc');
|
181
|
-
* setTimeout(() => { v8.setFlagsFromString('--notrace_gc'); }, 60e3);
|
182
|
-
* ```
|
183
|
-
* @since v1.0.0
|
184
|
-
*/
|
185
|
-
function setFlagsFromString(flags: string): void;
|
186
|
-
/**
|
187
|
-
* This is similar to the [`queryObjects()` console API](https://developer.chrome.com/docs/devtools/console/utilities#queryObjects-function)
|
188
|
-
* provided by the Chromium DevTools console. It can be used to search for objects that have the matching constructor on its prototype chain
|
189
|
-
* in the heap after a full garbage collection, which can be useful for memory leak regression tests. To avoid surprising results, users should
|
190
|
-
* avoid using this API on constructors whose implementation they don't control, or on constructors that can be invoked by other parties in the
|
191
|
-
* application.
|
192
|
-
*
|
193
|
-
* To avoid accidental leaks, this API does not return raw references to the objects found. By default, it returns the count of the objects
|
194
|
-
* found. If `options.format` is `'summary'`, it returns an array containing brief string representations for each object. The visibility provided
|
195
|
-
* in this API is similar to what the heap snapshot provides, while users can save the cost of serialization and parsing and directly filter the
|
196
|
-
* target objects during the search.
|
197
|
-
*
|
198
|
-
* Only objects created in the current execution context are included in the results.
|
199
|
-
*
|
200
|
-
* ```js
|
201
|
-
* import { queryObjects } from 'node:v8';
|
202
|
-
* class A { foo = 'bar'; }
|
203
|
-
* console.log(queryObjects(A)); // 0
|
204
|
-
* const a = new A();
|
205
|
-
* console.log(queryObjects(A)); // 1
|
206
|
-
* // [ "A { foo: 'bar' }" ]
|
207
|
-
* console.log(queryObjects(A, { format: 'summary' }));
|
208
|
-
*
|
209
|
-
* class B extends A { bar = 'qux'; }
|
210
|
-
* const b = new B();
|
211
|
-
* console.log(queryObjects(B)); // 1
|
212
|
-
* // [ "B { foo: 'bar', bar: 'qux' }" ]
|
213
|
-
* console.log(queryObjects(B, { format: 'summary' }));
|
214
|
-
*
|
215
|
-
* // Note that, when there are child classes inheriting from a constructor,
|
216
|
-
* // the constructor also shows up in the prototype chain of the child
|
217
|
-
* // classes's prototoype, so the child classes's prototoype would also be
|
218
|
-
* // included in the result.
|
219
|
-
* console.log(queryObjects(A)); // 3
|
220
|
-
* // [ "B { foo: 'bar', bar: 'qux' }", 'A {}', "A { foo: 'bar' }" ]
|
221
|
-
* console.log(queryObjects(A, { format: 'summary' }));
|
222
|
-
* ```
|
223
|
-
* @param ctor The constructor that can be used to search on the prototype chain in order to filter target objects in the heap.
|
224
|
-
* @since v20.13.0
|
225
|
-
* @experimental
|
226
|
-
*/
|
227
|
-
function queryObjects(ctor: Function): number | string[];
|
228
|
-
function queryObjects(ctor: Function, options: { format: "count" }): number;
|
229
|
-
function queryObjects(ctor: Function, options: { format: "summary" }): string[];
|
230
|
-
/**
|
231
|
-
* Generates a snapshot of the current V8 heap and returns a Readable
|
232
|
-
* Stream that may be used to read the JSON serialized representation.
|
233
|
-
* This JSON stream format is intended to be used with tools such as
|
234
|
-
* Chrome DevTools. The JSON schema is undocumented and specific to the
|
235
|
-
* V8 engine. Therefore, the schema may change from one version of V8 to the next.
|
236
|
-
*
|
237
|
-
* Creating a heap snapshot requires memory about twice the size of the heap at
|
238
|
-
* the time the snapshot is created. This results in the risk of OOM killers
|
239
|
-
* terminating the process.
|
240
|
-
*
|
241
|
-
* Generating a snapshot is a synchronous operation which blocks the event loop
|
242
|
-
* for a duration depending on the heap size.
|
243
|
-
*
|
244
|
-
* ```js
|
245
|
-
* // Print heap snapshot to the console
|
246
|
-
* const v8 = require('node:v8');
|
247
|
-
* const stream = v8.getHeapSnapshot();
|
248
|
-
* stream.pipe(process.stdout);
|
249
|
-
* ```
|
250
|
-
* @since v11.13.0
|
251
|
-
* @return A Readable containing the V8 heap snapshot.
|
252
|
-
*/
|
253
|
-
function getHeapSnapshot(options?: HeapSnapshotOptions): Readable;
|
254
|
-
/**
|
255
|
-
* Generates a snapshot of the current V8 heap and writes it to a JSON
|
256
|
-
* file. This file is intended to be used with tools such as Chrome
|
257
|
-
* DevTools. The JSON schema is undocumented and specific to the V8
|
258
|
-
* engine, and may change from one version of V8 to the next.
|
259
|
-
*
|
260
|
-
* A heap snapshot is specific to a single V8 isolate. When using `worker threads`, a heap snapshot generated from the main thread will
|
261
|
-
* not contain any information about the workers, and vice versa.
|
262
|
-
*
|
263
|
-
* Creating a heap snapshot requires memory about twice the size of the heap at
|
264
|
-
* the time the snapshot is created. This results in the risk of OOM killers
|
265
|
-
* terminating the process.
|
266
|
-
*
|
267
|
-
* Generating a snapshot is a synchronous operation which blocks the event loop
|
268
|
-
* for a duration depending on the heap size.
|
269
|
-
*
|
270
|
-
* ```js
|
271
|
-
* const { writeHeapSnapshot } = require('node:v8');
|
272
|
-
* const {
|
273
|
-
* Worker,
|
274
|
-
* isMainThread,
|
275
|
-
* parentPort,
|
276
|
-
* } = require('node:worker_threads');
|
277
|
-
*
|
278
|
-
* if (isMainThread) {
|
279
|
-
* const worker = new Worker(__filename);
|
280
|
-
*
|
281
|
-
* worker.once('message', (filename) => {
|
282
|
-
* console.log(`worker heapdump: ${filename}`);
|
283
|
-
* // Now get a heapdump for the main thread.
|
284
|
-
* console.log(`main thread heapdump: ${writeHeapSnapshot()}`);
|
285
|
-
* });
|
286
|
-
*
|
287
|
-
* // Tell the worker to create a heapdump.
|
288
|
-
* worker.postMessage('heapdump');
|
289
|
-
* } else {
|
290
|
-
* parentPort.once('message', (message) => {
|
291
|
-
* if (message === 'heapdump') {
|
292
|
-
* // Generate a heapdump for the worker
|
293
|
-
* // and return the filename to the parent.
|
294
|
-
* parentPort.postMessage(writeHeapSnapshot());
|
295
|
-
* }
|
296
|
-
* });
|
297
|
-
* }
|
298
|
-
* ```
|
299
|
-
* @since v11.13.0
|
300
|
-
* @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
|
301
|
-
* 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
|
302
|
-
* worker thread.
|
303
|
-
* @return The filename where the snapshot was saved.
|
304
|
-
*/
|
305
|
-
function writeHeapSnapshot(filename?: string, options?: HeapSnapshotOptions): string;
|
306
|
-
/**
|
307
|
-
* Get statistics about code and its metadata in the heap, see
|
308
|
-
* V8 [`GetHeapCodeAndMetadataStatistics`](https://v8docs.nodesource.com/node-13.2/d5/dda/classv8_1_1_isolate.html#a6079122af17612ef54ef3348ce170866) API. Returns an object with the
|
309
|
-
* following properties:
|
310
|
-
*
|
311
|
-
* ```js
|
312
|
-
* {
|
313
|
-
* code_and_metadata_size: 212208,
|
314
|
-
* bytecode_and_metadata_size: 161368,
|
315
|
-
* external_script_source_size: 1410794,
|
316
|
-
* cpu_profiler_metadata_size: 0,
|
317
|
-
* }
|
318
|
-
* ```
|
319
|
-
* @since v12.8.0
|
320
|
-
*/
|
321
|
-
function getHeapCodeStatistics(): HeapCodeStatistics;
|
322
|
-
/**
|
323
|
-
* @since v8.0.0
|
324
|
-
*/
|
325
|
-
class Serializer {
|
326
|
-
/**
|
327
|
-
* Writes out a header, which includes the serialization format version.
|
328
|
-
*/
|
329
|
-
writeHeader(): void;
|
330
|
-
/**
|
331
|
-
* Serializes a JavaScript value and adds the serialized representation to the
|
332
|
-
* internal buffer.
|
333
|
-
*
|
334
|
-
* This throws an error if `value` cannot be serialized.
|
335
|
-
*/
|
336
|
-
writeValue(val: any): boolean;
|
337
|
-
/**
|
338
|
-
* Returns the stored internal buffer. This serializer should not be used once
|
339
|
-
* the buffer is released. Calling this method results in undefined behavior
|
340
|
-
* if a previous write has failed.
|
341
|
-
*/
|
342
|
-
releaseBuffer(): Buffer;
|
343
|
-
/**
|
344
|
-
* Marks an `ArrayBuffer` as having its contents transferred out of band.
|
345
|
-
* Pass the corresponding `ArrayBuffer` in the deserializing context to `deserializer.transferArrayBuffer()`.
|
346
|
-
* @param id A 32-bit unsigned integer.
|
347
|
-
* @param arrayBuffer An `ArrayBuffer` instance.
|
348
|
-
*/
|
349
|
-
transferArrayBuffer(id: number, arrayBuffer: ArrayBuffer): void;
|
350
|
-
/**
|
351
|
-
* Write a raw 32-bit unsigned integer.
|
352
|
-
* For use inside of a custom `serializer._writeHostObject()`.
|
353
|
-
*/
|
354
|
-
writeUint32(value: number): void;
|
355
|
-
/**
|
356
|
-
* Write a raw 64-bit unsigned integer, split into high and low 32-bit parts.
|
357
|
-
* For use inside of a custom `serializer._writeHostObject()`.
|
358
|
-
*/
|
359
|
-
writeUint64(hi: number, lo: number): void;
|
360
|
-
/**
|
361
|
-
* Write a JS `number` value.
|
362
|
-
* For use inside of a custom `serializer._writeHostObject()`.
|
363
|
-
*/
|
364
|
-
writeDouble(value: number): void;
|
365
|
-
/**
|
366
|
-
* Write raw bytes into the serializer's internal buffer. The deserializer
|
367
|
-
* will require a way to compute the length of the buffer.
|
368
|
-
* For use inside of a custom `serializer._writeHostObject()`.
|
369
|
-
*/
|
370
|
-
writeRawBytes(buffer: NodeJS.TypedArray): void;
|
371
|
-
}
|
372
|
-
/**
|
373
|
-
* A subclass of `Serializer` that serializes `TypedArray`(in particular `Buffer`) and `DataView` objects as host objects, and only
|
374
|
-
* stores the part of their underlying `ArrayBuffer`s that they are referring to.
|
375
|
-
* @since v8.0.0
|
376
|
-
*/
|
377
|
-
class DefaultSerializer extends Serializer {}
|
378
|
-
/**
|
379
|
-
* @since v8.0.0
|
380
|
-
*/
|
381
|
-
class Deserializer {
|
382
|
-
constructor(data: NodeJS.TypedArray);
|
383
|
-
/**
|
384
|
-
* Reads and validates a header (including the format version).
|
385
|
-
* May, for example, reject an invalid or unsupported wire format. In that case,
|
386
|
-
* an `Error` is thrown.
|
387
|
-
*/
|
388
|
-
readHeader(): boolean;
|
389
|
-
/**
|
390
|
-
* Deserializes a JavaScript value from the buffer and returns it.
|
391
|
-
*/
|
392
|
-
readValue(): any;
|
393
|
-
/**
|
394
|
-
* Marks an `ArrayBuffer` as having its contents transferred out of band.
|
395
|
-
* Pass the corresponding `ArrayBuffer` in the serializing context to `serializer.transferArrayBuffer()` (or return the `id` from `serializer._getSharedArrayBufferId()` in the case of
|
396
|
-
* `SharedArrayBuffer`s).
|
397
|
-
* @param id A 32-bit unsigned integer.
|
398
|
-
* @param arrayBuffer An `ArrayBuffer` instance.
|
399
|
-
*/
|
400
|
-
transferArrayBuffer(id: number, arrayBuffer: ArrayBuffer): void;
|
401
|
-
/**
|
402
|
-
* Reads the underlying wire format version. Likely mostly to be useful to
|
403
|
-
* legacy code reading old wire format versions. May not be called before `.readHeader()`.
|
404
|
-
*/
|
405
|
-
getWireFormatVersion(): number;
|
406
|
-
/**
|
407
|
-
* Read a raw 32-bit unsigned integer and return it.
|
408
|
-
* For use inside of a custom `deserializer._readHostObject()`.
|
409
|
-
*/
|
410
|
-
readUint32(): number;
|
411
|
-
/**
|
412
|
-
* Read a raw 64-bit unsigned integer and return it as an array `[hi, lo]` with two 32-bit unsigned integer entries.
|
413
|
-
* For use inside of a custom `deserializer._readHostObject()`.
|
414
|
-
*/
|
415
|
-
readUint64(): [number, number];
|
416
|
-
/**
|
417
|
-
* Read a JS `number` value.
|
418
|
-
* For use inside of a custom `deserializer._readHostObject()`.
|
419
|
-
*/
|
420
|
-
readDouble(): number;
|
421
|
-
/**
|
422
|
-
* Read raw bytes from the deserializer's internal buffer. The `length` parameter
|
423
|
-
* must correspond to the length of the buffer that was passed to `serializer.writeRawBytes()`.
|
424
|
-
* For use inside of a custom `deserializer._readHostObject()`.
|
425
|
-
*/
|
426
|
-
readRawBytes(length: number): Buffer;
|
427
|
-
}
|
428
|
-
/**
|
429
|
-
* A subclass of `Deserializer` corresponding to the format written by `DefaultSerializer`.
|
430
|
-
* @since v8.0.0
|
431
|
-
*/
|
432
|
-
class DefaultDeserializer extends Deserializer {}
|
433
|
-
/**
|
434
|
-
* Uses a `DefaultSerializer` to serialize `value` into a buffer.
|
435
|
-
*
|
436
|
-
* `ERR_BUFFER_TOO_LARGE` will be thrown when trying to
|
437
|
-
* serialize a huge object which requires buffer
|
438
|
-
* larger than `buffer.constants.MAX_LENGTH`.
|
439
|
-
* @since v8.0.0
|
440
|
-
*/
|
441
|
-
function serialize(value: any): Buffer;
|
442
|
-
/**
|
443
|
-
* Uses a `DefaultDeserializer` with default options to read a JS value
|
444
|
-
* from a buffer.
|
445
|
-
* @since v8.0.0
|
446
|
-
* @param buffer A buffer returned by {@link serialize}.
|
447
|
-
*/
|
448
|
-
function deserialize(buffer: NodeJS.TypedArray): any;
|
449
|
-
/**
|
450
|
-
* 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
|
451
|
-
* times during the lifetime of the process. Each time the execution counter will
|
452
|
-
* be reset and a new coverage report will be written to the directory specified
|
453
|
-
* by `NODE_V8_COVERAGE`.
|
454
|
-
*
|
455
|
-
* When the process is about to exit, one last coverage will still be written to
|
456
|
-
* disk unless {@link stopCoverage} is invoked before the process exits.
|
457
|
-
* @since v15.1.0, v14.18.0, v12.22.0
|
458
|
-
*/
|
459
|
-
function takeCoverage(): void;
|
460
|
-
/**
|
461
|
-
* The `v8.stopCoverage()` method allows the user to stop the coverage collection
|
462
|
-
* started by `NODE_V8_COVERAGE`, so that V8 can release the execution count
|
463
|
-
* records and optimize code. This can be used in conjunction with {@link takeCoverage} if the user wants to collect the coverage on demand.
|
464
|
-
* @since v15.1.0, v14.18.0, v12.22.0
|
465
|
-
*/
|
466
|
-
function stopCoverage(): void;
|
467
|
-
/**
|
468
|
-
* The API is a no-op if `--heapsnapshot-near-heap-limit` is already set from the command line or the API is called more than once.
|
469
|
-
* `limit` must be a positive integer. See [`--heapsnapshot-near-heap-limit`](https://nodejs.org/docs/latest-v20.x/api/cli.html#--heapsnapshot-near-heap-limitmax_count) for more information.
|
470
|
-
* @experimental
|
471
|
-
* @since v18.10.0, v16.18.0
|
472
|
-
*/
|
473
|
-
function setHeapSnapshotNearHeapLimit(limit: number): void;
|
474
|
-
/**
|
475
|
-
* This API collects GC data in current thread.
|
476
|
-
* @since v19.6.0, v18.15.0
|
477
|
-
*/
|
478
|
-
class GCProfiler {
|
479
|
-
/**
|
480
|
-
* Start collecting GC data.
|
481
|
-
* @since v19.6.0, v18.15.0
|
482
|
-
*/
|
483
|
-
start(): void;
|
484
|
-
/**
|
485
|
-
* Stop collecting GC data and return an object. The content of object
|
486
|
-
* is as follows.
|
487
|
-
*
|
488
|
-
* ```json
|
489
|
-
* {
|
490
|
-
* "version": 1,
|
491
|
-
* "startTime": 1674059033862,
|
492
|
-
* "statistics": [
|
493
|
-
* {
|
494
|
-
* "gcType": "Scavenge",
|
495
|
-
* "beforeGC": {
|
496
|
-
* "heapStatistics": {
|
497
|
-
* "totalHeapSize": 5005312,
|
498
|
-
* "totalHeapSizeExecutable": 524288,
|
499
|
-
* "totalPhysicalSize": 5226496,
|
500
|
-
* "totalAvailableSize": 4341325216,
|
501
|
-
* "totalGlobalHandlesSize": 8192,
|
502
|
-
* "usedGlobalHandlesSize": 2112,
|
503
|
-
* "usedHeapSize": 4883840,
|
504
|
-
* "heapSizeLimit": 4345298944,
|
505
|
-
* "mallocedMemory": 254128,
|
506
|
-
* "externalMemory": 225138,
|
507
|
-
* "peakMallocedMemory": 181760
|
508
|
-
* },
|
509
|
-
* "heapSpaceStatistics": [
|
510
|
-
* {
|
511
|
-
* "spaceName": "read_only_space",
|
512
|
-
* "spaceSize": 0,
|
513
|
-
* "spaceUsedSize": 0,
|
514
|
-
* "spaceAvailableSize": 0,
|
515
|
-
* "physicalSpaceSize": 0
|
516
|
-
* }
|
517
|
-
* ]
|
518
|
-
* },
|
519
|
-
* "cost": 1574.14,
|
520
|
-
* "afterGC": {
|
521
|
-
* "heapStatistics": {
|
522
|
-
* "totalHeapSize": 6053888,
|
523
|
-
* "totalHeapSizeExecutable": 524288,
|
524
|
-
* "totalPhysicalSize": 5500928,
|
525
|
-
* "totalAvailableSize": 4341101384,
|
526
|
-
* "totalGlobalHandlesSize": 8192,
|
527
|
-
* "usedGlobalHandlesSize": 2112,
|
528
|
-
* "usedHeapSize": 4059096,
|
529
|
-
* "heapSizeLimit": 4345298944,
|
530
|
-
* "mallocedMemory": 254128,
|
531
|
-
* "externalMemory": 225138,
|
532
|
-
* "peakMallocedMemory": 181760
|
533
|
-
* },
|
534
|
-
* "heapSpaceStatistics": [
|
535
|
-
* {
|
536
|
-
* "spaceName": "read_only_space",
|
537
|
-
* "spaceSize": 0,
|
538
|
-
* "spaceUsedSize": 0,
|
539
|
-
* "spaceAvailableSize": 0,
|
540
|
-
* "physicalSpaceSize": 0
|
541
|
-
* }
|
542
|
-
* ]
|
543
|
-
* }
|
544
|
-
* }
|
545
|
-
* ],
|
546
|
-
* "endTime": 1674059036865
|
547
|
-
* }
|
548
|
-
* ```
|
549
|
-
*
|
550
|
-
* Here's an example.
|
551
|
-
*
|
552
|
-
* ```js
|
553
|
-
* const { GCProfiler } = require('v8');
|
554
|
-
* const profiler = new GCProfiler();
|
555
|
-
* profiler.start();
|
556
|
-
* setTimeout(() => {
|
557
|
-
* console.log(profiler.stop());
|
558
|
-
* }, 1000);
|
559
|
-
* ```
|
560
|
-
* @since v19.6.0, v18.15.0
|
561
|
-
*/
|
562
|
-
stop(): GCProfilerResult;
|
563
|
-
}
|
564
|
-
interface GCProfilerResult {
|
565
|
-
version: number;
|
566
|
-
startTime: number;
|
567
|
-
endTime: number;
|
568
|
-
statistics: Array<{
|
569
|
-
gcType: string;
|
570
|
-
cost: number;
|
571
|
-
beforeGC: {
|
572
|
-
heapStatistics: HeapStatistics;
|
573
|
-
heapSpaceStatistics: HeapSpaceStatistics[];
|
574
|
-
};
|
575
|
-
afterGC: {
|
576
|
-
heapStatistics: HeapStatistics;
|
577
|
-
heapSpaceStatistics: HeapSpaceStatistics[];
|
578
|
-
};
|
579
|
-
}>;
|
580
|
-
}
|
581
|
-
interface HeapStatistics {
|
582
|
-
totalHeapSize: number;
|
583
|
-
totalHeapSizeExecutable: number;
|
584
|
-
totalPhysicalSize: number;
|
585
|
-
totalAvailableSize: number;
|
586
|
-
totalGlobalHandlesSize: number;
|
587
|
-
usedGlobalHandlesSize: number;
|
588
|
-
usedHeapSize: number;
|
589
|
-
heapSizeLimit: number;
|
590
|
-
mallocedMemory: number;
|
591
|
-
externalMemory: number;
|
592
|
-
peakMallocedMemory: number;
|
593
|
-
}
|
594
|
-
interface HeapSpaceStatistics {
|
595
|
-
spaceName: string;
|
596
|
-
spaceSize: number;
|
597
|
-
spaceUsedSize: number;
|
598
|
-
spaceAvailableSize: number;
|
599
|
-
physicalSpaceSize: number;
|
600
|
-
}
|
601
|
-
/**
|
602
|
-
* Called when a promise is constructed. This does not mean that corresponding before/after events will occur, only that the possibility exists. This will
|
603
|
-
* happen if a promise is created without ever getting a continuation.
|
604
|
-
* @since v17.1.0, v16.14.0
|
605
|
-
* @param promise The promise being created.
|
606
|
-
* @param parent The promise continued from, if applicable.
|
607
|
-
*/
|
608
|
-
interface Init {
|
609
|
-
(promise: Promise<unknown>, parent: Promise<unknown>): void;
|
610
|
-
}
|
611
|
-
/**
|
612
|
-
* Called before a promise continuation executes. This can be in the form of `then()`, `catch()`, or `finally()` handlers or an await resuming.
|
613
|
-
*
|
614
|
-
* The before callback will be called 0 to N times. The before callback will typically be called 0 times if no continuation was ever made for the promise.
|
615
|
-
* The before callback may be called many times in the case where many continuations have been made from the same promise.
|
616
|
-
* @since v17.1.0, v16.14.0
|
617
|
-
*/
|
618
|
-
interface Before {
|
619
|
-
(promise: Promise<unknown>): void;
|
620
|
-
}
|
621
|
-
/**
|
622
|
-
* Called immediately after a promise continuation executes. This may be after a `then()`, `catch()`, or `finally()` handler or before an await after another await.
|
623
|
-
* @since v17.1.0, v16.14.0
|
624
|
-
*/
|
625
|
-
interface After {
|
626
|
-
(promise: Promise<unknown>): void;
|
627
|
-
}
|
628
|
-
/**
|
629
|
-
* Called when the promise receives a resolution or rejection value. This may occur synchronously in the case of {@link Promise.resolve()} or
|
630
|
-
* {@link Promise.reject()}.
|
631
|
-
* @since v17.1.0, v16.14.0
|
632
|
-
*/
|
633
|
-
interface Settled {
|
634
|
-
(promise: Promise<unknown>): void;
|
635
|
-
}
|
636
|
-
/**
|
637
|
-
* Key events in the lifetime of a promise have been categorized into four areas: creation of a promise, before/after a continuation handler is called or
|
638
|
-
* around an await, and when the promise resolves or rejects.
|
639
|
-
*
|
640
|
-
* Because promises are asynchronous resources whose lifecycle is tracked via the promise hooks mechanism, the `init()`, `before()`, `after()`, and
|
641
|
-
* `settled()` callbacks must not be async functions as they create more promises which would produce an infinite loop.
|
642
|
-
* @since v17.1.0, v16.14.0
|
643
|
-
*/
|
644
|
-
interface HookCallbacks {
|
645
|
-
init?: Init;
|
646
|
-
before?: Before;
|
647
|
-
after?: After;
|
648
|
-
settled?: Settled;
|
649
|
-
}
|
650
|
-
interface PromiseHooks {
|
651
|
-
/**
|
652
|
-
* The `init` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.
|
653
|
-
* @since v17.1.0, v16.14.0
|
654
|
-
* @param init The {@link Init | `init` callback} to call when a promise is created.
|
655
|
-
* @return Call to stop the hook.
|
656
|
-
*/
|
657
|
-
onInit: (init: Init) => Function;
|
658
|
-
/**
|
659
|
-
* The `settled` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.
|
660
|
-
* @since v17.1.0, v16.14.0
|
661
|
-
* @param settled The {@link Settled | `settled` callback} to call when a promise is created.
|
662
|
-
* @return Call to stop the hook.
|
663
|
-
*/
|
664
|
-
onSettled: (settled: Settled) => Function;
|
665
|
-
/**
|
666
|
-
* The `before` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.
|
667
|
-
* @since v17.1.0, v16.14.0
|
668
|
-
* @param before The {@link Before | `before` callback} to call before a promise continuation executes.
|
669
|
-
* @return Call to stop the hook.
|
670
|
-
*/
|
671
|
-
onBefore: (before: Before) => Function;
|
672
|
-
/**
|
673
|
-
* The `after` hook must be a plain function. Providing an async function will throw as it would produce an infinite microtask loop.
|
674
|
-
* @since v17.1.0, v16.14.0
|
675
|
-
* @param after The {@link After | `after` callback} to call after a promise continuation executes.
|
676
|
-
* @return Call to stop the hook.
|
677
|
-
*/
|
678
|
-
onAfter: (after: After) => Function;
|
679
|
-
/**
|
680
|
-
* Registers functions to be called for different lifetime events of each promise.
|
681
|
-
* The callbacks `init()`/`before()`/`after()`/`settled()` are called for the respective events during a promise's lifetime.
|
682
|
-
* All callbacks are optional. For example, if only promise creation needs to be tracked, then only the init callback needs to be passed.
|
683
|
-
* The hook callbacks must be plain functions. Providing async functions will throw as it would produce an infinite microtask loop.
|
684
|
-
* @since v17.1.0, v16.14.0
|
685
|
-
* @param callbacks The {@link HookCallbacks | Hook Callbacks} to register
|
686
|
-
* @return Used for disabling hooks
|
687
|
-
*/
|
688
|
-
createHook: (callbacks: HookCallbacks) => Function;
|
689
|
-
}
|
690
|
-
/**
|
691
|
-
* The `promiseHooks` interface can be used to track promise lifecycle events.
|
692
|
-
* @since v17.1.0, v16.14.0
|
693
|
-
*/
|
694
|
-
const promiseHooks: PromiseHooks;
|
695
|
-
type StartupSnapshotCallbackFn = (args: any) => any;
|
696
|
-
interface StartupSnapshot {
|
697
|
-
/**
|
698
|
-
* Add a callback that will be called when the Node.js instance is about to get serialized into a snapshot and exit.
|
699
|
-
* This can be used to release resources that should not or cannot be serialized or to convert user data into a form more suitable for serialization.
|
700
|
-
* @since v18.6.0, v16.17.0
|
701
|
-
*/
|
702
|
-
addSerializeCallback(callback: StartupSnapshotCallbackFn, data?: any): void;
|
703
|
-
/**
|
704
|
-
* Add a callback that will be called when the Node.js instance is deserialized from a snapshot.
|
705
|
-
* The `callback` and the `data` (if provided) will be serialized into the snapshot, they can be used to re-initialize the state of the application or
|
706
|
-
* to re-acquire resources that the application needs when the application is restarted from the snapshot.
|
707
|
-
* @since v18.6.0, v16.17.0
|
708
|
-
*/
|
709
|
-
addDeserializeCallback(callback: StartupSnapshotCallbackFn, data?: any): void;
|
710
|
-
/**
|
711
|
-
* This sets the entry point of the Node.js application when it is deserialized from a snapshot. This can be called only once in the snapshot building script.
|
712
|
-
* If called, the deserialized application no longer needs an additional entry point script to start up and will simply invoke the callback along with the deserialized
|
713
|
-
* data (if provided), otherwise an entry point script still needs to be provided to the deserialized application.
|
714
|
-
* @since v18.6.0, v16.17.0
|
715
|
-
*/
|
716
|
-
setDeserializeMainFunction(callback: StartupSnapshotCallbackFn, data?: any): void;
|
717
|
-
/**
|
718
|
-
* Returns true if the Node.js instance is run to build a snapshot.
|
719
|
-
* @since v18.6.0, v16.17.0
|
720
|
-
*/
|
721
|
-
isBuildingSnapshot(): boolean;
|
722
|
-
}
|
723
|
-
/**
|
724
|
-
* The `v8.startupSnapshot` interface can be used to add serialization and deserialization hooks for custom startup snapshots.
|
725
|
-
*
|
726
|
-
* ```bash
|
727
|
-
* $ node --snapshot-blob snapshot.blob --build-snapshot entry.js
|
728
|
-
* # This launches a process with the snapshot
|
729
|
-
* $ node --snapshot-blob snapshot.blob
|
730
|
-
* ```
|
731
|
-
*
|
732
|
-
* In the example above, `entry.js` can use methods from the `v8.startupSnapshot` interface to specify how to save information for custom objects
|
733
|
-
* in the snapshot during serialization and how the information can be used to synchronize these objects during deserialization of the snapshot.
|
734
|
-
* For example, if the `entry.js` contains the following script:
|
735
|
-
*
|
736
|
-
* ```js
|
737
|
-
* 'use strict';
|
738
|
-
*
|
739
|
-
* const fs = require('node:fs');
|
740
|
-
* const zlib = require('node:zlib');
|
741
|
-
* const path = require('node:path');
|
742
|
-
* const assert = require('node:assert');
|
743
|
-
*
|
744
|
-
* const v8 = require('node:v8');
|
745
|
-
*
|
746
|
-
* class BookShelf {
|
747
|
-
* storage = new Map();
|
748
|
-
*
|
749
|
-
* // Reading a series of files from directory and store them into storage.
|
750
|
-
* constructor(directory, books) {
|
751
|
-
* for (const book of books) {
|
752
|
-
* this.storage.set(book, fs.readFileSync(path.join(directory, book)));
|
753
|
-
* }
|
754
|
-
* }
|
755
|
-
*
|
756
|
-
* static compressAll(shelf) {
|
757
|
-
* for (const [ book, content ] of shelf.storage) {
|
758
|
-
* shelf.storage.set(book, zlib.gzipSync(content));
|
759
|
-
* }
|
760
|
-
* }
|
761
|
-
*
|
762
|
-
* static decompressAll(shelf) {
|
763
|
-
* for (const [ book, content ] of shelf.storage) {
|
764
|
-
* shelf.storage.set(book, zlib.gunzipSync(content));
|
765
|
-
* }
|
766
|
-
* }
|
767
|
-
* }
|
768
|
-
*
|
769
|
-
* // __dirname here is where the snapshot script is placed
|
770
|
-
* // during snapshot building time.
|
771
|
-
* const shelf = new BookShelf(__dirname, [
|
772
|
-
* 'book1.en_US.txt',
|
773
|
-
* 'book1.es_ES.txt',
|
774
|
-
* 'book2.zh_CN.txt',
|
775
|
-
* ]);
|
776
|
-
*
|
777
|
-
* assert(v8.startupSnapshot.isBuildingSnapshot());
|
778
|
-
* // On snapshot serialization, compress the books to reduce size.
|
779
|
-
* v8.startupSnapshot.addSerializeCallback(BookShelf.compressAll, shelf);
|
780
|
-
* // On snapshot deserialization, decompress the books.
|
781
|
-
* v8.startupSnapshot.addDeserializeCallback(BookShelf.decompressAll, shelf);
|
782
|
-
* v8.startupSnapshot.setDeserializeMainFunction((shelf) => {
|
783
|
-
* // process.env and process.argv are refreshed during snapshot
|
784
|
-
* // deserialization.
|
785
|
-
* const lang = process.env.BOOK_LANG || 'en_US';
|
786
|
-
* const book = process.argv[1];
|
787
|
-
* const name = `${book}.${lang}.txt`;
|
788
|
-
* console.log(shelf.storage.get(name));
|
789
|
-
* }, shelf);
|
790
|
-
* ```
|
791
|
-
*
|
792
|
-
* The resulted binary will get print the data deserialized from the snapshot during start up, using the refreshed `process.env` and `process.argv` of the launched process:
|
793
|
-
*
|
794
|
-
* ```bash
|
795
|
-
* $ BOOK_LANG=es_ES node --snapshot-blob snapshot.blob book1
|
796
|
-
* # Prints content of book1.es_ES.txt deserialized from the snapshot.
|
797
|
-
* ```
|
798
|
-
*
|
799
|
-
* Currently the application deserialized from a user-land snapshot cannot be snapshotted again, so these APIs are only available to applications that are not deserialized from a user-land snapshot.
|
800
|
-
*
|
801
|
-
* @experimental
|
802
|
-
* @since v18.6.0, v16.17.0
|
803
|
-
*/
|
804
|
-
const startupSnapshot: StartupSnapshot;
|
805
|
-
}
|
806
|
-
declare module "node:v8" {
|
807
|
-
export * from "v8";
|
808
|
-
}
|