node-red-contrib-tak-registration 0.8.0 → 0.8.3

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.
Files changed (75) hide show
  1. package/README.md +2 -0
  2. package/node_modules/@types/node/README.md +1 -1
  3. package/node_modules/@types/node/child_process.d.ts +5 -0
  4. package/node_modules/@types/node/dgram.d.ts +5 -0
  5. package/node_modules/@types/node/events.d.ts +35 -0
  6. package/node_modules/@types/node/fs/promises.d.ts +5 -0
  7. package/node_modules/@types/node/fs.d.ts +43 -5
  8. package/node_modules/@types/node/globals.d.ts +22 -0
  9. package/node_modules/@types/node/index.d.ts +1 -1
  10. package/node_modules/@types/node/inspector.d.ts +1 -1
  11. package/node_modules/@types/node/module.d.ts +103 -0
  12. package/node_modules/@types/node/net.d.ts +5 -0
  13. package/node_modules/@types/node/package.json +2 -2
  14. package/node_modules/@types/node/stream.d.ts +143 -0
  15. package/node_modules/@types/node/test.d.ts +33 -4
  16. package/node_modules/@types/node/timers.d.ts +12 -2
  17. package/node_modules/@types/node/ts4.8/child_process.d.ts +5 -0
  18. package/node_modules/@types/node/ts4.8/dgram.d.ts +5 -0
  19. package/node_modules/@types/node/ts4.8/events.d.ts +35 -0
  20. package/node_modules/@types/node/ts4.8/fs/promises.d.ts +5 -0
  21. package/node_modules/@types/node/ts4.8/fs.d.ts +43 -5
  22. package/node_modules/@types/node/ts4.8/globals.d.ts +22 -0
  23. package/node_modules/@types/node/ts4.8/inspector.d.ts +1 -1
  24. package/node_modules/@types/node/ts4.8/module.d.ts +103 -0
  25. package/node_modules/@types/node/ts4.8/net.d.ts +5 -0
  26. package/node_modules/@types/node/ts4.8/stream.d.ts +762 -728
  27. package/node_modules/@types/node/ts4.8/test.d.ts +97 -50
  28. package/node_modules/@types/node/ts4.8/timers.d.ts +12 -2
  29. package/node_modules/@types/node/ts4.8/vm.d.ts +2 -1
  30. package/node_modules/@types/node/vm.d.ts +2 -1
  31. package/node_modules/axios/CHANGELOG.md +23 -0
  32. package/node_modules/axios/README.md +33 -5
  33. package/node_modules/axios/dist/axios.js +26 -18
  34. package/node_modules/axios/dist/axios.js.map +1 -1
  35. package/node_modules/axios/dist/axios.min.js +1 -1
  36. package/node_modules/axios/dist/axios.min.js.map +1 -1
  37. package/node_modules/axios/dist/browser/axios.cjs +24 -20
  38. package/node_modules/axios/dist/browser/axios.cjs.map +1 -1
  39. package/node_modules/axios/dist/esm/axios.js +26 -21
  40. package/node_modules/axios/dist/esm/axios.js.map +1 -1
  41. package/node_modules/axios/dist/esm/axios.min.js +1 -1
  42. package/node_modules/axios/dist/esm/axios.min.js.map +1 -1
  43. package/node_modules/axios/dist/node/axios.cjs +27 -21
  44. package/node_modules/axios/dist/node/axios.cjs.map +1 -1
  45. package/node_modules/axios/index.d.cts +1 -0
  46. package/node_modules/axios/index.d.ts +3 -0
  47. package/node_modules/axios/index.js +2 -0
  48. package/node_modules/axios/lib/adapters/http.js +3 -1
  49. package/node_modules/axios/lib/axios.js +3 -0
  50. package/node_modules/axios/lib/core/Axios.js +2 -4
  51. package/node_modules/axios/lib/core/AxiosHeaders.js +11 -1
  52. package/node_modules/axios/lib/defaults/index.js +4 -11
  53. package/node_modules/axios/lib/env/data.js +1 -1
  54. package/node_modules/axios/lib/utils.js +3 -2
  55. package/node_modules/axios/package.json +3 -1
  56. package/node_modules/protobufjs/dist/light/protobuf.js +24 -13
  57. package/node_modules/protobufjs/dist/light/protobuf.js.map +1 -1
  58. package/node_modules/protobufjs/dist/light/protobuf.min.js +3 -3
  59. package/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -1
  60. package/node_modules/protobufjs/dist/minimal/protobuf.js +12 -7
  61. package/node_modules/protobufjs/dist/minimal/protobuf.js.map +1 -1
  62. package/node_modules/protobufjs/dist/minimal/protobuf.min.js +3 -3
  63. package/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +1 -1
  64. package/node_modules/protobufjs/dist/protobuf.js +40 -18
  65. package/node_modules/protobufjs/dist/protobuf.js.map +1 -1
  66. package/node_modules/protobufjs/dist/protobuf.min.js +3 -3
  67. package/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
  68. package/node_modules/protobufjs/package.json +1 -1
  69. package/node_modules/protobufjs/src/converter.js +2 -2
  70. package/node_modules/protobufjs/src/parse.js +4 -1
  71. package/node_modules/protobufjs/src/reader.js +8 -3
  72. package/node_modules/protobufjs/src/tokenize.js +2 -4
  73. package/package.json +3 -3
  74. package/tak-ingest.js +1 -1
  75. package/tak-registration.js +14 -5
package/README.md CHANGED
@@ -75,5 +75,7 @@ This node can accept input direct from a TCP request node, configured to point t
75
75
 
76
76
  It will produce a well formatted JSON object containing the event. It is returned as **msg.payload.event**
77
77
 
78
+ **msg.topic** is set to the COT type.
79
+
78
80
  It can also accept input from a UDP node configured to listen to *multicast* on group 239.2.3.1 port 6969. The JSON object produced contains similar information but formatted/organised slightly differently. (Very annoying).
79
81
  It is returned as **msg.payload.cotEvent**
@@ -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: Tue, 08 Aug 2023 20:32:42 GMT
11
+ * Last updated: Mon, 28 Aug 2023 00:33:00 GMT
12
12
  * Dependencies: none
13
13
  * Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`, `structuredClone`
14
14
 
@@ -302,6 +302,11 @@ declare module 'child_process' {
302
302
  * @since v0.1.90
303
303
  */
304
304
  kill(signal?: NodeJS.Signals | number): boolean;
305
+ /**
306
+ * Calls {@link ChildProcess.kill} with `'SIGTERM'`.
307
+ * @since v20.5.0
308
+ */
309
+ [Symbol.dispose](): void;
305
310
  /**
306
311
  * When an IPC channel has been established between the parent and child (
307
312
  * i.e. when using {@link fork}), the `subprocess.send()` method can
@@ -538,6 +538,11 @@ declare module 'dgram' {
538
538
  prependOnceListener(event: 'error', listener: (err: Error) => void): this;
539
539
  prependOnceListener(event: 'listening', listener: () => void): this;
540
540
  prependOnceListener(event: 'message', listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
541
+ /**
542
+ * Calls `socket.close()` and returns a promise that fulfills when the socket has closed.
543
+ * @since v20.5.0
544
+ */
545
+ [Symbol.asyncDispose](): Promise<void>;
541
546
  }
542
547
  }
543
548
  declare module 'node:dgram' {
@@ -338,6 +338,41 @@ declare module 'events' {
338
338
  * objects.
339
339
  */
340
340
  static setMaxListeners(n?: number, ...eventTargets: Array<_DOMEventTarget | NodeJS.EventEmitter>): void;
341
+ /**
342
+ * Listens once to the `abort` event on the provided `signal`.
343
+ *
344
+ * Listening to the `abort` event on abort signals is unsafe and may
345
+ * lead to resource leaks since another third party with the signal can
346
+ * call `e.stopImmediatePropagation()`. Unfortunately Node.js cannot change
347
+ * this since it would violate the web standard. Additionally, the original
348
+ * API makes it easy to forget to remove listeners.
349
+ *
350
+ * This API allows safely using `AbortSignal`s in Node.js APIs by solving these
351
+ * two issues by listening to the event such that `stopImmediatePropagation` does
352
+ * not prevent the listener from running.
353
+ *
354
+ * Returns a disposable so that it may be unsubscribed from more easily.
355
+ *
356
+ * ```js
357
+ * import { addAbortListener } from 'node:events';
358
+ *
359
+ * function example(signal) {
360
+ * let disposable;
361
+ * try {
362
+ * signal.addEventListener('abort', (e) => e.stopImmediatePropagation());
363
+ * disposable = addAbortListener(signal, (e) => {
364
+ * // Do something when signal is aborted.
365
+ * });
366
+ * } finally {
367
+ * disposable?.[Symbol.dispose]();
368
+ * }
369
+ * }
370
+ * ```
371
+ * @since v20.5.0
372
+ * @experimental
373
+ * @return that removes the `abort` listener.
374
+ */
375
+ static addAbortListener(signal: AbortSignal, resource: (event: Event) => void): Disposable;
341
376
  /**
342
377
  * This symbol shall be used to install a listener for only monitoring `'error'`events. Listeners installed using this symbol are called before the regular`'error'` listeners are called.
343
378
  *
@@ -456,6 +456,11 @@ declare module 'fs/promises' {
456
456
  * @return Fulfills with `undefined` upon success.
457
457
  */
458
458
  close(): Promise<void>;
459
+ /**
460
+ * An alias for {@link FileHandle.close()}.
461
+ * @since v20.4.0
462
+ */
463
+ [Symbol.asyncDispose](): Promise<void>;
459
464
  }
460
465
  const constants: typeof fsConstants;
461
466
  /**
@@ -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
- highWaterMark?: number | undefined;
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 | StreamOptions): WriteStream;
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
@@ -3900,6 +3913,31 @@ declare module 'fs' {
3900
3913
  * @return The number of bytes read.
3901
3914
  */
3902
3915
  export function readvSync(fd: number, buffers: ReadonlyArray<NodeJS.ArrayBufferView>, position?: number): number;
3916
+
3917
+ export interface OpenAsBlobOptions {
3918
+ /**
3919
+ * An optional mime type for the blob.
3920
+ *
3921
+ * @default 'undefined'
3922
+ */
3923
+ type?: string | undefined;
3924
+ }
3925
+
3926
+ /**
3927
+ * Returns a Blob whose data is backed by the given file.
3928
+ *
3929
+ * The file must not be modified after the `Blob` is created.
3930
+ * Any modifications will cause reading the `Blob` data to fail with a `DOMException` error.
3931
+ * Synchronous stat operations on the file when the `Blob` is created, and before each read in order to detect whether the file data has been modified on disk.
3932
+ *
3933
+ * @param path
3934
+ * @param [options]
3935
+ *
3936
+ * @experimental
3937
+ * @since v19.8.0
3938
+ */
3939
+ export function openAsBlob(path: PathLike, options?: OpenAsBlobOptions): Promise<Blob>;
3940
+
3903
3941
  export interface OpenDirOptions {
3904
3942
  /**
3905
3943
  * @default 'utf8'
@@ -84,6 +84,28 @@ declare var AbortSignal: typeof globalThis extends {onmessage: any; AbortSignal:
84
84
  };
85
85
  //#endregion borrowed
86
86
 
87
+ //#region Disposable
88
+ interface SymbolConstructor {
89
+ /**
90
+ * A method that is used to release resources held by an object. Called by the semantics of the `using` statement.
91
+ */
92
+ readonly dispose: unique symbol;
93
+
94
+ /**
95
+ * A method that is used to asynchronously release resources held by an object. Called by the semantics of the `await using` statement.
96
+ */
97
+ readonly asyncDispose: unique symbol;
98
+ }
99
+
100
+ interface Disposable {
101
+ [Symbol.dispose](): void;
102
+ }
103
+
104
+ interface AsyncDisposable {
105
+ [Symbol.asyncDispose](): PromiseLike<void>;
106
+ }
107
+ //#endregion Disposable
108
+
87
109
  //#region ArrayLike.at()
88
110
  interface RelativeIndexable<T> {
89
111
  /**
@@ -1,4 +1,4 @@
1
- // Type definitions for non-npm package Node.js 20.4
1
+ // Type definitions for non-npm package Node.js 20.5
2
2
  // Project: https://nodejs.org/
3
3
  // Definitions by: Microsoft TypeScript <https://github.com/Microsoft>
4
4
  // DefinitelyTyped <https://github.com/DefinitelyTyped>
@@ -1,4 +1,4 @@
1
- // eslint-disable-next-line dt-header
1
+ // eslint-disable-next-line @definitelytyped/dt-header
2
2
  // Type definitions for inspector
3
3
 
4
4
  // These definitions are auto-generated.
@@ -3,6 +3,7 @@
3
3
  */
4
4
  declare module 'module' {
5
5
  import { URL } from 'node:url';
6
+ import { MessagePort } from 'node:worker_threads';
6
7
  namespace Module {
7
8
  /**
8
9
  * The `module.syncBuiltinESMExports()` method updates all the live bindings for
@@ -92,6 +93,108 @@ declare module 'module' {
92
93
  */
93
94
  findEntry(lineOffset: number, columnOffset: number): SourceMapping;
94
95
  }
96
+ interface ImportAssertions extends NodeJS.Dict<string> {
97
+ type?: string | undefined;
98
+ }
99
+ type ModuleFormat = 'builtin' | 'commonjs' | 'json' | 'module' | 'wasm';
100
+ type ModuleSource = string | ArrayBuffer | NodeJS.TypedArray;
101
+ interface GlobalPreloadContext {
102
+ port: MessagePort;
103
+ }
104
+ /**
105
+ * Sometimes it might be necessary to run some code inside of the same global scope that the application runs in.
106
+ * This hook allows the return of a string that is run as a sloppy-mode script on startup.
107
+ *
108
+ * @param context Information to assist the preload code
109
+ * @return Code to run before application startup
110
+ */
111
+ type GlobalPreloadHook = (context: GlobalPreloadContext) => string;
112
+ interface ResolveHookContext {
113
+ /**
114
+ * Export conditions of the relevant `package.json`
115
+ */
116
+ conditions: string[];
117
+ /**
118
+ * An object whose key-value pairs represent the assertions for the module to import
119
+ */
120
+ importAssertions: ImportAssertions;
121
+ /**
122
+ * The module importing this one, or undefined if this is the Node.js entry point
123
+ */
124
+ parentURL: string | undefined;
125
+ }
126
+ interface ResolveFnOutput {
127
+ /**
128
+ * A hint to the load hook (it might be ignored)
129
+ */
130
+ format?: ModuleFormat | null | undefined;
131
+ /**
132
+ * The import assertions to use when caching the module (optional; if excluded the input will be used)
133
+ */
134
+ importAssertions?: ImportAssertions | undefined;
135
+ /**
136
+ * A signal that this hook intends to terminate the chain of `resolve` hooks.
137
+ * @default false
138
+ */
139
+ shortCircuit?: boolean | undefined;
140
+ /**
141
+ * The absolute URL to which this input resolves
142
+ */
143
+ url: string;
144
+ }
145
+ /**
146
+ * The `resolve` hook chain is responsible for resolving file URL for a given module specifier and parent URL, and optionally its format (such as `'module'`) as a hint to the `load` hook.
147
+ * If a format is specified, the load hook is ultimately responsible for providing the final `format` value (and it is free to ignore the hint provided by `resolve`);
148
+ * if `resolve` provides a format, a custom `load` hook is required even if only to pass the value to the Node.js default `load` hook.
149
+ *
150
+ * @param specifier The specified URL path of the module to be resolved
151
+ * @param context
152
+ * @param nextResolve The subsequent `resolve` hook in the chain, or the Node.js default `resolve` hook after the last user-supplied resolve hook
153
+ */
154
+ type ResolveHook = (
155
+ specifier: string,
156
+ context: ResolveHookContext,
157
+ nextResolve: (specifier: string, context?: ResolveHookContext) => ResolveFnOutput | Promise<ResolveFnOutput>
158
+ ) => ResolveFnOutput | Promise<ResolveFnOutput>;
159
+ interface LoadHookContext {
160
+ /**
161
+ * Export conditions of the relevant `package.json`
162
+ */
163
+ conditions: string[];
164
+ /**
165
+ * The format optionally supplied by the `resolve` hook chain
166
+ */
167
+ format: ModuleFormat;
168
+ /**
169
+ * An object whose key-value pairs represent the assertions for the module to import
170
+ */
171
+ importAssertions: ImportAssertions;
172
+ }
173
+ interface LoadFnOutput {
174
+ format: ModuleFormat;
175
+ /**
176
+ * A signal that this hook intends to terminate the chain of `resolve` hooks.
177
+ * @default false
178
+ */
179
+ shortCircuit?: boolean | undefined;
180
+ /**
181
+ * The source for Node.js to evaluate
182
+ */
183
+ source?: ModuleSource;
184
+ }
185
+ /**
186
+ * The `load` hook provides a way to define a custom method of determining how a URL should be interpreted, retrieved, and parsed.
187
+ * It is also in charge of validating the import assertion.
188
+ *
189
+ * @param url The URL/path of the module to be loaded
190
+ * @param context Metadata about the module
191
+ * @param nextLoad The subsequent `load` hook in the chain, or the Node.js default `load` hook after the last user-supplied `load` hook
192
+ */
193
+ type LoadHook = (
194
+ url: string,
195
+ context: LoadHookContext,
196
+ nextLoad: (url: string, context?: LoadHookContext) => LoadFnOutput | Promise<LoadFnOutput>
197
+ ) => LoadFnOutput | Promise<LoadFnOutput>;
95
198
  }
96
199
  interface Module extends NodeModule {}
97
200
  class Module {
@@ -639,6 +639,11 @@ declare module 'net' {
639
639
  prependOnceListener(event: 'error', listener: (err: Error) => void): this;
640
640
  prependOnceListener(event: 'listening', listener: () => void): this;
641
641
  prependOnceListener(event: 'drop', listener: (data?: DropArgument) => void): this;
642
+ /**
643
+ * Calls {@link Server.close()} and returns a promise that fulfills when the server has closed.
644
+ * @since v20.5.0
645
+ */
646
+ [Symbol.asyncDispose](): Promise<void>;
642
647
  }
643
648
  type IPVersion = 'ipv4' | 'ipv6';
644
649
  /**
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "20.4.9",
3
+ "version": "20.5.7",
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": "b2f4c2c06161f1c6a01968b024abf85b1541142467b4d7a7fe451165a706da3f",
230
+ "typesPublisherContentHash": "3c31754d724881876a0bd7b216ddce3840ec052e1944538329b9271e525d425c",
231
231
  "typeScriptVersion": "4.3"
232
232
  }
@@ -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
@@ -477,6 +615,11 @@ declare module 'stream' {
477
615
  removeListener(event: 'resume', listener: () => void): this;
478
616
  removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
479
617
  [Symbol.asyncIterator](): AsyncIterableIterator<any>;
618
+ /**
619
+ * Calls `readable.destroy()` with an `AbortError` and returns a promise that fulfills when the stream is finished.
620
+ * @since v20.4.0
621
+ */
622
+ [Symbol.asyncDispose](): Promise<void>;
480
623
  }
481
624
  import WritableOptions = internal.WritableOptions;
482
625
  class WritableBase extends Stream implements NodeJS.WritableStream {
@@ -256,9 +256,18 @@ declare module 'node:test' {
256
256
  type TestFn = (t: TestContext, done: (result?: any) => void) => void | Promise<void>;
257
257
  /**
258
258
  * The type of a function under Suite.
259
- * If the test uses callbacks, the callback function is passed as an argument
260
259
  */
261
260
  type SuiteFn = (s: SuiteContext) => void | Promise<void>;
261
+ interface TestShard {
262
+ /**
263
+ * A positive integer between 1 and `<total>` that specifies the index of the shard to run.
264
+ */
265
+ index: number;
266
+ /**
267
+ * A positive integer that specifies the total number of shards to split the test files to.
268
+ */
269
+ total: number;
270
+ }
262
271
  interface RunOptions {
263
272
  /**
264
273
  * If a number is provided, then that many files would run in parallel.
@@ -301,9 +310,15 @@ declare module 'node:test' {
301
310
  */
302
311
  setup?: (root: Test) => void | Promise<void>;
303
312
  /**
304
- * Whether to run in watch mode or not. Default: false.
313
+ * Whether to run in watch mode or not.
314
+ * @default false
305
315
  */
306
- watch?: boolean;
316
+ watch?: boolean | undefined;
317
+ /**
318
+ * Running tests in a specific shard.
319
+ * @default undefined
320
+ */
321
+ shard?: TestShard | undefined;
307
322
  }
308
323
  class Test extends AsyncResource {
309
324
  concurrency: number;
@@ -633,7 +648,7 @@ declare module 'node:test' {
633
648
  * The hook function. If the hook uses callbacks, the callback function is passed as the
634
649
  * second argument.
635
650
  */
636
- type HookFn = (done: (result?: any) => void) => any;
651
+ type HookFn = (s: SuiteContext, done: (result?: any) => void) => any;
637
652
  /**
638
653
  * Configuration options for hooks.
639
654
  * @since v18.8.0
@@ -1210,6 +1225,10 @@ declare module 'node:test' {
1210
1225
  * @since v20.4.0
1211
1226
  */
1212
1227
  runAll(): void;
1228
+ /**
1229
+ * Calls {@link MockTimers.reset()}.
1230
+ */
1231
+ [Symbol.dispose](): void;
1213
1232
  }
1214
1233
  export { test as default, run, test, describe, it, before, after, beforeEach, afterEach, mock, skip, only, todo };
1215
1234
  }
@@ -1241,6 +1260,11 @@ interface TestFail {
1241
1260
  * The error thrown by the test.
1242
1261
  */
1243
1262
  error: Error;
1263
+ /**
1264
+ * The type of the test, used to denote whether this is a suite.
1265
+ * @since 20.0.0, 19.9.0, 18.17.0
1266
+ */
1267
+ type?: 'suite';
1244
1268
  };
1245
1269
  /**
1246
1270
  * The test name.
@@ -1276,6 +1300,11 @@ interface TestPass {
1276
1300
  * The duration of the test in milliseconds.
1277
1301
  */
1278
1302
  duration_ms: number;
1303
+ /**
1304
+ * The type of the test, used to denote whether this is a suite.
1305
+ * @since 20.0.0, 19.9.0, 18.17.0
1306
+ */
1307
+ type?: 'suite';
1279
1308
  };
1280
1309
  /**
1281
1310
  * The test name.
@@ -68,6 +68,11 @@ declare module 'timers' {
68
68
  */
69
69
  hasRef(): boolean;
70
70
  _onImmediate: Function; // to distinguish it from the Timeout class
71
+ /**
72
+ * Cancels the immediate. This is similar to calling `clearImmediate()`.
73
+ * @since v20.5.0
74
+ */
75
+ [Symbol.dispose](): void;
71
76
  }
72
77
  /**
73
78
  * This object is created internally and is returned from `setTimeout()` and `setInterval()`. It can be passed to either `clearTimeout()` or `clearInterval()` in order to cancel the
@@ -114,6 +119,11 @@ declare module 'timers' {
114
119
  */
115
120
  refresh(): this;
116
121
  [Symbol.toPrimitive](): number;
122
+ /**
123
+ * Cancels the timeout.
124
+ * @since v20.5.0
125
+ */
126
+ [Symbol.dispose](): void;
117
127
  }
118
128
  }
119
129
  /**
@@ -163,10 +173,10 @@ declare module 'timers' {
163
173
  * @param args Optional arguments to pass when the `callback` is called.
164
174
  * @return for use with {@link clearInterval}
165
175
  */
166
- function setInterval<TArgs extends any[]>(callback: (...args: TArgs) => void, ms?: number, ...args: TArgs): NodeJS.Timer;
176
+ function setInterval<TArgs extends any[]>(callback: (...args: TArgs) => void, ms?: number, ...args: TArgs): NodeJS.Timeout;
167
177
  // util.promisify no rest args compability
168
178
  // tslint:disable-next-line void-return
169
- function setInterval(callback: (args: void) => void, ms?: number): NodeJS.Timer;
179
+ function setInterval(callback: (args: void) => void, ms?: number): NodeJS.Timeout;
170
180
  namespace setInterval {
171
181
  const __promisify__: typeof setIntervalPromise;
172
182
  }
@@ -302,6 +302,11 @@ declare module 'child_process' {
302
302
  * @since v0.1.90
303
303
  */
304
304
  kill(signal?: NodeJS.Signals | number): boolean;
305
+ /**
306
+ * Calls {@link ChildProcess.kill} with `'SIGTERM'`.
307
+ * @since v20.5.0
308
+ */
309
+ [Symbol.dispose](): void;
305
310
  /**
306
311
  * When an IPC channel has been established between the parent and child (
307
312
  * i.e. when using {@link fork}), the `subprocess.send()` method can