@types/node 15.3.1 → 15.9.0

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/fs.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  declare module 'fs' {
2
2
  import * as stream from 'stream';
3
- import EventEmitter = require('events');
3
+ import { Abortable, EventEmitter } from 'events';
4
4
  import { URL } from 'url';
5
5
  import * as promises from 'fs/promises';
6
6
 
@@ -142,11 +142,6 @@ declare module 'fs' {
142
142
  prependOnceListener(event: "close", listener: () => void): this;
143
143
  }
144
144
 
145
- // TODO: Move this to a more central location
146
- export interface Abortable {
147
- signal?: AbortSignal;
148
- }
149
-
150
145
  export class ReadStream extends stream.Readable {
151
146
  close(): void;
152
147
  bytesRead: number;
@@ -281,9 +276,7 @@ declare module 'fs' {
281
276
  /**
282
277
  * Asynchronous rename(2) - Change the name or location of a file or directory.
283
278
  * @param oldPath A path to a file. If a URL is provided, it must use the `file:` protocol.
284
- * URL support is _experimental_.
285
279
  * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
286
- * URL support is _experimental_.
287
280
  */
288
281
  export function rename(oldPath: PathLike, newPath: PathLike, callback: NoParamCallback): void;
289
282
 
@@ -302,9 +295,7 @@ declare module 'fs' {
302
295
  /**
303
296
  * Synchronous rename(2) - Change the name or location of a file or directory.
304
297
  * @param oldPath A path to a file. If a URL is provided, it must use the `file:` protocol.
305
- * URL support is _experimental_.
306
298
  * @param newPath A path to a file. If a URL is provided, it must use the `file:` protocol.
307
- * URL support is _experimental_.
308
299
  */
309
300
  export function renameSync(oldPath: PathLike, newPath: PathLike): void;
310
301
 
@@ -318,7 +309,6 @@ declare module 'fs' {
318
309
  /**
319
310
  * Asynchronous truncate(2) - Truncate a file to a specified length.
320
311
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
321
- * URL support is _experimental_.
322
312
  */
323
313
  export function truncate(path: PathLike, callback: NoParamCallback): void;
324
314
 
@@ -1247,7 +1237,7 @@ declare module 'fs' {
1247
1237
  * Asynchronous close(2) - close a file descriptor.
1248
1238
  * @param fd A file descriptor.
1249
1239
  */
1250
- export function close(fd: number, callback: NoParamCallback): void;
1240
+ export function close(fd: number, callback?: NoParamCallback): void;
1251
1241
 
1252
1242
  // NOTE: This namespace provides design-time support for util.promisify. Exported members do not exist at runtime.
1253
1243
  export namespace close {
@@ -1492,6 +1482,8 @@ declare module 'fs' {
1492
1482
  */
1493
1483
  export function writeSync(fd: number, string: string, position?: number | null, encoding?: BufferEncoding | null): number;
1494
1484
 
1485
+ export type ReadPosition = number | bigint;
1486
+
1495
1487
  /**
1496
1488
  * Asynchronously reads data from the file referenced by the supplied file descriptor.
1497
1489
  * @param fd A file descriptor.
@@ -1505,7 +1497,7 @@ declare module 'fs' {
1505
1497
  buffer: TBuffer,
1506
1498
  offset: number,
1507
1499
  length: number,
1508
- position: number | null,
1500
+ position: ReadPosition | null,
1509
1501
  callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void,
1510
1502
  ): void;
1511
1503
 
@@ -1539,7 +1531,7 @@ declare module 'fs' {
1539
1531
  /**
1540
1532
  * @default null
1541
1533
  */
1542
- position?: number | null;
1534
+ position?: ReadPosition | null;
1543
1535
  }
1544
1536
 
1545
1537
  /**
@@ -1550,7 +1542,7 @@ declare module 'fs' {
1550
1542
  * @param length The number of bytes to read.
1551
1543
  * @param position The offset from the beginning of the file from which data should be read. If `null`, data will be read from the current position.
1552
1544
  */
1553
- export function readSync(fd: number, buffer: NodeJS.ArrayBufferView, offset: number, length: number, position: number | null): number;
1545
+ export function readSync(fd: number, buffer: NodeJS.ArrayBufferView, offset: number, length: number, position: ReadPosition | null): number;
1554
1546
 
1555
1547
  /**
1556
1548
  * Similar to the above `fs.readSync` function, this version takes an optional `options` object.
@@ -1574,7 +1566,6 @@ declare module 'fs' {
1574
1566
  /**
1575
1567
  * Asynchronously reads the entire contents of a file.
1576
1568
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1577
- * URL support is _experimental_.
1578
1569
  * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
1579
1570
  * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
1580
1571
  * If a flag is not provided, it defaults to `'r'`.
@@ -1588,7 +1579,6 @@ declare module 'fs' {
1588
1579
  /**
1589
1580
  * Asynchronously reads the entire contents of a file.
1590
1581
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1591
- * URL support is _experimental_.
1592
1582
  * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
1593
1583
  * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
1594
1584
  * If a flag is not provided, it defaults to `'r'`.
@@ -1642,7 +1632,6 @@ declare module 'fs' {
1642
1632
  /**
1643
1633
  * Synchronously reads the entire contents of a file.
1644
1634
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1645
- * URL support is _experimental_.
1646
1635
  * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
1647
1636
  * @param options An object that may contain an optional flag. If a flag is not provided, it defaults to `'r'`.
1648
1637
  */
@@ -1651,7 +1640,6 @@ declare module 'fs' {
1651
1640
  /**
1652
1641
  * Synchronously reads the entire contents of a file.
1653
1642
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1654
- * URL support is _experimental_.
1655
1643
  * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
1656
1644
  * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
1657
1645
  * If a flag is not provided, it defaults to `'r'`.
@@ -1661,7 +1649,6 @@ declare module 'fs' {
1661
1649
  /**
1662
1650
  * Synchronously reads the entire contents of a file.
1663
1651
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1664
- * URL support is _experimental_.
1665
1652
  * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
1666
1653
  * @param options Either the encoding for the result, or an object that contains the encoding and an optional flag.
1667
1654
  * If a flag is not provided, it defaults to `'r'`.
@@ -1673,7 +1660,6 @@ declare module 'fs' {
1673
1660
  /**
1674
1661
  * Asynchronously writes data to a file, replacing the file if it already exists.
1675
1662
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1676
- * URL support is _experimental_.
1677
1663
  * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
1678
1664
  * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
1679
1665
  * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
@@ -1687,7 +1673,6 @@ declare module 'fs' {
1687
1673
  /**
1688
1674
  * Asynchronously writes data to a file, replacing the file if it already exists.
1689
1675
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1690
- * URL support is _experimental_.
1691
1676
  * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
1692
1677
  * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
1693
1678
  */
@@ -1713,7 +1698,6 @@ declare module 'fs' {
1713
1698
  /**
1714
1699
  * Synchronously writes data to a file, replacing the file if it already exists.
1715
1700
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
1716
- * URL support is _experimental_.
1717
1701
  * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
1718
1702
  * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
1719
1703
  * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
@@ -1727,7 +1711,6 @@ declare module 'fs' {
1727
1711
  /**
1728
1712
  * Asynchronously append data to a file, creating the file if it does not exist.
1729
1713
  * @param file A path to a file. If a URL is provided, it must use the `file:` protocol.
1730
- * URL support is _experimental_.
1731
1714
  * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
1732
1715
  * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
1733
1716
  * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
@@ -1741,7 +1724,6 @@ declare module 'fs' {
1741
1724
  /**
1742
1725
  * Asynchronously append data to a file, creating the file if it does not exist.
1743
1726
  * @param file A path to a file. If a URL is provided, it must use the `file:` protocol.
1744
- * URL support is _experimental_.
1745
1727
  * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
1746
1728
  * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
1747
1729
  */
@@ -1767,7 +1749,6 @@ declare module 'fs' {
1767
1749
  /**
1768
1750
  * Synchronously append data to a file, creating the file if it does not exist.
1769
1751
  * @param file A path to a file. If a URL is provided, it must use the `file:` protocol.
1770
- * URL support is _experimental_.
1771
1752
  * If a file descriptor is provided, the underlying file will _not_ be closed automatically.
1772
1753
  * @param data The data to write. If something other than a Buffer or Uint8Array is provided, the value is coerced to a string.
1773
1754
  * @param options Either the encoding for the file, or an object optionally specifying the encoding, file mode, and flag.
@@ -1786,36 +1767,36 @@ declare module 'fs' {
1786
1767
  /**
1787
1768
  * Watch for changes on `filename`. The callback `listener` will be called each time the file is accessed.
1788
1769
  * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
1789
- * URL support is _experimental_.
1790
1770
  */
1791
1771
  export function watchFile(filename: PathLike, listener: (curr: Stats, prev: Stats) => void): void;
1792
1772
 
1793
1773
  /**
1794
1774
  * Stop watching for changes on `filename`.
1795
1775
  * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
1796
- * URL support is _experimental_.
1797
1776
  */
1798
1777
  export function unwatchFile(filename: PathLike, listener?: (curr: Stats, prev: Stats) => void): void;
1799
1778
 
1779
+ export interface WatchOptions extends Abortable {
1780
+ encoding?: BufferEncoding | "buffer";
1781
+ persistent?: boolean;
1782
+ recursive?: boolean;
1783
+ }
1784
+
1785
+ export type WatchListener<T> = (event: "rename" | "change", filename: T) => void;
1786
+
1800
1787
  /**
1801
1788
  * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
1802
1789
  * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
1803
- * URL support is _experimental_.
1804
1790
  * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
1805
1791
  * If `encoding` is not supplied, the default of `'utf8'` is used.
1806
1792
  * If `persistent` is not supplied, the default of `true` is used.
1807
1793
  * If `recursive` is not supplied, the default of `false` is used.
1808
1794
  */
1809
- export function watch(
1810
- filename: PathLike,
1811
- options: { encoding?: BufferEncoding | null, persistent?: boolean, recursive?: boolean } | BufferEncoding | undefined | null,
1812
- listener?: (event: "rename" | "change", filename: string) => void,
1813
- ): FSWatcher;
1795
+ export function watch(filename: PathLike, options: WatchOptions & { encoding: "buffer" } | "buffer", listener?: WatchListener<Buffer>): FSWatcher;
1814
1796
 
1815
1797
  /**
1816
1798
  * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
1817
1799
  * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
1818
- * URL support is _experimental_.
1819
1800
  * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
1820
1801
  * If `encoding` is not supplied, the default of `'utf8'` is used.
1821
1802
  * If `persistent` is not supplied, the default of `true` is used.
@@ -1823,37 +1804,30 @@ declare module 'fs' {
1823
1804
  */
1824
1805
  export function watch(
1825
1806
  filename: PathLike,
1826
- options: { encoding: "buffer", persistent?: boolean, recursive?: boolean; } | "buffer",
1827
- listener?: (event: "rename" | "change", filename: Buffer) => void
1807
+ options?: WatchOptions | BufferEncoding | null,
1808
+ listener?: WatchListener<string>,
1828
1809
  ): FSWatcher;
1829
1810
 
1830
1811
  /**
1831
1812
  * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
1832
1813
  * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
1833
- * URL support is _experimental_.
1834
1814
  * @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
1835
1815
  * If `encoding` is not supplied, the default of `'utf8'` is used.
1836
1816
  * If `persistent` is not supplied, the default of `true` is used.
1837
1817
  * If `recursive` is not supplied, the default of `false` is used.
1838
1818
  */
1839
- export function watch(
1840
- filename: PathLike,
1841
- options: { encoding?: BufferEncoding | null, persistent?: boolean, recursive?: boolean } | string | null,
1842
- listener?: (event: "rename" | "change", filename: string | Buffer) => void,
1843
- ): FSWatcher;
1819
+ export function watch(filename: PathLike, options: WatchOptions | string, listener?: WatchListener<string | Buffer>): FSWatcher;
1844
1820
 
1845
1821
  /**
1846
1822
  * Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
1847
1823
  * @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
1848
- * URL support is _experimental_.
1849
1824
  */
1850
- export function watch(filename: PathLike, listener?: (event: "rename" | "change", filename: string) => any): FSWatcher;
1825
+ export function watch(filename: PathLike, listener?: WatchListener<string>): FSWatcher;
1851
1826
 
1852
1827
  /**
1853
1828
  * Asynchronously tests whether or not the given path exists by checking with the file system.
1854
1829
  * @deprecated since v1.0.0 Use `fs.stat()` or `fs.access()` instead
1855
1830
  * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
1856
- * URL support is _experimental_.
1857
1831
  */
1858
1832
  export function exists(path: PathLike, callback: (exists: boolean) => void): void;
1859
1833
 
@@ -1869,7 +1843,6 @@ declare module 'fs' {
1869
1843
  /**
1870
1844
  * Synchronously tests whether or not the given path exists by checking with the file system.
1871
1845
  * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
1872
- * URL support is _experimental_.
1873
1846
  */
1874
1847
  export function existsSync(path: PathLike): boolean;
1875
1848
 
@@ -2039,14 +2012,12 @@ declare module 'fs' {
2039
2012
  /**
2040
2013
  * Asynchronously tests a user's permissions for the file specified by path.
2041
2014
  * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
2042
- * URL support is _experimental_.
2043
2015
  */
2044
2016
  export function access(path: PathLike, mode: number | undefined, callback: NoParamCallback): void;
2045
2017
 
2046
2018
  /**
2047
2019
  * Asynchronously tests a user's permissions for the file specified by path.
2048
2020
  * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
2049
- * URL support is _experimental_.
2050
2021
  */
2051
2022
  export function access(path: PathLike, callback: NoParamCallback): void;
2052
2023
 
@@ -2063,19 +2034,13 @@ declare module 'fs' {
2063
2034
  /**
2064
2035
  * Synchronously tests a user's permissions for the file specified by path.
2065
2036
  * @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
2066
- * URL support is _experimental_.
2067
2037
  */
2068
2038
  export function accessSync(path: PathLike, mode?: number): void;
2069
2039
 
2070
- /**
2071
- * Returns a new `ReadStream` object.
2072
- * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2073
- * URL support is _experimental_.
2074
- */
2075
- export function createReadStream(path: PathLike, options?: string | {
2040
+ interface StreamOptions {
2076
2041
  flags?: string;
2077
2042
  encoding?: BufferEncoding;
2078
- fd?: number;
2043
+ fd?: number | promises.FileHandle;
2079
2044
  mode?: number;
2080
2045
  autoClose?: boolean;
2081
2046
  /**
@@ -2083,25 +2048,24 @@ declare module 'fs' {
2083
2048
  */
2084
2049
  emitClose?: boolean;
2085
2050
  start?: number;
2086
- end?: number;
2087
2051
  highWaterMark?: number;
2088
- }): ReadStream;
2052
+ }
2053
+
2054
+ interface ReadStreamOptions extends StreamOptions {
2055
+ end?: number;
2056
+ }
2057
+
2058
+ /**
2059
+ * Returns a new `ReadStream` object.
2060
+ * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2061
+ */
2062
+ export function createReadStream(path: PathLike, options?: string | ReadStreamOptions): ReadStream;
2089
2063
 
2090
2064
  /**
2091
2065
  * Returns a new `WriteStream` object.
2092
2066
  * @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
2093
- * URL support is _experimental_.
2094
2067
  */
2095
- export function createWriteStream(path: PathLike, options?: string | {
2096
- flags?: string;
2097
- encoding?: BufferEncoding;
2098
- fd?: number;
2099
- mode?: number;
2100
- autoClose?: boolean;
2101
- emitClose?: boolean;
2102
- start?: number;
2103
- highWaterMark?: number;
2104
- }): WriteStream;
2068
+ export function createWriteStream(path: PathLike, options?: string | StreamOptions): WriteStream;
2105
2069
 
2106
2070
  /**
2107
2071
  * Asynchronous fdatasync(2) - synchronize a file's in-core state with storage device.
node/globals.d.ts CHANGED
@@ -622,6 +622,10 @@ declare namespace NodeJS {
622
622
  '.node': (m: Module, filename: string) => any;
623
623
  }
624
624
  interface Module {
625
+ /**
626
+ * `true` if the module is running during the Node.js preload
627
+ */
628
+ isPreloading: boolean;
625
629
  exports: any;
626
630
  require: Require;
627
631
  id: string;
node/http.d.ts CHANGED
@@ -107,7 +107,7 @@ declare module 'http' {
107
107
  ServerResponse?: typeof ServerResponse;
108
108
  /**
109
109
  * Optionally overrides the value of
110
- * [`--max-http-header-size`][] for requests received by this server, i.e.
110
+ * `--max-http-header-size` for requests received by this server, i.e.
111
111
  * the maximum length of request headers in bytes.
112
112
  * @default 8192
113
113
  */
@@ -156,7 +156,8 @@ declare module 'http' {
156
156
 
157
157
  // https://github.com/nodejs/node/blob/master/lib/_http_outgoing.js
158
158
  class OutgoingMessage extends stream.Writable {
159
- upgrading: boolean;
159
+ readonly req: IncomingMessage;
160
+
160
161
  chunkedEncoding: boolean;
161
162
  shouldKeepAlive: boolean;
162
163
  useChunkedEncodingByDefault: boolean;
@@ -165,17 +166,17 @@ declare module 'http' {
165
166
  * @deprecated Use `writableEnded` instead.
166
167
  */
167
168
  finished: boolean;
168
- headersSent: boolean;
169
+ readonly headersSent: boolean;
169
170
  /**
170
- * @deprecate Use `socket` instead.
171
+ * @deprecated Use `socket` instead.
171
172
  */
172
- connection: Socket | null;
173
- socket: Socket | null;
173
+ readonly connection: Socket | null;
174
+ readonly socket: Socket | null;
174
175
 
175
176
  constructor();
176
177
 
177
178
  setTimeout(msecs: number, callback?: () => void): this;
178
- setHeader(name: string, value: number | string | ReadonlyArray<string>): void;
179
+ setHeader(name: string, value: number | string | ReadonlyArray<string>): this;
179
180
  getHeader(name: string): number | string | string[] | undefined;
180
181
  getHeaders(): OutgoingHttpHeaders;
181
182
  getHeaderNames(): string[];
@@ -374,7 +375,8 @@ declare module 'http' {
374
375
  */
375
376
  timeout?: number;
376
377
  /**
377
- * Scheduling strategy to apply when picking the next free socket to use. Default: 'fifo'.
378
+ * Scheduling strategy to apply when picking the next free socket to use.
379
+ * @default `lifo`
378
380
  */
379
381
  scheduling?: 'fifo' | 'lifo';
380
382
  }
@@ -419,7 +421,14 @@ declare module 'http' {
419
421
 
420
422
  /**
421
423
  * Read-only property specifying the maximum allowed size of HTTP headers in bytes.
422
- * Defaults to 16KB. Configurable using the [`--max-http-header-size`][] CLI option.
424
+ * Defaults to 16KB. Configurable using the `--max-http-header-size` CLI option.
423
425
  */
424
426
  const maxHeaderSize: number;
427
+
428
+ /**
429
+ *
430
+ * This utility function converts a URL object into an ordinary options object as
431
+ * expected by the `http.request()` and `https.request()` APIs.
432
+ */
433
+ function urlToHttpOptions(url: URL): ClientRequestArgs;
425
434
  }
node/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Type definitions for non-npm package Node.js 15.3
1
+ // Type definitions for non-npm package Node.js 15.9
2
2
  // Project: http://nodejs.org/
3
3
  // Definitions by: Microsoft TypeScript <https://github.com/Microsoft>
4
4
  // DefinitelyTyped <https://github.com/DefinitelyTyped>
node/net.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  declare module 'net' {
2
2
  import * as stream from 'stream';
3
- import EventEmitter = require('events');
3
+ import { Abortable, EventEmitter } from 'events';
4
4
  import * as dns from 'dns';
5
5
 
6
6
  type LookupFunction = (
@@ -168,7 +168,7 @@ declare module 'net' {
168
168
  prependOnceListener(event: "timeout", listener: () => void): this;
169
169
  }
170
170
 
171
- interface ListenOptions {
171
+ interface ListenOptions extends Abortable {
172
172
  port?: number;
173
173
  host?: string;
174
174
  backlog?: number;
node/os.d.ts CHANGED
@@ -212,7 +212,7 @@ declare module 'os' {
212
212
  /**
213
213
  * Returns a string identifying the kernel version.
214
214
  * On POSIX systems, the operating system release is determined by calling
215
- * [uname(3)][]. On Windows, `pRtlGetVersion` is used, and if it is not available,
215
+ * uname(3). On Windows, `pRtlGetVersion` is used, and if it is not available,
216
216
  * `GetVersionExW()` will be used. See
217
217
  * https://en.wikipedia.org/wiki/Uname#Examples for more information.
218
218
  */
node/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "15.3.1",
3
+ "version": "15.9.0",
4
4
  "description": "TypeScript definitions for Node.js",
5
+ "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
5
6
  "license": "MIT",
6
7
  "contributors": [
7
8
  {
@@ -226,6 +227,6 @@
226
227
  },
227
228
  "scripts": {},
228
229
  "dependencies": {},
229
- "typesPublisherContentHash": "5487ee1e7936fac57cddce52c08f0af61a7f0067c859eb399f5234be24a3e9f9",
230
- "typeScriptVersion": "3.5"
230
+ "typesPublisherContentHash": "cb014fbf92870923982004e4fca76f59150c147625c5fc51365d369f858eb620",
231
+ "typeScriptVersion": "3.6"
231
232
  }
node/perf_hooks.d.ts CHANGED
@@ -3,7 +3,8 @@ declare module 'perf_hooks' {
3
3
 
4
4
  type EntryType = 'node' | 'mark' | 'measure' | 'gc' | 'function' | 'http2' | 'http';
5
5
 
6
- interface PerformanceEntry {
6
+ class PerformanceEntry {
7
+ protected constructor();
7
8
  /**
8
9
  * The total number of milliseconds elapsed for this entry.
9
10
  * This value will not be meaningful for all Performance Entry types.
@@ -41,7 +42,7 @@ declare module 'perf_hooks' {
41
42
  readonly flags?: number;
42
43
  }
43
44
 
44
- interface PerformanceNodeTiming extends PerformanceEntry {
45
+ class PerformanceNodeTiming extends PerformanceEntry {
45
46
  /**
46
47
  * The high resolution millisecond timestamp at which the Node.js process completed bootstrap.
47
48
  */
@@ -88,7 +89,10 @@ declare module 'perf_hooks' {
88
89
  * @param util1 The result of a previous call to eventLoopUtilization()
89
90
  * @param util2 The result of a previous call to eventLoopUtilization() prior to util1
90
91
  */
91
- type EventLoopUtilityFunction = (util1?: EventLoopUtilization, util2?: EventLoopUtilization) => EventLoopUtilization;
92
+ type EventLoopUtilityFunction = (
93
+ util1?: EventLoopUtilization,
94
+ util2?: EventLoopUtilization,
95
+ ) => EventLoopUtilization;
92
96
 
93
97
  interface Performance {
94
98
  /**
@@ -122,7 +126,7 @@ declare module 'perf_hooks' {
122
126
  * @param startMark
123
127
  * @param endMark
124
128
  */
125
- measure(name: string, startMark: string, endMark: string): void;
129
+ measure(name: string, startMark?: string, endMark?: string): void;
126
130
 
127
131
  /**
128
132
  * An instance of the PerformanceNodeTiming class that provides performance metrics for specific Node.js operational milestones.
@@ -218,15 +222,36 @@ declare module 'perf_hooks' {
218
222
  resolution?: number;
219
223
  }
220
224
 
221
- interface EventLoopDelayMonitor {
225
+ interface Histogram {
222
226
  /**
223
- * Enables the event loop delay sample timer. Returns `true` if the timer was started, `false` if it was already started.
227
+ * A `Map` object detailing the accumulated percentile distribution.
224
228
  */
225
- enable(): boolean;
229
+ readonly percentiles: Map<number, number>;
230
+
226
231
  /**
227
- * Disables the event loop delay sample timer. Returns `true` if the timer was stopped, `false` if it was already stopped.
232
+ * The number of times the event loop delay exceeded the maximum 1 hour eventloop delay threshold.
228
233
  */
229
- disable(): boolean;
234
+ readonly exceeds: number;
235
+
236
+ /**
237
+ * The minimum recorded event loop delay.
238
+ */
239
+ readonly min: number;
240
+
241
+ /**
242
+ * The maximum recorded event loop delay.
243
+ */
244
+ readonly max: number;
245
+
246
+ /**
247
+ * The mean of the recorded event loop delays.
248
+ */
249
+ readonly mean: number;
250
+
251
+ /**
252
+ * The standard deviation of the recorded event loop delays.
253
+ */
254
+ readonly stddev: number;
230
255
 
231
256
  /**
232
257
  * Resets the collected histogram data.
@@ -238,37 +263,48 @@ declare module 'perf_hooks' {
238
263
  * @param percentile A percentile value between 1 and 100.
239
264
  */
240
265
  percentile(percentile: number): number;
266
+ }
241
267
 
268
+ interface IntervalHistogram extends Histogram {
242
269
  /**
243
- * A `Map` object detailing the accumulated percentile distribution.
270
+ * Enables the event loop delay sample timer. Returns `true` if the timer was started, `false` if it was already started.
244
271
  */
245
- readonly percentiles: Map<number, number>;
246
-
272
+ enable(): boolean;
247
273
  /**
248
- * The number of times the event loop delay exceeded the maximum 1 hour eventloop delay threshold.
274
+ * Disables the event loop delay sample timer. Returns `true` if the timer was stopped, `false` if it was already stopped.
249
275
  */
250
- readonly exceeds: number;
276
+ disable(): boolean;
277
+ }
278
+
279
+ interface RecordableHistogram extends Histogram {
280
+ record(val: number | bigint): void;
251
281
 
252
282
  /**
253
- * The minimum recorded event loop delay.
283
+ * Calculates the amount of time (in nanoseconds) that has passed since the previous call to recordDelta() and records that amount in the histogram.
254
284
  */
255
- readonly min: number;
285
+ recordDelta(): void;
286
+ }
287
+
288
+ function monitorEventLoopDelay(options?: EventLoopMonitorOptions): IntervalHistogram;
256
289
 
290
+ interface CreateHistogramOptions {
257
291
  /**
258
- * The maximum recorded event loop delay.
292
+ * The minimum recordable value. Must be an integer value greater than 0.
293
+ * @default 1
259
294
  */
260
- readonly max: number;
295
+ min?: number | bigint;
261
296
 
262
297
  /**
263
- * The mean of the recorded event loop delays.
298
+ * The maximum recordable value. Must be an integer value greater than min.
299
+ * @default Number.MAX_SAFE_INTEGER
264
300
  */
265
- readonly mean: number;
266
-
301
+ max?: number | bigint;
267
302
  /**
268
- * The standard deviation of the recorded event loop delays.
303
+ * The number of accuracy digits. Must be a number between 1 and 5.
304
+ * @default 3
269
305
  */
270
- readonly stddev: number;
306
+ figures?: number;
271
307
  }
272
308
 
273
- function monitorEventLoopDelay(options?: EventLoopMonitorOptions): EventLoopDelayMonitor;
309
+ function createHistogram(options?: CreateHistogramOptions): RecordableHistogram;
274
310
  }
node/process.d.ts CHANGED
@@ -11,6 +11,18 @@ declare module 'process' {
11
11
  interface ReadStream extends tty.ReadStream {}
12
12
  interface WriteStream extends tty.WriteStream {}
13
13
 
14
+ interface MemoryUsageFn {
15
+ /**
16
+ * The `process.memoryUsage()` method iterate over each page to gather informations about memory
17
+ * usage which can be slow depending on the program memory allocations.
18
+ */
19
+ (): MemoryUsage;
20
+ /**
21
+ * method returns an integer representing the Resident Set Size (RSS) in bytes.
22
+ */
23
+ rss(): number;
24
+ }
25
+
14
26
  interface MemoryUsage {
15
27
  rss: number;
16
28
  heapTotal: number;
@@ -289,7 +301,7 @@ declare module 'process' {
289
301
  platform: Platform;
290
302
  /** @deprecated since v14.0.0 - use `require.main` instead. */
291
303
  mainModule?: Module;
292
- memoryUsage(): MemoryUsage;
304
+ memoryUsage: MemoryUsageFn;
293
305
  cpuUsage(previousValue?: CpuUsage): CpuUsage;
294
306
  nextTick(callback: Function, ...args: any[]): void;
295
307
  release: ProcessRelease;
@@ -324,7 +336,7 @@ declare module 'process' {
324
336
 
325
337
  /**
326
338
  * The `process.allowedNodeEnvironmentFlags` property is a special,
327
- * read-only `Set` of flags allowable within the [`NODE_OPTIONS`][]
339
+ * read-only `Set` of flags allowable within the `NODE_OPTIONS`
328
340
  * environment variable.
329
341
  */
330
342
  allowedNodeEnvironmentFlags: ReadonlySet<string>;