@types/node 18.17.9 → 18.17.11

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 v18.17/README.md CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for Node.js (https://nodejs.org/).
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node/v18.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Wed, 23 Aug 2023 21:03:06 GMT
11
+ * Last updated: Thu, 24 Aug 2023 22:03:17 GMT
12
12
  * Dependencies: none
13
13
  * Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`, `structuredClone`
14
14
 
node v18.17/module.d.ts CHANGED
@@ -79,6 +79,9 @@ declare module 'module' {
79
79
  */
80
80
  findEntry(line: number, column: number): SourceMapping;
81
81
  }
82
+ interface ImportAssertions extends NodeJS.Dict<string> {
83
+ type?: string | undefined;
84
+ }
82
85
  type ModuleFormat = 'builtin' | 'commonjs' | 'json' | 'module' | 'wasm';
83
86
  type ModuleSource = string | ArrayBuffer | NodeJS.TypedArray;
84
87
  interface GlobalPreloadContext {
@@ -100,7 +103,7 @@ declare module 'module' {
100
103
  /**
101
104
  * An object whose key-value pairs represent the assertions for the module to import
102
105
  */
103
- importAssertions: Object;
106
+ importAssertions: ImportAssertions;
104
107
  /**
105
108
  * The module importing this one, or undefined if this is the Node.js entry point
106
109
  */
@@ -114,7 +117,7 @@ declare module 'module' {
114
117
  /**
115
118
  * The import assertions to use when caching the module (optional; if excluded the input will be used)
116
119
  */
117
- importAssertions?: Object | undefined;
120
+ importAssertions?: ImportAssertions | undefined;
118
121
  /**
119
122
  * A signal that this hook intends to terminate the chain of `resolve` hooks.
120
123
  * @default false
@@ -137,7 +140,7 @@ declare module 'module' {
137
140
  type ResolveHook = (
138
141
  specifier: string,
139
142
  context: ResolveHookContext,
140
- nextResolve: (specifier: string, context?: ResolveHookContext) => ResolveFnOutput
143
+ nextResolve: (specifier: string, context?: ResolveHookContext) => ResolveFnOutput | Promise<ResolveFnOutput>
141
144
  ) => ResolveFnOutput | Promise<ResolveFnOutput>;
142
145
  interface LoadHookContext {
143
146
  /**
@@ -151,7 +154,7 @@ declare module 'module' {
151
154
  /**
152
155
  * An object whose key-value pairs represent the assertions for the module to import
153
156
  */
154
- importAssertions: Object;
157
+ importAssertions: ImportAssertions;
155
158
  }
156
159
  interface LoadFnOutput {
157
160
  format: ModuleFormat;
@@ -173,7 +176,11 @@ declare module 'module' {
173
176
  * @param context Metadata about the module
174
177
  * @param nextLoad The subsequent `load` hook in the chain, or the Node.js default `load` hook after the last user-supplied `load` hook
175
178
  */
176
- type LoadHook = (url: string, context: LoadHookContext, nextLoad: (url: string, context?: LoadHookContext) => LoadFnOutput) => LoadFnOutput | Promise<LoadFnOutput>;
179
+ type LoadHook = (
180
+ url: string,
181
+ context: LoadHookContext,
182
+ nextLoad: (url: string, context?: LoadHookContext) => LoadFnOutput | Promise<LoadFnOutput>
183
+ ) => LoadFnOutput | Promise<LoadFnOutput>;
177
184
  }
178
185
  interface Module extends NodeModule {}
179
186
  class Module {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "18.17.9",
3
+ "version": "18.17.11",
4
4
  "description": "TypeScript definitions for Node.js",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -232,6 +232,6 @@
232
232
  },
233
233
  "scripts": {},
234
234
  "dependencies": {},
235
- "typesPublisherContentHash": "1ac2d87015f8895c0d056cf53ed50f7936b5306c403b9b7ee02a7191e4deb8ec",
235
+ "typesPublisherContentHash": "2c7fab874e636c1fe036a027917b5774caaf6b5d1ecd18b0e9ea9355e359d769",
236
236
  "typeScriptVersion": "4.3"
237
237
  }
node v18.17/stream.d.ts CHANGED
@@ -50,6 +50,12 @@ declare module 'stream' {
50
50
  encoding?: BufferEncoding | undefined;
51
51
  read?(this: Readable, size: number): void;
52
52
  }
53
+ interface ArrayOptions {
54
+ /** the maximum concurrent invocations of `fn` to call on the stream at once. **Default: 1**. */
55
+ concurrency?: number;
56
+ /** allows destroying the stream if the signal is aborted. */
57
+ signal?: AbortSignal;
58
+ }
53
59
  /**
54
60
  * @since v0.9.4
55
61
  */
@@ -424,6 +430,138 @@ declare module 'stream' {
424
430
  */
425
431
  wrap(stream: NodeJS.ReadableStream): this;
426
432
  push(chunk: any, encoding?: BufferEncoding): boolean;
433
+ /**
434
+ * The iterator created by this method gives users the option to cancel the destruction
435
+ * of the stream if the `for await...of` loop is exited by `return`, `break`, or `throw`,
436
+ * or if the iterator should destroy the stream if the stream emitted an error during iteration.
437
+ * @since v16.3.0
438
+ * @param options.destroyOnReturn When set to `false`, calling `return` on the async iterator,
439
+ * or exiting a `for await...of` iteration using a `break`, `return`, or `throw` will not destroy the stream.
440
+ * **Default: `true`**.
441
+ */
442
+ iterator(options?: {destroyOnReturn?: boolean}): AsyncIterableIterator<any>;
443
+ /**
444
+ * This method allows mapping over the stream. The *fn* function will be called for every chunk in the stream.
445
+ * If the *fn* function returns a promise - that promise will be `await`ed before being passed to the result stream.
446
+ * @since v17.4.0, v16.14.0
447
+ * @param fn a function to map over every chunk in the stream. Async or not.
448
+ * @returns a stream mapped with the function *fn*.
449
+ */
450
+ map(fn: (data: any, options?: Pick<ArrayOptions, "signal">) => any, options?: ArrayOptions): Readable;
451
+ /**
452
+ * This method allows filtering the stream. For each chunk in the stream the *fn* function will be called
453
+ * and if it returns a truthy value, the chunk will be passed to the result stream.
454
+ * If the *fn* function returns a promise - that promise will be `await`ed.
455
+ * @since v17.4.0, v16.14.0
456
+ * @param fn a function to filter chunks from the stream. Async or not.
457
+ * @returns a stream filtered with the predicate *fn*.
458
+ */
459
+ filter(fn: (data: any, options?: Pick<ArrayOptions, "signal">) => boolean | Promise<boolean>, options?: ArrayOptions): Readable;
460
+ /**
461
+ * This method allows iterating a stream. For each chunk in the stream the *fn* function will be called.
462
+ * If the *fn* function returns a promise - that promise will be `await`ed.
463
+ *
464
+ * This method is different from `for await...of` loops in that it can optionally process chunks concurrently.
465
+ * In addition, a `forEach` iteration can only be stopped by having passed a `signal` option
466
+ * and aborting the related AbortController while `for await...of` can be stopped with `break` or `return`.
467
+ * In either case the stream will be destroyed.
468
+ *
469
+ * This method is different from listening to the `'data'` event in that it uses the `readable` event
470
+ * in the underlying machinary and can limit the number of concurrent *fn* calls.
471
+ * @since v17.5.0
472
+ * @param fn a function to call on each chunk of the stream. Async or not.
473
+ * @returns a promise for when the stream has finished.
474
+ */
475
+ forEach(fn: (data: any, options?: Pick<ArrayOptions, "signal">) => void | Promise<void>, options?: ArrayOptions): Promise<void>;
476
+ /**
477
+ * This method allows easily obtaining the contents of a stream.
478
+ *
479
+ * As this method reads the entire stream into memory, it negates the benefits of streams. It's intended
480
+ * for interoperability and convenience, not as the primary way to consume streams.
481
+ * @since v17.5.0
482
+ * @returns a promise containing an array with the contents of the stream.
483
+ */
484
+ toArray(options?: Pick<ArrayOptions, "signal">): Promise<any[]>;
485
+ /**
486
+ * This method is similar to `Array.prototype.some` and calls *fn* on each chunk in the stream
487
+ * until the awaited return value is `true` (or any truthy value). Once an *fn* call on a chunk
488
+ * `await`ed return value is truthy, the stream is destroyed and the promise is fulfilled with `true`.
489
+ * If none of the *fn* calls on the chunks return a truthy value, the promise is fulfilled with `false`.
490
+ * @since v17.5.0
491
+ * @param fn a function to call on each chunk of the stream. Async or not.
492
+ * @returns a promise evaluating to `true` if *fn* returned a truthy value for at least one of the chunks.
493
+ */
494
+ some(fn: (data: any, options?: Pick<ArrayOptions, "signal">) => boolean | Promise<boolean>, options?: ArrayOptions): Promise<boolean>;
495
+ /**
496
+ * This method is similar to `Array.prototype.find` and calls *fn* on each chunk in the stream
497
+ * to find a chunk with a truthy value for *fn*. Once an *fn* call's awaited return value is truthy,
498
+ * the stream is destroyed and the promise is fulfilled with value for which *fn* returned a truthy value.
499
+ * If all of the *fn* calls on the chunks return a falsy value, the promise is fulfilled with `undefined`.
500
+ * @since v17.5.0
501
+ * @param fn a function to call on each chunk of the stream. Async or not.
502
+ * @returns a promise evaluating to the first chunk for which *fn* evaluated with a truthy value,
503
+ * or `undefined` if no element was found.
504
+ */
505
+ find<T>(fn: (data: any, options?: Pick<ArrayOptions, "signal">) => data is T, options?: ArrayOptions): Promise<T | undefined>;
506
+ find(fn: (data: any, options?: Pick<ArrayOptions, "signal">) => boolean | Promise<boolean>, options?: ArrayOptions): Promise<any>;
507
+ /**
508
+ * This method is similar to `Array.prototype.every` and calls *fn* on each chunk in the stream
509
+ * to check if all awaited return values are truthy value for *fn*. Once an *fn* call on a chunk
510
+ * `await`ed return value is falsy, the stream is destroyed and the promise is fulfilled with `false`.
511
+ * If all of the *fn* calls on the chunks return a truthy value, the promise is fulfilled with `true`.
512
+ * @since v17.5.0
513
+ * @param fn a function to call on each chunk of the stream. Async or not.
514
+ * @returns a promise evaluating to `true` if *fn* returned a truthy value for every one of the chunks.
515
+ */
516
+ every(fn: (data: any, options?: Pick<ArrayOptions, "signal">) => boolean | Promise<boolean>, options?: ArrayOptions): Promise<boolean>;
517
+ /**
518
+ * This method returns a new stream by applying the given callback to each chunk of the stream
519
+ * and then flattening the result.
520
+ *
521
+ * It is possible to return a stream or another iterable or async iterable from *fn* and the result streams
522
+ * will be merged (flattened) into the returned stream.
523
+ * @since v17.5.0
524
+ * @param fn a function to map over every chunk in the stream. May be async. May be a stream or generator.
525
+ * @returns a stream flat-mapped with the function *fn*.
526
+ */
527
+ flatMap(fn: (data: any, options?: Pick<ArrayOptions, "signal">) => any, options?: ArrayOptions): Readable;
528
+ /**
529
+ * This method returns a new stream with the first *limit* chunks dropped from the start.
530
+ * @since v17.5.0
531
+ * @param limit the number of chunks to drop from the readable.
532
+ * @returns a stream with *limit* chunks dropped from the start.
533
+ */
534
+ drop(limit: number, options?: Pick<ArrayOptions, "signal">): Readable;
535
+ /**
536
+ * This method returns a new stream with the first *limit* chunks.
537
+ * @since v17.5.0
538
+ * @param limit the number of chunks to take from the readable.
539
+ * @returns a stream with *limit* chunks taken.
540
+ */
541
+ take(limit: number, options?: Pick<ArrayOptions, "signal">): Readable;
542
+ /**
543
+ * This method returns a new stream with chunks of the underlying stream paired with a counter
544
+ * in the form `[index, chunk]`. The first index value is `0` and it increases by 1 for each chunk produced.
545
+ * @since v17.5.0
546
+ * @returns a stream of indexed pairs.
547
+ */
548
+ asIndexedPairs(options?: Pick<ArrayOptions, "signal">): Readable;
549
+ /**
550
+ * This method calls *fn* on each chunk of the stream in order, passing it the result from the calculation
551
+ * on the previous element. It returns a promise for the final value of the reduction.
552
+ *
553
+ * If no *initial* value is supplied the first chunk of the stream is used as the initial value.
554
+ * If the stream is empty, the promise is rejected with a `TypeError` with the `ERR_INVALID_ARGS` code property.
555
+ *
556
+ * The reducer function iterates the stream element-by-element which means that there is no *concurrency* parameter
557
+ * or parallelism. To perform a reduce concurrently, you can extract the async function to `readable.map` method.
558
+ * @since v17.5.0
559
+ * @param fn a reducer function to call over every chunk in the stream. Async or not.
560
+ * @param initial the initial value to use in the reduction.
561
+ * @returns a promise for the final value of the reduction.
562
+ */
563
+ reduce<T = any>(fn: (previous: any, data: any, options?: Pick<ArrayOptions, "signal">) => T, initial?: undefined, options?: Pick<ArrayOptions, "signal">): Promise<T>;
564
+ reduce<T = any>(fn: (previous: T, data: any, options?: Pick<ArrayOptions, "signal">) => T, initial: T, options?: Pick<ArrayOptions, "signal">): Promise<T>;
427
565
  _destroy(error: Error | null, callback: (error?: Error | null) => void): void;
428
566
  /**
429
567
  * Destroy the stream. Optionally emit an `'error'` event, and emit a `'close'`event (unless `emitClose` is set to `false`). After this call, the readable
@@ -79,6 +79,9 @@ declare module 'module' {
79
79
  */
80
80
  findEntry(line: number, column: number): SourceMapping;
81
81
  }
82
+ interface ImportAssertions extends NodeJS.Dict<string> {
83
+ type?: string | undefined;
84
+ }
82
85
  type ModuleFormat = 'builtin' | 'commonjs' | 'json' | 'module' | 'wasm';
83
86
  type ModuleSource = string | ArrayBuffer | NodeJS.TypedArray;
84
87
  interface GlobalPreloadContext {
@@ -100,7 +103,7 @@ declare module 'module' {
100
103
  /**
101
104
  * An object whose key-value pairs represent the assertions for the module to import
102
105
  */
103
- importAssertions: Object;
106
+ importAssertions: ImportAssertions;
104
107
  /**
105
108
  * The module importing this one, or undefined if this is the Node.js entry point
106
109
  */
@@ -114,7 +117,7 @@ declare module 'module' {
114
117
  /**
115
118
  * The import assertions to use when caching the module (optional; if excluded the input will be used)
116
119
  */
117
- importAssertions?: Object | undefined;
120
+ importAssertions?: ImportAssertions | undefined;
118
121
  /**
119
122
  * A signal that this hook intends to terminate the chain of `resolve` hooks.
120
123
  * @default false
@@ -137,7 +140,7 @@ declare module 'module' {
137
140
  type ResolveHook = (
138
141
  specifier: string,
139
142
  context: ResolveHookContext,
140
- nextResolve: (specifier: string, context?: ResolveHookContext) => ResolveFnOutput
143
+ nextResolve: (specifier: string, context?: ResolveHookContext) => ResolveFnOutput | Promise<ResolveFnOutput>
141
144
  ) => ResolveFnOutput | Promise<ResolveFnOutput>;
142
145
  interface LoadHookContext {
143
146
  /**
@@ -151,7 +154,7 @@ declare module 'module' {
151
154
  /**
152
155
  * An object whose key-value pairs represent the assertions for the module to import
153
156
  */
154
- importAssertions: Object;
157
+ importAssertions: ImportAssertions;
155
158
  }
156
159
  interface LoadFnOutput {
157
160
  format: ModuleFormat;
@@ -173,7 +176,11 @@ declare module 'module' {
173
176
  * @param context Metadata about the module
174
177
  * @param nextLoad The subsequent `load` hook in the chain, or the Node.js default `load` hook after the last user-supplied `load` hook
175
178
  */
176
- type LoadHook = (url: string, context: LoadHookContext, nextLoad: (url: string, context?: LoadHookContext) => LoadFnOutput) => LoadFnOutput | Promise<LoadFnOutput>;
179
+ type LoadHook = (
180
+ url: string,
181
+ context: LoadHookContext,
182
+ nextLoad: (url: string, context?: LoadHookContext) => LoadFnOutput | Promise<LoadFnOutput>
183
+ ) => LoadFnOutput | Promise<LoadFnOutput>;
177
184
  }
178
185
  interface Module extends NodeModule {}
179
186
  class Module {
@@ -37,6 +37,7 @@
37
37
  * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/vm.js)
38
38
  */
39
39
  declare module 'vm' {
40
+ import { ImportAssertions } from 'node:module';
40
41
  interface Context extends NodeJS.Dict<any> {}
41
42
  interface BaseOptions {
42
43
  /**
@@ -66,7 +67,7 @@ declare module 'vm' {
66
67
  * Called during evaluation of this module when `import()` is called.
67
68
  * If this option is not specified, calls to `import()` will reject with `ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING`.
68
69
  */
69
- importModuleDynamically?: ((specifier: string, script: Script, importAssertions: Object) => Module) | undefined;
70
+ importModuleDynamically?: ((specifier: string, script: Script, importAssertions: ImportAssertions) => Module) | undefined;
70
71
  }
71
72
  interface RunningScriptOptions extends BaseOptions {
72
73
  /**
node v18.17/vm.d.ts CHANGED
@@ -37,6 +37,7 @@
37
37
  * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/vm.js)
38
38
  */
39
39
  declare module 'vm' {
40
+ import { ImportAssertions } from 'node:module';
40
41
  interface Context extends NodeJS.Dict<any> {}
41
42
  interface BaseOptions {
42
43
  /**
@@ -66,7 +67,7 @@ declare module 'vm' {
66
67
  * Called during evaluation of this module when `import()` is called.
67
68
  * If this option is not specified, calls to `import()` will reject with `ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING`.
68
69
  */
69
- importModuleDynamically?: ((specifier: string, script: Script, importAssertions: Object) => Module) | undefined;
70
+ importModuleDynamically?: ((specifier: string, script: Script, importAssertions: ImportAssertions) => Module) | undefined;
70
71
  }
71
72
  interface RunningScriptOptions extends BaseOptions {
72
73
  /**