@types/node 18.17.8 → 18.17.10

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: Tue, 22 Aug 2023 18:04:30 GMT
11
+ * Last updated: Thu, 24 Aug 2023 21:33:09 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/fs.d.ts CHANGED
@@ -3582,15 +3582,27 @@ declare module 'fs' {
3582
3582
  fd?: number | promises.FileHandle | undefined;
3583
3583
  mode?: number | undefined;
3584
3584
  autoClose?: boolean | undefined;
3585
- /**
3586
- * @default false
3587
- */
3588
3585
  emitClose?: boolean | undefined;
3589
3586
  start?: number | undefined;
3590
- highWaterMark?: number | undefined;
3587
+ }
3588
+ interface FSImplementation {
3589
+ open?: (...args: any[]) => any;
3590
+ close?: (...args: any[]) => any;
3591
+ }
3592
+ interface CreateReadStreamFSImplementation extends FSImplementation {
3593
+ read: (...args: any[]) => any;
3594
+ }
3595
+ interface CreateWriteStreamFSImplementation extends FSImplementation {
3596
+ write: (...args: any[]) => any;
3597
+ writev?: (...args: any[]) => any;
3591
3598
  }
3592
3599
  interface ReadStreamOptions extends StreamOptions {
3600
+ fs?: CreateReadStreamFSImplementation | null | undefined;
3593
3601
  end?: number | undefined;
3602
+ highWaterMark?: number | undefined;
3603
+ }
3604
+ interface WriteStreamOptions extends StreamOptions {
3605
+ fs?: CreateWriteStreamFSImplementation | null | undefined;
3594
3606
  }
3595
3607
  /**
3596
3608
  * Unlike the 16 kb default `highWaterMark` for a `stream.Readable`, the stream
@@ -3684,7 +3696,7 @@ declare module 'fs' {
3684
3696
  * If `options` is a string, then it specifies the encoding.
3685
3697
  * @since v0.1.31
3686
3698
  */
3687
- export function createWriteStream(path: PathLike, options?: BufferEncoding | StreamOptions): WriteStream;
3699
+ export function createWriteStream(path: PathLike, options?: BufferEncoding | WriteStreamOptions): WriteStream;
3688
3700
  /**
3689
3701
  * Forces all currently queued I/O operations associated with the file to the
3690
3702
  * operating system's synchronized I/O completion state. Refer to the POSIX [`fdatasync(2)`](http://man7.org/linux/man-pages/man2/fdatasync.2.html) documentation for details. No arguments other
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "18.17.8",
3
+ "version": "18.17.10",
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": "677ff4e5e4d78b1e84ce944118a6c6d4844fca1db1e7226baa54d4c48c6e2f97",
235
+ "typesPublisherContentHash": "e7d4c795a67a90f21fdfacae6ed2b4127ad04555d1acd5c2340fc8621582a606",
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
@@ -3582,15 +3582,27 @@ declare module 'fs' {
3582
3582
  fd?: number | promises.FileHandle | undefined;
3583
3583
  mode?: number | undefined;
3584
3584
  autoClose?: boolean | undefined;
3585
- /**
3586
- * @default false
3587
- */
3588
3585
  emitClose?: boolean | undefined;
3589
3586
  start?: number | undefined;
3590
- highWaterMark?: number | undefined;
3587
+ }
3588
+ interface FSImplementation {
3589
+ open?: (...args: any[]) => any;
3590
+ close?: (...args: any[]) => any;
3591
+ }
3592
+ interface CreateReadStreamFSImplementation extends FSImplementation {
3593
+ read: (...args: any[]) => any;
3594
+ }
3595
+ interface CreateWriteStreamFSImplementation extends FSImplementation {
3596
+ write: (...args: any[]) => any;
3597
+ writev?: (...args: any[]) => any;
3591
3598
  }
3592
3599
  interface ReadStreamOptions extends StreamOptions {
3600
+ fs?: CreateReadStreamFSImplementation | null | undefined;
3593
3601
  end?: number | undefined;
3602
+ highWaterMark?: number | undefined;
3603
+ }
3604
+ interface WriteStreamOptions extends StreamOptions {
3605
+ fs?: CreateWriteStreamFSImplementation | null | undefined;
3594
3606
  }
3595
3607
  /**
3596
3608
  * Unlike the 16 kb default `highWaterMark` for a `stream.Readable`, the stream
@@ -3684,7 +3696,7 @@ declare module 'fs' {
3684
3696
  * If `options` is a string, then it specifies the encoding.
3685
3697
  * @since v0.1.31
3686
3698
  */
3687
- export function createWriteStream(path: PathLike, options?: BufferEncoding | StreamOptions): WriteStream;
3699
+ export function createWriteStream(path: PathLike, options?: BufferEncoding | WriteStreamOptions): WriteStream;
3688
3700
  /**
3689
3701
  * Forces all currently queued I/O operations associated with the file to the
3690
3702
  * operating system's synchronized I/O completion state. Refer to the POSIX [`fdatasync(2)`](http://man7.org/linux/man-pages/man2/fdatasync.2.html) documentation for details. No arguments other