@types/node 20.5.3 → 20.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- node/README.md +1 -1
- node/fs.d.ts +18 -5
- node/package.json +2 -2
- node/stream.d.ts +138 -0
- node/ts4.8/fs.d.ts +18 -5
node/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.
|
|
9
9
|
|
|
10
10
|
### Additional Details
|
|
11
|
-
* Last updated:
|
|
11
|
+
* Last updated: Thu, 24 Aug 2023 21:33:08 GMT
|
|
12
12
|
* Dependencies: none
|
|
13
13
|
* Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`, `structuredClone`
|
|
14
14
|
|
node/fs.d.ts
CHANGED
|
@@ -3618,15 +3618,28 @@ declare module 'fs' {
|
|
|
3618
3618
|
fd?: number | promises.FileHandle | undefined;
|
|
3619
3619
|
mode?: number | undefined;
|
|
3620
3620
|
autoClose?: boolean | undefined;
|
|
3621
|
-
/**
|
|
3622
|
-
* @default false
|
|
3623
|
-
*/
|
|
3624
3621
|
emitClose?: boolean | undefined;
|
|
3625
3622
|
start?: number | undefined;
|
|
3626
|
-
|
|
3623
|
+
signal?: AbortSignal | null | undefined;
|
|
3624
|
+
}
|
|
3625
|
+
interface FSImplementation {
|
|
3626
|
+
open?: (...args: any[]) => any;
|
|
3627
|
+
close?: (...args: any[]) => any;
|
|
3628
|
+
}
|
|
3629
|
+
interface CreateReadStreamFSImplementation extends FSImplementation {
|
|
3630
|
+
read: (...args: any[]) => any;
|
|
3631
|
+
}
|
|
3632
|
+
interface CreateWriteStreamFSImplementation extends FSImplementation {
|
|
3633
|
+
write: (...args: any[]) => any;
|
|
3634
|
+
writev?: (...args: any[]) => any;
|
|
3627
3635
|
}
|
|
3628
3636
|
interface ReadStreamOptions extends StreamOptions {
|
|
3637
|
+
fs?: CreateReadStreamFSImplementation | null | undefined;
|
|
3629
3638
|
end?: number | undefined;
|
|
3639
|
+
highWaterMark?: number | undefined;
|
|
3640
|
+
}
|
|
3641
|
+
interface WriteStreamOptions extends StreamOptions {
|
|
3642
|
+
fs?: CreateWriteStreamFSImplementation | null | undefined;
|
|
3630
3643
|
}
|
|
3631
3644
|
/**
|
|
3632
3645
|
* Unlike the 16 KiB default `highWaterMark` for a `stream.Readable`, the stream
|
|
@@ -3720,7 +3733,7 @@ declare module 'fs' {
|
|
|
3720
3733
|
* If `options` is a string, then it specifies the encoding.
|
|
3721
3734
|
* @since v0.1.31
|
|
3722
3735
|
*/
|
|
3723
|
-
export function createWriteStream(path: PathLike, options?: BufferEncoding |
|
|
3736
|
+
export function createWriteStream(path: PathLike, options?: BufferEncoding | WriteStreamOptions): WriteStream;
|
|
3724
3737
|
/**
|
|
3725
3738
|
* Forces all currently queued I/O operations associated with the file to the
|
|
3726
3739
|
* 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
|
node/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/node",
|
|
3
|
-
"version": "20.5.
|
|
3
|
+
"version": "20.5.5",
|
|
4
4
|
"description": "TypeScript definitions for Node.js",
|
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
|
|
6
6
|
"license": "MIT",
|
|
@@ -227,6 +227,6 @@
|
|
|
227
227
|
},
|
|
228
228
|
"scripts": {},
|
|
229
229
|
"dependencies": {},
|
|
230
|
-
"typesPublisherContentHash": "
|
|
230
|
+
"typesPublisherContentHash": "d4faf6ea736f0d9b6f9d07881d440c3c6ab018e823a8dae5017cf3c7f0e4b731",
|
|
231
231
|
"typeScriptVersion": "4.3"
|
|
232
232
|
}
|
node/stream.d.ts
CHANGED
|
@@ -37,6 +37,12 @@ declare module 'stream' {
|
|
|
37
37
|
import Stream = internal.Stream;
|
|
38
38
|
import Readable = internal.Readable;
|
|
39
39
|
import ReadableOptions = internal.ReadableOptions;
|
|
40
|
+
interface ArrayOptions {
|
|
41
|
+
/** the maximum concurrent invocations of `fn` to call on the stream at once. **Default: 1**. */
|
|
42
|
+
concurrency?: number;
|
|
43
|
+
/** allows destroying the stream if the signal is aborted. */
|
|
44
|
+
signal?: AbortSignal;
|
|
45
|
+
}
|
|
40
46
|
class ReadableBase extends Stream implements NodeJS.ReadableStream {
|
|
41
47
|
/**
|
|
42
48
|
* A utility method for creating Readable Streams out of iterators.
|
|
@@ -396,6 +402,138 @@ declare module 'stream' {
|
|
|
396
402
|
*/
|
|
397
403
|
wrap(stream: NodeJS.ReadableStream): this;
|
|
398
404
|
push(chunk: any, encoding?: BufferEncoding): boolean;
|
|
405
|
+
/**
|
|
406
|
+
* The iterator created by this method gives users the option to cancel the destruction
|
|
407
|
+
* of the stream if the `for await...of` loop is exited by `return`, `break`, or `throw`,
|
|
408
|
+
* or if the iterator should destroy the stream if the stream emitted an error during iteration.
|
|
409
|
+
* @since v16.3.0
|
|
410
|
+
* @param options.destroyOnReturn When set to `false`, calling `return` on the async iterator,
|
|
411
|
+
* or exiting a `for await...of` iteration using a `break`, `return`, or `throw` will not destroy the stream.
|
|
412
|
+
* **Default: `true`**.
|
|
413
|
+
*/
|
|
414
|
+
iterator(options?: {destroyOnReturn?: boolean}): AsyncIterableIterator<any>;
|
|
415
|
+
/**
|
|
416
|
+
* This method allows mapping over the stream. The *fn* function will be called for every chunk in the stream.
|
|
417
|
+
* If the *fn* function returns a promise - that promise will be `await`ed before being passed to the result stream.
|
|
418
|
+
* @since v17.4.0, v16.14.0
|
|
419
|
+
* @param fn a function to map over every chunk in the stream. Async or not.
|
|
420
|
+
* @returns a stream mapped with the function *fn*.
|
|
421
|
+
*/
|
|
422
|
+
map(fn: (data: any, options?: Pick<ArrayOptions, "signal">) => any, options?: ArrayOptions): Readable;
|
|
423
|
+
/**
|
|
424
|
+
* This method allows filtering the stream. For each chunk in the stream the *fn* function will be called
|
|
425
|
+
* and if it returns a truthy value, the chunk will be passed to the result stream.
|
|
426
|
+
* If the *fn* function returns a promise - that promise will be `await`ed.
|
|
427
|
+
* @since v17.4.0, v16.14.0
|
|
428
|
+
* @param fn a function to filter chunks from the stream. Async or not.
|
|
429
|
+
* @returns a stream filtered with the predicate *fn*.
|
|
430
|
+
*/
|
|
431
|
+
filter(fn: (data: any, options?: Pick<ArrayOptions, "signal">) => boolean | Promise<boolean>, options?: ArrayOptions): Readable;
|
|
432
|
+
/**
|
|
433
|
+
* This method allows iterating a stream. For each chunk in the stream the *fn* function will be called.
|
|
434
|
+
* If the *fn* function returns a promise - that promise will be `await`ed.
|
|
435
|
+
*
|
|
436
|
+
* This method is different from `for await...of` loops in that it can optionally process chunks concurrently.
|
|
437
|
+
* In addition, a `forEach` iteration can only be stopped by having passed a `signal` option
|
|
438
|
+
* and aborting the related AbortController while `for await...of` can be stopped with `break` or `return`.
|
|
439
|
+
* In either case the stream will be destroyed.
|
|
440
|
+
*
|
|
441
|
+
* This method is different from listening to the `'data'` event in that it uses the `readable` event
|
|
442
|
+
* in the underlying machinary and can limit the number of concurrent *fn* calls.
|
|
443
|
+
* @since v17.5.0
|
|
444
|
+
* @param fn a function to call on each chunk of the stream. Async or not.
|
|
445
|
+
* @returns a promise for when the stream has finished.
|
|
446
|
+
*/
|
|
447
|
+
forEach(fn: (data: any, options?: Pick<ArrayOptions, "signal">) => void | Promise<void>, options?: ArrayOptions): Promise<void>;
|
|
448
|
+
/**
|
|
449
|
+
* This method allows easily obtaining the contents of a stream.
|
|
450
|
+
*
|
|
451
|
+
* As this method reads the entire stream into memory, it negates the benefits of streams. It's intended
|
|
452
|
+
* for interoperability and convenience, not as the primary way to consume streams.
|
|
453
|
+
* @since v17.5.0
|
|
454
|
+
* @returns a promise containing an array with the contents of the stream.
|
|
455
|
+
*/
|
|
456
|
+
toArray(options?: Pick<ArrayOptions, "signal">): Promise<any[]>;
|
|
457
|
+
/**
|
|
458
|
+
* This method is similar to `Array.prototype.some` and calls *fn* on each chunk in the stream
|
|
459
|
+
* until the awaited return value is `true` (or any truthy value). Once an *fn* call on a chunk
|
|
460
|
+
* `await`ed return value is truthy, the stream is destroyed and the promise is fulfilled with `true`.
|
|
461
|
+
* If none of the *fn* calls on the chunks return a truthy value, the promise is fulfilled with `false`.
|
|
462
|
+
* @since v17.5.0
|
|
463
|
+
* @param fn a function to call on each chunk of the stream. Async or not.
|
|
464
|
+
* @returns a promise evaluating to `true` if *fn* returned a truthy value for at least one of the chunks.
|
|
465
|
+
*/
|
|
466
|
+
some(fn: (data: any, options?: Pick<ArrayOptions, "signal">) => boolean | Promise<boolean>, options?: ArrayOptions): Promise<boolean>;
|
|
467
|
+
/**
|
|
468
|
+
* This method is similar to `Array.prototype.find` and calls *fn* on each chunk in the stream
|
|
469
|
+
* to find a chunk with a truthy value for *fn*. Once an *fn* call's awaited return value is truthy,
|
|
470
|
+
* the stream is destroyed and the promise is fulfilled with value for which *fn* returned a truthy value.
|
|
471
|
+
* If all of the *fn* calls on the chunks return a falsy value, the promise is fulfilled with `undefined`.
|
|
472
|
+
* @since v17.5.0
|
|
473
|
+
* @param fn a function to call on each chunk of the stream. Async or not.
|
|
474
|
+
* @returns a promise evaluating to the first chunk for which *fn* evaluated with a truthy value,
|
|
475
|
+
* or `undefined` if no element was found.
|
|
476
|
+
*/
|
|
477
|
+
find<T>(fn: (data: any, options?: Pick<ArrayOptions, "signal">) => data is T, options?: ArrayOptions): Promise<T | undefined>;
|
|
478
|
+
find(fn: (data: any, options?: Pick<ArrayOptions, "signal">) => boolean | Promise<boolean>, options?: ArrayOptions): Promise<any>;
|
|
479
|
+
/**
|
|
480
|
+
* This method is similar to `Array.prototype.every` and calls *fn* on each chunk in the stream
|
|
481
|
+
* to check if all awaited return values are truthy value for *fn*. Once an *fn* call on a chunk
|
|
482
|
+
* `await`ed return value is falsy, the stream is destroyed and the promise is fulfilled with `false`.
|
|
483
|
+
* If all of the *fn* calls on the chunks return a truthy value, the promise is fulfilled with `true`.
|
|
484
|
+
* @since v17.5.0
|
|
485
|
+
* @param fn a function to call on each chunk of the stream. Async or not.
|
|
486
|
+
* @returns a promise evaluating to `true` if *fn* returned a truthy value for every one of the chunks.
|
|
487
|
+
*/
|
|
488
|
+
every(fn: (data: any, options?: Pick<ArrayOptions, "signal">) => boolean | Promise<boolean>, options?: ArrayOptions): Promise<boolean>;
|
|
489
|
+
/**
|
|
490
|
+
* This method returns a new stream by applying the given callback to each chunk of the stream
|
|
491
|
+
* and then flattening the result.
|
|
492
|
+
*
|
|
493
|
+
* It is possible to return a stream or another iterable or async iterable from *fn* and the result streams
|
|
494
|
+
* will be merged (flattened) into the returned stream.
|
|
495
|
+
* @since v17.5.0
|
|
496
|
+
* @param fn a function to map over every chunk in the stream. May be async. May be a stream or generator.
|
|
497
|
+
* @returns a stream flat-mapped with the function *fn*.
|
|
498
|
+
*/
|
|
499
|
+
flatMap(fn: (data: any, options?: Pick<ArrayOptions, "signal">) => any, options?: ArrayOptions): Readable;
|
|
500
|
+
/**
|
|
501
|
+
* This method returns a new stream with the first *limit* chunks dropped from the start.
|
|
502
|
+
* @since v17.5.0
|
|
503
|
+
* @param limit the number of chunks to drop from the readable.
|
|
504
|
+
* @returns a stream with *limit* chunks dropped from the start.
|
|
505
|
+
*/
|
|
506
|
+
drop(limit: number, options?: Pick<ArrayOptions, "signal">): Readable;
|
|
507
|
+
/**
|
|
508
|
+
* This method returns a new stream with the first *limit* chunks.
|
|
509
|
+
* @since v17.5.0
|
|
510
|
+
* @param limit the number of chunks to take from the readable.
|
|
511
|
+
* @returns a stream with *limit* chunks taken.
|
|
512
|
+
*/
|
|
513
|
+
take(limit: number, options?: Pick<ArrayOptions, "signal">): Readable;
|
|
514
|
+
/**
|
|
515
|
+
* This method returns a new stream with chunks of the underlying stream paired with a counter
|
|
516
|
+
* in the form `[index, chunk]`. The first index value is `0` and it increases by 1 for each chunk produced.
|
|
517
|
+
* @since v17.5.0
|
|
518
|
+
* @returns a stream of indexed pairs.
|
|
519
|
+
*/
|
|
520
|
+
asIndexedPairs(options?: Pick<ArrayOptions, "signal">): Readable;
|
|
521
|
+
/**
|
|
522
|
+
* This method calls *fn* on each chunk of the stream in order, passing it the result from the calculation
|
|
523
|
+
* on the previous element. It returns a promise for the final value of the reduction.
|
|
524
|
+
*
|
|
525
|
+
* If no *initial* value is supplied the first chunk of the stream is used as the initial value.
|
|
526
|
+
* If the stream is empty, the promise is rejected with a `TypeError` with the `ERR_INVALID_ARGS` code property.
|
|
527
|
+
*
|
|
528
|
+
* The reducer function iterates the stream element-by-element which means that there is no *concurrency* parameter
|
|
529
|
+
* or parallelism. To perform a reduce concurrently, you can extract the async function to `readable.map` method.
|
|
530
|
+
* @since v17.5.0
|
|
531
|
+
* @param fn a reducer function to call over every chunk in the stream. Async or not.
|
|
532
|
+
* @param initial the initial value to use in the reduction.
|
|
533
|
+
* @returns a promise for the final value of the reduction.
|
|
534
|
+
*/
|
|
535
|
+
reduce<T = any>(fn: (previous: any, data: any, options?: Pick<ArrayOptions, "signal">) => T, initial?: undefined, options?: Pick<ArrayOptions, "signal">): Promise<T>;
|
|
536
|
+
reduce<T = any>(fn: (previous: T, data: any, options?: Pick<ArrayOptions, "signal">) => T, initial: T, options?: Pick<ArrayOptions, "signal">): Promise<T>;
|
|
399
537
|
_destroy(error: Error | null, callback: (error?: Error | null) => void): void;
|
|
400
538
|
/**
|
|
401
539
|
* Destroy the stream. Optionally emit an `'error'` event, and emit a `'close'`event (unless `emitClose` is set to `false`). After this call, the readable
|
node/ts4.8/fs.d.ts
CHANGED
|
@@ -3618,15 +3618,28 @@ declare module 'fs' {
|
|
|
3618
3618
|
fd?: number | promises.FileHandle | undefined;
|
|
3619
3619
|
mode?: number | undefined;
|
|
3620
3620
|
autoClose?: boolean | undefined;
|
|
3621
|
-
/**
|
|
3622
|
-
* @default false
|
|
3623
|
-
*/
|
|
3624
3621
|
emitClose?: boolean | undefined;
|
|
3625
3622
|
start?: number | undefined;
|
|
3626
|
-
|
|
3623
|
+
signal?: AbortSignal | null | undefined;
|
|
3624
|
+
}
|
|
3625
|
+
interface FSImplementation {
|
|
3626
|
+
open?: (...args: any[]) => any;
|
|
3627
|
+
close?: (...args: any[]) => any;
|
|
3628
|
+
}
|
|
3629
|
+
interface CreateReadStreamFSImplementation extends FSImplementation {
|
|
3630
|
+
read: (...args: any[]) => any;
|
|
3631
|
+
}
|
|
3632
|
+
interface CreateWriteStreamFSImplementation extends FSImplementation {
|
|
3633
|
+
write: (...args: any[]) => any;
|
|
3634
|
+
writev?: (...args: any[]) => any;
|
|
3627
3635
|
}
|
|
3628
3636
|
interface ReadStreamOptions extends StreamOptions {
|
|
3637
|
+
fs?: CreateReadStreamFSImplementation | null | undefined;
|
|
3629
3638
|
end?: number | undefined;
|
|
3639
|
+
highWaterMark?: number | undefined;
|
|
3640
|
+
}
|
|
3641
|
+
interface WriteStreamOptions extends StreamOptions {
|
|
3642
|
+
fs?: CreateWriteStreamFSImplementation | null | undefined;
|
|
3630
3643
|
}
|
|
3631
3644
|
/**
|
|
3632
3645
|
* Unlike the 16 KiB default `highWaterMark` for a `stream.Readable`, the stream
|
|
@@ -3720,7 +3733,7 @@ declare module 'fs' {
|
|
|
3720
3733
|
* If `options` is a string, then it specifies the encoding.
|
|
3721
3734
|
* @since v0.1.31
|
|
3722
3735
|
*/
|
|
3723
|
-
export function createWriteStream(path: PathLike, options?: BufferEncoding |
|
|
3736
|
+
export function createWriteStream(path: PathLike, options?: BufferEncoding | WriteStreamOptions): WriteStream;
|
|
3724
3737
|
/**
|
|
3725
3738
|
* Forces all currently queued I/O operations associated with the file to the
|
|
3726
3739
|
* 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
|