1 | declare module 'v8' {
|
2 | import { Readable } from 'stream';
|
3 |
|
4 | interface HeapSpaceInfo {
|
5 | space_name: string;
|
6 | space_size: number;
|
7 | space_used_size: number;
|
8 | space_available_size: number;
|
9 | physical_space_size: number;
|
10 | }
|
11 |
|
12 |
|
13 | type DoesZapCodeSpaceFlag = 0 | 1;
|
14 |
|
15 | interface HeapInfo {
|
16 | total_heap_size: number;
|
17 | total_heap_size_executable: number;
|
18 | total_physical_size: number;
|
19 | total_available_size: number;
|
20 | used_heap_size: number;
|
21 | heap_size_limit: number;
|
22 | malloced_memory: number;
|
23 | peak_malloced_memory: number;
|
24 | does_zap_garbage: DoesZapCodeSpaceFlag;
|
25 | number_of_native_contexts: number;
|
26 | number_of_detached_contexts: number;
|
27 | }
|
28 |
|
29 | interface HeapCodeStatistics {
|
30 | code_and_metadata_size: number;
|
31 | bytecode_and_metadata_size: number;
|
32 | external_script_source_size: number;
|
33 | }
|
34 |
|
35 | |
36 |
|
37 |
|
38 |
|
39 | function cachedDataVersionTag(): number;
|
40 |
|
41 | function getHeapStatistics(): HeapInfo;
|
42 | function getHeapSpaceStatistics(): HeapSpaceInfo[];
|
43 | function setFlagsFromString(flags: string): void;
|
44 | |
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 | function getHeapSnapshot(): Readable;
|
53 |
|
54 | |
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
62 |
|
63 | function writeHeapSnapshot(fileName?: string): string;
|
64 |
|
65 | function getHeapCodeStatistics(): HeapCodeStatistics;
|
66 |
|
67 | class Serializer {
|
68 | |
69 |
|
70 |
|
71 | writeHeader(): void;
|
72 |
|
73 | |
74 |
|
75 |
|
76 |
|
77 | writeValue(val: any): boolean;
|
78 |
|
79 | |
80 |
|
81 |
|
82 |
|
83 |
|
84 | releaseBuffer(): Buffer;
|
85 |
|
86 | |
87 |
|
88 |
|
89 |
|
90 | transferArrayBuffer(id: number, arrayBuffer: ArrayBuffer): void;
|
91 |
|
92 | |
93 |
|
94 |
|
95 | writeUint32(value: number): void;
|
96 |
|
97 | |
98 |
|
99 |
|
100 | writeUint64(hi: number, lo: number): void;
|
101 |
|
102 | |
103 |
|
104 |
|
105 | writeDouble(value: number): void;
|
106 |
|
107 | |
108 |
|
109 |
|
110 |
|
111 | writeRawBytes(buffer: NodeJS.TypedArray): void;
|
112 | }
|
113 |
|
114 | |
115 |
|
116 |
|
117 |
|
118 | class DefaultSerializer extends Serializer {
|
119 | }
|
120 |
|
121 | class Deserializer {
|
122 | constructor(data: NodeJS.TypedArray);
|
123 | /**
|
124 | * Reads and validates a header (including the format version).
|
125 | * May, for example, reject an invalid or unsupported wire format.
|
126 | * In that case, an Error is thrown.
|
127 | */
|
128 | readHeader(): boolean;
|
129 |
|
130 | /**
|
131 | * Deserializes a JavaScript value from the buffer and returns it.
|
132 | */
|
133 | readValue(): any;
|
134 |
|
135 | /**
|
136 | * Marks an ArrayBuffer as having its contents transferred out of band.
|
137 | * Pass the corresponding `ArrayBuffer` in the serializing context to serializer.transferArrayBuffer()
|
138 | * (or return the id from serializer._getSharedArrayBufferId() in the case of SharedArrayBuffers).
|
139 | */
|
140 | transferArrayBuffer(id: number, arrayBuffer: ArrayBuffer): void;
|
141 |
|
142 | /**
|
143 | * Reads the underlying wire format version.
|
144 | * Likely mostly to be useful to legacy code reading old wire format versions.
|
145 | * May not be called before .readHeader().
|
146 | */
|
147 | getWireFormatVersion(): number;
|
148 |
|
149 | /**
|
150 | * Read a raw 32-bit unsigned integer and return it.
|
151 | */
|
152 | readUint32(): number;
|
153 |
|
154 | /**
|
155 | * Read a raw 64-bit unsigned integer and return it as an array [hi, lo] with two 32-bit unsigned integer entries.
|
156 | */
|
157 | readUint64(): [number, number];
|
158 |
|
159 | /**
|
160 | * Read a JS number value.
|
161 | */
|
162 | readDouble(): number;
|
163 |
|
164 | /**
|
165 | * Read raw bytes from the deserializer’s internal buffer.
|
166 | * The length parameter must correspond to the length of the buffer that was passed to serializer.writeRawBytes().
|
167 | */
|
168 | readRawBytes(length: number): Buffer;
|
169 | }
|
170 |
|
171 | /**
|
172 | * A subclass of `Serializer` that serializes `TypedArray` (in particular `Buffer`) and `DataView` objects as host objects,
|
173 | * and only stores the part of their underlying `ArrayBuffers` that they are referring to.
|
174 | */
|
175 | class DefaultDeserializer extends Deserializer {
|
176 | }
|
177 |
|
178 | |
179 |
|
180 |
|
181 | function serialize(value: any): Buffer;
|
182 |
|
183 | |
184 |
|
185 |
|
186 | function deserialize(data: NodeJS.TypedArray): any;
|
187 | }
|
188 | declare module 'node:v8' {
|
189 | export * from 'v8';
|
190 | }
|