@idlebox/stripe-node-types 24.0.14 → 24.0.15
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/README.md +1 -1
- package/assert/strict.d.ts +98 -1
- package/assert.d.ts +147 -248
- package/async_hooks.d.ts +5 -5
- package/buffer.buffer.d.ts +9 -6
- package/buffer.d.ts +49 -169
- package/child_process.d.ts +102 -223
- package/cluster.d.ts +236 -329
- package/console.d.ts +45 -346
- package/constants.d.ts +0 -1
- package/crypto.d.ts +698 -1149
- package/dgram.d.ts +15 -50
- package/diagnostics_channel.d.ts +1 -3
- package/dns.d.ts +135 -131
- package/domain.d.ts +10 -14
- package/events.d.ts +846 -722
- package/fs/promises.d.ts +102 -53
- package/fs.d.ts +714 -484
- package/globals.d.ts +130 -347
- package/globals.typedarray.d.ts +79 -0
- package/http.d.ts +343 -246
- package/http2.d.ts +563 -711
- package/https.d.ts +70 -216
- package/index.d.ts +24 -3
- package/inspector/promises.d.ts +54 -0
- package/inspector.d.ts +167 -3938
- package/inspector.generated.d.ts +4242 -0
- package/module.d.ts +45 -95
- package/net.d.ts +87 -186
- package/os.d.ts +17 -6
- package/package.json +3 -8
- package/path/posix.d.ts +20 -0
- package/path/win32.d.ts +20 -0
- package/path.d.ts +117 -122
- package/perf_hooks.d.ts +295 -644
- package/process.d.ts +177 -138
- package/punycode.d.ts +2 -2
- package/querystring.d.ts +1 -1
- package/quic.d.ts +926 -0
- package/readline/promises.d.ts +1 -1
- package/readline.d.ts +65 -118
- package/repl.d.ts +83 -96
- package/sea.d.ts +10 -1
- package/sqlite.d.ts +262 -13
- package/stream/consumers.d.ts +7 -7
- package/stream/promises.d.ts +133 -12
- package/stream/web.d.ts +173 -495
- package/stream.d.ts +593 -490
- package/string_decoder.d.ts +3 -3
- package/test/reporters.d.ts +112 -0
- package/test.d.ts +223 -199
- package/timers/promises.d.ts +1 -1
- package/timers.d.ts +1 -129
- package/tls.d.ts +148 -163
- package/trace_events.d.ts +6 -6
- package/ts5.6/buffer.buffer.d.ts +10 -8
- package/ts5.6/globals.typedarray.d.ts +16 -0
- package/ts5.6/index.d.ts +24 -3
- package/ts5.7/index.d.ts +24 -3
- package/tty.d.ts +55 -13
- package/url.d.ts +92 -587
- package/util/types.d.ts +571 -0
- package/util.d.ts +143 -792
- package/v8.d.ts +67 -7
- package/vm.d.ts +252 -108
- package/wasi.d.ts +23 -2
- package/web-globals/abortcontroller.d.ts +75 -0
- package/web-globals/blob.d.ts +39 -0
- package/{ts5.1/compatibility/disposable.d.ts → web-globals/console.d.ts} +6 -9
- package/web-globals/crypto.d.ts +55 -0
- package/web-globals/domexception.d.ts +84 -0
- package/web-globals/encoding.d.ts +27 -0
- package/{dom-events.d.ts → web-globals/events.d.ts} +57 -50
- package/web-globals/fetch.d.ts +70 -0
- package/web-globals/importmeta.d.ts +29 -0
- package/web-globals/messaging.d.ts +39 -0
- package/web-globals/navigator.d.ts +41 -0
- package/web-globals/performance.d.ts +61 -0
- package/web-globals/storage.d.ts +40 -0
- package/web-globals/streams.d.ts +131 -0
- package/web-globals/timers.d.ts +60 -0
- package/web-globals/url.d.ts +40 -0
- package/worker_threads.d.ts +291 -349
- package/zlib.d.ts +44 -94
- package/ts5.1/index.d.ts +0 -115
package/util.d.ts
CHANGED
|
@@ -21,11 +21,61 @@
|
|
|
21
21
|
* ```js
|
|
22
22
|
* import util from 'node:util';
|
|
23
23
|
* ```
|
|
24
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
24
|
+
* @see [source](https://github.com/nodejs/node/blob/v25.x/lib/util.js)
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
declare module "node:util" {
|
|
28
|
-
|
|
28
|
+
export * as types from "node:util/types";
|
|
29
|
+
export type InspectStyle =
|
|
30
|
+
| "special"
|
|
31
|
+
| "number"
|
|
32
|
+
| "bigint"
|
|
33
|
+
| "boolean"
|
|
34
|
+
| "undefined"
|
|
35
|
+
| "null"
|
|
36
|
+
| "string"
|
|
37
|
+
| "symbol"
|
|
38
|
+
| "date"
|
|
39
|
+
| "name"
|
|
40
|
+
| "regexp"
|
|
41
|
+
| "module";
|
|
42
|
+
export interface InspectStyles extends Record<InspectStyle, InspectColor | ((value: string) => string)> {
|
|
43
|
+
regexp: {
|
|
44
|
+
(value: string): string;
|
|
45
|
+
colors: InspectColor[];
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export type InspectColorModifier =
|
|
49
|
+
| "reset"
|
|
50
|
+
| "bold"
|
|
51
|
+
| "dim"
|
|
52
|
+
| "italic"
|
|
53
|
+
| "underline"
|
|
54
|
+
| "blink"
|
|
55
|
+
| "inverse"
|
|
56
|
+
| "hidden"
|
|
57
|
+
| "strikethrough"
|
|
58
|
+
| "doubleunderline";
|
|
59
|
+
export type InspectColorForeground =
|
|
60
|
+
| "black"
|
|
61
|
+
| "red"
|
|
62
|
+
| "green"
|
|
63
|
+
| "yellow"
|
|
64
|
+
| "blue"
|
|
65
|
+
| "magenta"
|
|
66
|
+
| "cyan"
|
|
67
|
+
| "white"
|
|
68
|
+
| "gray"
|
|
69
|
+
| "redBright"
|
|
70
|
+
| "greenBright"
|
|
71
|
+
| "yellowBright"
|
|
72
|
+
| "blueBright"
|
|
73
|
+
| "magentaBright"
|
|
74
|
+
| "cyanBright"
|
|
75
|
+
| "whiteBright";
|
|
76
|
+
export type InspectColorBackground = `bg${Capitalize<InspectColorForeground>}`;
|
|
77
|
+
export type InspectColor = InspectColorModifier | InspectColorForeground | InspectColorBackground;
|
|
78
|
+
export interface InspectColors extends Record<InspectColor, [number, number]> {}
|
|
29
79
|
export interface InspectOptions {
|
|
30
80
|
/**
|
|
31
81
|
* If `true`, object's non-enumerable symbols and properties are included in the formatted result.
|
|
@@ -108,22 +158,26 @@ declare module "node:util" {
|
|
|
108
158
|
*/
|
|
109
159
|
numericSeparator?: boolean | undefined;
|
|
110
160
|
}
|
|
111
|
-
export
|
|
112
|
-
|
|
113
|
-
| "number"
|
|
114
|
-
| "bigint"
|
|
115
|
-
| "boolean"
|
|
116
|
-
| "undefined"
|
|
117
|
-
| "null"
|
|
118
|
-
| "string"
|
|
119
|
-
| "symbol"
|
|
120
|
-
| "date"
|
|
121
|
-
| "regexp"
|
|
122
|
-
| "module";
|
|
123
|
-
export type CustomInspectFunction = (depth: number, options: InspectOptionsStylized) => any; // TODO: , inspect: inspect
|
|
124
|
-
export interface InspectOptionsStylized extends InspectOptions {
|
|
125
|
-
stylize(text: string, styleType: Style): string;
|
|
161
|
+
export interface InspectContext extends Required<InspectOptions> {
|
|
162
|
+
stylize(text: string, styleType: InspectStyle): string;
|
|
126
163
|
}
|
|
164
|
+
import _inspect = inspect;
|
|
165
|
+
export interface Inspectable {
|
|
166
|
+
[inspect.custom](depth: number, options: InspectContext, inspect: typeof _inspect): any;
|
|
167
|
+
}
|
|
168
|
+
// TODO: Remove these in a future major
|
|
169
|
+
/** @deprecated Use `InspectStyle` instead. */
|
|
170
|
+
export type Style = Exclude<InspectStyle, "name">;
|
|
171
|
+
/** @deprecated Use the `Inspectable` interface instead. */
|
|
172
|
+
export type CustomInspectFunction = (depth: number, options: InspectContext) => any;
|
|
173
|
+
/** @deprecated Use `InspectContext` instead. */
|
|
174
|
+
export interface InspectOptionsStylized extends InspectContext {}
|
|
175
|
+
/** @deprecated Use `InspectColorModifier` instead. */
|
|
176
|
+
export type Modifiers = InspectColorModifier;
|
|
177
|
+
/** @deprecated Use `InspectColorForeground` instead. */
|
|
178
|
+
export type ForegroundColors = InspectColorForeground;
|
|
179
|
+
/** @deprecated Use `InspectColorBackground` instead. */
|
|
180
|
+
export type BackgroundColors = InspectColorBackground;
|
|
127
181
|
export interface CallSiteObject {
|
|
128
182
|
/**
|
|
129
183
|
* Returns the name of the function associated with this call site.
|
|
@@ -259,7 +313,7 @@ declare module "node:util" {
|
|
|
259
313
|
* @since v10.0.0
|
|
260
314
|
*/
|
|
261
315
|
export function formatWithOptions(inspectOptions: InspectOptions, format?: any, ...param: any[]): string;
|
|
262
|
-
interface GetCallSitesOptions {
|
|
316
|
+
export interface GetCallSitesOptions {
|
|
263
317
|
/**
|
|
264
318
|
* Reconstruct the original location in the stacktrace from the source-map.
|
|
265
319
|
* Enabled by default with the flag `--enable-source-maps`.
|
|
@@ -354,6 +408,11 @@ declare module "node:util" {
|
|
|
354
408
|
* @since v9.7.0
|
|
355
409
|
*/
|
|
356
410
|
export function getSystemErrorName(err: number): string;
|
|
411
|
+
/**
|
|
412
|
+
* Enable or disable printing a stack trace on `SIGINT`. The API is only available on the main thread.
|
|
413
|
+
* @since 24.6.0
|
|
414
|
+
*/
|
|
415
|
+
export function setTraceSigInt(enable: boolean): void;
|
|
357
416
|
/**
|
|
358
417
|
* Returns a Map of all system error codes available from the Node.js API.
|
|
359
418
|
* The mapping between error codes and error names is platform-dependent.
|
|
@@ -447,8 +506,8 @@ declare module "node:util" {
|
|
|
447
506
|
* intended for debugging. The output of `util.inspect` may change at any time
|
|
448
507
|
* and should not be depended upon programmatically. Additional `options` may be
|
|
449
508
|
* passed that alter the result.
|
|
450
|
-
* `util.inspect()` will use the constructor's name and/or
|
|
451
|
-
* an identifiable tag for an inspected value.
|
|
509
|
+
* `util.inspect()` will use the constructor's name and/or `Symbol.toStringTag`
|
|
510
|
+
* property to make an identifiable tag for an inspected value.
|
|
452
511
|
*
|
|
453
512
|
* ```js
|
|
454
513
|
* class Foo {
|
|
@@ -620,19 +679,11 @@ declare module "node:util" {
|
|
|
620
679
|
export function inspect(object: any, showHidden?: boolean, depth?: number | null, color?: boolean): string;
|
|
621
680
|
export function inspect(object: any, options?: InspectOptions): string;
|
|
622
681
|
export namespace inspect {
|
|
623
|
-
|
|
624
|
-
let
|
|
625
|
-
|
|
626
|
-
};
|
|
682
|
+
const custom: unique symbol;
|
|
683
|
+
let colors: InspectColors;
|
|
684
|
+
let styles: InspectStyles;
|
|
627
685
|
let defaultOptions: InspectOptions;
|
|
628
|
-
/**
|
|
629
|
-
* Allows changing inspect settings from the repl.
|
|
630
|
-
*/
|
|
631
686
|
let replDefaults: InspectOptions;
|
|
632
|
-
/**
|
|
633
|
-
* That can be used to declare custom inspect functions.
|
|
634
|
-
*/
|
|
635
|
-
const custom: unique symbol;
|
|
636
687
|
}
|
|
637
688
|
/**
|
|
638
689
|
* Alias for [`Array.isArray()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray).
|
|
@@ -864,6 +915,15 @@ declare module "node:util" {
|
|
|
864
915
|
* @return The deprecated function wrapped to emit a warning.
|
|
865
916
|
*/
|
|
866
917
|
export function deprecate<T extends Function>(fn: T, msg: string, code?: string): T;
|
|
918
|
+
export interface IsDeepStrictEqualOptions {
|
|
919
|
+
/**
|
|
920
|
+
* If `true`, prototype and constructor
|
|
921
|
+
* comparison is skipped during deep strict equality check.
|
|
922
|
+
* @since v24.9.0
|
|
923
|
+
* @default false
|
|
924
|
+
*/
|
|
925
|
+
skipPrototype?: boolean | undefined;
|
|
926
|
+
}
|
|
867
927
|
/**
|
|
868
928
|
* Returns `true` if there is deep strict equality between `val1` and `val2`.
|
|
869
929
|
* Otherwise, returns `false`.
|
|
@@ -872,7 +932,7 @@ declare module "node:util" {
|
|
|
872
932
|
* equality.
|
|
873
933
|
* @since v9.0.0
|
|
874
934
|
*/
|
|
875
|
-
export function isDeepStrictEqual(val1: unknown, val2: unknown): boolean;
|
|
935
|
+
export function isDeepStrictEqual(val1: unknown, val2: unknown, options?: IsDeepStrictEqualOptions): boolean;
|
|
876
936
|
/**
|
|
877
937
|
* Returns `str` with any ANSI escape codes removed.
|
|
878
938
|
*
|
|
@@ -1047,7 +1107,7 @@ declare module "node:util" {
|
|
|
1047
1107
|
* ```
|
|
1048
1108
|
*
|
|
1049
1109
|
* If there is an `original[util.promisify.custom]` property present, `promisify`
|
|
1050
|
-
* will return its value, see [Custom promisified functions](https://nodejs.org/docs/latest-
|
|
1110
|
+
* will return its value, see [Custom promisified functions](https://nodejs.org/docs/latest-v25.x/api/util.html#custom-promisified-functions).
|
|
1051
1111
|
*
|
|
1052
1112
|
* `promisify()` assumes that `original` is a function taking a callback as its
|
|
1053
1113
|
* final argument in all cases. If `original` is not a function, `promisify()`
|
|
@@ -1138,60 +1198,6 @@ declare module "node:util" {
|
|
|
1138
1198
|
* @since v20.12.0
|
|
1139
1199
|
*/
|
|
1140
1200
|
export function parseEnv(content: string): NodeJS.Dict<string>;
|
|
1141
|
-
// https://nodejs.org/docs/latest/api/util.html#foreground-colors
|
|
1142
|
-
type ForegroundColors =
|
|
1143
|
-
| "black"
|
|
1144
|
-
| "blackBright"
|
|
1145
|
-
| "blue"
|
|
1146
|
-
| "blueBright"
|
|
1147
|
-
| "cyan"
|
|
1148
|
-
| "cyanBright"
|
|
1149
|
-
| "gray"
|
|
1150
|
-
| "green"
|
|
1151
|
-
| "greenBright"
|
|
1152
|
-
| "grey"
|
|
1153
|
-
| "magenta"
|
|
1154
|
-
| "magentaBright"
|
|
1155
|
-
| "red"
|
|
1156
|
-
| "redBright"
|
|
1157
|
-
| "white"
|
|
1158
|
-
| "whiteBright"
|
|
1159
|
-
| "yellow"
|
|
1160
|
-
| "yellowBright";
|
|
1161
|
-
// https://nodejs.org/docs/latest/api/util.html#background-colors
|
|
1162
|
-
type BackgroundColors =
|
|
1163
|
-
| "bgBlack"
|
|
1164
|
-
| "bgBlackBright"
|
|
1165
|
-
| "bgBlue"
|
|
1166
|
-
| "bgBlueBright"
|
|
1167
|
-
| "bgCyan"
|
|
1168
|
-
| "bgCyanBright"
|
|
1169
|
-
| "bgGray"
|
|
1170
|
-
| "bgGreen"
|
|
1171
|
-
| "bgGreenBright"
|
|
1172
|
-
| "bgGrey"
|
|
1173
|
-
| "bgMagenta"
|
|
1174
|
-
| "bgMagentaBright"
|
|
1175
|
-
| "bgRed"
|
|
1176
|
-
| "bgRedBright"
|
|
1177
|
-
| "bgWhite"
|
|
1178
|
-
| "bgWhiteBright"
|
|
1179
|
-
| "bgYellow"
|
|
1180
|
-
| "bgYellowBright";
|
|
1181
|
-
// https://nodejs.org/docs/latest/api/util.html#modifiers
|
|
1182
|
-
type Modifiers =
|
|
1183
|
-
| "blink"
|
|
1184
|
-
| "bold"
|
|
1185
|
-
| "dim"
|
|
1186
|
-
| "doubleunderline"
|
|
1187
|
-
| "framed"
|
|
1188
|
-
| "hidden"
|
|
1189
|
-
| "inverse"
|
|
1190
|
-
| "italic"
|
|
1191
|
-
| "overlined"
|
|
1192
|
-
| "reset"
|
|
1193
|
-
| "strikethrough"
|
|
1194
|
-
| "underline";
|
|
1195
1201
|
export interface StyleTextOptions {
|
|
1196
1202
|
/**
|
|
1197
1203
|
* When true, `stream` is checked to see if it can handle colors.
|
|
@@ -1244,142 +1250,21 @@ declare module "node:util" {
|
|
|
1244
1250
|
* );
|
|
1245
1251
|
* ```
|
|
1246
1252
|
*
|
|
1247
|
-
* The
|
|
1253
|
+
* The special format value `none` applies no additional styling to the text.
|
|
1254
|
+
*
|
|
1255
|
+
* The full list of formats can be found in [modifiers](https://nodejs.org/docs/latest-v25.x/api/util.html#modifiers).
|
|
1248
1256
|
* @param format A text format or an Array of text formats defined in `util.inspect.colors`.
|
|
1249
1257
|
* @param text The text to to be formatted.
|
|
1250
1258
|
* @since v20.12.0
|
|
1251
1259
|
*/
|
|
1252
1260
|
export function styleText(
|
|
1253
|
-
format:
|
|
1254
|
-
| ForegroundColors
|
|
1255
|
-
| BackgroundColors
|
|
1256
|
-
| Modifiers
|
|
1257
|
-
| Array<ForegroundColors | BackgroundColors | Modifiers>,
|
|
1261
|
+
format: InspectColor | readonly InspectColor[],
|
|
1258
1262
|
text: string,
|
|
1259
1263
|
options?: StyleTextOptions,
|
|
1260
1264
|
): string;
|
|
1261
|
-
/**
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
* ```js
|
|
1265
|
-
* const decoder = new TextDecoder();
|
|
1266
|
-
* const u8arr = new Uint8Array([72, 101, 108, 108, 111]);
|
|
1267
|
-
* console.log(decoder.decode(u8arr)); // Hello
|
|
1268
|
-
* ```
|
|
1269
|
-
* @since v8.3.0
|
|
1270
|
-
*/
|
|
1271
|
-
export class TextDecoder {
|
|
1272
|
-
/**
|
|
1273
|
-
* The encoding supported by the `TextDecoder` instance.
|
|
1274
|
-
*/
|
|
1275
|
-
readonly encoding: string;
|
|
1276
|
-
/**
|
|
1277
|
-
* The value will be `true` if decoding errors result in a `TypeError` being
|
|
1278
|
-
* thrown.
|
|
1279
|
-
*/
|
|
1280
|
-
readonly fatal: boolean;
|
|
1281
|
-
/**
|
|
1282
|
-
* The value will be `true` if the decoding result will include the byte order
|
|
1283
|
-
* mark.
|
|
1284
|
-
*/
|
|
1285
|
-
readonly ignoreBOM: boolean;
|
|
1286
|
-
constructor(
|
|
1287
|
-
encoding?: string,
|
|
1288
|
-
options?: {
|
|
1289
|
-
fatal?: boolean | undefined;
|
|
1290
|
-
ignoreBOM?: boolean | undefined;
|
|
1291
|
-
},
|
|
1292
|
-
);
|
|
1293
|
-
/**
|
|
1294
|
-
* Decodes the `input` and returns a string. If `options.stream` is `true`, any
|
|
1295
|
-
* incomplete byte sequences occurring at the end of the `input` are buffered
|
|
1296
|
-
* internally and emitted after the next call to `textDecoder.decode()`.
|
|
1297
|
-
*
|
|
1298
|
-
* If `textDecoder.fatal` is `true`, decoding errors that occur will result in a `TypeError` being thrown.
|
|
1299
|
-
* @param input An `ArrayBuffer`, `DataView`, or `TypedArray` instance containing the encoded data.
|
|
1300
|
-
*/
|
|
1301
|
-
decode(
|
|
1302
|
-
input?: NodeJS.ArrayBufferView | ArrayBuffer | null,
|
|
1303
|
-
options?: {
|
|
1304
|
-
stream?: boolean | undefined;
|
|
1305
|
-
},
|
|
1306
|
-
): string;
|
|
1307
|
-
}
|
|
1308
|
-
export interface EncodeIntoResult {
|
|
1309
|
-
/**
|
|
1310
|
-
* The read Unicode code units of input.
|
|
1311
|
-
*/
|
|
1312
|
-
read: number;
|
|
1313
|
-
/**
|
|
1314
|
-
* The written UTF-8 bytes of output.
|
|
1315
|
-
*/
|
|
1316
|
-
written: number;
|
|
1317
|
-
}
|
|
1318
|
-
export { types };
|
|
1319
|
-
|
|
1320
|
-
//// TextEncoder/Decoder
|
|
1321
|
-
/**
|
|
1322
|
-
* An implementation of the [WHATWG Encoding Standard](https://encoding.spec.whatwg.org/) `TextEncoder` API. All
|
|
1323
|
-
* instances of `TextEncoder` only support UTF-8 encoding.
|
|
1324
|
-
*
|
|
1325
|
-
* ```js
|
|
1326
|
-
* const encoder = new TextEncoder();
|
|
1327
|
-
* const uint8array = encoder.encode('this is some data');
|
|
1328
|
-
* ```
|
|
1329
|
-
*
|
|
1330
|
-
* The `TextEncoder` class is also available on the global object.
|
|
1331
|
-
* @since v8.3.0
|
|
1332
|
-
*/
|
|
1333
|
-
export class TextEncoder {
|
|
1334
|
-
/**
|
|
1335
|
-
* The encoding supported by the `TextEncoder` instance. Always set to `'utf-8'`.
|
|
1336
|
-
*/
|
|
1337
|
-
readonly encoding: string;
|
|
1338
|
-
/**
|
|
1339
|
-
* UTF-8 encodes the `input` string and returns a `Uint8Array` containing the
|
|
1340
|
-
* encoded bytes.
|
|
1341
|
-
* @param [input='an empty string'] The text to encode.
|
|
1342
|
-
*/
|
|
1343
|
-
encode(input?: string): Uint8Array;
|
|
1344
|
-
/**
|
|
1345
|
-
* UTF-8 encodes the `src` string to the `dest` Uint8Array and returns an object
|
|
1346
|
-
* containing the read Unicode code units and written UTF-8 bytes.
|
|
1347
|
-
*
|
|
1348
|
-
* ```js
|
|
1349
|
-
* const encoder = new TextEncoder();
|
|
1350
|
-
* const src = 'this is some data';
|
|
1351
|
-
* const dest = new Uint8Array(10);
|
|
1352
|
-
* const { read, written } = encoder.encodeInto(src, dest);
|
|
1353
|
-
* ```
|
|
1354
|
-
* @param src The text to encode.
|
|
1355
|
-
* @param dest The array to hold the encode result.
|
|
1356
|
-
*/
|
|
1357
|
-
encodeInto(src: string, dest: Uint8Array): EncodeIntoResult;
|
|
1358
|
-
}
|
|
1359
|
-
import { TextDecoder as _TextDecoder, TextEncoder as _TextEncoder } from 'node:util';
|
|
1360
|
-
global {
|
|
1361
|
-
/**
|
|
1362
|
-
* `TextDecoder` class is a global reference for `import { TextDecoder } from 'node:util'`
|
|
1363
|
-
* https://nodejs.org/api/globals.html#textdecoder
|
|
1364
|
-
* @since v11.0.0
|
|
1365
|
-
*/
|
|
1366
|
-
var TextDecoder: typeof globalThis extends {
|
|
1367
|
-
onmessage: any;
|
|
1368
|
-
TextDecoder: infer TextDecoder;
|
|
1369
|
-
} ? TextDecoder
|
|
1370
|
-
: typeof _TextDecoder;
|
|
1371
|
-
/**
|
|
1372
|
-
* `TextEncoder` class is a global reference for `import { TextEncoder } from 'node:util'`
|
|
1373
|
-
* https://nodejs.org/api/globals.html#textencoder
|
|
1374
|
-
* @since v11.0.0
|
|
1375
|
-
*/
|
|
1376
|
-
var TextEncoder: typeof globalThis extends {
|
|
1377
|
-
onmessage: any;
|
|
1378
|
-
TextEncoder: infer TextEncoder;
|
|
1379
|
-
} ? TextEncoder
|
|
1380
|
-
: typeof _TextEncoder;
|
|
1381
|
-
}
|
|
1382
|
-
|
|
1265
|
+
/** @deprecated This alias will be removed in a future version. Use the canonical `TextEncoderEncodeIntoResult` instead. */
|
|
1266
|
+
// TODO: remove in future major
|
|
1267
|
+
export interface EncodeIntoResult extends TextEncoderEncodeIntoResult {}
|
|
1383
1268
|
//// parseArgs
|
|
1384
1269
|
/**
|
|
1385
1270
|
* Provides a higher level API for command-line argument parsing than interacting
|
|
@@ -1410,12 +1295,10 @@ declare module "node:util" {
|
|
|
1410
1295
|
* @return The parsed command line arguments:
|
|
1411
1296
|
*/
|
|
1412
1297
|
export function parseArgs<T extends ParseArgsConfig>(config?: T): ParsedResults<T>;
|
|
1413
|
-
|
|
1414
1298
|
/**
|
|
1415
1299
|
* Type of argument used in {@link parseArgs}.
|
|
1416
1300
|
*/
|
|
1417
1301
|
export type ParseArgsOptionsType = "boolean" | "string";
|
|
1418
|
-
|
|
1419
1302
|
export interface ParseArgsOptionDescriptor {
|
|
1420
1303
|
/**
|
|
1421
1304
|
* Type of argument.
|
|
@@ -1433,10 +1316,12 @@ declare module "node:util" {
|
|
|
1433
1316
|
*/
|
|
1434
1317
|
short?: string | undefined;
|
|
1435
1318
|
/**
|
|
1436
|
-
* The
|
|
1437
|
-
*
|
|
1438
|
-
*
|
|
1439
|
-
*
|
|
1319
|
+
* The value to assign to
|
|
1320
|
+
* the option if it does not appear in the arguments to be parsed. The value
|
|
1321
|
+
* must match the type specified by the `type` property. If `multiple` is
|
|
1322
|
+
* `true`, it must be an array. No default value is applied when the option
|
|
1323
|
+
* does appear in the arguments to be parsed, even if the provided value
|
|
1324
|
+
* is falsy.
|
|
1440
1325
|
* @since v18.11.0
|
|
1441
1326
|
*/
|
|
1442
1327
|
default?: string | boolean | string[] | boolean[] | undefined;
|
|
@@ -1448,7 +1333,7 @@ declare module "node:util" {
|
|
|
1448
1333
|
/**
|
|
1449
1334
|
* Array of argument strings.
|
|
1450
1335
|
*/
|
|
1451
|
-
args?: string[] | undefined;
|
|
1336
|
+
args?: readonly string[] | undefined;
|
|
1452
1337
|
/**
|
|
1453
1338
|
* Used to describe arguments known to the parser.
|
|
1454
1339
|
*/
|
|
@@ -1488,23 +1373,19 @@ declare module "node:util" {
|
|
|
1488
1373
|
type IfDefaultsTrue<T, IfTrue, IfFalse> = T extends true ? IfTrue
|
|
1489
1374
|
: T extends false ? IfFalse
|
|
1490
1375
|
: IfTrue;
|
|
1491
|
-
|
|
1492
1376
|
// we put the `extends false` condition first here because `undefined` compares like `any` when `strictNullChecks: false`
|
|
1493
1377
|
type IfDefaultsFalse<T, IfTrue, IfFalse> = T extends false ? IfFalse
|
|
1494
1378
|
: T extends true ? IfTrue
|
|
1495
1379
|
: IfFalse;
|
|
1496
|
-
|
|
1497
1380
|
type ExtractOptionValue<T extends ParseArgsConfig, O extends ParseArgsOptionDescriptor> = IfDefaultsTrue<
|
|
1498
1381
|
T["strict"],
|
|
1499
1382
|
O["type"] extends "string" ? string : O["type"] extends "boolean" ? boolean : string | boolean,
|
|
1500
1383
|
string | boolean
|
|
1501
1384
|
>;
|
|
1502
|
-
|
|
1503
1385
|
type ApplyOptionalModifiers<O extends ParseArgsOptionsConfig, V extends Record<keyof O, unknown>> = (
|
|
1504
1386
|
& { -readonly [LongOption in keyof O]?: V[LongOption] }
|
|
1505
1387
|
& { [LongOption in keyof O as O[LongOption]["default"] extends {} ? LongOption : never]: V[LongOption] }
|
|
1506
1388
|
) extends infer P ? { [K in keyof P]: P[K] } : never; // resolve intersection to object
|
|
1507
|
-
|
|
1508
1389
|
type ParsedValues<T extends ParseArgsConfig> =
|
|
1509
1390
|
& IfDefaultsTrue<T["strict"], unknown, { [longOption: string]: undefined | string | boolean }>
|
|
1510
1391
|
& (T["options"] extends ParseArgsOptionsConfig ? ApplyOptionalModifiers<
|
|
@@ -1518,13 +1399,11 @@ declare module "node:util" {
|
|
|
1518
1399
|
}
|
|
1519
1400
|
>
|
|
1520
1401
|
: {});
|
|
1521
|
-
|
|
1522
1402
|
type ParsedPositionals<T extends ParseArgsConfig> = IfDefaultsTrue<
|
|
1523
1403
|
T["strict"],
|
|
1524
1404
|
IfDefaultsFalse<T["allowPositionals"], string[], []>,
|
|
1525
1405
|
IfDefaultsTrue<T["allowPositionals"], string[], []>
|
|
1526
1406
|
>;
|
|
1527
|
-
|
|
1528
1407
|
type PreciseTokenForOptions<
|
|
1529
1408
|
K extends string,
|
|
1530
1409
|
O extends ParseArgsOptionDescriptor,
|
|
@@ -1545,7 +1424,6 @@ declare module "node:util" {
|
|
|
1545
1424
|
inlineValue: undefined;
|
|
1546
1425
|
}
|
|
1547
1426
|
: OptionToken & { name: K };
|
|
1548
|
-
|
|
1549
1427
|
type TokenForOptions<
|
|
1550
1428
|
T extends ParseArgsConfig,
|
|
1551
1429
|
K extends keyof T["options"] = keyof T["options"],
|
|
@@ -1553,19 +1431,15 @@ declare module "node:util" {
|
|
|
1553
1431
|
? T["options"] extends ParseArgsOptionsConfig ? PreciseTokenForOptions<K & string, T["options"][K]>
|
|
1554
1432
|
: OptionToken
|
|
1555
1433
|
: never;
|
|
1556
|
-
|
|
1557
1434
|
type ParsedOptionToken<T extends ParseArgsConfig> = IfDefaultsTrue<T["strict"], TokenForOptions<T>, OptionToken>;
|
|
1558
|
-
|
|
1559
1435
|
type ParsedPositionalToken<T extends ParseArgsConfig> = IfDefaultsTrue<
|
|
1560
1436
|
T["strict"],
|
|
1561
1437
|
IfDefaultsFalse<T["allowPositionals"], { kind: "positional"; index: number; value: string }, never>,
|
|
1562
1438
|
IfDefaultsTrue<T["allowPositionals"], { kind: "positional"; index: number; value: string }, never>
|
|
1563
1439
|
>;
|
|
1564
|
-
|
|
1565
1440
|
type ParsedTokens<T extends ParseArgsConfig> = Array<
|
|
1566
1441
|
ParsedOptionToken<T> | ParsedPositionalToken<T> | { kind: "option-terminator"; index: number }
|
|
1567
1442
|
>;
|
|
1568
|
-
|
|
1569
1443
|
type PreciseParsedResults<T extends ParseArgsConfig> = IfDefaultsFalse<
|
|
1570
1444
|
T["tokens"],
|
|
1571
1445
|
{
|
|
@@ -1578,7 +1452,6 @@ declare module "node:util" {
|
|
|
1578
1452
|
positionals: ParsedPositionals<T>;
|
|
1579
1453
|
}
|
|
1580
1454
|
>;
|
|
1581
|
-
|
|
1582
1455
|
type OptionToken =
|
|
1583
1456
|
| { kind: "option"; index: number; name: string; rawName: string; value: string; inlineValue: boolean }
|
|
1584
1457
|
| {
|
|
@@ -1589,12 +1462,10 @@ declare module "node:util" {
|
|
|
1589
1462
|
value: undefined;
|
|
1590
1463
|
inlineValue: undefined;
|
|
1591
1464
|
};
|
|
1592
|
-
|
|
1593
1465
|
type Token =
|
|
1594
1466
|
| OptionToken
|
|
1595
1467
|
| { kind: "positional"; index: number; value: string }
|
|
1596
1468
|
| { kind: "option-terminator"; index: number };
|
|
1597
|
-
|
|
1598
1469
|
// If ParseArgsConfig extends T, then the user passed config constructed elsewhere.
|
|
1599
1470
|
// So we can't rely on the `"not definitely present" implies "definitely not present"` assumption mentioned above.
|
|
1600
1471
|
type ParsedResults<T extends ParseArgsConfig> = ParseArgsConfig extends T ? {
|
|
@@ -1605,7 +1476,6 @@ declare module "node:util" {
|
|
|
1605
1476
|
tokens?: Token[];
|
|
1606
1477
|
}
|
|
1607
1478
|
: PreciseParsedResults<T>;
|
|
1608
|
-
|
|
1609
1479
|
/**
|
|
1610
1480
|
* An implementation of [the MIMEType class](https://bmeck.github.io/node-proposal-mime-api/).
|
|
1611
1481
|
*
|
|
@@ -1627,7 +1497,6 @@ declare module "node:util" {
|
|
|
1627
1497
|
* @param input The input MIME to parse.
|
|
1628
1498
|
*/
|
|
1629
1499
|
constructor(input: string | { toString: () => string });
|
|
1630
|
-
|
|
1631
1500
|
/**
|
|
1632
1501
|
* Gets and sets the type portion of the MIME.
|
|
1633
1502
|
*
|
|
@@ -1758,558 +1627,40 @@ declare module "node:util" {
|
|
|
1758
1627
|
*/
|
|
1759
1628
|
[Symbol.iterator](): NodeJS.Iterator<[name: string, value: string]>;
|
|
1760
1629
|
}
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
* @since v10.0.0
|
|
1798
|
-
*/
|
|
1799
|
-
function isArrayBuffer(object: unknown): object is ArrayBuffer;
|
|
1800
|
-
/**
|
|
1801
|
-
* Returns `true` if the value is an instance of one of the [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) views, such as typed
|
|
1802
|
-
* array objects or [`DataView`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView). Equivalent to
|
|
1803
|
-
* [`ArrayBuffer.isView()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView).
|
|
1804
|
-
*
|
|
1805
|
-
* ```js
|
|
1806
|
-
* util.types.isArrayBufferView(new Int8Array()); // true
|
|
1807
|
-
* util.types.isArrayBufferView(Buffer.from('hello world')); // true
|
|
1808
|
-
* util.types.isArrayBufferView(new DataView(new ArrayBuffer(16))); // true
|
|
1809
|
-
* util.types.isArrayBufferView(new ArrayBuffer()); // false
|
|
1810
|
-
* ```
|
|
1811
|
-
* @since v10.0.0
|
|
1812
|
-
*/
|
|
1813
|
-
function isArrayBufferView(object: unknown): object is NodeJS.ArrayBufferView;
|
|
1814
|
-
/**
|
|
1815
|
-
* Returns `true` if the value is an [async function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function).
|
|
1816
|
-
* This only reports back what the JavaScript engine is seeing;
|
|
1817
|
-
* in particular, the return value may not match the original source code if
|
|
1818
|
-
* a transpilation tool was used.
|
|
1819
|
-
*
|
|
1820
|
-
* ```js
|
|
1821
|
-
* util.types.isAsyncFunction(function foo() {}); // Returns false
|
|
1822
|
-
* util.types.isAsyncFunction(async function foo() {}); // Returns true
|
|
1823
|
-
* ```
|
|
1824
|
-
* @since v10.0.0
|
|
1825
|
-
*/
|
|
1826
|
-
function isAsyncFunction(object: unknown): boolean;
|
|
1827
|
-
/**
|
|
1828
|
-
* Returns `true` if the value is a `BigInt64Array` instance.
|
|
1829
|
-
*
|
|
1830
|
-
* ```js
|
|
1831
|
-
* util.types.isBigInt64Array(new BigInt64Array()); // Returns true
|
|
1832
|
-
* util.types.isBigInt64Array(new BigUint64Array()); // Returns false
|
|
1833
|
-
* ```
|
|
1834
|
-
* @since v10.0.0
|
|
1835
|
-
*/
|
|
1836
|
-
function isBigInt64Array(value: unknown): value is BigInt64Array;
|
|
1837
|
-
/**
|
|
1838
|
-
* Returns `true` if the value is a BigInt object, e.g. created
|
|
1839
|
-
* by `Object(BigInt(123))`.
|
|
1840
|
-
*
|
|
1841
|
-
* ```js
|
|
1842
|
-
* util.types.isBigIntObject(Object(BigInt(123))); // Returns true
|
|
1843
|
-
* util.types.isBigIntObject(BigInt(123)); // Returns false
|
|
1844
|
-
* util.types.isBigIntObject(123); // Returns false
|
|
1845
|
-
* ```
|
|
1846
|
-
* @since v10.4.0
|
|
1847
|
-
*/
|
|
1848
|
-
function isBigIntObject(object: unknown): object is BigInt;
|
|
1849
|
-
/**
|
|
1850
|
-
* Returns `true` if the value is a `BigUint64Array` instance.
|
|
1851
|
-
*
|
|
1852
|
-
* ```js
|
|
1853
|
-
* util.types.isBigUint64Array(new BigInt64Array()); // Returns false
|
|
1854
|
-
* util.types.isBigUint64Array(new BigUint64Array()); // Returns true
|
|
1855
|
-
* ```
|
|
1856
|
-
* @since v10.0.0
|
|
1857
|
-
*/
|
|
1858
|
-
function isBigUint64Array(value: unknown): value is BigUint64Array;
|
|
1859
|
-
/**
|
|
1860
|
-
* Returns `true` if the value is a boolean object, e.g. created
|
|
1861
|
-
* by `new Boolean()`.
|
|
1862
|
-
*
|
|
1863
|
-
* ```js
|
|
1864
|
-
* util.types.isBooleanObject(false); // Returns false
|
|
1865
|
-
* util.types.isBooleanObject(true); // Returns false
|
|
1866
|
-
* util.types.isBooleanObject(new Boolean(false)); // Returns true
|
|
1867
|
-
* util.types.isBooleanObject(new Boolean(true)); // Returns true
|
|
1868
|
-
* util.types.isBooleanObject(Boolean(false)); // Returns false
|
|
1869
|
-
* util.types.isBooleanObject(Boolean(true)); // Returns false
|
|
1870
|
-
* ```
|
|
1871
|
-
* @since v10.0.0
|
|
1872
|
-
*/
|
|
1873
|
-
function isBooleanObject(object: unknown): object is Boolean;
|
|
1874
|
-
/**
|
|
1875
|
-
* Returns `true` if the value is any boxed primitive object, e.g. created
|
|
1876
|
-
* by `new Boolean()`, `new String()` or `Object(Symbol())`.
|
|
1877
|
-
*
|
|
1878
|
-
* For example:
|
|
1879
|
-
*
|
|
1880
|
-
* ```js
|
|
1881
|
-
* util.types.isBoxedPrimitive(false); // Returns false
|
|
1882
|
-
* util.types.isBoxedPrimitive(new Boolean(false)); // Returns true
|
|
1883
|
-
* util.types.isBoxedPrimitive(Symbol('foo')); // Returns false
|
|
1884
|
-
* util.types.isBoxedPrimitive(Object(Symbol('foo'))); // Returns true
|
|
1885
|
-
* util.types.isBoxedPrimitive(Object(BigInt(5))); // Returns true
|
|
1886
|
-
* ```
|
|
1887
|
-
* @since v10.11.0
|
|
1888
|
-
*/
|
|
1889
|
-
function isBoxedPrimitive(object: unknown): object is String | Number | BigInt | Boolean | Symbol;
|
|
1890
|
-
/**
|
|
1891
|
-
* Returns `true` if the value is a built-in [`DataView`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView) instance.
|
|
1892
|
-
*
|
|
1893
|
-
* ```js
|
|
1894
|
-
* const ab = new ArrayBuffer(20);
|
|
1895
|
-
* util.types.isDataView(new DataView(ab)); // Returns true
|
|
1896
|
-
* util.types.isDataView(new Float64Array()); // Returns false
|
|
1897
|
-
* ```
|
|
1898
|
-
*
|
|
1899
|
-
* See also [`ArrayBuffer.isView()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView).
|
|
1900
|
-
* @since v10.0.0
|
|
1901
|
-
*/
|
|
1902
|
-
function isDataView(object: unknown): object is DataView;
|
|
1903
|
-
/**
|
|
1904
|
-
* Returns `true` if the value is a built-in [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) instance.
|
|
1905
|
-
*
|
|
1906
|
-
* ```js
|
|
1907
|
-
* util.types.isDate(new Date()); // Returns true
|
|
1908
|
-
* ```
|
|
1909
|
-
* @since v10.0.0
|
|
1910
|
-
*/
|
|
1911
|
-
function isDate(object: unknown): object is Date;
|
|
1912
|
-
/**
|
|
1913
|
-
* Returns `true` if the value is a native `External` value.
|
|
1914
|
-
*
|
|
1915
|
-
* A native `External` value is a special type of object that contains a
|
|
1916
|
-
* raw C++ pointer (`void*`) for access from native code, and has no other
|
|
1917
|
-
* properties. Such objects are created either by Node.js internals or native
|
|
1918
|
-
* addons. In JavaScript, they are
|
|
1919
|
-
* [frozen](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze) objects with a
|
|
1920
|
-
* `null` prototype.
|
|
1921
|
-
*
|
|
1922
|
-
* ```c
|
|
1923
|
-
* #include <js_native_api.h>
|
|
1924
|
-
* #include <stdlib.h>
|
|
1925
|
-
* napi_value result;
|
|
1926
|
-
* static napi_value MyNapi(napi_env env, napi_callback_info info) {
|
|
1927
|
-
* int* raw = (int*) malloc(1024);
|
|
1928
|
-
* napi_status status = napi_create_external(env, (void*) raw, NULL, NULL, &result);
|
|
1929
|
-
* if (status != napi_ok) {
|
|
1930
|
-
* napi_throw_error(env, NULL, "napi_create_external failed");
|
|
1931
|
-
* return NULL;
|
|
1932
|
-
* }
|
|
1933
|
-
* return result;
|
|
1934
|
-
* }
|
|
1935
|
-
* ...
|
|
1936
|
-
* DECLARE_NAPI_PROPERTY("myNapi", MyNapi)
|
|
1937
|
-
* ...
|
|
1938
|
-
* ```
|
|
1939
|
-
*
|
|
1940
|
-
* ```js
|
|
1941
|
-
* import native from 'napi_addon.node';
|
|
1942
|
-
* import { types } from 'node:util';
|
|
1943
|
-
*
|
|
1944
|
-
* const data = native.myNapi();
|
|
1945
|
-
* types.isExternal(data); // returns true
|
|
1946
|
-
* types.isExternal(0); // returns false
|
|
1947
|
-
* types.isExternal(new String('foo')); // returns false
|
|
1948
|
-
* ```
|
|
1949
|
-
*
|
|
1950
|
-
* For further information on `napi_create_external`, refer to
|
|
1951
|
-
* [`napi_create_external()`](https://nodejs.org/docs/latest-v24.x/api/n-api.html#napi_create_external).
|
|
1952
|
-
* @since v10.0.0
|
|
1953
|
-
*/
|
|
1954
|
-
function isExternal(object: unknown): boolean;
|
|
1955
|
-
/**
|
|
1956
|
-
* Returns `true` if the value is a built-in [`Float16Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float16Array) instance.
|
|
1957
|
-
*
|
|
1958
|
-
* ```js
|
|
1959
|
-
* util.types.isFloat16Array(new ArrayBuffer()); // Returns false
|
|
1960
|
-
* util.types.isFloat16Array(new Float16Array()); // Returns true
|
|
1961
|
-
* util.types.isFloat16Array(new Float32Array()); // Returns false
|
|
1962
|
-
* ```
|
|
1963
|
-
* @since v24.0.0
|
|
1964
|
-
*/
|
|
1965
|
-
function isFloat16Array(object: unknown): object is Float16Array;
|
|
1966
|
-
/**
|
|
1967
|
-
* Returns `true` if the value is a built-in [`Float32Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array) instance.
|
|
1968
|
-
*
|
|
1969
|
-
* ```js
|
|
1970
|
-
* util.types.isFloat32Array(new ArrayBuffer()); // Returns false
|
|
1971
|
-
* util.types.isFloat32Array(new Float32Array()); // Returns true
|
|
1972
|
-
* util.types.isFloat32Array(new Float64Array()); // Returns false
|
|
1973
|
-
* ```
|
|
1974
|
-
* @since v10.0.0
|
|
1975
|
-
*/
|
|
1976
|
-
function isFloat32Array(object: unknown): object is Float32Array;
|
|
1977
|
-
/**
|
|
1978
|
-
* Returns `true` if the value is a built-in [`Float64Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array) instance.
|
|
1979
|
-
*
|
|
1980
|
-
* ```js
|
|
1981
|
-
* util.types.isFloat64Array(new ArrayBuffer()); // Returns false
|
|
1982
|
-
* util.types.isFloat64Array(new Uint8Array()); // Returns false
|
|
1983
|
-
* util.types.isFloat64Array(new Float64Array()); // Returns true
|
|
1984
|
-
* ```
|
|
1985
|
-
* @since v10.0.0
|
|
1986
|
-
*/
|
|
1987
|
-
function isFloat64Array(object: unknown): object is Float64Array;
|
|
1988
|
-
/**
|
|
1989
|
-
* Returns `true` if the value is a generator function.
|
|
1990
|
-
* This only reports back what the JavaScript engine is seeing;
|
|
1991
|
-
* in particular, the return value may not match the original source code if
|
|
1992
|
-
* a transpilation tool was used.
|
|
1993
|
-
*
|
|
1994
|
-
* ```js
|
|
1995
|
-
* util.types.isGeneratorFunction(function foo() {}); // Returns false
|
|
1996
|
-
* util.types.isGeneratorFunction(function* foo() {}); // Returns true
|
|
1997
|
-
* ```
|
|
1998
|
-
* @since v10.0.0
|
|
1999
|
-
*/
|
|
2000
|
-
function isGeneratorFunction(object: unknown): object is GeneratorFunction;
|
|
2001
|
-
/**
|
|
2002
|
-
* Returns `true` if the value is a generator object as returned from a
|
|
2003
|
-
* built-in generator function.
|
|
2004
|
-
* This only reports back what the JavaScript engine is seeing;
|
|
2005
|
-
* in particular, the return value may not match the original source code if
|
|
2006
|
-
* a transpilation tool was used.
|
|
2007
|
-
*
|
|
2008
|
-
* ```js
|
|
2009
|
-
* function* foo() {}
|
|
2010
|
-
* const generator = foo();
|
|
2011
|
-
* util.types.isGeneratorObject(generator); // Returns true
|
|
2012
|
-
* ```
|
|
2013
|
-
* @since v10.0.0
|
|
2014
|
-
*/
|
|
2015
|
-
function isGeneratorObject(object: unknown): object is Generator;
|
|
2016
|
-
/**
|
|
2017
|
-
* Returns `true` if the value is a built-in [`Int8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int8Array) instance.
|
|
2018
|
-
*
|
|
2019
|
-
* ```js
|
|
2020
|
-
* util.types.isInt8Array(new ArrayBuffer()); // Returns false
|
|
2021
|
-
* util.types.isInt8Array(new Int8Array()); // Returns true
|
|
2022
|
-
* util.types.isInt8Array(new Float64Array()); // Returns false
|
|
2023
|
-
* ```
|
|
2024
|
-
* @since v10.0.0
|
|
2025
|
-
*/
|
|
2026
|
-
function isInt8Array(object: unknown): object is Int8Array;
|
|
2027
|
-
/**
|
|
2028
|
-
* Returns `true` if the value is a built-in [`Int16Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array) instance.
|
|
2029
|
-
*
|
|
2030
|
-
* ```js
|
|
2031
|
-
* util.types.isInt16Array(new ArrayBuffer()); // Returns false
|
|
2032
|
-
* util.types.isInt16Array(new Int16Array()); // Returns true
|
|
2033
|
-
* util.types.isInt16Array(new Float64Array()); // Returns false
|
|
2034
|
-
* ```
|
|
2035
|
-
* @since v10.0.0
|
|
2036
|
-
*/
|
|
2037
|
-
function isInt16Array(object: unknown): object is Int16Array;
|
|
2038
|
-
/**
|
|
2039
|
-
* Returns `true` if the value is a built-in [`Int32Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array) instance.
|
|
2040
|
-
*
|
|
2041
|
-
* ```js
|
|
2042
|
-
* util.types.isInt32Array(new ArrayBuffer()); // Returns false
|
|
2043
|
-
* util.types.isInt32Array(new Int32Array()); // Returns true
|
|
2044
|
-
* util.types.isInt32Array(new Float64Array()); // Returns false
|
|
2045
|
-
* ```
|
|
2046
|
-
* @since v10.0.0
|
|
2047
|
-
*/
|
|
2048
|
-
function isInt32Array(object: unknown): object is Int32Array;
|
|
2049
|
-
/**
|
|
2050
|
-
* Returns `true` if the value is a built-in [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) instance.
|
|
2051
|
-
*
|
|
2052
|
-
* ```js
|
|
2053
|
-
* util.types.isMap(new Map()); // Returns true
|
|
2054
|
-
* ```
|
|
2055
|
-
* @since v10.0.0
|
|
2056
|
-
*/
|
|
2057
|
-
function isMap<T>(
|
|
2058
|
-
object: T | {},
|
|
2059
|
-
): object is T extends ReadonlyMap<any, any> ? (unknown extends T ? never : ReadonlyMap<any, any>)
|
|
2060
|
-
: Map<unknown, unknown>;
|
|
2061
|
-
/**
|
|
2062
|
-
* Returns `true` if the value is an iterator returned for a built-in [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) instance.
|
|
2063
|
-
*
|
|
2064
|
-
* ```js
|
|
2065
|
-
* const map = new Map();
|
|
2066
|
-
* util.types.isMapIterator(map.keys()); // Returns true
|
|
2067
|
-
* util.types.isMapIterator(map.values()); // Returns true
|
|
2068
|
-
* util.types.isMapIterator(map.entries()); // Returns true
|
|
2069
|
-
* util.types.isMapIterator(map[Symbol.iterator]()); // Returns true
|
|
2070
|
-
* ```
|
|
2071
|
-
* @since v10.0.0
|
|
2072
|
-
*/
|
|
2073
|
-
function isMapIterator(object: unknown): boolean;
|
|
2074
|
-
/**
|
|
2075
|
-
* Returns `true` if the value is an instance of a [Module Namespace Object](https://tc39.github.io/ecma262/#sec-module-namespace-exotic-objects).
|
|
2076
|
-
*
|
|
2077
|
-
* ```js
|
|
2078
|
-
* import * as ns from './a.js';
|
|
2079
|
-
*
|
|
2080
|
-
* util.types.isModuleNamespaceObject(ns); // Returns true
|
|
2081
|
-
* ```
|
|
2082
|
-
* @since v10.0.0
|
|
2083
|
-
*/
|
|
2084
|
-
function isModuleNamespaceObject(value: unknown): boolean;
|
|
2085
|
-
/**
|
|
2086
|
-
* Returns `true` if the value was returned by the constructor of a
|
|
2087
|
-
* [built-in `Error` type](https://tc39.es/ecma262/#sec-error-objects).
|
|
2088
|
-
*
|
|
2089
|
-
* ```js
|
|
2090
|
-
* console.log(util.types.isNativeError(new Error())); // true
|
|
2091
|
-
* console.log(util.types.isNativeError(new TypeError())); // true
|
|
2092
|
-
* console.log(util.types.isNativeError(new RangeError())); // true
|
|
2093
|
-
* ```
|
|
2094
|
-
*
|
|
2095
|
-
* Subclasses of the native error types are also native errors:
|
|
2096
|
-
*
|
|
2097
|
-
* ```js
|
|
2098
|
-
* class MyError extends Error {}
|
|
2099
|
-
* console.log(util.types.isNativeError(new MyError())); // true
|
|
2100
|
-
* ```
|
|
2101
|
-
*
|
|
2102
|
-
* A value being `instanceof` a native error class is not equivalent to `isNativeError()`
|
|
2103
|
-
* returning `true` for that value. `isNativeError()` returns `true` for errors
|
|
2104
|
-
* which come from a different [realm](https://tc39.es/ecma262/#realm) while `instanceof Error` returns `false`
|
|
2105
|
-
* for these errors:
|
|
2106
|
-
*
|
|
2107
|
-
* ```js
|
|
2108
|
-
* import { createContext, runInContext } from 'node:vm';
|
|
2109
|
-
* import { types } from 'node:util';
|
|
2110
|
-
*
|
|
2111
|
-
* const context = createContext({});
|
|
2112
|
-
* const myError = runInContext('new Error()', context);
|
|
2113
|
-
* console.log(types.isNativeError(myError)); // true
|
|
2114
|
-
* console.log(myError instanceof Error); // false
|
|
2115
|
-
* ```
|
|
2116
|
-
*
|
|
2117
|
-
* Conversely, `isNativeError()` returns `false` for all objects which were not
|
|
2118
|
-
* returned by the constructor of a native error. That includes values
|
|
2119
|
-
* which are `instanceof` native errors:
|
|
2120
|
-
*
|
|
2121
|
-
* ```js
|
|
2122
|
-
* const myError = { __proto__: Error.prototype };
|
|
2123
|
-
* console.log(util.types.isNativeError(myError)); // false
|
|
2124
|
-
* console.log(myError instanceof Error); // true
|
|
2125
|
-
* ```
|
|
2126
|
-
* @since v10.0.0
|
|
2127
|
-
*/
|
|
2128
|
-
function isNativeError(object: unknown): object is Error;
|
|
2129
|
-
/**
|
|
2130
|
-
* Returns `true` if the value is a number object, e.g. created
|
|
2131
|
-
* by `new Number()`.
|
|
2132
|
-
*
|
|
2133
|
-
* ```js
|
|
2134
|
-
* util.types.isNumberObject(0); // Returns false
|
|
2135
|
-
* util.types.isNumberObject(new Number(0)); // Returns true
|
|
2136
|
-
* ```
|
|
2137
|
-
* @since v10.0.0
|
|
2138
|
-
*/
|
|
2139
|
-
function isNumberObject(object: unknown): object is Number;
|
|
2140
|
-
/**
|
|
2141
|
-
* Returns `true` if the value is a built-in [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise).
|
|
2142
|
-
*
|
|
2143
|
-
* ```js
|
|
2144
|
-
* util.types.isPromise(Promise.resolve(42)); // Returns true
|
|
2145
|
-
* ```
|
|
2146
|
-
* @since v10.0.0
|
|
2147
|
-
*/
|
|
2148
|
-
function isPromise(object: unknown): object is Promise<unknown>;
|
|
2149
|
-
/**
|
|
2150
|
-
* Returns `true` if the value is a [`Proxy`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy) instance.
|
|
2151
|
-
*
|
|
2152
|
-
* ```js
|
|
2153
|
-
* const target = {};
|
|
2154
|
-
* const proxy = new Proxy(target, {});
|
|
2155
|
-
* util.types.isProxy(target); // Returns false
|
|
2156
|
-
* util.types.isProxy(proxy); // Returns true
|
|
2157
|
-
* ```
|
|
2158
|
-
* @since v10.0.0
|
|
2159
|
-
*/
|
|
2160
|
-
function isProxy(object: unknown): boolean;
|
|
2161
|
-
/**
|
|
2162
|
-
* Returns `true` if the value is a regular expression object.
|
|
2163
|
-
*
|
|
2164
|
-
* ```js
|
|
2165
|
-
* util.types.isRegExp(/abc/); // Returns true
|
|
2166
|
-
* util.types.isRegExp(new RegExp('abc')); // Returns true
|
|
2167
|
-
* ```
|
|
2168
|
-
* @since v10.0.0
|
|
2169
|
-
*/
|
|
2170
|
-
function isRegExp(object: unknown): object is RegExp;
|
|
2171
|
-
/**
|
|
2172
|
-
* Returns `true` if the value is a built-in [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) instance.
|
|
2173
|
-
*
|
|
2174
|
-
* ```js
|
|
2175
|
-
* util.types.isSet(new Set()); // Returns true
|
|
2176
|
-
* ```
|
|
2177
|
-
* @since v10.0.0
|
|
2178
|
-
*/
|
|
2179
|
-
function isSet<T>(
|
|
2180
|
-
object: T | {},
|
|
2181
|
-
): object is T extends ReadonlySet<any> ? (unknown extends T ? never : ReadonlySet<any>) : Set<unknown>;
|
|
2182
|
-
/**
|
|
2183
|
-
* Returns `true` if the value is an iterator returned for a built-in [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) instance.
|
|
2184
|
-
*
|
|
2185
|
-
* ```js
|
|
2186
|
-
* const set = new Set();
|
|
2187
|
-
* util.types.isSetIterator(set.keys()); // Returns true
|
|
2188
|
-
* util.types.isSetIterator(set.values()); // Returns true
|
|
2189
|
-
* util.types.isSetIterator(set.entries()); // Returns true
|
|
2190
|
-
* util.types.isSetIterator(set[Symbol.iterator]()); // Returns true
|
|
2191
|
-
* ```
|
|
2192
|
-
* @since v10.0.0
|
|
2193
|
-
*/
|
|
2194
|
-
function isSetIterator(object: unknown): boolean;
|
|
2195
|
-
/**
|
|
2196
|
-
* Returns `true` if the value is a built-in [`SharedArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer) instance.
|
|
2197
|
-
* This does _not_ include [`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) instances. Usually, it is
|
|
2198
|
-
* desirable to test for both; See `util.types.isAnyArrayBuffer()` for that.
|
|
2199
|
-
*
|
|
2200
|
-
* ```js
|
|
2201
|
-
* util.types.isSharedArrayBuffer(new ArrayBuffer()); // Returns false
|
|
2202
|
-
* util.types.isSharedArrayBuffer(new SharedArrayBuffer()); // Returns true
|
|
2203
|
-
* ```
|
|
2204
|
-
* @since v10.0.0
|
|
2205
|
-
*/
|
|
2206
|
-
function isSharedArrayBuffer(object: unknown): object is SharedArrayBuffer;
|
|
2207
|
-
/**
|
|
2208
|
-
* Returns `true` if the value is a string object, e.g. created
|
|
2209
|
-
* by `new String()`.
|
|
2210
|
-
*
|
|
2211
|
-
* ```js
|
|
2212
|
-
* util.types.isStringObject('foo'); // Returns false
|
|
2213
|
-
* util.types.isStringObject(new String('foo')); // Returns true
|
|
2214
|
-
* ```
|
|
2215
|
-
* @since v10.0.0
|
|
2216
|
-
*/
|
|
2217
|
-
function isStringObject(object: unknown): object is String;
|
|
2218
|
-
/**
|
|
2219
|
-
* Returns `true` if the value is a symbol object, created
|
|
2220
|
-
* by calling `Object()` on a `Symbol` primitive.
|
|
2221
|
-
*
|
|
2222
|
-
* ```js
|
|
2223
|
-
* const symbol = Symbol('foo');
|
|
2224
|
-
* util.types.isSymbolObject(symbol); // Returns false
|
|
2225
|
-
* util.types.isSymbolObject(Object(symbol)); // Returns true
|
|
2226
|
-
* ```
|
|
2227
|
-
* @since v10.0.0
|
|
2228
|
-
*/
|
|
2229
|
-
function isSymbolObject(object: unknown): object is Symbol;
|
|
2230
|
-
/**
|
|
2231
|
-
* Returns `true` if the value is a built-in [`TypedArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) instance.
|
|
2232
|
-
*
|
|
2233
|
-
* ```js
|
|
2234
|
-
* util.types.isTypedArray(new ArrayBuffer()); // Returns false
|
|
2235
|
-
* util.types.isTypedArray(new Uint8Array()); // Returns true
|
|
2236
|
-
* util.types.isTypedArray(new Float64Array()); // Returns true
|
|
2237
|
-
* ```
|
|
2238
|
-
*
|
|
2239
|
-
* See also [`ArrayBuffer.isView()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/isView).
|
|
2240
|
-
* @since v10.0.0
|
|
2241
|
-
*/
|
|
2242
|
-
function isTypedArray(object: unknown): object is NodeJS.TypedArray;
|
|
2243
|
-
/**
|
|
2244
|
-
* Returns `true` if the value is a built-in [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) instance.
|
|
2245
|
-
*
|
|
2246
|
-
* ```js
|
|
2247
|
-
* util.types.isUint8Array(new ArrayBuffer()); // Returns false
|
|
2248
|
-
* util.types.isUint8Array(new Uint8Array()); // Returns true
|
|
2249
|
-
* util.types.isUint8Array(new Float64Array()); // Returns false
|
|
2250
|
-
* ```
|
|
2251
|
-
* @since v10.0.0
|
|
2252
|
-
*/
|
|
2253
|
-
function isUint8Array(object: unknown): object is Uint8Array;
|
|
2254
|
-
/**
|
|
2255
|
-
* Returns `true` if the value is a built-in [`Uint8ClampedArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray) instance.
|
|
2256
|
-
*
|
|
2257
|
-
* ```js
|
|
2258
|
-
* util.types.isUint8ClampedArray(new ArrayBuffer()); // Returns false
|
|
2259
|
-
* util.types.isUint8ClampedArray(new Uint8ClampedArray()); // Returns true
|
|
2260
|
-
* util.types.isUint8ClampedArray(new Float64Array()); // Returns false
|
|
2261
|
-
* ```
|
|
2262
|
-
* @since v10.0.0
|
|
2263
|
-
*/
|
|
2264
|
-
function isUint8ClampedArray(object: unknown): object is Uint8ClampedArray;
|
|
2265
|
-
/**
|
|
2266
|
-
* Returns `true` if the value is a built-in [`Uint16Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint16Array) instance.
|
|
2267
|
-
*
|
|
2268
|
-
* ```js
|
|
2269
|
-
* util.types.isUint16Array(new ArrayBuffer()); // Returns false
|
|
2270
|
-
* util.types.isUint16Array(new Uint16Array()); // Returns true
|
|
2271
|
-
* util.types.isUint16Array(new Float64Array()); // Returns false
|
|
2272
|
-
* ```
|
|
2273
|
-
* @since v10.0.0
|
|
2274
|
-
*/
|
|
2275
|
-
function isUint16Array(object: unknown): object is Uint16Array;
|
|
2276
|
-
/**
|
|
2277
|
-
* Returns `true` if the value is a built-in [`Uint32Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint32Array) instance.
|
|
2278
|
-
*
|
|
2279
|
-
* ```js
|
|
2280
|
-
* util.types.isUint32Array(new ArrayBuffer()); // Returns false
|
|
2281
|
-
* util.types.isUint32Array(new Uint32Array()); // Returns true
|
|
2282
|
-
* util.types.isUint32Array(new Float64Array()); // Returns false
|
|
2283
|
-
* ```
|
|
2284
|
-
* @since v10.0.0
|
|
2285
|
-
*/
|
|
2286
|
-
function isUint32Array(object: unknown): object is Uint32Array;
|
|
2287
|
-
/**
|
|
2288
|
-
* Returns `true` if the value is a built-in [`WeakMap`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap) instance.
|
|
2289
|
-
*
|
|
2290
|
-
* ```js
|
|
2291
|
-
* util.types.isWeakMap(new WeakMap()); // Returns true
|
|
2292
|
-
* ```
|
|
2293
|
-
* @since v10.0.0
|
|
2294
|
-
*/
|
|
2295
|
-
function isWeakMap(object: unknown): object is WeakMap<object, unknown>;
|
|
2296
|
-
/**
|
|
2297
|
-
* Returns `true` if the value is a built-in [`WeakSet`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet) instance.
|
|
2298
|
-
*
|
|
2299
|
-
* ```js
|
|
2300
|
-
* util.types.isWeakSet(new WeakSet()); // Returns true
|
|
2301
|
-
* ```
|
|
2302
|
-
* @since v10.0.0
|
|
2303
|
-
*/
|
|
2304
|
-
function isWeakSet(object: unknown): object is WeakSet<object>;
|
|
2305
|
-
/**
|
|
2306
|
-
* Returns `true` if `value` is a `KeyObject`, `false` otherwise.
|
|
2307
|
-
* @since v16.2.0
|
|
2308
|
-
*/
|
|
2309
|
-
function isKeyObject(object: unknown): object is KeyObject;
|
|
2310
|
-
/**
|
|
2311
|
-
* Returns `true` if `value` is a `CryptoKey`, `false` otherwise.
|
|
2312
|
-
* @since v16.2.0
|
|
2313
|
-
*/
|
|
2314
|
-
function isCryptoKey(object: unknown): object is webcrypto.CryptoKey;
|
|
1630
|
+
// #region web types
|
|
1631
|
+
export interface TextDecodeOptions {
|
|
1632
|
+
stream?: boolean;
|
|
1633
|
+
}
|
|
1634
|
+
export interface TextDecoderCommon {
|
|
1635
|
+
readonly encoding: string;
|
|
1636
|
+
readonly fatal: boolean;
|
|
1637
|
+
readonly ignoreBOM: boolean;
|
|
1638
|
+
}
|
|
1639
|
+
export interface TextDecoderOptions {
|
|
1640
|
+
fatal?: boolean;
|
|
1641
|
+
ignoreBOM?: boolean;
|
|
1642
|
+
}
|
|
1643
|
+
export interface TextEncoderCommon {
|
|
1644
|
+
readonly encoding: string;
|
|
1645
|
+
}
|
|
1646
|
+
export interface TextEncoderEncodeIntoResult {
|
|
1647
|
+
read: number;
|
|
1648
|
+
written: number;
|
|
1649
|
+
}
|
|
1650
|
+
export interface TextDecoder extends TextDecoderCommon {
|
|
1651
|
+
decode(input?: NodeJS.AllowSharedBufferSource, options?: TextDecodeOptions): string;
|
|
1652
|
+
}
|
|
1653
|
+
export var TextDecoder: {
|
|
1654
|
+
prototype: TextDecoder;
|
|
1655
|
+
new(label?: string, options?: TextDecoderOptions): TextDecoder;
|
|
1656
|
+
};
|
|
1657
|
+
export interface TextEncoder extends TextEncoderCommon {
|
|
1658
|
+
encode(input?: string): NodeJS.NonSharedUint8Array;
|
|
1659
|
+
encodeInto(source: string, destination: Uint8Array): TextEncoderEncodeIntoResult;
|
|
1660
|
+
}
|
|
1661
|
+
export var TextEncoder: {
|
|
1662
|
+
prototype: TextEncoder;
|
|
1663
|
+
new(): TextEncoder;
|
|
1664
|
+
};
|
|
1665
|
+
// #endregion
|
|
2315
1666
|
}
|