@types/node 22.15.30 → 24.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- node/README.md +1 -1
- node/assert.d.ts +5 -5
- node/async_hooks.d.ts +26 -6
- node/buffer.d.ts +1 -2
- node/child_process.d.ts +2 -2
- node/cluster.d.ts +15 -15
- node/console.d.ts +17 -17
- node/crypto.d.ts +35 -28
- node/dgram.d.ts +1 -1
- node/diagnostics_channel.d.ts +1 -1
- node/dns.d.ts +16 -16
- node/domain.d.ts +1 -1
- node/events.d.ts +1 -2
- node/fs/promises.d.ts +16 -9
- node/fs.d.ts +28 -19
- node/globals.d.ts +7 -6
- node/globals.typedarray.d.ts +1 -0
- node/http.d.ts +2 -2
- node/http2.d.ts +6 -3
- node/https.d.ts +1 -1
- node/index.d.ts +7 -5
- node/inspector.d.ts +3 -7
- node/module.d.ts +63 -29
- node/net.d.ts +2 -5
- node/os.d.ts +8 -7
- node/package.json +13 -3
- node/path.d.ts +1 -1
- node/perf_hooks.d.ts +8 -8
- node/process.d.ts +21 -11
- node/punycode.d.ts +1 -1
- node/querystring.d.ts +1 -1
- node/readline/promises.d.ts +0 -1
- node/readline.d.ts +13 -13
- node/repl.d.ts +14 -16
- node/sea.d.ts +1 -1
- node/sqlite.d.ts +182 -2
- node/stream.d.ts +8 -19
- node/string_decoder.d.ts +1 -1
- node/test.d.ts +53 -15
- node/timers/promises.d.ts +1 -1
- node/timers.d.ts +1 -1
- node/tls.d.ts +2 -48
- node/trace_events.d.ts +6 -6
- node/{compatibility → ts5.1/compatibility}/disposable.d.ts +0 -4
- node/ts5.1/index.d.ts +98 -0
- node/ts5.6/compatibility/float16array.d.ts +71 -0
- node/ts5.6/globals.typedarray.d.ts +1 -0
- node/ts5.6/index.d.ts +9 -5
- node/ts5.7/compatibility/float16array.d.ts +72 -0
- node/ts5.7/index.d.ts +96 -0
- node/tty.d.ts +1 -1
- node/url.d.ts +52 -19
- node/util.d.ts +16 -295
- node/v8.d.ts +29 -32
- node/vm.d.ts +17 -10
- node/wasi.d.ts +1 -1
- node/worker_threads.d.ts +34 -18
- node/zlib.d.ts +5 -7
- node/compatibility/index.d.ts +0 -9
- node/compatibility/indexable.d.ts +0 -23
node/util.d.ts
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
* ```js
|
7
7
|
* import util from 'node:util';
|
8
8
|
* ```
|
9
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
9
|
+
* @see [source](https://github.com/nodejs/node/blob/v24.x/lib/util.js)
|
10
10
|
*/
|
11
11
|
declare module "util" {
|
12
12
|
import * as types from "node:util/types";
|
@@ -367,19 +367,6 @@ declare module "util" {
|
|
367
367
|
* @since v22.12.0
|
368
368
|
*/
|
369
369
|
export function getSystemErrorMessage(err: number): string;
|
370
|
-
/**
|
371
|
-
* The `util.log()` method prints the given `string` to `stdout` with an included
|
372
|
-
* timestamp.
|
373
|
-
*
|
374
|
-
* ```js
|
375
|
-
* import util from 'node:util';
|
376
|
-
*
|
377
|
-
* util.log('Timestamped message.');
|
378
|
-
* ```
|
379
|
-
* @since v0.3.0
|
380
|
-
* @deprecated Since v6.0.0 - Use a third party module instead.
|
381
|
-
*/
|
382
|
-
export function log(string: string): void;
|
383
370
|
/**
|
384
371
|
* Returns the `string` after replacing any surrogate code points
|
385
372
|
* (or equivalently, any unpaired surrogate code units) with the
|
@@ -433,7 +420,6 @@ declare module "util" {
|
|
433
420
|
* });
|
434
421
|
* ```
|
435
422
|
* @since v19.7.0
|
436
|
-
* @experimental
|
437
423
|
* @param resource Any non-null object tied to the abortable operation and held weakly.
|
438
424
|
* If `resource` is garbage collected before the `signal` aborts, the promise remains pending,
|
439
425
|
* allowing Node.js to stop tracking it.
|
@@ -651,71 +637,6 @@ declare module "util" {
|
|
651
637
|
* @deprecated Since v4.0.0 - Use `isArray` instead.
|
652
638
|
*/
|
653
639
|
export function isArray(object: unknown): object is unknown[];
|
654
|
-
/**
|
655
|
-
* Returns `true` if the given `object` is a `RegExp`. Otherwise, returns `false`.
|
656
|
-
*
|
657
|
-
* ```js
|
658
|
-
* import util from 'node:util';
|
659
|
-
*
|
660
|
-
* util.isRegExp(/some regexp/);
|
661
|
-
* // Returns: true
|
662
|
-
* util.isRegExp(new RegExp('another regexp'));
|
663
|
-
* // Returns: true
|
664
|
-
* util.isRegExp({});
|
665
|
-
* // Returns: false
|
666
|
-
* ```
|
667
|
-
* @since v0.6.0
|
668
|
-
* @deprecated Since v4.0.0 - Deprecated
|
669
|
-
*/
|
670
|
-
export function isRegExp(object: unknown): object is RegExp;
|
671
|
-
/**
|
672
|
-
* Returns `true` if the given `object` is a `Date`. Otherwise, returns `false`.
|
673
|
-
*
|
674
|
-
* ```js
|
675
|
-
* import util from 'node:util';
|
676
|
-
*
|
677
|
-
* util.isDate(new Date());
|
678
|
-
* // Returns: true
|
679
|
-
* util.isDate(Date());
|
680
|
-
* // false (without 'new' returns a String)
|
681
|
-
* util.isDate({});
|
682
|
-
* // Returns: false
|
683
|
-
* ```
|
684
|
-
* @since v0.6.0
|
685
|
-
* @deprecated Since v4.0.0 - Use {@link types.isDate} instead.
|
686
|
-
*/
|
687
|
-
export function isDate(object: unknown): object is Date;
|
688
|
-
/**
|
689
|
-
* Returns `true` if the given `object` is an `Error`. Otherwise, returns `false`.
|
690
|
-
*
|
691
|
-
* ```js
|
692
|
-
* import util from 'node:util';
|
693
|
-
*
|
694
|
-
* util.isError(new Error());
|
695
|
-
* // Returns: true
|
696
|
-
* util.isError(new TypeError());
|
697
|
-
* // Returns: true
|
698
|
-
* util.isError({ name: 'Error', message: 'an error occurred' });
|
699
|
-
* // Returns: false
|
700
|
-
* ```
|
701
|
-
*
|
702
|
-
* This method relies on `Object.prototype.toString()` behavior. It is
|
703
|
-
* possible to obtain an incorrect result when the `object` argument manipulates `@@toStringTag`.
|
704
|
-
*
|
705
|
-
* ```js
|
706
|
-
* import util from 'node:util';
|
707
|
-
* const obj = { name: 'Error', message: 'an error occurred' };
|
708
|
-
*
|
709
|
-
* util.isError(obj);
|
710
|
-
* // Returns: false
|
711
|
-
* obj[Symbol.toStringTag] = 'Error';
|
712
|
-
* util.isError(obj);
|
713
|
-
* // Returns: true
|
714
|
-
* ```
|
715
|
-
* @since v0.6.0
|
716
|
-
* @deprecated Since v4.0.0 - Use {@link types.isNativeError} instead.
|
717
|
-
*/
|
718
|
-
export function isError(object: unknown): object is Error;
|
719
640
|
/**
|
720
641
|
* Usage of `util.inherits()` is discouraged. Please use the ES6 `class` and
|
721
642
|
* `extends` keywords to get language level inheritance support. Also note
|
@@ -866,217 +787,6 @@ declare module "util" {
|
|
866
787
|
*/
|
867
788
|
export function debuglog(section: string, callback?: (fn: DebugLoggerFunction) => void): DebugLogger;
|
868
789
|
export { debuglog as debug };
|
869
|
-
/**
|
870
|
-
* Returns `true` if the given `object` is a `Boolean`. Otherwise, returns `false`.
|
871
|
-
*
|
872
|
-
* ```js
|
873
|
-
* import util from 'node:util';
|
874
|
-
*
|
875
|
-
* util.isBoolean(1);
|
876
|
-
* // Returns: false
|
877
|
-
* util.isBoolean(0);
|
878
|
-
* // Returns: false
|
879
|
-
* util.isBoolean(false);
|
880
|
-
* // Returns: true
|
881
|
-
* ```
|
882
|
-
* @since v0.11.5
|
883
|
-
* @deprecated Since v4.0.0 - Use `typeof value === 'boolean'` instead.
|
884
|
-
*/
|
885
|
-
export function isBoolean(object: unknown): object is boolean;
|
886
|
-
/**
|
887
|
-
* Returns `true` if the given `object` is a `Buffer`. Otherwise, returns `false`.
|
888
|
-
*
|
889
|
-
* ```js
|
890
|
-
* import util from 'node:util';
|
891
|
-
*
|
892
|
-
* util.isBuffer({ length: 0 });
|
893
|
-
* // Returns: false
|
894
|
-
* util.isBuffer([]);
|
895
|
-
* // Returns: false
|
896
|
-
* util.isBuffer(Buffer.from('hello world'));
|
897
|
-
* // Returns: true
|
898
|
-
* ```
|
899
|
-
* @since v0.11.5
|
900
|
-
* @deprecated Since v4.0.0 - Use `isBuffer` instead.
|
901
|
-
*/
|
902
|
-
export function isBuffer(object: unknown): object is Buffer;
|
903
|
-
/**
|
904
|
-
* Returns `true` if the given `object` is a `Function`. Otherwise, returns `false`.
|
905
|
-
*
|
906
|
-
* ```js
|
907
|
-
* import util from 'node:util';
|
908
|
-
*
|
909
|
-
* function Foo() {}
|
910
|
-
* const Bar = () => {};
|
911
|
-
*
|
912
|
-
* util.isFunction({});
|
913
|
-
* // Returns: false
|
914
|
-
* util.isFunction(Foo);
|
915
|
-
* // Returns: true
|
916
|
-
* util.isFunction(Bar);
|
917
|
-
* // Returns: true
|
918
|
-
* ```
|
919
|
-
* @since v0.11.5
|
920
|
-
* @deprecated Since v4.0.0 - Use `typeof value === 'function'` instead.
|
921
|
-
*/
|
922
|
-
export function isFunction(object: unknown): boolean;
|
923
|
-
/**
|
924
|
-
* Returns `true` if the given `object` is strictly `null`. Otherwise, returns`false`.
|
925
|
-
*
|
926
|
-
* ```js
|
927
|
-
* import util from 'node:util';
|
928
|
-
*
|
929
|
-
* util.isNull(0);
|
930
|
-
* // Returns: false
|
931
|
-
* util.isNull(undefined);
|
932
|
-
* // Returns: false
|
933
|
-
* util.isNull(null);
|
934
|
-
* // Returns: true
|
935
|
-
* ```
|
936
|
-
* @since v0.11.5
|
937
|
-
* @deprecated Since v4.0.0 - Use `value === null` instead.
|
938
|
-
*/
|
939
|
-
export function isNull(object: unknown): object is null;
|
940
|
-
/**
|
941
|
-
* Returns `true` if the given `object` is `null` or `undefined`. Otherwise,
|
942
|
-
* returns `false`.
|
943
|
-
*
|
944
|
-
* ```js
|
945
|
-
* import util from 'node:util';
|
946
|
-
*
|
947
|
-
* util.isNullOrUndefined(0);
|
948
|
-
* // Returns: false
|
949
|
-
* util.isNullOrUndefined(undefined);
|
950
|
-
* // Returns: true
|
951
|
-
* util.isNullOrUndefined(null);
|
952
|
-
* // Returns: true
|
953
|
-
* ```
|
954
|
-
* @since v0.11.5
|
955
|
-
* @deprecated Since v4.0.0 - Use `value === undefined || value === null` instead.
|
956
|
-
*/
|
957
|
-
export function isNullOrUndefined(object: unknown): object is null | undefined;
|
958
|
-
/**
|
959
|
-
* Returns `true` if the given `object` is a `Number`. Otherwise, returns `false`.
|
960
|
-
*
|
961
|
-
* ```js
|
962
|
-
* import util from 'node:util';
|
963
|
-
*
|
964
|
-
* util.isNumber(false);
|
965
|
-
* // Returns: false
|
966
|
-
* util.isNumber(Infinity);
|
967
|
-
* // Returns: true
|
968
|
-
* util.isNumber(0);
|
969
|
-
* // Returns: true
|
970
|
-
* util.isNumber(NaN);
|
971
|
-
* // Returns: true
|
972
|
-
* ```
|
973
|
-
* @since v0.11.5
|
974
|
-
* @deprecated Since v4.0.0 - Use `typeof value === 'number'` instead.
|
975
|
-
*/
|
976
|
-
export function isNumber(object: unknown): object is number;
|
977
|
-
/**
|
978
|
-
* Returns `true` if the given `object` is strictly an `Object`**and** not a`Function` (even though functions are objects in JavaScript).
|
979
|
-
* Otherwise, returns `false`.
|
980
|
-
*
|
981
|
-
* ```js
|
982
|
-
* import util from 'node:util';
|
983
|
-
*
|
984
|
-
* util.isObject(5);
|
985
|
-
* // Returns: false
|
986
|
-
* util.isObject(null);
|
987
|
-
* // Returns: false
|
988
|
-
* util.isObject({});
|
989
|
-
* // Returns: true
|
990
|
-
* util.isObject(() => {});
|
991
|
-
* // Returns: false
|
992
|
-
* ```
|
993
|
-
* @since v0.11.5
|
994
|
-
* @deprecated Since v4.0.0 - Use `value !== null && typeof value === 'object'` instead.
|
995
|
-
*/
|
996
|
-
export function isObject(object: unknown): boolean;
|
997
|
-
/**
|
998
|
-
* Returns `true` if the given `object` is a primitive type. Otherwise, returns`false`.
|
999
|
-
*
|
1000
|
-
* ```js
|
1001
|
-
* import util from 'node:util';
|
1002
|
-
*
|
1003
|
-
* util.isPrimitive(5);
|
1004
|
-
* // Returns: true
|
1005
|
-
* util.isPrimitive('foo');
|
1006
|
-
* // Returns: true
|
1007
|
-
* util.isPrimitive(false);
|
1008
|
-
* // Returns: true
|
1009
|
-
* util.isPrimitive(null);
|
1010
|
-
* // Returns: true
|
1011
|
-
* util.isPrimitive(undefined);
|
1012
|
-
* // Returns: true
|
1013
|
-
* util.isPrimitive({});
|
1014
|
-
* // Returns: false
|
1015
|
-
* util.isPrimitive(() => {});
|
1016
|
-
* // Returns: false
|
1017
|
-
* util.isPrimitive(/^$/);
|
1018
|
-
* // Returns: false
|
1019
|
-
* util.isPrimitive(new Date());
|
1020
|
-
* // Returns: false
|
1021
|
-
* ```
|
1022
|
-
* @since v0.11.5
|
1023
|
-
* @deprecated Since v4.0.0 - Use `(typeof value !== 'object' && typeof value !== 'function') || value === null` instead.
|
1024
|
-
*/
|
1025
|
-
export function isPrimitive(object: unknown): boolean;
|
1026
|
-
/**
|
1027
|
-
* Returns `true` if the given `object` is a `string`. Otherwise, returns `false`.
|
1028
|
-
*
|
1029
|
-
* ```js
|
1030
|
-
* import util from 'node:util';
|
1031
|
-
*
|
1032
|
-
* util.isString('');
|
1033
|
-
* // Returns: true
|
1034
|
-
* util.isString('foo');
|
1035
|
-
* // Returns: true
|
1036
|
-
* util.isString(String('foo'));
|
1037
|
-
* // Returns: true
|
1038
|
-
* util.isString(5);
|
1039
|
-
* // Returns: false
|
1040
|
-
* ```
|
1041
|
-
* @since v0.11.5
|
1042
|
-
* @deprecated Since v4.0.0 - Use `typeof value === 'string'` instead.
|
1043
|
-
*/
|
1044
|
-
export function isString(object: unknown): object is string;
|
1045
|
-
/**
|
1046
|
-
* Returns `true` if the given `object` is a `Symbol`. Otherwise, returns `false`.
|
1047
|
-
*
|
1048
|
-
* ```js
|
1049
|
-
* import util from 'node:util';
|
1050
|
-
*
|
1051
|
-
* util.isSymbol(5);
|
1052
|
-
* // Returns: false
|
1053
|
-
* util.isSymbol('foo');
|
1054
|
-
* // Returns: false
|
1055
|
-
* util.isSymbol(Symbol('foo'));
|
1056
|
-
* // Returns: true
|
1057
|
-
* ```
|
1058
|
-
* @since v0.11.5
|
1059
|
-
* @deprecated Since v4.0.0 - Use `typeof value === 'symbol'` instead.
|
1060
|
-
*/
|
1061
|
-
export function isSymbol(object: unknown): object is symbol;
|
1062
|
-
/**
|
1063
|
-
* Returns `true` if the given `object` is `undefined`. Otherwise, returns `false`.
|
1064
|
-
*
|
1065
|
-
* ```js
|
1066
|
-
* import util from 'node:util';
|
1067
|
-
*
|
1068
|
-
* const foo = undefined;
|
1069
|
-
* util.isUndefined(5);
|
1070
|
-
* // Returns: false
|
1071
|
-
* util.isUndefined(foo);
|
1072
|
-
* // Returns: true
|
1073
|
-
* util.isUndefined(null);
|
1074
|
-
* // Returns: false
|
1075
|
-
* ```
|
1076
|
-
* @since v0.11.5
|
1077
|
-
* @deprecated Since v4.0.0 - Use `value === undefined` instead.
|
1078
|
-
*/
|
1079
|
-
export function isUndefined(object: unknown): object is undefined;
|
1080
790
|
/**
|
1081
791
|
* The `util.deprecate()` method wraps `fn` (which may be a function or class) in
|
1082
792
|
* such a way that it is marked as deprecated.
|
@@ -1321,7 +1031,7 @@ declare module "util" {
|
|
1321
1031
|
* ```
|
1322
1032
|
*
|
1323
1033
|
* If there is an `original[util.promisify.custom]` property present, `promisify`
|
1324
|
-
* will return its value, see [Custom promisified functions](https://nodejs.org/docs/latest-
|
1034
|
+
* will return its value, see [Custom promisified functions](https://nodejs.org/docs/latest-v24.x/api/util.html#custom-promisified-functions).
|
1325
1035
|
*
|
1326
1036
|
* `promisify()` assumes that `original` is a function taking a callback as its
|
1327
1037
|
* final argument in all cases. If `original` is not a function, `promisify()`
|
@@ -1481,7 +1191,7 @@ declare module "util" {
|
|
1481
1191
|
/**
|
1482
1192
|
* This function returns a formatted text considering the `format` passed
|
1483
1193
|
* for printing in a terminal. It is aware of the terminal's capabilities
|
1484
|
-
* and acts according to the configuration set via `
|
1194
|
+
* and acts according to the configuration set via `NO_COLOR`,
|
1485
1195
|
* `NODE_DISABLE_COLORS` and `FORCE_COLOR` environment variables.
|
1486
1196
|
*
|
1487
1197
|
* ```js
|
@@ -1518,7 +1228,7 @@ declare module "util" {
|
|
1518
1228
|
* );
|
1519
1229
|
* ```
|
1520
1230
|
*
|
1521
|
-
* The full list of formats can be found in [modifiers](https://nodejs.org/docs/latest-
|
1231
|
+
* The full list of formats can be found in [modifiers](https://nodejs.org/docs/latest-v24.x/api/util.html#modifiers).
|
1522
1232
|
* @param format A text format or an Array of text formats defined in `util.inspect.colors`.
|
1523
1233
|
* @param text The text to to be formatted.
|
1524
1234
|
* @since v20.12.0
|
@@ -2222,10 +1932,21 @@ declare module "util/types" {
|
|
2222
1932
|
* ```
|
2223
1933
|
*
|
2224
1934
|
* For further information on `napi_create_external`, refer to
|
2225
|
-
* [`napi_create_external()`](https://nodejs.org/docs/latest-
|
1935
|
+
* [`napi_create_external()`](https://nodejs.org/docs/latest-v24.x/api/n-api.html#napi_create_external).
|
2226
1936
|
* @since v10.0.0
|
2227
1937
|
*/
|
2228
1938
|
function isExternal(object: unknown): boolean;
|
1939
|
+
/**
|
1940
|
+
* Returns `true` if the value is a built-in [`Float16Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float16Array) instance.
|
1941
|
+
*
|
1942
|
+
* ```js
|
1943
|
+
* util.types.isFloat16Array(new ArrayBuffer()); // Returns false
|
1944
|
+
* util.types.isFloat16Array(new Float16Array()); // Returns true
|
1945
|
+
* util.types.isFloat16Array(new Float32Array()); // Returns false
|
1946
|
+
* ```
|
1947
|
+
* @since v24.0.0
|
1948
|
+
*/
|
1949
|
+
function isFloat16Array(object: unknown): object is Float16Array;
|
2229
1950
|
/**
|
2230
1951
|
* Returns `true` if the value is a built-in [`Float32Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array) instance.
|
2231
1952
|
*
|
node/v8.d.ts
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
* ```js
|
5
5
|
* import v8 from 'node:v8';
|
6
6
|
* ```
|
7
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
7
|
+
* @see [source](https://github.com/nodejs/node/blob/v24.x/lib/v8.js)
|
8
8
|
*/
|
9
9
|
declare module "v8" {
|
10
10
|
import { Readable } from "node:stream";
|
@@ -547,8 +547,7 @@ declare module "v8" {
|
|
547
547
|
function stopCoverage(): void;
|
548
548
|
/**
|
549
549
|
* 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.
|
550
|
-
* `limit` must be a positive integer. See [`--heapsnapshot-near-heap-limit`](https://nodejs.org/docs/latest-
|
551
|
-
* @experimental
|
550
|
+
* `limit` must be a positive integer. See [`--heapsnapshot-near-heap-limit`](https://nodejs.org/docs/latest-v24.x/api/cli.html#--heapsnapshot-near-heap-limitmax_count) for more information.
|
552
551
|
* @since v18.10.0, v16.18.0
|
553
552
|
*/
|
554
553
|
function setHeapSnapshotNearHeapLimit(limit: number): void;
|
@@ -774,33 +773,6 @@ declare module "v8" {
|
|
774
773
|
*/
|
775
774
|
const promiseHooks: PromiseHooks;
|
776
775
|
type StartupSnapshotCallbackFn = (args: any) => any;
|
777
|
-
interface StartupSnapshot {
|
778
|
-
/**
|
779
|
-
* Add a callback that will be called when the Node.js instance is about to get serialized into a snapshot and exit.
|
780
|
-
* 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.
|
781
|
-
* @since v18.6.0, v16.17.0
|
782
|
-
*/
|
783
|
-
addSerializeCallback(callback: StartupSnapshotCallbackFn, data?: any): void;
|
784
|
-
/**
|
785
|
-
* Add a callback that will be called when the Node.js instance is deserialized from a snapshot.
|
786
|
-
* 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
|
787
|
-
* to re-acquire resources that the application needs when the application is restarted from the snapshot.
|
788
|
-
* @since v18.6.0, v16.17.0
|
789
|
-
*/
|
790
|
-
addDeserializeCallback(callback: StartupSnapshotCallbackFn, data?: any): void;
|
791
|
-
/**
|
792
|
-
* 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.
|
793
|
-
* 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
|
794
|
-
* data (if provided), otherwise an entry point script still needs to be provided to the deserialized application.
|
795
|
-
* @since v18.6.0, v16.17.0
|
796
|
-
*/
|
797
|
-
setDeserializeMainFunction(callback: StartupSnapshotCallbackFn, data?: any): void;
|
798
|
-
/**
|
799
|
-
* Returns true if the Node.js instance is run to build a snapshot.
|
800
|
-
* @since v18.6.0, v16.17.0
|
801
|
-
*/
|
802
|
-
isBuildingSnapshot(): boolean;
|
803
|
-
}
|
804
776
|
/**
|
805
777
|
* The `v8.startupSnapshot` interface can be used to add serialization and deserialization hooks for custom startup snapshots.
|
806
778
|
*
|
@@ -879,10 +851,35 @@ declare module "v8" {
|
|
879
851
|
*
|
880
852
|
* 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.
|
881
853
|
*
|
882
|
-
* @experimental
|
883
854
|
* @since v18.6.0, v16.17.0
|
884
855
|
*/
|
885
|
-
|
856
|
+
namespace startupSnapshot {
|
857
|
+
/**
|
858
|
+
* Add a callback that will be called when the Node.js instance is about to get serialized into a snapshot and exit.
|
859
|
+
* 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.
|
860
|
+
* @since v18.6.0, v16.17.0
|
861
|
+
*/
|
862
|
+
function addSerializeCallback(callback: StartupSnapshotCallbackFn, data?: any): void;
|
863
|
+
/**
|
864
|
+
* Add a callback that will be called when the Node.js instance is deserialized from a snapshot.
|
865
|
+
* 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
|
866
|
+
* to re-acquire resources that the application needs when the application is restarted from the snapshot.
|
867
|
+
* @since v18.6.0, v16.17.0
|
868
|
+
*/
|
869
|
+
function addDeserializeCallback(callback: StartupSnapshotCallbackFn, data?: any): void;
|
870
|
+
/**
|
871
|
+
* 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.
|
872
|
+
* 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
|
873
|
+
* data (if provided), otherwise an entry point script still needs to be provided to the deserialized application.
|
874
|
+
* @since v18.6.0, v16.17.0
|
875
|
+
*/
|
876
|
+
function setDeserializeMainFunction(callback: StartupSnapshotCallbackFn, data?: any): void;
|
877
|
+
/**
|
878
|
+
* Returns true if the Node.js instance is run to build a snapshot.
|
879
|
+
* @since v18.6.0, v16.17.0
|
880
|
+
*/
|
881
|
+
function isBuildingSnapshot(): boolean;
|
882
|
+
}
|
886
883
|
}
|
887
884
|
declare module "node:v8" {
|
888
885
|
export * from "v8";
|
node/vm.d.ts
CHANGED
@@ -34,7 +34,7 @@
|
|
34
34
|
*
|
35
35
|
* console.log(x); // 1; y is not defined.
|
36
36
|
* ```
|
37
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
37
|
+
* @see [source](https://github.com/nodejs/node/blob/v24.x/lib/vm.js)
|
38
38
|
*/
|
39
39
|
declare module "vm" {
|
40
40
|
import { ImportAttributes } from "node:module";
|
@@ -60,6 +60,7 @@ declare module "vm" {
|
|
60
60
|
specifier: string,
|
61
61
|
referrer: T,
|
62
62
|
importAttributes: ImportAttributes,
|
63
|
+
phase: "source" | "evaluation",
|
63
64
|
) => Module | Promise<Module>;
|
64
65
|
interface ScriptOptions extends BaseOptions {
|
65
66
|
/**
|
@@ -71,7 +72,8 @@ declare module "vm" {
|
|
71
72
|
/**
|
72
73
|
* Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
|
73
74
|
* part of the experimental modules API. We do not recommend using it in a production environment. For detailed information, see
|
74
|
-
* [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-
|
75
|
+
* [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v24.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
|
76
|
+
* @experimental
|
75
77
|
*/
|
76
78
|
importModuleDynamically?:
|
77
79
|
| DynamicModuleLoader<Script>
|
@@ -122,7 +124,8 @@ declare module "vm" {
|
|
122
124
|
/**
|
123
125
|
* Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
|
124
126
|
* part of the experimental modules API. We do not recommend using it in a production environment. For detailed information, see
|
125
|
-
* [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-
|
127
|
+
* [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v24.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
|
128
|
+
* @experimental
|
126
129
|
*/
|
127
130
|
importModuleDynamically?:
|
128
131
|
| DynamicModuleLoader<Script>
|
@@ -137,7 +140,8 @@ declare module "vm" {
|
|
137
140
|
/**
|
138
141
|
* Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
|
139
142
|
* part of the experimental modules API. We do not recommend using it in a production environment. For detailed information, see
|
140
|
-
* [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-
|
143
|
+
* [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v24.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
|
144
|
+
* @experimental
|
141
145
|
*/
|
142
146
|
importModuleDynamically?:
|
143
147
|
| DynamicModuleLoader<Script>
|
@@ -165,7 +169,8 @@ declare module "vm" {
|
|
165
169
|
/**
|
166
170
|
* Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
|
167
171
|
* part of the experimental modules API. We do not recommend using it in a production environment. For detailed information, see
|
168
|
-
* [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-
|
172
|
+
* [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v24.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
|
173
|
+
* @experimental
|
169
174
|
*/
|
170
175
|
importModuleDynamically?:
|
171
176
|
| DynamicModuleLoader<ReturnType<typeof compileFunction>>
|
@@ -208,7 +213,8 @@ declare module "vm" {
|
|
208
213
|
/**
|
209
214
|
* Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
|
210
215
|
* part of the experimental modules API. We do not recommend using it in a production environment. For detailed information, see
|
211
|
-
* [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-
|
216
|
+
* [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v24.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
|
217
|
+
* @experimental
|
212
218
|
*/
|
213
219
|
importModuleDynamically?:
|
214
220
|
| DynamicModuleLoader<Context>
|
@@ -410,9 +416,9 @@ declare module "vm" {
|
|
410
416
|
}
|
411
417
|
/**
|
412
418
|
* If the given `contextObject` is an object, the `vm.createContext()` method will
|
413
|
-
* [prepare that object](https://nodejs.org/docs/latest-
|
419
|
+
* [prepare that object](https://nodejs.org/docs/latest-v24.x/api/vm.html#what-does-it-mean-to-contextify-an-object)
|
414
420
|
* and return a reference to it so that it can be used in calls to {@link runInContext} or
|
415
|
-
* [`script.runInContext()`](https://nodejs.org/docs/latest-
|
421
|
+
* [`script.runInContext()`](https://nodejs.org/docs/latest-v24.x/api/vm.html#scriptrunincontextcontextifiedobject-options).
|
416
422
|
* Inside such scripts, the global object will be wrapped by the `contextObject`, retaining all of its
|
417
423
|
* existing properties but also having the built-in objects and functions any standard
|
418
424
|
* [global object](https://es5.github.io/#x15.1) has. Outside of scripts run by the vm module, global
|
@@ -907,7 +913,8 @@ declare module "vm" {
|
|
907
913
|
/**
|
908
914
|
* Used to specify how the modules should be loaded during the evaluation of this script when `import()` is called. This option is
|
909
915
|
* part of the experimental modules API. We do not recommend using it in a production environment. For detailed information, see
|
910
|
-
* [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-
|
916
|
+
* [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v24.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
|
917
|
+
* @experimental
|
911
918
|
*/
|
912
919
|
importModuleDynamically?: DynamicModuleLoader<SourceTextModule> | undefined;
|
913
920
|
}
|
@@ -1005,7 +1012,7 @@ declare module "vm" {
|
|
1005
1012
|
* and `vm.compileFunction()` so that Node.js uses the default ESM loader from the main
|
1006
1013
|
* context to load the requested module.
|
1007
1014
|
*
|
1008
|
-
* For detailed information, see [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-
|
1015
|
+
* For detailed information, see [Support of dynamic `import()` in compilation APIs](https://nodejs.org/docs/latest-v24.x/api/vm.html#support-of-dynamic-import-in-compilation-apis).
|
1009
1016
|
* @since v21.7.0, v20.12.0
|
1010
1017
|
*/
|
1011
1018
|
const USE_MAIN_CONTEXT_DEFAULT_LOADER: number;
|
node/wasi.d.ts
CHANGED
node/worker_threads.d.ts
CHANGED
@@ -15,28 +15,31 @@
|
|
15
15
|
*
|
16
16
|
* ```js
|
17
17
|
* import {
|
18
|
-
* Worker,
|
18
|
+
* Worker,
|
19
|
+
* isMainThread,
|
20
|
+
* parentPort,
|
21
|
+
* workerData,
|
19
22
|
* } from 'node:worker_threads';
|
20
|
-
* import { parse } from 'some-js-parsing-library';
|
21
23
|
*
|
22
|
-
* if (isMainThread) {
|
23
|
-
*
|
24
|
-
* return new Promise((resolve, reject) => {
|
25
|
-
* const worker = new Worker(__filename, {
|
26
|
-
* workerData: script,
|
27
|
-
* });
|
28
|
-
* worker.on('message', resolve);
|
29
|
-
* worker.on('error', reject);
|
30
|
-
* worker.on('exit', (code) => {
|
31
|
-
* if (code !== 0)
|
32
|
-
* reject(new Error(`Worker stopped with exit code ${code}`));
|
33
|
-
* });
|
34
|
-
* });
|
35
|
-
* };
|
36
|
-
* } else {
|
24
|
+
* if (!isMainThread) {
|
25
|
+
* const { parse } = await import('some-js-parsing-library');
|
37
26
|
* const script = workerData;
|
38
27
|
* parentPort.postMessage(parse(script));
|
39
28
|
* }
|
29
|
+
*
|
30
|
+
* export default function parseJSAsync(script) {
|
31
|
+
* return new Promise((resolve, reject) => {
|
32
|
+
* const worker = new Worker(new URL(import.meta.url), {
|
33
|
+
* workerData: script,
|
34
|
+
* });
|
35
|
+
* worker.on('message', resolve);
|
36
|
+
* worker.on('error', reject);
|
37
|
+
* worker.on('exit', (code) => {
|
38
|
+
* if (code !== 0)
|
39
|
+
* reject(new Error(`Worker stopped with exit code ${code}`));
|
40
|
+
* });
|
41
|
+
* });
|
42
|
+
* };
|
40
43
|
* ```
|
41
44
|
*
|
42
45
|
* The above example spawns a Worker thread for each `parseJSAsync()` call. In
|
@@ -49,7 +52,7 @@
|
|
49
52
|
*
|
50
53
|
* Worker threads inherit non-process-specific options by default. Refer to `Worker constructor options` to know how to customize worker thread options,
|
51
54
|
* specifically `argv` and `execArgv` options.
|
52
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
55
|
+
* @see [source](https://github.com/nodejs/node/blob/v24.x/lib/worker_threads.js)
|
53
56
|
*/
|
54
57
|
declare module "worker_threads" {
|
55
58
|
import { Context } from "node:vm";
|
@@ -59,6 +62,7 @@ declare module "worker_threads" {
|
|
59
62
|
import { Readable, Writable } from "node:stream";
|
60
63
|
import { ReadableStream, TransformStream, WritableStream } from "node:stream/web";
|
61
64
|
import { URL } from "node:url";
|
65
|
+
import { HeapInfo } from "node:v8";
|
62
66
|
const isInternalThread: boolean;
|
63
67
|
const isMainThread: boolean;
|
64
68
|
const parentPort: null | MessagePort;
|
@@ -184,6 +188,11 @@ declare module "worker_threads" {
|
|
184
188
|
* @since v10.5.0
|
185
189
|
*/
|
186
190
|
postMessage(value: any, transferList?: readonly Transferable[]): void;
|
191
|
+
/**
|
192
|
+
* If true, the `MessagePort` object will keep the Node.js event loop active.
|
193
|
+
* @since v18.1.0, v16.17.0
|
194
|
+
*/
|
195
|
+
hasRef(): boolean;
|
187
196
|
/**
|
188
197
|
* Opposite of `unref()`. Calling `ref()` on a previously `unref()`ed port does _not_ let the program exit if it's the only active handle left (the default
|
189
198
|
* behavior). If the port is `ref()`ed, calling `ref()` again has no effect.
|
@@ -466,6 +475,13 @@ declare module "worker_threads" {
|
|
466
475
|
* @return A promise for a Readable Stream containing a V8 heap snapshot
|
467
476
|
*/
|
468
477
|
getHeapSnapshot(): Promise<Readable>;
|
478
|
+
/**
|
479
|
+
* This method returns a `Promise` that will resolve to an object identical to `v8.getHeapStatistics()`,
|
480
|
+
* or reject with an `ERR_WORKER_NOT_RUNNING` error if the worker is no longer running.
|
481
|
+
* This methods allows the statistics to be observed from outside the actual thread.
|
482
|
+
* @since v24.0.0
|
483
|
+
*/
|
484
|
+
getHeapStatistics(): Promise<HeapInfo>;
|
469
485
|
addListener(event: "error", listener: (err: Error) => void): this;
|
470
486
|
addListener(event: "exit", listener: (exitCode: number) => void): this;
|
471
487
|
addListener(event: "message", listener: (value: any) => void): this;
|