aws-delivlib 14.15.84 → 14.15.86
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.
- package/lib/custom-resource-handlers/src/certificate-signing-request.tsbuildinfo +1 -1
- package/lib/custom-resource-handlers/src/pgp-secret.tsbuildinfo +1 -1
- package/lib/custom-resource-handlers/src/private-key.tsbuildinfo +1 -1
- package/lib/package-integrity/handler/validate.bundle.js +169 -104
- package/lib/publishing/github/node_modules/.yarn-integrity +1 -1
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/README.md +1 -1
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/assert.d.ts +7 -48
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/async_hooks.d.ts +0 -2
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/crypto.d.ts +8 -9
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/fs/promises.d.ts +3 -9
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/http2.d.ts +3 -4
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/inspector.d.ts +36 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/module.d.ts +25 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/package.json +2 -2
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/process.d.ts +22 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/readline.d.ts +6 -1
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/sqlite.d.ts +36 -13
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/test.d.ts +54 -6
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/tls.d.ts +25 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/util.d.ts +207 -88
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/v8.d.ts +81 -0
- package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/zlib.d.ts +167 -36
- package/package.json +9 -9
package/lib/publishing/github/node_modules/@types/jsonwebtoken/node_modules/@types/node/util.d.ts
CHANGED
@@ -133,6 +133,58 @@ declare module "util" {
|
|
133
133
|
*/
|
134
134
|
columnNumber: number;
|
135
135
|
}
|
136
|
+
export type DiffEntry = [operation: -1 | 0 | 1, value: string];
|
137
|
+
/**
|
138
|
+
* `util.diff()` compares two string or array values and returns an array of difference entries.
|
139
|
+
* It uses the Myers diff algorithm to compute minimal differences, which is the same algorithm
|
140
|
+
* used internally by assertion error messages.
|
141
|
+
*
|
142
|
+
* If the values are equal, an empty array is returned.
|
143
|
+
*
|
144
|
+
* ```js
|
145
|
+
* const { diff } = require('node:util');
|
146
|
+
*
|
147
|
+
* // Comparing strings
|
148
|
+
* const actualString = '12345678';
|
149
|
+
* const expectedString = '12!!5!7!';
|
150
|
+
* console.log(diff(actualString, expectedString));
|
151
|
+
* // [
|
152
|
+
* // [0, '1'],
|
153
|
+
* // [0, '2'],
|
154
|
+
* // [1, '3'],
|
155
|
+
* // [1, '4'],
|
156
|
+
* // [-1, '!'],
|
157
|
+
* // [-1, '!'],
|
158
|
+
* // [0, '5'],
|
159
|
+
* // [1, '6'],
|
160
|
+
* // [-1, '!'],
|
161
|
+
* // [0, '7'],
|
162
|
+
* // [1, '8'],
|
163
|
+
* // [-1, '!'],
|
164
|
+
* // ]
|
165
|
+
* // Comparing arrays
|
166
|
+
* const actualArray = ['1', '2', '3'];
|
167
|
+
* const expectedArray = ['1', '3', '4'];
|
168
|
+
* console.log(diff(actualArray, expectedArray));
|
169
|
+
* // [
|
170
|
+
* // [0, '1'],
|
171
|
+
* // [1, '2'],
|
172
|
+
* // [0, '3'],
|
173
|
+
* // [-1, '4'],
|
174
|
+
* // ]
|
175
|
+
* // Equal values return empty array
|
176
|
+
* console.log(diff('same', 'same'));
|
177
|
+
* // []
|
178
|
+
* ```
|
179
|
+
* @since v22.15.0
|
180
|
+
* @experimental
|
181
|
+
* @param actual The first value to compare
|
182
|
+
* @param expected The second value to compare
|
183
|
+
* @returns An array of difference entries. Each entry is an array with two elements:
|
184
|
+
* * Index 0: `number` Operation code: `-1` for delete, `0` for no-op/unchanged, `1` for insert
|
185
|
+
* * Index 1: `string` The value associated with the operation
|
186
|
+
*/
|
187
|
+
export function diff(actual: string | readonly string[], expected: string | readonly string[]): DiffEntry[];
|
136
188
|
/**
|
137
189
|
* The `util.format()` method returns a formatted string using the first argument
|
138
190
|
* as a `printf`-like format string which can contain zero or more format
|
@@ -203,10 +255,10 @@ declare module "util" {
|
|
203
255
|
* the caller function.
|
204
256
|
*
|
205
257
|
* ```js
|
206
|
-
*
|
258
|
+
* import { getCallSites } from 'node:util';
|
207
259
|
*
|
208
260
|
* function exampleFunction() {
|
209
|
-
* const callSites =
|
261
|
+
* const callSites = getCallSites();
|
210
262
|
*
|
211
263
|
* console.log('Call Sites:');
|
212
264
|
* callSites.forEach((callSite, index) => {
|
@@ -245,13 +297,13 @@ declare module "util" {
|
|
245
297
|
* `sourceMap` will be true by default.
|
246
298
|
*
|
247
299
|
* ```ts
|
248
|
-
* import
|
300
|
+
* import { getCallSites } from 'node:util';
|
249
301
|
*
|
250
302
|
* interface Foo {
|
251
303
|
* foo: string;
|
252
304
|
* }
|
253
305
|
*
|
254
|
-
* const callSites =
|
306
|
+
* const callSites = getCallSites({ sourceMap: true });
|
255
307
|
*
|
256
308
|
* // With sourceMap:
|
257
309
|
* // Function Name: ''
|
@@ -308,8 +360,8 @@ declare module "util" {
|
|
308
360
|
*
|
309
361
|
* ```js
|
310
362
|
* fs.access('file/that/does/not/exist', (err) => {
|
311
|
-
* const
|
312
|
-
* console.error(
|
363
|
+
* const message = util.getSystemErrorMessage(err.errno);
|
364
|
+
* console.error(message); // no such file or directory
|
313
365
|
* });
|
314
366
|
* ```
|
315
367
|
* @since v22.12.0
|
@@ -339,7 +391,6 @@ declare module "util" {
|
|
339
391
|
* Creates and returns an `AbortController` instance whose `AbortSignal` is marked
|
340
392
|
* as transferable and can be used with `structuredClone()` or `postMessage()`.
|
341
393
|
* @since v18.11.0
|
342
|
-
* @experimental
|
343
394
|
* @returns A transferable AbortController
|
344
395
|
*/
|
345
396
|
export function transferableAbortController(): AbortController;
|
@@ -352,7 +403,6 @@ declare module "util" {
|
|
352
403
|
* channel.port2.postMessage(signal, [signal]);
|
353
404
|
* ```
|
354
405
|
* @since v18.11.0
|
355
|
-
* @experimental
|
356
406
|
* @param signal The AbortSignal
|
357
407
|
* @returns The same AbortSignal
|
358
408
|
*/
|
@@ -394,7 +444,8 @@ declare module "util" {
|
|
394
444
|
* The `util.inspect()` method returns a string representation of `object` that is
|
395
445
|
* intended for debugging. The output of `util.inspect` may change at any time
|
396
446
|
* and should not be depended upon programmatically. Additional `options` may be
|
397
|
-
* passed that alter the result.
|
447
|
+
* passed that alter the result.
|
448
|
+
* `util.inspect()` will use the constructor's name and/or `@@toStringTag` to make
|
398
449
|
* an identifiable tag for an inspected value.
|
399
450
|
*
|
400
451
|
* ```js
|
@@ -442,7 +493,7 @@ declare module "util" {
|
|
442
493
|
* The following example highlights the effect of the `compact` option:
|
443
494
|
*
|
444
495
|
* ```js
|
445
|
-
* import
|
496
|
+
* import { inspect } from 'node:util';
|
446
497
|
*
|
447
498
|
* const o = {
|
448
499
|
* a: [1, 2, [[
|
@@ -452,7 +503,7 @@ declare module "util" {
|
|
452
503
|
* 'foo']], 4],
|
453
504
|
* b: new Map([['za', 1], ['zb', 'test']]),
|
454
505
|
* };
|
455
|
-
* console.log(
|
506
|
+
* console.log(inspect(o, { compact: true, depth: 5, breakLength: 80 }));
|
456
507
|
*
|
457
508
|
* // { a:
|
458
509
|
* // [ 1,
|
@@ -464,7 +515,7 @@ declare module "util" {
|
|
464
515
|
* // b: Map(2) { 'za' => 1, 'zb' => 'test' } }
|
465
516
|
*
|
466
517
|
* // Setting `compact` to false or an integer creates more reader friendly output.
|
467
|
-
* console.log(
|
518
|
+
* console.log(inspect(o, { compact: false, depth: 5, breakLength: 80 }));
|
468
519
|
*
|
469
520
|
* // {
|
470
521
|
* // a: [
|
@@ -491,11 +542,10 @@ declare module "util" {
|
|
491
542
|
* // single line.
|
492
543
|
* ```
|
493
544
|
*
|
494
|
-
* The `showHidden` option allows
|
495
|
-
* [`WeakSet`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet) entries to be
|
545
|
+
* The `showHidden` option allows `WeakMap` and `WeakSet` entries to be
|
496
546
|
* inspected. If there are more entries than `maxArrayLength`, there is no
|
497
|
-
* guarantee which entries are displayed. That means retrieving the same
|
498
|
-
* result in different output. Furthermore, entries
|
547
|
+
* guarantee which entries are displayed. That means retrieving the same
|
548
|
+
* `WeakSet` entries twice may result in different output. Furthermore, entries
|
499
549
|
* with no remaining strong references may be garbage collected at any time.
|
500
550
|
*
|
501
551
|
* ```js
|
@@ -543,10 +593,10 @@ declare module "util" {
|
|
543
593
|
* ```js
|
544
594
|
* import { inspect } from 'node:util';
|
545
595
|
*
|
546
|
-
* const thousand =
|
547
|
-
* const million =
|
548
|
-
* const bigNumber =
|
549
|
-
* const bigDecimal =
|
596
|
+
* const thousand = 1000;
|
597
|
+
* const million = 1000000;
|
598
|
+
* const bigNumber = 123456789n;
|
599
|
+
* const bigDecimal = 1234.12345;
|
550
600
|
*
|
551
601
|
* console.log(inspect(thousand, { numericSeparator: true }));
|
552
602
|
* // 1_000
|
@@ -667,19 +717,23 @@ declare module "util" {
|
|
667
717
|
*/
|
668
718
|
export function isError(object: unknown): object is Error;
|
669
719
|
/**
|
670
|
-
* Usage of `util.inherits()` is discouraged. Please use the ES6 `class` and
|
720
|
+
* Usage of `util.inherits()` is discouraged. Please use the ES6 `class` and
|
721
|
+
* `extends` keywords to get language level inheritance support. Also note
|
671
722
|
* that the two styles are [semantically incompatible](https://github.com/nodejs/node/issues/4179).
|
672
723
|
*
|
673
|
-
* Inherit the prototype methods from one
|
674
|
-
*
|
724
|
+
* Inherit the prototype methods from one
|
725
|
+
* [constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor) into another. The
|
726
|
+
* prototype of `constructor` will be set to a new object created from
|
727
|
+
* `superConstructor`.
|
675
728
|
*
|
676
|
-
* This mainly adds some input validation on top of
|
729
|
+
* This mainly adds some input validation on top of
|
730
|
+
* `Object.setPrototypeOf(constructor.prototype, superConstructor.prototype)`.
|
677
731
|
* As an additional convenience, `superConstructor` will be accessible
|
678
732
|
* through the `constructor.super_` property.
|
679
733
|
*
|
680
734
|
* ```js
|
681
|
-
*
|
682
|
-
*
|
735
|
+
* const util = require('node:util');
|
736
|
+
* const EventEmitter = require('node:events');
|
683
737
|
*
|
684
738
|
* function MyStream() {
|
685
739
|
* EventEmitter.call(this);
|
@@ -726,18 +780,42 @@ declare module "util" {
|
|
726
780
|
export function inherits(constructor: unknown, superConstructor: unknown): void;
|
727
781
|
export type DebugLoggerFunction = (msg: string, ...param: unknown[]) => void;
|
728
782
|
export interface DebugLogger extends DebugLoggerFunction {
|
783
|
+
/**
|
784
|
+
* The `util.debuglog().enabled` getter is used to create a test that can be used
|
785
|
+
* in conditionals based on the existence of the `NODE_DEBUG` environment variable.
|
786
|
+
* If the `section` name appears within the value of that environment variable,
|
787
|
+
* then the returned value will be `true`. If not, then the returned value will be
|
788
|
+
* `false`.
|
789
|
+
*
|
790
|
+
* ```js
|
791
|
+
* import { debuglog } from 'node:util';
|
792
|
+
* const enabled = debuglog('foo').enabled;
|
793
|
+
* if (enabled) {
|
794
|
+
* console.log('hello from foo [%d]', 123);
|
795
|
+
* }
|
796
|
+
* ```
|
797
|
+
*
|
798
|
+
* If this program is run with `NODE_DEBUG=foo` in the environment, then it will
|
799
|
+
* output something like:
|
800
|
+
*
|
801
|
+
* ```console
|
802
|
+
* hello from foo [123]
|
803
|
+
* ```
|
804
|
+
*/
|
729
805
|
enabled: boolean;
|
730
806
|
}
|
731
807
|
/**
|
732
808
|
* The `util.debuglog()` method is used to create a function that conditionally
|
733
|
-
* writes debug messages to `stderr` based on the existence of the `NODE_DEBUG`
|
734
|
-
* environment variable
|
809
|
+
* writes debug messages to `stderr` based on the existence of the `NODE_DEBUG`
|
810
|
+
* environment variable. If the `section` name appears within the value of that
|
811
|
+
* environment variable, then the returned function operates similar to
|
812
|
+
* `console.error()`. If not, then the returned function is a no-op.
|
735
813
|
*
|
736
814
|
* ```js
|
737
|
-
* import
|
738
|
-
* const
|
815
|
+
* import { debuglog } from 'node:util';
|
816
|
+
* const log = debuglog('foo');
|
739
817
|
*
|
740
|
-
*
|
818
|
+
* log('hello from foo [%d]', 123);
|
741
819
|
* ```
|
742
820
|
*
|
743
821
|
* If this program is run with `NODE_DEBUG=foo` in the environment, then
|
@@ -753,10 +831,10 @@ declare module "util" {
|
|
753
831
|
* The `section` supports wildcard also:
|
754
832
|
*
|
755
833
|
* ```js
|
756
|
-
* import
|
757
|
-
* const
|
834
|
+
* import { debuglog } from 'node:util';
|
835
|
+
* const log = debuglog('foo');
|
758
836
|
*
|
759
|
-
*
|
837
|
+
* log('hi there, it\'s foo-bar [%d]', 2333);
|
760
838
|
* ```
|
761
839
|
*
|
762
840
|
* if it is run with `NODE_DEBUG=foo*` in the environment, then it will output
|
@@ -766,18 +844,19 @@ declare module "util" {
|
|
766
844
|
* FOO-BAR 3257: hi there, it's foo-bar [2333]
|
767
845
|
* ```
|
768
846
|
*
|
769
|
-
* Multiple comma-separated `section` names may be specified in the `NODE_DEBUG`
|
847
|
+
* Multiple comma-separated `section` names may be specified in the `NODE_DEBUG`
|
848
|
+
* environment variable: `NODE_DEBUG=fs,net,tls`.
|
770
849
|
*
|
771
850
|
* The optional `callback` argument can be used to replace the logging function
|
772
851
|
* with a different function that doesn't have any initialization or
|
773
852
|
* unnecessary wrapping.
|
774
853
|
*
|
775
854
|
* ```js
|
776
|
-
* import
|
777
|
-
* let
|
855
|
+
* import { debuglog } from 'node:util';
|
856
|
+
* let log = debuglog('internals', (debug) => {
|
778
857
|
* // Replace with a logging function that optimizes out
|
779
858
|
* // testing if the section is enabled
|
780
|
-
*
|
859
|
+
* log = debug;
|
781
860
|
* });
|
782
861
|
* ```
|
783
862
|
* @since v0.11.3
|
@@ -786,7 +865,7 @@ declare module "util" {
|
|
786
865
|
* @return The logging function
|
787
866
|
*/
|
788
867
|
export function debuglog(section: string, callback?: (fn: DebugLoggerFunction) => void): DebugLogger;
|
789
|
-
export
|
868
|
+
export { debuglog as debug };
|
790
869
|
/**
|
791
870
|
* Returns `true` if the given `object` is a `Boolean`. Otherwise, returns `false`.
|
792
871
|
*
|
@@ -1003,14 +1082,15 @@ declare module "util" {
|
|
1003
1082
|
* such a way that it is marked as deprecated.
|
1004
1083
|
*
|
1005
1084
|
* ```js
|
1006
|
-
* import
|
1085
|
+
* import { deprecate } from 'node:util';
|
1007
1086
|
*
|
1008
|
-
*
|
1087
|
+
* export const obsoleteFunction = deprecate(() => {
|
1009
1088
|
* // Do something here.
|
1010
1089
|
* }, 'obsoleteFunction() is deprecated. Use newShinyFunction() instead.');
|
1011
1090
|
* ```
|
1012
1091
|
*
|
1013
|
-
* When called, `util.deprecate()` will return a function that will emit a
|
1092
|
+
* When called, `util.deprecate()` will return a function that will emit a
|
1093
|
+
* `DeprecationWarning` using the `'warning'` event. The warning will
|
1014
1094
|
* be emitted and printed to `stderr` the first time the returned function is
|
1015
1095
|
* called. After the warning is emitted, the wrapped function is called without
|
1016
1096
|
* emitting a warning.
|
@@ -1019,16 +1099,24 @@ declare module "util" {
|
|
1019
1099
|
* the warning will be emitted only once for that `code`.
|
1020
1100
|
*
|
1021
1101
|
* ```js
|
1022
|
-
* import
|
1102
|
+
* import { deprecate } from 'node:util';
|
1023
1103
|
*
|
1024
|
-
* const fn1 =
|
1025
|
-
*
|
1104
|
+
* const fn1 = deprecate(
|
1105
|
+
* () => 'a value',
|
1106
|
+
* 'deprecation message',
|
1107
|
+
* 'DEP0001',
|
1108
|
+
* );
|
1109
|
+
* const fn2 = deprecate(
|
1110
|
+
* () => 'a different value',
|
1111
|
+
* 'other dep message',
|
1112
|
+
* 'DEP0001',
|
1113
|
+
* );
|
1026
1114
|
* fn1(); // Emits a deprecation warning with code DEP0001
|
1027
1115
|
* fn2(); // Does not emit a deprecation warning because it has the same code
|
1028
1116
|
* ```
|
1029
1117
|
*
|
1030
1118
|
* If either the `--no-deprecation` or `--no-warnings` command-line flags are
|
1031
|
-
* used, or if the `process.noDeprecation` property is set to `true`_prior_ to
|
1119
|
+
* used, or if the `process.noDeprecation` property is set to `true` _prior_ to
|
1032
1120
|
* the first deprecation warning, the `util.deprecate()` method does nothing.
|
1033
1121
|
*
|
1034
1122
|
* If the `--trace-deprecation` or `--trace-warnings` command-line flags are set,
|
@@ -1036,10 +1124,13 @@ declare module "util" {
|
|
1036
1124
|
* stack trace are printed to `stderr` the first time the deprecated function is
|
1037
1125
|
* called.
|
1038
1126
|
*
|
1039
|
-
* If the `--throw-deprecation` command-line flag is set, or the
|
1127
|
+
* If the `--throw-deprecation` command-line flag is set, or the
|
1128
|
+
* `process.throwDeprecation` property is set to `true`, then an exception will be
|
1040
1129
|
* thrown when the deprecated function is called.
|
1041
1130
|
*
|
1042
|
-
* The `--throw-deprecation` command-line flag and `process.throwDeprecation`
|
1131
|
+
* The `--throw-deprecation` command-line flag and `process.throwDeprecation`
|
1132
|
+
* property take precedence over `--trace-deprecation` and
|
1133
|
+
* `process.traceDeprecation`.
|
1043
1134
|
* @since v0.8.0
|
1044
1135
|
* @param fn The function that is being deprecated.
|
1045
1136
|
* @param msg A warning message to display when the deprecated function is invoked.
|
@@ -1070,15 +1161,16 @@ declare module "util" {
|
|
1070
1161
|
* Takes an `async` function (or a function that returns a `Promise`) and returns a
|
1071
1162
|
* function following the error-first callback style, i.e. taking
|
1072
1163
|
* an `(err, value) => ...` callback as the last argument. In the callback, the
|
1073
|
-
* first argument will be the rejection reason (or `null` if the `Promise`
|
1164
|
+
* first argument will be the rejection reason (or `null` if the `Promise`
|
1165
|
+
* resolved), and the second argument will be the resolved value.
|
1074
1166
|
*
|
1075
1167
|
* ```js
|
1076
|
-
* import
|
1168
|
+
* import { callbackify } from 'node:util';
|
1077
1169
|
*
|
1078
1170
|
* async function fn() {
|
1079
1171
|
* return 'hello world';
|
1080
1172
|
* }
|
1081
|
-
* const callbackFunction =
|
1173
|
+
* const callbackFunction = callbackify(fn);
|
1082
1174
|
*
|
1083
1175
|
* callbackFunction((err, ret) => {
|
1084
1176
|
* if (err) throw err;
|
@@ -1093,11 +1185,13 @@ declare module "util" {
|
|
1093
1185
|
* ```
|
1094
1186
|
*
|
1095
1187
|
* The callback is executed asynchronously, and will have a limited stack trace.
|
1096
|
-
* If the callback throws, the process will emit an `'uncaughtException'`
|
1188
|
+
* If the callback throws, the process will emit an `'uncaughtException'`
|
1189
|
+
* event, and if not handled will exit.
|
1097
1190
|
*
|
1098
1191
|
* Since `null` has a special meaning as the first argument to a callback, if a
|
1099
1192
|
* wrapped function rejects a `Promise` with a falsy value as a reason, the value
|
1100
|
-
* is wrapped in an `Error` with the original value stored in a field named
|
1193
|
+
* is wrapped in an `Error` with the original value stored in a field named
|
1194
|
+
* `reason`.
|
1101
1195
|
*
|
1102
1196
|
* ```js
|
1103
1197
|
* function fn() {
|
@@ -1108,7 +1202,7 @@ declare module "util" {
|
|
1108
1202
|
* callbackFunction((err, ret) => {
|
1109
1203
|
* // When the Promise was rejected with `null` it is wrapped with an Error and
|
1110
1204
|
* // the original value is stored in `reason`.
|
1111
|
-
* err
|
1205
|
+
* err && Object.hasOwn(err, 'reason') && err.reason === null; // true
|
1112
1206
|
* });
|
1113
1207
|
* ```
|
1114
1208
|
* @since v8.2.0
|
@@ -1199,11 +1293,11 @@ declare module "util" {
|
|
1199
1293
|
* that returns promises.
|
1200
1294
|
*
|
1201
1295
|
* ```js
|
1202
|
-
* import
|
1203
|
-
* import
|
1296
|
+
* import { promisify } from 'node:util';
|
1297
|
+
* import { stat } from 'node:fs';
|
1204
1298
|
*
|
1205
|
-
* const
|
1206
|
-
*
|
1299
|
+
* const promisifiedStat = promisify(stat);
|
1300
|
+
* promisifiedStat('.').then((stats) => {
|
1207
1301
|
* // Do something with `stats`
|
1208
1302
|
* }).catch((error) => {
|
1209
1303
|
* // Handle the error.
|
@@ -1213,23 +1307,25 @@ declare module "util" {
|
|
1213
1307
|
* Or, equivalently using `async function`s:
|
1214
1308
|
*
|
1215
1309
|
* ```js
|
1216
|
-
* import
|
1217
|
-
* import
|
1310
|
+
* import { promisify } from 'node:util';
|
1311
|
+
* import { stat } from 'node:fs';
|
1218
1312
|
*
|
1219
|
-
* const
|
1313
|
+
* const promisifiedStat = promisify(stat);
|
1220
1314
|
*
|
1221
1315
|
* async function callStat() {
|
1222
|
-
* const stats = await
|
1316
|
+
* const stats = await promisifiedStat('.');
|
1223
1317
|
* console.log(`This directory is owned by ${stats.uid}`);
|
1224
1318
|
* }
|
1225
1319
|
*
|
1226
1320
|
* callStat();
|
1227
1321
|
* ```
|
1228
1322
|
*
|
1229
|
-
* If there is an `original[util.promisify.custom]` property present, `promisify`
|
1323
|
+
* 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-v22.x/api/util.html#custom-promisified-functions).
|
1230
1325
|
*
|
1231
1326
|
* `promisify()` assumes that `original` is a function taking a callback as its
|
1232
|
-
* final argument in all cases. If `original` is not a function, `promisify()`
|
1327
|
+
* final argument in all cases. If `original` is not a function, `promisify()`
|
1328
|
+
* will throw an error. If `original` is a function but its last argument is not
|
1233
1329
|
* an error-first callback, it will still be passed an error-first
|
1234
1330
|
* callback as its last argument.
|
1235
1331
|
*
|
@@ -1237,7 +1333,7 @@ declare module "util" {
|
|
1237
1333
|
* work as expected unless handled specially:
|
1238
1334
|
*
|
1239
1335
|
* ```js
|
1240
|
-
* import
|
1336
|
+
* import { promisify } from 'node:util';
|
1241
1337
|
*
|
1242
1338
|
* class Foo {
|
1243
1339
|
* constructor() {
|
@@ -1251,8 +1347,8 @@ declare module "util" {
|
|
1251
1347
|
*
|
1252
1348
|
* const foo = new Foo();
|
1253
1349
|
*
|
1254
|
-
* const naiveBar =
|
1255
|
-
* // TypeError: Cannot read
|
1350
|
+
* const naiveBar = promisify(foo.bar);
|
1351
|
+
* // TypeError: Cannot read properties of undefined (reading 'a')
|
1256
1352
|
* // naiveBar().then(a => console.log(a));
|
1257
1353
|
*
|
1258
1354
|
* naiveBar.call(foo).then((a) => console.log(a)); // '42'
|
@@ -1371,15 +1467,29 @@ declare module "util" {
|
|
1371
1467
|
| "strikethrough"
|
1372
1468
|
| "underline";
|
1373
1469
|
/**
|
1374
|
-
* This function returns a formatted text considering the `format` passed
|
1470
|
+
* This function returns a formatted text considering the `format` passed
|
1471
|
+
* for printing in a terminal. It is aware of the terminal's capabilities
|
1472
|
+
* and acts according to the configuration set via `NO_COLORS`,
|
1473
|
+
* `NODE_DISABLE_COLORS` and `FORCE_COLOR` environment variables.
|
1375
1474
|
*
|
1376
1475
|
* ```js
|
1377
1476
|
* import { styleText } from 'node:util';
|
1378
|
-
*
|
1379
|
-
*
|
1477
|
+
* import { stderr } from 'node:process';
|
1478
|
+
*
|
1479
|
+
* const successMessage = styleText('green', 'Success!');
|
1480
|
+
* console.log(successMessage);
|
1481
|
+
*
|
1482
|
+
* const errorMessage = styleText(
|
1483
|
+
* 'red',
|
1484
|
+
* 'Error! Error!',
|
1485
|
+
* // Validate if process.stderr has TTY
|
1486
|
+
* { stream: stderr },
|
1487
|
+
* );
|
1488
|
+
* console.error(errorMessage);
|
1380
1489
|
* ```
|
1381
1490
|
*
|
1382
|
-
* `util.inspect.colors` also provides text formats such as `italic`, and
|
1491
|
+
* `util.inspect.colors` also provides text formats such as `italic`, and
|
1492
|
+
* `underline` and you can combine both:
|
1383
1493
|
*
|
1384
1494
|
* ```js
|
1385
1495
|
* console.log(
|
@@ -1387,8 +1497,8 @@ declare module "util" {
|
|
1387
1497
|
* );
|
1388
1498
|
* ```
|
1389
1499
|
*
|
1390
|
-
* When passing an array of formats, the order of the format applied
|
1391
|
-
* might overwrite the previous one.
|
1500
|
+
* When passing an array of formats, the order of the format applied
|
1501
|
+
* is left to right so the following style might overwrite the previous one.
|
1392
1502
|
*
|
1393
1503
|
* ```js
|
1394
1504
|
* console.log(
|
@@ -1768,7 +1878,6 @@ declare module "util" {
|
|
1768
1878
|
* components. When parsed, a `MIMEType` object is returned containing
|
1769
1879
|
* properties for each of these components.
|
1770
1880
|
* @since v19.1.0, v18.13.0
|
1771
|
-
* @experimental
|
1772
1881
|
*/
|
1773
1882
|
export class MIMEType {
|
1774
1883
|
/**
|
@@ -2067,7 +2176,9 @@ declare module "util/types" {
|
|
2067
2176
|
* A native `External` value is a special type of object that contains a
|
2068
2177
|
* raw C++ pointer (`void*`) for access from native code, and has no other
|
2069
2178
|
* properties. Such objects are created either by Node.js internals or native
|
2070
|
-
* addons. In JavaScript, they are
|
2179
|
+
* addons. In JavaScript, they are
|
2180
|
+
* [frozen](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze) objects with a
|
2181
|
+
* `null` prototype.
|
2071
2182
|
*
|
2072
2183
|
* ```c
|
2073
2184
|
* #include <js_native_api.h>
|
@@ -2075,7 +2186,7 @@ declare module "util/types" {
|
|
2075
2186
|
* napi_value result;
|
2076
2187
|
* static napi_value MyNapi(napi_env env, napi_callback_info info) {
|
2077
2188
|
* int* raw = (int*) malloc(1024);
|
2078
|
-
* napi_status status = napi_create_external(env, (void*) raw, NULL, NULL,
|
2189
|
+
* napi_status status = napi_create_external(env, (void*) raw, NULL, NULL, &result);
|
2079
2190
|
* if (status != napi_ok) {
|
2080
2191
|
* napi_throw_error(env, NULL, "napi_create_external failed");
|
2081
2192
|
* return NULL;
|
@@ -2088,14 +2199,17 @@ declare module "util/types" {
|
|
2088
2199
|
* ```
|
2089
2200
|
*
|
2090
2201
|
* ```js
|
2091
|
-
*
|
2202
|
+
* import native from 'napi_addon.node';
|
2203
|
+
* import { types } from 'node:util';
|
2204
|
+
*
|
2092
2205
|
* const data = native.myNapi();
|
2093
|
-
*
|
2094
|
-
*
|
2095
|
-
*
|
2206
|
+
* types.isExternal(data); // returns true
|
2207
|
+
* types.isExternal(0); // returns false
|
2208
|
+
* types.isExternal(new String('foo')); // returns false
|
2096
2209
|
* ```
|
2097
2210
|
*
|
2098
|
-
* For further information on `napi_create_external`, refer to
|
2211
|
+
* For further information on `napi_create_external`, refer to
|
2212
|
+
* [`napi_create_external()`](https://nodejs.org/docs/latest-v22.x/api/n-api.html#napi_create_external).
|
2099
2213
|
* @since v10.0.0
|
2100
2214
|
*/
|
2101
2215
|
function isExternal(object: unknown): boolean;
|
@@ -2219,7 +2333,8 @@ declare module "util/types" {
|
|
2219
2333
|
*/
|
2220
2334
|
function isModuleNamespaceObject(value: unknown): boolean;
|
2221
2335
|
/**
|
2222
|
-
* Returns `true` if the value was returned by the constructor of a
|
2336
|
+
* Returns `true` if the value was returned by the constructor of a
|
2337
|
+
* [built-in `Error` type](https://tc39.es/ecma262/#sec-error-objects).
|
2223
2338
|
*
|
2224
2339
|
* ```js
|
2225
2340
|
* console.log(util.types.isNativeError(new Error())); // true
|
@@ -2234,14 +2349,18 @@ declare module "util/types" {
|
|
2234
2349
|
* console.log(util.types.isNativeError(new MyError())); // true
|
2235
2350
|
* ```
|
2236
2351
|
*
|
2237
|
-
* A value being `instanceof` a native error class is not equivalent to `isNativeError()`
|
2238
|
-
*
|
2352
|
+
* A value being `instanceof` a native error class is not equivalent to `isNativeError()`
|
2353
|
+
* returning `true` for that value. `isNativeError()` returns `true` for errors
|
2354
|
+
* which come from a different [realm](https://tc39.es/ecma262/#realm) while `instanceof Error` returns `false`
|
2355
|
+
* for these errors:
|
2239
2356
|
*
|
2240
2357
|
* ```js
|
2241
|
-
* import
|
2242
|
-
*
|
2243
|
-
*
|
2244
|
-
*
|
2358
|
+
* import { createContext, runInContext } from 'node:vm';
|
2359
|
+
* import { types } from 'node:util';
|
2360
|
+
*
|
2361
|
+
* const context = createContext({});
|
2362
|
+
* const myError = runInContext('new Error()', context);
|
2363
|
+
* console.log(types.isNativeError(myError)); // true
|
2245
2364
|
* console.log(myError instanceof Error); // false
|
2246
2365
|
* ```
|
2247
2366
|
*
|