Spaces:
Sleeping
Sleeping
supercat666
commited on
Commit
•
78c921d
1
Parent(s):
7c3204a
add igv
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- igv_component/__init__.py +11 -0
- igv_component/igvcomponent.js +81 -0
- igv_component/node_modules/.bin/arrow2csv +12 -0
- igv_component/node_modules/.bin/arrow2csv.cmd +17 -0
- igv_component/node_modules/.bin/arrow2csv.ps1 +28 -0
- igv_component/node_modules/.bin/loose-envify +12 -0
- igv_component/node_modules/.bin/loose-envify.cmd +17 -0
- igv_component/node_modules/.bin/loose-envify.ps1 +28 -0
- igv_component/node_modules/.package-lock.json +396 -0
- igv_component/node_modules/@types/command-line-args/LICENSE +21 -0
- igv_component/node_modules/@types/command-line-args/README.md +16 -0
- igv_component/node_modules/@types/command-line-args/index.d.ts +96 -0
- igv_component/node_modules/@types/command-line-args/package.json +25 -0
- igv_component/node_modules/@types/command-line-usage/LICENSE +21 -0
- igv_component/node_modules/@types/command-line-usage/README.md +16 -0
- igv_component/node_modules/@types/command-line-usage/index.d.ts +82 -0
- igv_component/node_modules/@types/command-line-usage/package.json +30 -0
- igv_component/node_modules/@types/flatbuffers/LICENSE +21 -0
- igv_component/node_modules/@types/flatbuffers/README.md +15 -0
- igv_component/node_modules/@types/flatbuffers/index.d.ts +301 -0
- igv_component/node_modules/@types/flatbuffers/package.json +28 -0
- igv_component/node_modules/@types/node/LICENSE +21 -0
- igv_component/node_modules/@types/node/README.md +16 -0
- igv_component/node_modules/@types/node/assert.d.ts +911 -0
- igv_component/node_modules/@types/node/assert/strict.d.ts +8 -0
- igv_component/node_modules/@types/node/async_hooks.d.ts +501 -0
- igv_component/node_modules/@types/node/buffer.d.ts +0 -0
- igv_component/node_modules/@types/node/child_process.d.ts +1369 -0
- igv_component/node_modules/@types/node/cluster.d.ts +410 -0
- igv_component/node_modules/@types/node/console.d.ts +412 -0
- igv_component/node_modules/@types/node/constants.d.ts +18 -0
- igv_component/node_modules/@types/node/crypto.d.ts +0 -0
- igv_component/node_modules/@types/node/dgram.d.ts +545 -0
- igv_component/node_modules/@types/node/diagnostics_channel.d.ts +153 -0
- igv_component/node_modules/@types/node/dns.d.ts +659 -0
- igv_component/node_modules/@types/node/dns/promises.d.ts +370 -0
- igv_component/node_modules/@types/node/domain.d.ts +170 -0
- igv_component/node_modules/@types/node/events.d.ts +641 -0
- igv_component/node_modules/@types/node/fs.d.ts +0 -0
- igv_component/node_modules/@types/node/fs/promises.d.ts +1120 -0
- igv_component/node_modules/@types/node/globals.d.ts +296 -0
- igv_component/node_modules/@types/node/globals.global.d.ts +1 -0
- igv_component/node_modules/@types/node/http.d.ts +1553 -0
- igv_component/node_modules/@types/node/http2.d.ts +0 -0
- igv_component/node_modules/@types/node/https.d.ts +541 -0
- igv_component/node_modules/@types/node/index.d.ts +132 -0
- igv_component/node_modules/@types/node/inspector.d.ts +0 -0
- igv_component/node_modules/@types/node/module.d.ts +114 -0
- igv_component/node_modules/@types/node/net.d.ts +838 -0
- igv_component/node_modules/@types/node/os.d.ts +466 -0
igv_component/__init__.py
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit.components.v1 as components
|
2 |
+
|
3 |
+
def igv_component(crispr_results=None, key=None):
|
4 |
+
# Define the path to the built frontend component
|
5 |
+
component_path = "./igv_component/build"
|
6 |
+
|
7 |
+
# Streamlit components function
|
8 |
+
component = components.declare_component("igv_component", path=component_path)
|
9 |
+
|
10 |
+
# Call the component and pass the CRISPR results
|
11 |
+
return component(crispr_results=crispr_results, key=key)
|
igv_component/igvcomponent.js
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import React from "react";
|
2 |
+
import { Streamlit, withStreamlitConnection } from "streamlit-component-lib";
|
3 |
+
import igv from "igv";
|
4 |
+
|
5 |
+
class IGVComponent extends React.Component {
|
6 |
+
constructor(props) {
|
7 |
+
super(props);
|
8 |
+
this.browser = null;
|
9 |
+
}
|
10 |
+
|
11 |
+
componentDidMount() {
|
12 |
+
// Initialize the IGV viewer with default options
|
13 |
+
this.initializeIGV(this.props.genomeReference || "hg19");
|
14 |
+
}
|
15 |
+
|
16 |
+
componentDidUpdate(prevProps) {
|
17 |
+
// Update the genome if it changes
|
18 |
+
if (this.props.genomeReference !== prevProps.genomeReference) {
|
19 |
+
this.initializeIGV(this.props.genomeReference);
|
20 |
+
}
|
21 |
+
|
22 |
+
// Update tracks when new CRISPR results are received
|
23 |
+
if (this.props.crisprResults !== prevProps.crisprResults) {
|
24 |
+
this.updateTracks(this.props.crisprResults);
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
initializeIGV(genomeReference) {
|
29 |
+
const igvDiv = document.getElementById("igvDiv");
|
30 |
+
const options = {
|
31 |
+
genome: genomeReference,
|
32 |
+
// Add other IGV options here based on your requirements
|
33 |
+
};
|
34 |
+
|
35 |
+
igv.createBrowser(igvDiv, options).then((browser) => {
|
36 |
+
this.browser = browser;
|
37 |
+
// Load initial tracks if any
|
38 |
+
this.updateTracks(this.props.crisprResults);
|
39 |
+
});
|
40 |
+
}
|
41 |
+
|
42 |
+
updateTracks(crisprResults) {
|
43 |
+
if (this.browser && crisprResults && crisprResults.length > 0) {
|
44 |
+
// Clear existing tracks
|
45 |
+
this.browser.removeAllTracks();
|
46 |
+
|
47 |
+
// Create a BED string from CRISPR results
|
48 |
+
let bedData = "track name='CRISPR Targets' description='CRISPR Cas9 Predictions'\n";
|
49 |
+
bedData += crisprResults.map(result => {
|
50 |
+
const chr = result[0]; // "Gene ID"
|
51 |
+
const start = result[1]; // "Start Pos"
|
52 |
+
const end = result[2]; // "End Pos"
|
53 |
+
const strand = result[3] === 1 ? "+" : "-"; // "Strand"
|
54 |
+
const name = `gRNA: ${result[4]} Score: ${result[5]}`; // "gRNA" and "Prediction"
|
55 |
+
return `${chr}\t${start}\t${end}\t${name}\t0\t${strand}`;
|
56 |
+
}).join("\n");
|
57 |
+
|
58 |
+
// Create a blob from the BED string
|
59 |
+
const blob = new Blob([bedData], { type: 'text/plain' });
|
60 |
+
const url = URL.createObjectURL(blob);
|
61 |
+
|
62 |
+
// Define a track configuration for IGV
|
63 |
+
const trackConfig = {
|
64 |
+
name: "CRISPR Targets",
|
65 |
+
url: url,
|
66 |
+
format: "bed",
|
67 |
+
type: "annotation",
|
68 |
+
indexed: false
|
69 |
+
};
|
70 |
+
|
71 |
+
// Load the track into the IGV browser
|
72 |
+
this.browser.loadTrack(trackConfig);
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
render() {
|
77 |
+
return <div id="igvDiv" style={{ height: "500px" }}></div>;
|
78 |
+
}
|
79 |
+
}
|
80 |
+
|
81 |
+
export default withStreamlitConnection(IGVComponent);
|
igv_component/node_modules/.bin/arrow2csv
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/sh
|
2 |
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
3 |
+
|
4 |
+
case `uname` in
|
5 |
+
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
6 |
+
esac
|
7 |
+
|
8 |
+
if [ -x "$basedir/node" ]; then
|
9 |
+
exec "$basedir/node" "$basedir/../apache-arrow/bin/arrow2csv.js" "$@"
|
10 |
+
else
|
11 |
+
exec node "$basedir/../apache-arrow/bin/arrow2csv.js" "$@"
|
12 |
+
fi
|
igv_component/node_modules/.bin/arrow2csv.cmd
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
@ECHO off
|
2 |
+
GOTO start
|
3 |
+
:find_dp0
|
4 |
+
SET dp0=%~dp0
|
5 |
+
EXIT /b
|
6 |
+
:start
|
7 |
+
SETLOCAL
|
8 |
+
CALL :find_dp0
|
9 |
+
|
10 |
+
IF EXIST "%dp0%\node.exe" (
|
11 |
+
SET "_prog=%dp0%\node.exe"
|
12 |
+
) ELSE (
|
13 |
+
SET "_prog=node"
|
14 |
+
SET PATHEXT=%PATHEXT:;.JS;=;%
|
15 |
+
)
|
16 |
+
|
17 |
+
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\apache-arrow\bin\arrow2csv.js" %*
|
igv_component/node_modules/.bin/arrow2csv.ps1
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env pwsh
|
2 |
+
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
3 |
+
|
4 |
+
$exe=""
|
5 |
+
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
6 |
+
# Fix case when both the Windows and Linux builds of Node
|
7 |
+
# are installed in the same directory
|
8 |
+
$exe=".exe"
|
9 |
+
}
|
10 |
+
$ret=0
|
11 |
+
if (Test-Path "$basedir/node$exe") {
|
12 |
+
# Support pipeline input
|
13 |
+
if ($MyInvocation.ExpectingInput) {
|
14 |
+
$input | & "$basedir/node$exe" "$basedir/../apache-arrow/bin/arrow2csv.js" $args
|
15 |
+
} else {
|
16 |
+
& "$basedir/node$exe" "$basedir/../apache-arrow/bin/arrow2csv.js" $args
|
17 |
+
}
|
18 |
+
$ret=$LASTEXITCODE
|
19 |
+
} else {
|
20 |
+
# Support pipeline input
|
21 |
+
if ($MyInvocation.ExpectingInput) {
|
22 |
+
$input | & "node$exe" "$basedir/../apache-arrow/bin/arrow2csv.js" $args
|
23 |
+
} else {
|
24 |
+
& "node$exe" "$basedir/../apache-arrow/bin/arrow2csv.js" $args
|
25 |
+
}
|
26 |
+
$ret=$LASTEXITCODE
|
27 |
+
}
|
28 |
+
exit $ret
|
igv_component/node_modules/.bin/loose-envify
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/sh
|
2 |
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
3 |
+
|
4 |
+
case `uname` in
|
5 |
+
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
|
6 |
+
esac
|
7 |
+
|
8 |
+
if [ -x "$basedir/node" ]; then
|
9 |
+
exec "$basedir/node" "$basedir/../loose-envify/cli.js" "$@"
|
10 |
+
else
|
11 |
+
exec node "$basedir/../loose-envify/cli.js" "$@"
|
12 |
+
fi
|
igv_component/node_modules/.bin/loose-envify.cmd
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
@ECHO off
|
2 |
+
GOTO start
|
3 |
+
:find_dp0
|
4 |
+
SET dp0=%~dp0
|
5 |
+
EXIT /b
|
6 |
+
:start
|
7 |
+
SETLOCAL
|
8 |
+
CALL :find_dp0
|
9 |
+
|
10 |
+
IF EXIST "%dp0%\node.exe" (
|
11 |
+
SET "_prog=%dp0%\node.exe"
|
12 |
+
) ELSE (
|
13 |
+
SET "_prog=node"
|
14 |
+
SET PATHEXT=%PATHEXT:;.JS;=;%
|
15 |
+
)
|
16 |
+
|
17 |
+
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\loose-envify\cli.js" %*
|
igv_component/node_modules/.bin/loose-envify.ps1
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env pwsh
|
2 |
+
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
|
3 |
+
|
4 |
+
$exe=""
|
5 |
+
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
|
6 |
+
# Fix case when both the Windows and Linux builds of Node
|
7 |
+
# are installed in the same directory
|
8 |
+
$exe=".exe"
|
9 |
+
}
|
10 |
+
$ret=0
|
11 |
+
if (Test-Path "$basedir/node$exe") {
|
12 |
+
# Support pipeline input
|
13 |
+
if ($MyInvocation.ExpectingInput) {
|
14 |
+
$input | & "$basedir/node$exe" "$basedir/../loose-envify/cli.js" $args
|
15 |
+
} else {
|
16 |
+
& "$basedir/node$exe" "$basedir/../loose-envify/cli.js" $args
|
17 |
+
}
|
18 |
+
$ret=$LASTEXITCODE
|
19 |
+
} else {
|
20 |
+
# Support pipeline input
|
21 |
+
if ($MyInvocation.ExpectingInput) {
|
22 |
+
$input | & "node$exe" "$basedir/../loose-envify/cli.js" $args
|
23 |
+
} else {
|
24 |
+
& "node$exe" "$basedir/../loose-envify/cli.js" $args
|
25 |
+
}
|
26 |
+
$ret=$LASTEXITCODE
|
27 |
+
}
|
28 |
+
exit $ret
|
igv_component/node_modules/.package-lock.json
ADDED
@@ -0,0 +1,396 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "igvcomponent",
|
3 |
+
"version": "1.0.0",
|
4 |
+
"lockfileVersion": 3,
|
5 |
+
"requires": true,
|
6 |
+
"packages": {
|
7 |
+
"node_modules/@types/command-line-args": {
|
8 |
+
"version": "5.2.0",
|
9 |
+
"resolved": "https://registry.npmjs.org/@types/command-line-args/-/command-line-args-5.2.0.tgz",
|
10 |
+
"integrity": "sha512-UuKzKpJJ/Ief6ufIaIzr3A/0XnluX7RvFgwkV89Yzvm77wCh1kFaFmqN8XEnGcN62EuHdedQjEMb8mYxFLGPyA=="
|
11 |
+
},
|
12 |
+
"node_modules/@types/command-line-usage": {
|
13 |
+
"version": "5.0.2",
|
14 |
+
"resolved": "https://registry.npmjs.org/@types/command-line-usage/-/command-line-usage-5.0.2.tgz",
|
15 |
+
"integrity": "sha512-n7RlEEJ+4x4TS7ZQddTmNSxP+zziEG0TNsMfiRIxcIVXt71ENJ9ojeXmGO3wPoTdn7pJcU2xc3CJYMktNT6DPg=="
|
16 |
+
},
|
17 |
+
"node_modules/@types/flatbuffers": {
|
18 |
+
"version": "1.10.3",
|
19 |
+
"resolved": "https://registry.npmjs.org/@types/flatbuffers/-/flatbuffers-1.10.3.tgz",
|
20 |
+
"integrity": "sha512-kwJQsAROanCiMXSLjcTLmYVBIJ9Qyuqs92SaDIcj2EII2KnDgZbiU7it1Z/JfZd1gmxw/lAahMysQ6ZM+j3Ryw=="
|
21 |
+
},
|
22 |
+
"node_modules/@types/node": {
|
23 |
+
"version": "18.7.23",
|
24 |
+
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.23.tgz",
|
25 |
+
"integrity": "sha512-DWNcCHolDq0ZKGizjx2DZjR/PqsYwAcYUJmfMWqtVU2MBMG5Mo+xFZrhGId5r/O5HOuMPyQEcM6KUBp5lBZZBg=="
|
26 |
+
},
|
27 |
+
"node_modules/@types/pad-left": {
|
28 |
+
"version": "2.1.1",
|
29 |
+
"resolved": "https://registry.npmjs.org/@types/pad-left/-/pad-left-2.1.1.tgz",
|
30 |
+
"integrity": "sha512-Xd22WCRBydkGSApl5Bw0PhAOHKSVjNL3E3AwzKaps96IMraPqy5BvZIsBVK6JLwdybUzjHnuWVwpDd0JjTfHXA=="
|
31 |
+
},
|
32 |
+
"node_modules/ansi-styles": {
|
33 |
+
"version": "3.2.1",
|
34 |
+
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
|
35 |
+
"integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
|
36 |
+
"dependencies": {
|
37 |
+
"color-convert": "^1.9.0"
|
38 |
+
},
|
39 |
+
"engines": {
|
40 |
+
"node": ">=4"
|
41 |
+
}
|
42 |
+
},
|
43 |
+
"node_modules/apache-arrow": {
|
44 |
+
"version": "11.0.0",
|
45 |
+
"resolved": "https://registry.npmjs.org/apache-arrow/-/apache-arrow-11.0.0.tgz",
|
46 |
+
"integrity": "sha512-M8J4y+DimIyS44w2KOmVfzNHbTroR1oDpBKK6BYnlu8xVB41lxTz0yLmapo8/WJVAt5XcinAxMm14M771dm/rA==",
|
47 |
+
"dependencies": {
|
48 |
+
"@types/command-line-args": "5.2.0",
|
49 |
+
"@types/command-line-usage": "5.0.2",
|
50 |
+
"@types/flatbuffers": "*",
|
51 |
+
"@types/node": "18.7.23",
|
52 |
+
"@types/pad-left": "2.1.1",
|
53 |
+
"command-line-args": "5.2.1",
|
54 |
+
"command-line-usage": "6.1.3",
|
55 |
+
"flatbuffers": "2.0.4",
|
56 |
+
"json-bignum": "^0.0.3",
|
57 |
+
"pad-left": "^2.1.0",
|
58 |
+
"tslib": "^2.4.0"
|
59 |
+
},
|
60 |
+
"bin": {
|
61 |
+
"arrow2csv": "bin/arrow2csv.js"
|
62 |
+
}
|
63 |
+
},
|
64 |
+
"node_modules/array-back": {
|
65 |
+
"version": "3.1.0",
|
66 |
+
"resolved": "https://registry.npmjs.org/array-back/-/array-back-3.1.0.tgz",
|
67 |
+
"integrity": "sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q==",
|
68 |
+
"engines": {
|
69 |
+
"node": ">=6"
|
70 |
+
}
|
71 |
+
},
|
72 |
+
"node_modules/chalk": {
|
73 |
+
"version": "2.4.2",
|
74 |
+
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
|
75 |
+
"integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
|
76 |
+
"dependencies": {
|
77 |
+
"ansi-styles": "^3.2.1",
|
78 |
+
"escape-string-regexp": "^1.0.5",
|
79 |
+
"supports-color": "^5.3.0"
|
80 |
+
},
|
81 |
+
"engines": {
|
82 |
+
"node": ">=4"
|
83 |
+
}
|
84 |
+
},
|
85 |
+
"node_modules/color-convert": {
|
86 |
+
"version": "1.9.3",
|
87 |
+
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
|
88 |
+
"integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
|
89 |
+
"dependencies": {
|
90 |
+
"color-name": "1.1.3"
|
91 |
+
}
|
92 |
+
},
|
93 |
+
"node_modules/color-name": {
|
94 |
+
"version": "1.1.3",
|
95 |
+
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
|
96 |
+
"integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw=="
|
97 |
+
},
|
98 |
+
"node_modules/command-line-args": {
|
99 |
+
"version": "5.2.1",
|
100 |
+
"resolved": "https://registry.npmjs.org/command-line-args/-/command-line-args-5.2.1.tgz",
|
101 |
+
"integrity": "sha512-H4UfQhZyakIjC74I9d34fGYDwk3XpSr17QhEd0Q3I9Xq1CETHo4Hcuo87WyWHpAF1aSLjLRf5lD9ZGX2qStUvg==",
|
102 |
+
"dependencies": {
|
103 |
+
"array-back": "^3.1.0",
|
104 |
+
"find-replace": "^3.0.0",
|
105 |
+
"lodash.camelcase": "^4.3.0",
|
106 |
+
"typical": "^4.0.0"
|
107 |
+
},
|
108 |
+
"engines": {
|
109 |
+
"node": ">=4.0.0"
|
110 |
+
}
|
111 |
+
},
|
112 |
+
"node_modules/command-line-usage": {
|
113 |
+
"version": "6.1.3",
|
114 |
+
"resolved": "https://registry.npmjs.org/command-line-usage/-/command-line-usage-6.1.3.tgz",
|
115 |
+
"integrity": "sha512-sH5ZSPr+7UStsloltmDh7Ce5fb8XPlHyoPzTpyyMuYCtervL65+ubVZ6Q61cFtFl62UyJlc8/JwERRbAFPUqgw==",
|
116 |
+
"dependencies": {
|
117 |
+
"array-back": "^4.0.2",
|
118 |
+
"chalk": "^2.4.2",
|
119 |
+
"table-layout": "^1.0.2",
|
120 |
+
"typical": "^5.2.0"
|
121 |
+
},
|
122 |
+
"engines": {
|
123 |
+
"node": ">=8.0.0"
|
124 |
+
}
|
125 |
+
},
|
126 |
+
"node_modules/command-line-usage/node_modules/array-back": {
|
127 |
+
"version": "4.0.2",
|
128 |
+
"resolved": "https://registry.npmjs.org/array-back/-/array-back-4.0.2.tgz",
|
129 |
+
"integrity": "sha512-NbdMezxqf94cnNfWLL7V/im0Ub+Anbb0IoZhvzie8+4HJ4nMQuzHuy49FkGYCJK2yAloZ3meiB6AVMClbrI1vg==",
|
130 |
+
"engines": {
|
131 |
+
"node": ">=8"
|
132 |
+
}
|
133 |
+
},
|
134 |
+
"node_modules/command-line-usage/node_modules/typical": {
|
135 |
+
"version": "5.2.0",
|
136 |
+
"resolved": "https://registry.npmjs.org/typical/-/typical-5.2.0.tgz",
|
137 |
+
"integrity": "sha512-dvdQgNDNJo+8B2uBQoqdb11eUCE1JQXhvjC/CZtgvZseVd5TYMXnq0+vuUemXbd/Se29cTaUuPX3YIc2xgbvIg==",
|
138 |
+
"engines": {
|
139 |
+
"node": ">=8"
|
140 |
+
}
|
141 |
+
},
|
142 |
+
"node_modules/deep-extend": {
|
143 |
+
"version": "0.6.0",
|
144 |
+
"resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz",
|
145 |
+
"integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==",
|
146 |
+
"engines": {
|
147 |
+
"node": ">=4.0.0"
|
148 |
+
}
|
149 |
+
},
|
150 |
+
"node_modules/escape-string-regexp": {
|
151 |
+
"version": "1.0.5",
|
152 |
+
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
|
153 |
+
"integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==",
|
154 |
+
"engines": {
|
155 |
+
"node": ">=0.8.0"
|
156 |
+
}
|
157 |
+
},
|
158 |
+
"node_modules/find-replace": {
|
159 |
+
"version": "3.0.0",
|
160 |
+
"resolved": "https://registry.npmjs.org/find-replace/-/find-replace-3.0.0.tgz",
|
161 |
+
"integrity": "sha512-6Tb2myMioCAgv5kfvP5/PkZZ/ntTpVK39fHY7WkWBgvbeE+VHd/tZuZ4mrC+bxh4cfOZeYKVPaJIZtZXV7GNCQ==",
|
162 |
+
"dependencies": {
|
163 |
+
"array-back": "^3.0.1"
|
164 |
+
},
|
165 |
+
"engines": {
|
166 |
+
"node": ">=4.0.0"
|
167 |
+
}
|
168 |
+
},
|
169 |
+
"node_modules/flatbuffers": {
|
170 |
+
"version": "2.0.4",
|
171 |
+
"resolved": "https://registry.npmjs.org/flatbuffers/-/flatbuffers-2.0.4.tgz",
|
172 |
+
"integrity": "sha512-4rUFVDPjSoP0tOII34oQf+72NKU7E088U5oX7kwICahft0UB2kOQ9wUzzCp+OHxByERIfxRDCgX5mP8Pjkfl0g=="
|
173 |
+
},
|
174 |
+
"node_modules/has-flag": {
|
175 |
+
"version": "3.0.0",
|
176 |
+
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
|
177 |
+
"integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==",
|
178 |
+
"engines": {
|
179 |
+
"node": ">=4"
|
180 |
+
}
|
181 |
+
},
|
182 |
+
"node_modules/hoist-non-react-statics": {
|
183 |
+
"version": "3.3.2",
|
184 |
+
"resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz",
|
185 |
+
"integrity": "sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==",
|
186 |
+
"dependencies": {
|
187 |
+
"react-is": "^16.7.0"
|
188 |
+
}
|
189 |
+
},
|
190 |
+
"node_modules/igv": {
|
191 |
+
"version": "2.15.11",
|
192 |
+
"resolved": "https://registry.npmjs.org/igv/-/igv-2.15.11.tgz",
|
193 |
+
"integrity": "sha512-oJs6z4ogv1GefIWaMdG5s4jFRuFQ/PjUgrGBMn12SbeeIC/VgHkHr56K5yIaC8ZSyameq/7IFDQaXu0qIu6cpA=="
|
194 |
+
},
|
195 |
+
"node_modules/js-tokens": {
|
196 |
+
"version": "4.0.0",
|
197 |
+
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
|
198 |
+
"integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="
|
199 |
+
},
|
200 |
+
"node_modules/json-bignum": {
|
201 |
+
"version": "0.0.3",
|
202 |
+
"resolved": "https://registry.npmjs.org/json-bignum/-/json-bignum-0.0.3.tgz",
|
203 |
+
"integrity": "sha512-2WHyXj3OfHSgNyuzDbSxI1w2jgw5gkWSWhS7Qg4bWXx1nLk3jnbwfUeS0PSba3IzpTUWdHxBieELUzXRjQB2zg==",
|
204 |
+
"engines": {
|
205 |
+
"node": ">=0.8"
|
206 |
+
}
|
207 |
+
},
|
208 |
+
"node_modules/lodash.camelcase": {
|
209 |
+
"version": "4.3.0",
|
210 |
+
"resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz",
|
211 |
+
"integrity": "sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA=="
|
212 |
+
},
|
213 |
+
"node_modules/loose-envify": {
|
214 |
+
"version": "1.4.0",
|
215 |
+
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
|
216 |
+
"integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==",
|
217 |
+
"dependencies": {
|
218 |
+
"js-tokens": "^3.0.0 || ^4.0.0"
|
219 |
+
},
|
220 |
+
"bin": {
|
221 |
+
"loose-envify": "cli.js"
|
222 |
+
}
|
223 |
+
},
|
224 |
+
"node_modules/object-assign": {
|
225 |
+
"version": "4.1.1",
|
226 |
+
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
227 |
+
"integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
|
228 |
+
"engines": {
|
229 |
+
"node": ">=0.10.0"
|
230 |
+
}
|
231 |
+
},
|
232 |
+
"node_modules/pad-left": {
|
233 |
+
"version": "2.1.0",
|
234 |
+
"resolved": "https://registry.npmjs.org/pad-left/-/pad-left-2.1.0.tgz",
|
235 |
+
"integrity": "sha512-HJxs9K9AztdIQIAIa/OIazRAUW/L6B9hbQDxO4X07roW3eo9XqZc2ur9bn1StH9CnbbI9EgvejHQX7CBpCF1QA==",
|
236 |
+
"dependencies": {
|
237 |
+
"repeat-string": "^1.5.4"
|
238 |
+
},
|
239 |
+
"engines": {
|
240 |
+
"node": ">=0.10.0"
|
241 |
+
}
|
242 |
+
},
|
243 |
+
"node_modules/prop-types": {
|
244 |
+
"version": "15.8.1",
|
245 |
+
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz",
|
246 |
+
"integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==",
|
247 |
+
"dependencies": {
|
248 |
+
"loose-envify": "^1.4.0",
|
249 |
+
"object-assign": "^4.1.1",
|
250 |
+
"react-is": "^16.13.1"
|
251 |
+
}
|
252 |
+
},
|
253 |
+
"node_modules/react": {
|
254 |
+
"version": "16.14.0",
|
255 |
+
"resolved": "https://registry.npmjs.org/react/-/react-16.14.0.tgz",
|
256 |
+
"integrity": "sha512-0X2CImDkJGApiAlcf0ODKIneSwBPhqJawOa5wCtKbu7ZECrmS26NvtSILynQ66cgkT/RJ4LidJOc3bUESwmU8g==",
|
257 |
+
"dependencies": {
|
258 |
+
"loose-envify": "^1.1.0",
|
259 |
+
"object-assign": "^4.1.1",
|
260 |
+
"prop-types": "^15.6.2"
|
261 |
+
},
|
262 |
+
"engines": {
|
263 |
+
"node": ">=0.10.0"
|
264 |
+
}
|
265 |
+
},
|
266 |
+
"node_modules/react-dom": {
|
267 |
+
"version": "16.14.0",
|
268 |
+
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-16.14.0.tgz",
|
269 |
+
"integrity": "sha512-1gCeQXDLoIqMgqD3IO2Ah9bnf0w9kzhwN5q4FGnHZ67hBm9yePzB5JJAIQCc8x3pFnNlwFq4RidZggNAAkzWWw==",
|
270 |
+
"dependencies": {
|
271 |
+
"loose-envify": "^1.1.0",
|
272 |
+
"object-assign": "^4.1.1",
|
273 |
+
"prop-types": "^15.6.2",
|
274 |
+
"scheduler": "^0.19.1"
|
275 |
+
},
|
276 |
+
"peerDependencies": {
|
277 |
+
"react": "^16.14.0"
|
278 |
+
}
|
279 |
+
},
|
280 |
+
"node_modules/react-is": {
|
281 |
+
"version": "16.13.1",
|
282 |
+
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
|
283 |
+
"integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ=="
|
284 |
+
},
|
285 |
+
"node_modules/reduce-flatten": {
|
286 |
+
"version": "2.0.0",
|
287 |
+
"resolved": "https://registry.npmjs.org/reduce-flatten/-/reduce-flatten-2.0.0.tgz",
|
288 |
+
"integrity": "sha512-EJ4UNY/U1t2P/2k6oqotuX2Cc3T6nxJwsM0N0asT7dhrtH1ltUxDn4NalSYmPE2rCkVpcf/X6R0wDwcFpzhd4w==",
|
289 |
+
"engines": {
|
290 |
+
"node": ">=6"
|
291 |
+
}
|
292 |
+
},
|
293 |
+
"node_modules/repeat-string": {
|
294 |
+
"version": "1.6.1",
|
295 |
+
"resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz",
|
296 |
+
"integrity": "sha512-PV0dzCYDNfRi1jCDbJzpW7jNNDRuCOG/jI5ctQcGKt/clZD+YcPS3yIlWuTJMmESC8aevCFmWJy5wjAFgNqN6w==",
|
297 |
+
"engines": {
|
298 |
+
"node": ">=0.10"
|
299 |
+
}
|
300 |
+
},
|
301 |
+
"node_modules/scheduler": {
|
302 |
+
"version": "0.19.1",
|
303 |
+
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.19.1.tgz",
|
304 |
+
"integrity": "sha512-n/zwRWRYSUj0/3g/otKDRPMh6qv2SYMWNq85IEa8iZyAv8od9zDYpGSnpBEjNgcMNq6Scbu5KfIPxNF72R/2EA==",
|
305 |
+
"dependencies": {
|
306 |
+
"loose-envify": "^1.1.0",
|
307 |
+
"object-assign": "^4.1.1"
|
308 |
+
}
|
309 |
+
},
|
310 |
+
"node_modules/streamlit-component-lib": {
|
311 |
+
"version": "2.0.0",
|
312 |
+
"resolved": "https://registry.npmjs.org/streamlit-component-lib/-/streamlit-component-lib-2.0.0.tgz",
|
313 |
+
"integrity": "sha512-ekLjskU4Cz+zSLkTC9jpppv2hb8jlA3z2h+TtwGUGuwMKrGLrvTpzLJI1ibPuI+bZ60mLHVI1GP/OyNb7K7UjA==",
|
314 |
+
"dependencies": {
|
315 |
+
"apache-arrow": "^11.0.0",
|
316 |
+
"hoist-non-react-statics": "^3.3.2",
|
317 |
+
"react": "^16.14.0",
|
318 |
+
"react-dom": "^16.14.0"
|
319 |
+
}
|
320 |
+
},
|
321 |
+
"node_modules/supports-color": {
|
322 |
+
"version": "5.5.0",
|
323 |
+
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
|
324 |
+
"integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
|
325 |
+
"dependencies": {
|
326 |
+
"has-flag": "^3.0.0"
|
327 |
+
},
|
328 |
+
"engines": {
|
329 |
+
"node": ">=4"
|
330 |
+
}
|
331 |
+
},
|
332 |
+
"node_modules/table-layout": {
|
333 |
+
"version": "1.0.2",
|
334 |
+
"resolved": "https://registry.npmjs.org/table-layout/-/table-layout-1.0.2.tgz",
|
335 |
+
"integrity": "sha512-qd/R7n5rQTRFi+Zf2sk5XVVd9UQl6ZkduPFC3S7WEGJAmetDTjY3qPN50eSKzwuzEyQKy5TN2TiZdkIjos2L6A==",
|
336 |
+
"dependencies": {
|
337 |
+
"array-back": "^4.0.1",
|
338 |
+
"deep-extend": "~0.6.0",
|
339 |
+
"typical": "^5.2.0",
|
340 |
+
"wordwrapjs": "^4.0.0"
|
341 |
+
},
|
342 |
+
"engines": {
|
343 |
+
"node": ">=8.0.0"
|
344 |
+
}
|
345 |
+
},
|
346 |
+
"node_modules/table-layout/node_modules/array-back": {
|
347 |
+
"version": "4.0.2",
|
348 |
+
"resolved": "https://registry.npmjs.org/array-back/-/array-back-4.0.2.tgz",
|
349 |
+
"integrity": "sha512-NbdMezxqf94cnNfWLL7V/im0Ub+Anbb0IoZhvzie8+4HJ4nMQuzHuy49FkGYCJK2yAloZ3meiB6AVMClbrI1vg==",
|
350 |
+
"engines": {
|
351 |
+
"node": ">=8"
|
352 |
+
}
|
353 |
+
},
|
354 |
+
"node_modules/table-layout/node_modules/typical": {
|
355 |
+
"version": "5.2.0",
|
356 |
+
"resolved": "https://registry.npmjs.org/typical/-/typical-5.2.0.tgz",
|
357 |
+
"integrity": "sha512-dvdQgNDNJo+8B2uBQoqdb11eUCE1JQXhvjC/CZtgvZseVd5TYMXnq0+vuUemXbd/Se29cTaUuPX3YIc2xgbvIg==",
|
358 |
+
"engines": {
|
359 |
+
"node": ">=8"
|
360 |
+
}
|
361 |
+
},
|
362 |
+
"node_modules/tslib": {
|
363 |
+
"version": "2.6.2",
|
364 |
+
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
|
365 |
+
"integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q=="
|
366 |
+
},
|
367 |
+
"node_modules/typical": {
|
368 |
+
"version": "4.0.0",
|
369 |
+
"resolved": "https://registry.npmjs.org/typical/-/typical-4.0.0.tgz",
|
370 |
+
"integrity": "sha512-VAH4IvQ7BDFYglMd7BPRDfLgxZZX4O4TFcRDA6EN5X7erNJJq+McIEp8np9aVtxrCJ6qx4GTYVfOWNjcqwZgRw==",
|
371 |
+
"engines": {
|
372 |
+
"node": ">=8"
|
373 |
+
}
|
374 |
+
},
|
375 |
+
"node_modules/wordwrapjs": {
|
376 |
+
"version": "4.0.1",
|
377 |
+
"resolved": "https://registry.npmjs.org/wordwrapjs/-/wordwrapjs-4.0.1.tgz",
|
378 |
+
"integrity": "sha512-kKlNACbvHrkpIw6oPeYDSmdCTu2hdMHoyXLTcUKala++lx5Y+wjJ/e474Jqv5abnVmwxw08DiTuHmw69lJGksA==",
|
379 |
+
"dependencies": {
|
380 |
+
"reduce-flatten": "^2.0.0",
|
381 |
+
"typical": "^5.2.0"
|
382 |
+
},
|
383 |
+
"engines": {
|
384 |
+
"node": ">=8.0.0"
|
385 |
+
}
|
386 |
+
},
|
387 |
+
"node_modules/wordwrapjs/node_modules/typical": {
|
388 |
+
"version": "5.2.0",
|
389 |
+
"resolved": "https://registry.npmjs.org/typical/-/typical-5.2.0.tgz",
|
390 |
+
"integrity": "sha512-dvdQgNDNJo+8B2uBQoqdb11eUCE1JQXhvjC/CZtgvZseVd5TYMXnq0+vuUemXbd/Se29cTaUuPX3YIc2xgbvIg==",
|
391 |
+
"engines": {
|
392 |
+
"node": ">=8"
|
393 |
+
}
|
394 |
+
}
|
395 |
+
}
|
396 |
+
}
|
igv_component/node_modules/@types/command-line-args/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
MIT License
|
2 |
+
|
3 |
+
Copyright (c) Microsoft Corporation.
|
4 |
+
|
5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 |
+
of this software and associated documentation files (the "Software"), to deal
|
7 |
+
in the Software without restriction, including without limitation the rights
|
8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
+
copies of the Software, and to permit persons to whom the Software is
|
10 |
+
furnished to do so, subject to the following conditions:
|
11 |
+
|
12 |
+
The above copyright notice and this permission notice shall be included in all
|
13 |
+
copies or substantial portions of the Software.
|
14 |
+
|
15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21 |
+
SOFTWARE
|
igv_component/node_modules/@types/command-line-args/README.md
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Installation
|
2 |
+
> `npm install --save @types/command-line-args`
|
3 |
+
|
4 |
+
# Summary
|
5 |
+
This package contains type definitions for command-line-args (https://github.com/75lb/command-line-args).
|
6 |
+
|
7 |
+
# Details
|
8 |
+
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/command-line-args.
|
9 |
+
|
10 |
+
### Additional Details
|
11 |
+
* Last updated: Fri, 06 Aug 2021 17:01:23 GMT
|
12 |
+
* Dependencies: none
|
13 |
+
* Global values: none
|
14 |
+
|
15 |
+
# Credits
|
16 |
+
These definitions were written by [Lloyd Brookes](https://github.com/75lb).
|
igv_component/node_modules/@types/command-line-args/index.d.ts
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// Type definitions for command-line-args 5.2
|
2 |
+
// Project: https://github.com/75lb/command-line-args
|
3 |
+
// Definitions by: Lloyd Brookes <https://github.com/75lb>
|
4 |
+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
5 |
+
// TypeScript Version: 2.2
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Returns an object containing option values parsed from the command line. By default it parses the global `process.argv` array.
|
9 |
+
* Parsing is strict by default. To be more permissive, enable `partial` or `stopAtFirstUnknown` modes.
|
10 |
+
*/
|
11 |
+
declare function commandLineArgs(optionDefinitions: commandLineArgs.OptionDefinition[], options?: commandLineArgs.ParseOptions): commandLineArgs.CommandLineOptions;
|
12 |
+
|
13 |
+
declare namespace commandLineArgs {
|
14 |
+
interface CommandLineOptions {
|
15 |
+
/**
|
16 |
+
* Command-line arguments not parsed by `commandLineArgs`.
|
17 |
+
*/
|
18 |
+
_unknown?: string[] | undefined;
|
19 |
+
[propName: string]: any;
|
20 |
+
}
|
21 |
+
|
22 |
+
interface ParseOptions {
|
23 |
+
/**
|
24 |
+
* An array of strings which if present will be parsed instead of `process.argv`.
|
25 |
+
*/
|
26 |
+
argv?: string[] | undefined;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* If `true`, `commandLineArgs` will not throw on unknown options or values, instead returning them in the `_unknown` property of the output.
|
30 |
+
*/
|
31 |
+
partial?: boolean | undefined;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* If `true`, `commandLineArgs` will not throw on unknown options or values. Instead, parsing will stop at the first unknown argument
|
35 |
+
* and the remaining arguments returned in the `_unknown` property of the output. If set, `partial: true` is implied.
|
36 |
+
*/
|
37 |
+
stopAtFirstUnknown?: boolean | undefined;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* If `true`, options with hypenated names (e.g. `move-to`) will be returned in camel-case (e.g. `moveTo`).
|
41 |
+
*/
|
42 |
+
camelCase?: boolean | undefined;
|
43 |
+
|
44 |
+
/**
|
45 |
+
* If `true`, the case of each option name or alias parsed is insignificant. For example, `--Verbose` and
|
46 |
+
* `--verbose` would be parsed identically, as would the aliases `-V` and `-v`. Defaults to false.
|
47 |
+
*/
|
48 |
+
caseInsensitive?: boolean | undefined;
|
49 |
+
}
|
50 |
+
|
51 |
+
interface OptionDefinition {
|
52 |
+
/**
|
53 |
+
* The long option name.
|
54 |
+
*/
|
55 |
+
name: string;
|
56 |
+
|
57 |
+
/**
|
58 |
+
* A setter function (you receive the output from this) enabling you to be specific about the type and value received. Typical values
|
59 |
+
* are `String` (the default), `Number` and `Boolean` but you can use a custom function. If no option value was set you will receive `null`.
|
60 |
+
*/
|
61 |
+
type?: ((input: string) => any) | undefined;
|
62 |
+
|
63 |
+
/**
|
64 |
+
* A getopt-style short option name. Can be any single character except a digit or hyphen.
|
65 |
+
*/
|
66 |
+
alias?: string | undefined;
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Set this flag if the option accepts multiple values. In the output, you will receive an array of values each passed through the `type` function.
|
70 |
+
*/
|
71 |
+
multiple?: boolean | undefined;
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Identical to `multiple` but with greedy parsing disabled.
|
75 |
+
*/
|
76 |
+
lazyMultiple?: boolean | undefined;
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Any values unaccounted for by an option definition will be set on the `defaultOption`. This flag is typically set
|
80 |
+
* on the most commonly-used option to enable more concise usage.
|
81 |
+
*/
|
82 |
+
defaultOption?: boolean | undefined;
|
83 |
+
|
84 |
+
/**
|
85 |
+
* An initial value for the option.
|
86 |
+
*/
|
87 |
+
defaultValue?: any;
|
88 |
+
|
89 |
+
/**
|
90 |
+
* One or more group names the option belongs to.
|
91 |
+
*/
|
92 |
+
group?: string | string[] | undefined;
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
export = commandLineArgs;
|
igv_component/node_modules/@types/command-line-args/package.json
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "@types/command-line-args",
|
3 |
+
"version": "5.2.0",
|
4 |
+
"description": "TypeScript definitions for command-line-args",
|
5 |
+
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/command-line-args",
|
6 |
+
"license": "MIT",
|
7 |
+
"contributors": [
|
8 |
+
{
|
9 |
+
"name": "Lloyd Brookes",
|
10 |
+
"url": "https://github.com/75lb",
|
11 |
+
"githubUsername": "75lb"
|
12 |
+
}
|
13 |
+
],
|
14 |
+
"main": "",
|
15 |
+
"types": "index.d.ts",
|
16 |
+
"repository": {
|
17 |
+
"type": "git",
|
18 |
+
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
19 |
+
"directory": "types/command-line-args"
|
20 |
+
},
|
21 |
+
"scripts": {},
|
22 |
+
"dependencies": {},
|
23 |
+
"typesPublisherContentHash": "b44afacbbb8ed8fce26cd811d8299b1c12f8b34f1229bda8fbbc802679ecb17c",
|
24 |
+
"typeScriptVersion": "3.6"
|
25 |
+
}
|
igv_component/node_modules/@types/command-line-usage/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
MIT License
|
2 |
+
|
3 |
+
Copyright (c) Microsoft Corporation.
|
4 |
+
|
5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 |
+
of this software and associated documentation files (the "Software"), to deal
|
7 |
+
in the Software without restriction, including without limitation the rights
|
8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
+
copies of the Software, and to permit persons to whom the Software is
|
10 |
+
furnished to do so, subject to the following conditions:
|
11 |
+
|
12 |
+
The above copyright notice and this permission notice shall be included in all
|
13 |
+
copies or substantial portions of the Software.
|
14 |
+
|
15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21 |
+
SOFTWARE
|
igv_component/node_modules/@types/command-line-usage/README.md
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Installation
|
2 |
+
> `npm install --save @types/command-line-usage`
|
3 |
+
|
4 |
+
# Summary
|
5 |
+
This package contains type definitions for command-line-usage (https://github.com/75lb/command-line-usage#readme).
|
6 |
+
|
7 |
+
# Details
|
8 |
+
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/command-line-usage.
|
9 |
+
|
10 |
+
### Additional Details
|
11 |
+
* Last updated: Tue, 06 Jul 2021 18:05:57 GMT
|
12 |
+
* Dependencies: none
|
13 |
+
* Global values: none
|
14 |
+
|
15 |
+
# Credits
|
16 |
+
These definitions were written by [matrumz](https://github.com/matrumz), and [Andrija Dvorski](https://github.com/Dvorsky).
|
igv_component/node_modules/@types/command-line-usage/index.d.ts
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// Type definitions for command-line-usage 5.0
|
2 |
+
// Project: https://github.com/75lb/command-line-usage#readme
|
3 |
+
// Definitions by: matrumz <https://github.com/matrumz>
|
4 |
+
// Andrija Dvorski <https://github.com/Dvorsky>
|
5 |
+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
6 |
+
// TypeScript Version: 2.2
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Generates a usage guide suitable for a command-line app.
|
10 |
+
* @param sections One or more Section objects
|
11 |
+
* @alias module:command-line-usage
|
12 |
+
*/
|
13 |
+
declare function commandLineUsage(sections: commandLineUsage.Section | commandLineUsage.Section[]): string;
|
14 |
+
export = commandLineUsage;
|
15 |
+
|
16 |
+
declare namespace commandLineUsage {
|
17 |
+
/** Section object. */
|
18 |
+
type Section = Content | OptionList;
|
19 |
+
|
20 |
+
/** A Content section comprises a header and one or more lines of content. */
|
21 |
+
interface Content {
|
22 |
+
/** The section header, always bold and underlined. */
|
23 |
+
header?: string | undefined;
|
24 |
+
/**
|
25 |
+
* Overloaded property, accepting data in one of four formats.
|
26 |
+
* 1. A single string (one line of text).
|
27 |
+
* 2. An array of strings (multiple lines of text).
|
28 |
+
* 3. An array of objects (recordset-style data). In this case, the data will be rendered in table format. The property names of each object are not important, so long as they are
|
29 |
+
* consistent throughout the array.
|
30 |
+
* 4. An object with two properties - data and options. In this case, the data and options will be passed directly to the underlying table layout module for rendering.
|
31 |
+
*/
|
32 |
+
content?: string | string[] | any[] | { data: any; options: any } | undefined;
|
33 |
+
/** Set to true to avoid indentation and wrapping. Useful for banners. */
|
34 |
+
raw?: boolean | undefined;
|
35 |
+
}
|
36 |
+
|
37 |
+
/** Describes a command-line option. Additionally, if generating a usage guide with command-line-usage you could optionally add description and typeLabel properties to each definition. */
|
38 |
+
interface OptionDefinition {
|
39 |
+
name: string;
|
40 |
+
/**
|
41 |
+
* The type value is a setter function (you receive the output from this), enabling you to be specific about the type and value received.
|
42 |
+
*
|
43 |
+
* The most common values used are String (the default), Number and Boolean but you can use a custom function.
|
44 |
+
*/
|
45 |
+
type?: any;
|
46 |
+
/** getopt-style short option names. Can be any single character (unicode included) except a digit or hyphen. */
|
47 |
+
alias?: string | undefined;
|
48 |
+
/** Set this flag if the option takes a list of values. You will receive an array of values, each passed through the type function (if specified). */
|
49 |
+
multiple?: boolean | undefined;
|
50 |
+
/** Identical to multiple but with greedy parsing disabled. */
|
51 |
+
lazyMultiple?: boolean | undefined;
|
52 |
+
/** Any values unaccounted for by an option definition will be set on the defaultOption. This flag is typically set on the most commonly-used option to make for more concise usage. */
|
53 |
+
defaultOption?: boolean | undefined;
|
54 |
+
/** An initial value for the option. */
|
55 |
+
defaultValue?: any;
|
56 |
+
/**
|
57 |
+
* When your app has a large amount of options it makes sense to organise them in groups.
|
58 |
+
*
|
59 |
+
* There are two automatic groups: _all (contains all options) and _none (contains options without a group specified in their definition).
|
60 |
+
*/
|
61 |
+
group?: string | string[] | undefined;
|
62 |
+
/** A string describing the option. */
|
63 |
+
description?: string | undefined;
|
64 |
+
/** A string to replace the default type string (e.g. <string>). It's often more useful to set a more descriptive type label, like <ms>, <files>, <command>, etc.. */
|
65 |
+
typeLabel?: string | undefined;
|
66 |
+
}
|
67 |
+
|
68 |
+
/** A OptionList section adds a table displaying details of the available options. */
|
69 |
+
interface OptionList {
|
70 |
+
header?: string | undefined;
|
71 |
+
/** An array of option definition objects. */
|
72 |
+
optionList?: OptionDefinition[] | undefined;
|
73 |
+
/** If specified, only options from this particular group will be printed. */
|
74 |
+
group?: string | string[] | undefined;
|
75 |
+
/** The names of one of more option definitions to hide from the option list. */
|
76 |
+
hide?: string | string[] | undefined;
|
77 |
+
/** If true, the option alias will be displayed after the name, i.e. --verbose, -v instead of -v, --verbose). */
|
78 |
+
reverseNameOrder?: boolean | undefined;
|
79 |
+
/** An options object suitable for passing into table-layout. */
|
80 |
+
tableOptions?: any;
|
81 |
+
}
|
82 |
+
}
|
igv_component/node_modules/@types/command-line-usage/package.json
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "@types/command-line-usage",
|
3 |
+
"version": "5.0.2",
|
4 |
+
"description": "TypeScript definitions for command-line-usage",
|
5 |
+
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/command-line-usage",
|
6 |
+
"license": "MIT",
|
7 |
+
"contributors": [
|
8 |
+
{
|
9 |
+
"name": "matrumz",
|
10 |
+
"url": "https://github.com/matrumz",
|
11 |
+
"githubUsername": "matrumz"
|
12 |
+
},
|
13 |
+
{
|
14 |
+
"name": "Andrija Dvorski",
|
15 |
+
"url": "https://github.com/Dvorsky",
|
16 |
+
"githubUsername": "Dvorsky"
|
17 |
+
}
|
18 |
+
],
|
19 |
+
"main": "",
|
20 |
+
"types": "index.d.ts",
|
21 |
+
"repository": {
|
22 |
+
"type": "git",
|
23 |
+
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
24 |
+
"directory": "types/command-line-usage"
|
25 |
+
},
|
26 |
+
"scripts": {},
|
27 |
+
"dependencies": {},
|
28 |
+
"typesPublisherContentHash": "03b9ed61ee642797665fa7cf8854bd11d48568e26c096514ec0f348a5407a5e5",
|
29 |
+
"typeScriptVersion": "3.6"
|
30 |
+
}
|
igv_component/node_modules/@types/flatbuffers/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
MIT License
|
2 |
+
|
3 |
+
Copyright (c) Microsoft Corporation.
|
4 |
+
|
5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 |
+
of this software and associated documentation files (the "Software"), to deal
|
7 |
+
in the Software without restriction, including without limitation the rights
|
8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
+
copies of the Software, and to permit persons to whom the Software is
|
10 |
+
furnished to do so, subject to the following conditions:
|
11 |
+
|
12 |
+
The above copyright notice and this permission notice shall be included in all
|
13 |
+
copies or substantial portions of the Software.
|
14 |
+
|
15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21 |
+
SOFTWARE
|
igv_component/node_modules/@types/flatbuffers/README.md
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Installation
|
2 |
+
> `npm install --save @types/flatbuffers`
|
3 |
+
|
4 |
+
# Summary
|
5 |
+
This package contains type definitions for flatbuffers (http://google.github.io/flatbuffers/index.html).
|
6 |
+
|
7 |
+
# Details
|
8 |
+
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/flatbuffers.
|
9 |
+
|
10 |
+
### Additional Details
|
11 |
+
* Last updated: Tue, 07 Nov 2023 03:09:37 GMT
|
12 |
+
* Dependencies: none
|
13 |
+
|
14 |
+
# Credits
|
15 |
+
These definitions were written by [Kamil Rojewski](kamil.rojewski@gmail.com), and [Robin Giese](robin@grumpycorp.com).
|
igv_component/node_modules/@types/flatbuffers/index.d.ts
ADDED
@@ -0,0 +1,301 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export { flatbuffers };
|
2 |
+
|
3 |
+
declare global {
|
4 |
+
namespace flatbuffers {
|
5 |
+
type Offset = number;
|
6 |
+
|
7 |
+
interface Table {
|
8 |
+
bb: ByteBuffer | null;
|
9 |
+
bb_pos: number;
|
10 |
+
}
|
11 |
+
|
12 |
+
const SIZEOF_SHORT: number;
|
13 |
+
const SIZEOF_INT: number;
|
14 |
+
const FILE_IDENTIFIER_LENGTH: number;
|
15 |
+
const SIZE_PREFIX_LENGTH: number;
|
16 |
+
|
17 |
+
enum Encoding {
|
18 |
+
UTF8_BYTES,
|
19 |
+
UTF16_STRING,
|
20 |
+
}
|
21 |
+
|
22 |
+
const int32: Int32Array;
|
23 |
+
const float32: Float32Array;
|
24 |
+
const float64: Float64Array;
|
25 |
+
const isLittleEndian: boolean;
|
26 |
+
|
27 |
+
////////////////////////////////////////////////////////////////////////////////
|
28 |
+
|
29 |
+
class Long {
|
30 |
+
low: number;
|
31 |
+
high: number;
|
32 |
+
static ZERO: Long;
|
33 |
+
constructor(low: number, high: number);
|
34 |
+
toFloat64(): number;
|
35 |
+
equals(other: any): boolean;
|
36 |
+
static create(low: number, high: number): Long;
|
37 |
+
}
|
38 |
+
|
39 |
+
////////////////////////////////////////////////////////////////////////////////
|
40 |
+
|
41 |
+
class Builder {
|
42 |
+
constructor(initial_size?: number);
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Reset all the state in this FlatBufferBuilder
|
46 |
+
* so it can be reused to construct another buffer.
|
47 |
+
*/
|
48 |
+
clear(): void;
|
49 |
+
|
50 |
+
/**
|
51 |
+
* In order to save space, fields that are set to their default value
|
52 |
+
* don't get serialized into the buffer. Forcing defaults provides a
|
53 |
+
* way to manually disable this optimization.
|
54 |
+
*
|
55 |
+
* @param forceDefaults true always serializes default values
|
56 |
+
*/
|
57 |
+
forceDefaults(forceDefaults: boolean): void;
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Get the ByteBuffer representing the FlatBuffer. Only call this after you've
|
61 |
+
* called finish(). The actual data starts at the ByteBuffer's current position,
|
62 |
+
* not necessarily at 0.
|
63 |
+
*/
|
64 |
+
dataBuffer(): ByteBuffer;
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Get the ByteBuffer representing the FlatBuffer. Only call this after you've
|
68 |
+
* called finish(). The actual data starts at the ByteBuffer's current position,
|
69 |
+
* not necessarily at 0.
|
70 |
+
*/
|
71 |
+
asUint8Array(): Uint8Array;
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Prepare to write an element of `size` after `additional_bytes` have been
|
75 |
+
* written, e.g. if you write a string, you need to align such the int length
|
76 |
+
* field is aligned to 4 bytes, and the string data follows it directly. If all
|
77 |
+
* you need to do is alignment, `additional_bytes` will be 0.
|
78 |
+
*
|
79 |
+
* @param size This is the of the new element to write
|
80 |
+
* @param additional_bytes The padding size
|
81 |
+
*/
|
82 |
+
prep(size: number, additional_bytes: number): void;
|
83 |
+
|
84 |
+
pad(byte_size: number): void;
|
85 |
+
|
86 |
+
writeInt8(value: number): void;
|
87 |
+
writeInt16(value: number): void;
|
88 |
+
writeInt32(value: number): void;
|
89 |
+
writeInt64(value: Long): void;
|
90 |
+
writeFloat32(value: number): void;
|
91 |
+
writeFloat64(value: number): void;
|
92 |
+
|
93 |
+
addInt8(value: number): void;
|
94 |
+
addInt16(value: number): void;
|
95 |
+
addInt32(value: number): void;
|
96 |
+
addInt64(value: Long): void;
|
97 |
+
addFloat32(value: number): void;
|
98 |
+
addFloat64(value: number): void;
|
99 |
+
addFieldInt8(voffset: number, value: number, defaultValue: number): void;
|
100 |
+
addFieldInt16(voffset: number, value: number, defaultValue: number): void;
|
101 |
+
addFieldInt32(voffset: number, value: number, defaultValue: number): void;
|
102 |
+
addFieldInt64(voffset: number, value: Long, defaultValue: Long): void;
|
103 |
+
addFieldFloat32(voffset: number, value: number, defaultValue: number): void;
|
104 |
+
addFieldFloat64(voffset: number, value: number, defaultValue: number): void;
|
105 |
+
|
106 |
+
addFieldOffset(voffset: number, value: Offset, defaultValue: Offset): void;
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Structs are stored inline, so nothing additional is being added. `d` is always 0.
|
110 |
+
*/
|
111 |
+
addFieldStruct(voffset: number, value: Offset, defaultValue: Offset): void;
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Structures are always stored inline, they need to be created right
|
115 |
+
* where they're used. You'll get this assertion failure if you
|
116 |
+
* created it elsewhere.
|
117 |
+
*
|
118 |
+
* @param obj The offset of the created object
|
119 |
+
*/
|
120 |
+
nested(obj: Offset): void;
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Should not be creating any other object, string or vector
|
124 |
+
* while an object is being constructed
|
125 |
+
*/
|
126 |
+
notNested(): void;
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Set the current vtable at `voffset` to the current location in the buffer.
|
130 |
+
*/
|
131 |
+
slot(voffset: number): void;
|
132 |
+
|
133 |
+
/**
|
134 |
+
* @returns Offset relative to the end of the buffer.
|
135 |
+
*/
|
136 |
+
offset(): Offset;
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Doubles the size of the backing ByteBuffer and copies the old data towards
|
140 |
+
* the end of the new buffer (since we build the buffer backwards).
|
141 |
+
*
|
142 |
+
* @param bb The current buffer with the existing data
|
143 |
+
* @returns A new byte buffer with the old data copied
|
144 |
+
* to it. The data is located at the end of the buffer.
|
145 |
+
*/
|
146 |
+
static growByteBuffer(bb: ByteBuffer): ByteBuffer;
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Adds on offset, relative to where it will be written.
|
150 |
+
*
|
151 |
+
* @param offset The offset to add
|
152 |
+
*/
|
153 |
+
addOffset(offset: Offset): void;
|
154 |
+
|
155 |
+
/**
|
156 |
+
* Start encoding a new object in the buffer. Users will not usually need to
|
157 |
+
* call this directly. The FlatBuffers compiler will generate helper methods
|
158 |
+
* that call this method internally.
|
159 |
+
*/
|
160 |
+
startObject(numfields: number): void;
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Finish off writing the object that is under construction.
|
164 |
+
*
|
165 |
+
* @returns The offset to the object inside `dataBuffer`
|
166 |
+
*/
|
167 |
+
endObject(): Offset;
|
168 |
+
|
169 |
+
finish(root_table: Offset, file_identifier?: string, size_prefix?: boolean): void;
|
170 |
+
finishSizePrefixed(root_table: Offset, file_identifier?: string): void;
|
171 |
+
|
172 |
+
/**
|
173 |
+
* This checks a required field has been set in a given table that has
|
174 |
+
* just been constructed.
|
175 |
+
*/
|
176 |
+
requiredField(table: Offset, field: number): void;
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Start a new array/vector of objects. Users usually will not call
|
180 |
+
* this directly. The FlatBuffers compiler will create a start/end
|
181 |
+
* method for vector types in generated code.
|
182 |
+
*
|
183 |
+
* @param elem_size The size of each element in the array
|
184 |
+
* @param num_elems The number of elements in the array
|
185 |
+
* @param alignment The alignment of the array
|
186 |
+
*/
|
187 |
+
startVector(elem_size: number, num_elems: number, alignment: number): void;
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Finish off the creation of an array and all its elements. The array must be
|
191 |
+
* created with `startVector`.
|
192 |
+
*
|
193 |
+
* @returns The offset at which the newly created array
|
194 |
+
* starts.
|
195 |
+
*/
|
196 |
+
endVector(): Offset;
|
197 |
+
|
198 |
+
/**
|
199 |
+
* Encode the string `s` in the buffer using UTF-8. If a Uint8Array is passed
|
200 |
+
* instead of a string, it is assumed to contain valid UTF-8 encoded data.
|
201 |
+
*
|
202 |
+
* @param s The string to encode
|
203 |
+
* @return The offset in the buffer where the encoded string starts
|
204 |
+
*/
|
205 |
+
createString(s: string | Uint8Array): Offset;
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Convenience function for creating Long objects.
|
209 |
+
*/
|
210 |
+
createLong(low: number, high: number): Long;
|
211 |
+
}
|
212 |
+
|
213 |
+
////////////////////////////////////////////////////////////////////////////////
|
214 |
+
|
215 |
+
class ByteBuffer {
|
216 |
+
constructor(bytes: Uint8Array);
|
217 |
+
|
218 |
+
static allocate(byte_size: number): ByteBuffer;
|
219 |
+
|
220 |
+
clear(): void;
|
221 |
+
|
222 |
+
bytes(): Uint8Array;
|
223 |
+
|
224 |
+
position(): number;
|
225 |
+
|
226 |
+
setPosition(position: number): void;
|
227 |
+
|
228 |
+
capacity(): number;
|
229 |
+
|
230 |
+
readInt8(offset: number): number;
|
231 |
+
readUint8(offset: number): number;
|
232 |
+
readInt16(offset: number): number;
|
233 |
+
readUint16(offset: number): number;
|
234 |
+
readInt32(offset: number): number;
|
235 |
+
readUint32(offset: number): number;
|
236 |
+
readInt64(offset: number): Long;
|
237 |
+
readUint64(offset: number): Long;
|
238 |
+
readFloat32(offset: number): number;
|
239 |
+
readFloat64(offset: number): number;
|
240 |
+
|
241 |
+
writeInt8(offset: number, value: number): void;
|
242 |
+
writeUint8(offset: number, value: number): void;
|
243 |
+
writeInt16(offset: number, value: number): void;
|
244 |
+
writeUint16(offset: number, value: number): void;
|
245 |
+
writeInt32(offset: number, value: number): void;
|
246 |
+
writeUint32(offset: number, value: number): void;
|
247 |
+
writeInt64(offset: number, value: Long): void;
|
248 |
+
writeUint64(offset: number, value: Long): void;
|
249 |
+
writeFloat32(offset: number, value: number): void;
|
250 |
+
writeFloat64(offset: number, value: number): void;
|
251 |
+
|
252 |
+
getBufferIdentifier(): string;
|
253 |
+
|
254 |
+
/**
|
255 |
+
* Look up a field in the vtable, return an offset into the object, or 0 if the
|
256 |
+
* field is not present.
|
257 |
+
*/
|
258 |
+
__offset(bb_pos: number, vtable_offset: number): number;
|
259 |
+
|
260 |
+
/**
|
261 |
+
* Initialize any Table-derived type to point to the union at the given offset.
|
262 |
+
*/
|
263 |
+
__union<T extends Table>(t: T, offset: number): T;
|
264 |
+
|
265 |
+
/**
|
266 |
+
* Create a JavaScript string from UTF-8 data stored inside the FlatBuffer.
|
267 |
+
* This allocates a new string and converts to wide chars upon each access.
|
268 |
+
*
|
269 |
+
* To avoid the conversion to UTF-16, pass flatbuffers.Encoding.UTF8_BYTES as
|
270 |
+
* the "optionalEncoding" argument. This is useful for avoiding conversion to
|
271 |
+
* and from UTF-16 when the data will just be packaged back up in another
|
272 |
+
* FlatBuffer later on.
|
273 |
+
*
|
274 |
+
* @param optionalEncoding Defaults to UTF16_STRING
|
275 |
+
*/
|
276 |
+
__string(offset: number, optionalEncoding?: Encoding): string | Uint8Array;
|
277 |
+
|
278 |
+
/**
|
279 |
+
* Retrieve the relative offset stored at "offset"
|
280 |
+
*/
|
281 |
+
__indirect(offset: number): number;
|
282 |
+
|
283 |
+
/**
|
284 |
+
* Get the start of data of a vector whose offset is stored at "offset" in this object.
|
285 |
+
*/
|
286 |
+
__vector(offset: number): number;
|
287 |
+
|
288 |
+
/**
|
289 |
+
* Get the length of a vector whose offset is stored at "offset" in this object.
|
290 |
+
*/
|
291 |
+
__vector_len(offset: number): number;
|
292 |
+
|
293 |
+
__has_identifier(ident: string): boolean;
|
294 |
+
|
295 |
+
/**
|
296 |
+
* Convenience function for creating Long objects.
|
297 |
+
*/
|
298 |
+
createLong(low: number, high: number): Long;
|
299 |
+
}
|
300 |
+
}
|
301 |
+
}
|
igv_component/node_modules/@types/flatbuffers/package.json
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "@types/flatbuffers",
|
3 |
+
"version": "1.10.3",
|
4 |
+
"description": "TypeScript definitions for flatbuffers",
|
5 |
+
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/flatbuffers",
|
6 |
+
"license": "MIT",
|
7 |
+
"contributors": [
|
8 |
+
{
|
9 |
+
"name": "Kamil Rojewski",
|
10 |
+
"url": "kamil.rojewski@gmail.com"
|
11 |
+
},
|
12 |
+
{
|
13 |
+
"name": "Robin Giese",
|
14 |
+
"url": "robin@grumpycorp.com"
|
15 |
+
}
|
16 |
+
],
|
17 |
+
"main": "",
|
18 |
+
"types": "index.d.ts",
|
19 |
+
"repository": {
|
20 |
+
"type": "git",
|
21 |
+
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
22 |
+
"directory": "types/flatbuffers"
|
23 |
+
},
|
24 |
+
"scripts": {},
|
25 |
+
"dependencies": {},
|
26 |
+
"typesPublisherContentHash": "25e10a0cd9ec5476e7089ed89e9cf2f820f8675685cfcc1a2fc33483354e82d3",
|
27 |
+
"typeScriptVersion": "4.5"
|
28 |
+
}
|
igv_component/node_modules/@types/node/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
MIT License
|
2 |
+
|
3 |
+
Copyright (c) Microsoft Corporation.
|
4 |
+
|
5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 |
+
of this software and associated documentation files (the "Software"), to deal
|
7 |
+
in the Software without restriction, including without limitation the rights
|
8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
+
copies of the Software, and to permit persons to whom the Software is
|
10 |
+
furnished to do so, subject to the following conditions:
|
11 |
+
|
12 |
+
The above copyright notice and this permission notice shall be included in all
|
13 |
+
copies or substantial portions of the Software.
|
14 |
+
|
15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21 |
+
SOFTWARE
|
igv_component/node_modules/@types/node/README.md
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Installation
|
2 |
+
> `npm install --save @types/node`
|
3 |
+
|
4 |
+
# Summary
|
5 |
+
This package contains type definitions for Node.js (https://nodejs.org/).
|
6 |
+
|
7 |
+
# Details
|
8 |
+
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
|
9 |
+
|
10 |
+
### Additional Details
|
11 |
+
* Last updated: Mon, 26 Sep 2022 19:33:03 GMT
|
12 |
+
* Dependencies: none
|
13 |
+
* Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`, `structuredClone`
|
14 |
+
|
15 |
+
# Credits
|
16 |
+
These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [DefinitelyTyped](https://github.com/DefinitelyTyped), [Alberto Schiabel](https://github.com/jkomyno), [Alvis HT Tang](https://github.com/alvis), [Andrew Makarov](https://github.com/r3nya), [Benjamin Toueg](https://github.com/btoueg), [Chigozirim C.](https://github.com/smac89), [David Junger](https://github.com/touffy), [Deividas Bakanas](https://github.com/DeividasBakanas), [Eugene Y. Q. Shen](https://github.com/eyqs), [Hannes Magnusson](https://github.com/Hannes-Magnusson-CK), [Huw](https://github.com/hoo29), [Kelvin Jin](https://github.com/kjin), [Klaus Meinhardt](https://github.com/ajafff), [Lishude](https://github.com/islishude), [Mariusz Wiktorczyk](https://github.com/mwiktorczyk), [Mohsen Azimi](https://github.com/mohsen1), [Nicolas Even](https://github.com/n-e), [Nikita Galkin](https://github.com/galkin), [Parambir Singh](https://github.com/parambirs), [Sebastian Silbermann](https://github.com/eps1lon), [Simon Schick](https://github.com/SimonSchick), [Thomas den Hollander](https://github.com/ThomasdenH), [Wilco Bakker](https://github.com/WilcoBakker), [wwwy3y3](https://github.com/wwwy3y3), [Samuel Ainsworth](https://github.com/samuela), [Kyle Uehlein](https://github.com/kuehlein), [Thanik Bhongbhibhat](https://github.com/bhongy), [Marcin Kopacz](https://github.com/chyzwar), [Trivikram Kamat](https://github.com/trivikr), [Junxiao Shi](https://github.com/yoursunny), [Ilia Baryshnikov](https://github.com/qwelias), [ExE Boss](https://github.com/ExE-Boss), [Piotr Błażejewicz](https://github.com/peterblazejewicz), [Anna Henningsen](https://github.com/addaleax), [Victor Perin](https://github.com/victorperin), [Yongsheng Zhang](https://github.com/ZYSzys), [NodeJS Contributors](https://github.com/NodeJS), [Linus Unnebäck](https://github.com/LinusU), [wafuwafu13](https://github.com/wafuwafu13), and [Matteo Collina](https://github.com/mcollina).
|
igv_component/node_modules/@types/node/assert.d.ts
ADDED
@@ -0,0 +1,911 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* The `assert` module provides a set of assertion functions for verifying
|
3 |
+
* invariants.
|
4 |
+
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/assert.js)
|
5 |
+
*/
|
6 |
+
declare module 'assert' {
|
7 |
+
/**
|
8 |
+
* An alias of {@link ok}.
|
9 |
+
* @since v0.5.9
|
10 |
+
* @param value The input that is checked for being truthy.
|
11 |
+
*/
|
12 |
+
function assert(value: unknown, message?: string | Error): asserts value;
|
13 |
+
namespace assert {
|
14 |
+
/**
|
15 |
+
* Indicates the failure of an assertion. All errors thrown by the `assert` module
|
16 |
+
* will be instances of the `AssertionError` class.
|
17 |
+
*/
|
18 |
+
class AssertionError extends Error {
|
19 |
+
actual: unknown;
|
20 |
+
expected: unknown;
|
21 |
+
operator: string;
|
22 |
+
generatedMessage: boolean;
|
23 |
+
code: 'ERR_ASSERTION';
|
24 |
+
constructor(options?: {
|
25 |
+
/** If provided, the error message is set to this value. */
|
26 |
+
message?: string | undefined;
|
27 |
+
/** The `actual` property on the error instance. */
|
28 |
+
actual?: unknown | undefined;
|
29 |
+
/** The `expected` property on the error instance. */
|
30 |
+
expected?: unknown | undefined;
|
31 |
+
/** The `operator` property on the error instance. */
|
32 |
+
operator?: string | undefined;
|
33 |
+
/** If provided, the generated stack trace omits frames before this function. */
|
34 |
+
// tslint:disable-next-line:ban-types
|
35 |
+
stackStartFn?: Function | undefined;
|
36 |
+
});
|
37 |
+
}
|
38 |
+
/**
|
39 |
+
* This feature is currently experimental and behavior might still change.
|
40 |
+
* @since v14.2.0, v12.19.0
|
41 |
+
* @experimental
|
42 |
+
*/
|
43 |
+
class CallTracker {
|
44 |
+
/**
|
45 |
+
* The wrapper function is expected to be called exactly `exact` times. If the
|
46 |
+
* function has not been called exactly `exact` times when `tracker.verify()` is called, then `tracker.verify()` will throw an
|
47 |
+
* error.
|
48 |
+
*
|
49 |
+
* ```js
|
50 |
+
* import assert from 'assert';
|
51 |
+
*
|
52 |
+
* // Creates call tracker.
|
53 |
+
* const tracker = new assert.CallTracker();
|
54 |
+
*
|
55 |
+
* function func() {}
|
56 |
+
*
|
57 |
+
* // Returns a function that wraps func() that must be called exact times
|
58 |
+
* // before tracker.verify().
|
59 |
+
* const callsfunc = tracker.calls(func);
|
60 |
+
* ```
|
61 |
+
* @since v14.2.0, v12.19.0
|
62 |
+
* @param [fn='A no-op function']
|
63 |
+
* @param [exact=1]
|
64 |
+
* @return that wraps `fn`.
|
65 |
+
*/
|
66 |
+
calls(exact?: number): () => void;
|
67 |
+
calls<Func extends (...args: any[]) => any>(fn?: Func, exact?: number): Func;
|
68 |
+
/**
|
69 |
+
* The arrays contains information about the expected and actual number of calls of
|
70 |
+
* the functions that have not been called the expected number of times.
|
71 |
+
*
|
72 |
+
* ```js
|
73 |
+
* import assert from 'assert';
|
74 |
+
*
|
75 |
+
* // Creates call tracker.
|
76 |
+
* const tracker = new assert.CallTracker();
|
77 |
+
*
|
78 |
+
* function func() {}
|
79 |
+
*
|
80 |
+
* function foo() {}
|
81 |
+
*
|
82 |
+
* // Returns a function that wraps func() that must be called exact times
|
83 |
+
* // before tracker.verify().
|
84 |
+
* const callsfunc = tracker.calls(func, 2);
|
85 |
+
*
|
86 |
+
* // Returns an array containing information on callsfunc()
|
87 |
+
* tracker.report();
|
88 |
+
* // [
|
89 |
+
* // {
|
90 |
+
* // message: 'Expected the func function to be executed 2 time(s) but was
|
91 |
+
* // executed 0 time(s).',
|
92 |
+
* // actual: 0,
|
93 |
+
* // expected: 2,
|
94 |
+
* // operator: 'func',
|
95 |
+
* // stack: stack trace
|
96 |
+
* // }
|
97 |
+
* // ]
|
98 |
+
* ```
|
99 |
+
* @since v14.2.0, v12.19.0
|
100 |
+
* @return of objects containing information about the wrapper functions returned by `calls`.
|
101 |
+
*/
|
102 |
+
report(): CallTrackerReportInformation[];
|
103 |
+
/**
|
104 |
+
* Iterates through the list of functions passed to `tracker.calls()` and will throw an error for functions that
|
105 |
+
* have not been called the expected number of times.
|
106 |
+
*
|
107 |
+
* ```js
|
108 |
+
* import assert from 'assert';
|
109 |
+
*
|
110 |
+
* // Creates call tracker.
|
111 |
+
* const tracker = new assert.CallTracker();
|
112 |
+
*
|
113 |
+
* function func() {}
|
114 |
+
*
|
115 |
+
* // Returns a function that wraps func() that must be called exact times
|
116 |
+
* // before tracker.verify().
|
117 |
+
* const callsfunc = tracker.calls(func, 2);
|
118 |
+
*
|
119 |
+
* callsfunc();
|
120 |
+
*
|
121 |
+
* // Will throw an error since callsfunc() was only called once.
|
122 |
+
* tracker.verify();
|
123 |
+
* ```
|
124 |
+
* @since v14.2.0, v12.19.0
|
125 |
+
*/
|
126 |
+
verify(): void;
|
127 |
+
}
|
128 |
+
interface CallTrackerReportInformation {
|
129 |
+
message: string;
|
130 |
+
/** The actual number of times the function was called. */
|
131 |
+
actual: number;
|
132 |
+
/** The number of times the function was expected to be called. */
|
133 |
+
expected: number;
|
134 |
+
/** The name of the function that is wrapped. */
|
135 |
+
operator: string;
|
136 |
+
/** A stack trace of the function. */
|
137 |
+
stack: object;
|
138 |
+
}
|
139 |
+
type AssertPredicate = RegExp | (new () => object) | ((thrown: unknown) => boolean) | object | Error;
|
140 |
+
/**
|
141 |
+
* Throws an `AssertionError` with the provided error message or a default
|
142 |
+
* error message. If the `message` parameter is an instance of an `Error` then
|
143 |
+
* it will be thrown instead of the `AssertionError`.
|
144 |
+
*
|
145 |
+
* ```js
|
146 |
+
* import assert from 'assert/strict';
|
147 |
+
*
|
148 |
+
* assert.fail();
|
149 |
+
* // AssertionError [ERR_ASSERTION]: Failed
|
150 |
+
*
|
151 |
+
* assert.fail('boom');
|
152 |
+
* // AssertionError [ERR_ASSERTION]: boom
|
153 |
+
*
|
154 |
+
* assert.fail(new TypeError('need array'));
|
155 |
+
* // TypeError: need array
|
156 |
+
* ```
|
157 |
+
*
|
158 |
+
* Using `assert.fail()` with more than two arguments is possible but deprecated.
|
159 |
+
* See below for further details.
|
160 |
+
* @since v0.1.21
|
161 |
+
* @param [message='Failed']
|
162 |
+
*/
|
163 |
+
function fail(message?: string | Error): never;
|
164 |
+
/** @deprecated since v10.0.0 - use fail([message]) or other assert functions instead. */
|
165 |
+
function fail(
|
166 |
+
actual: unknown,
|
167 |
+
expected: unknown,
|
168 |
+
message?: string | Error,
|
169 |
+
operator?: string,
|
170 |
+
// tslint:disable-next-line:ban-types
|
171 |
+
stackStartFn?: Function
|
172 |
+
): never;
|
173 |
+
/**
|
174 |
+
* Tests if `value` is truthy. It is equivalent to`assert.equal(!!value, true, message)`.
|
175 |
+
*
|
176 |
+
* If `value` is not truthy, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is `undefined`, a default
|
177 |
+
* error message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`.
|
178 |
+
* If no arguments are passed in at all `message` will be set to the string:`` 'No value argument passed to `assert.ok()`' ``.
|
179 |
+
*
|
180 |
+
* Be aware that in the `repl` the error message will be different to the one
|
181 |
+
* thrown in a file! See below for further details.
|
182 |
+
*
|
183 |
+
* ```js
|
184 |
+
* import assert from 'assert/strict';
|
185 |
+
*
|
186 |
+
* assert.ok(true);
|
187 |
+
* // OK
|
188 |
+
* assert.ok(1);
|
189 |
+
* // OK
|
190 |
+
*
|
191 |
+
* assert.ok();
|
192 |
+
* // AssertionError: No value argument passed to `assert.ok()`
|
193 |
+
*
|
194 |
+
* assert.ok(false, 'it\'s false');
|
195 |
+
* // AssertionError: it's false
|
196 |
+
*
|
197 |
+
* // In the repl:
|
198 |
+
* assert.ok(typeof 123 === 'string');
|
199 |
+
* // AssertionError: false == true
|
200 |
+
*
|
201 |
+
* // In a file (e.g. test.js):
|
202 |
+
* assert.ok(typeof 123 === 'string');
|
203 |
+
* // AssertionError: The expression evaluated to a falsy value:
|
204 |
+
* //
|
205 |
+
* // assert.ok(typeof 123 === 'string')
|
206 |
+
*
|
207 |
+
* assert.ok(false);
|
208 |
+
* // AssertionError: The expression evaluated to a falsy value:
|
209 |
+
* //
|
210 |
+
* // assert.ok(false)
|
211 |
+
*
|
212 |
+
* assert.ok(0);
|
213 |
+
* // AssertionError: The expression evaluated to a falsy value:
|
214 |
+
* //
|
215 |
+
* // assert.ok(0)
|
216 |
+
* ```
|
217 |
+
*
|
218 |
+
* ```js
|
219 |
+
* import assert from 'assert/strict';
|
220 |
+
*
|
221 |
+
* // Using `assert()` works the same:
|
222 |
+
* assert(0);
|
223 |
+
* // AssertionError: The expression evaluated to a falsy value:
|
224 |
+
* //
|
225 |
+
* // assert(0)
|
226 |
+
* ```
|
227 |
+
* @since v0.1.21
|
228 |
+
*/
|
229 |
+
function ok(value: unknown, message?: string | Error): asserts value;
|
230 |
+
/**
|
231 |
+
* **Strict assertion mode**
|
232 |
+
*
|
233 |
+
* An alias of {@link strictEqual}.
|
234 |
+
*
|
235 |
+
* **Legacy assertion mode**
|
236 |
+
*
|
237 |
+
* > Stability: 3 - Legacy: Use {@link strictEqual} instead.
|
238 |
+
*
|
239 |
+
* Tests shallow, coercive equality between the `actual` and `expected` parameters
|
240 |
+
* using the [`==` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Equality). `NaN` is specially handled
|
241 |
+
* and treated as being identical if both sides are `NaN`.
|
242 |
+
*
|
243 |
+
* ```js
|
244 |
+
* import assert from 'assert';
|
245 |
+
*
|
246 |
+
* assert.equal(1, 1);
|
247 |
+
* // OK, 1 == 1
|
248 |
+
* assert.equal(1, '1');
|
249 |
+
* // OK, 1 == '1'
|
250 |
+
* assert.equal(NaN, NaN);
|
251 |
+
* // OK
|
252 |
+
*
|
253 |
+
* assert.equal(1, 2);
|
254 |
+
* // AssertionError: 1 == 2
|
255 |
+
* assert.equal({ a: { b: 1 } }, { a: { b: 1 } });
|
256 |
+
* // AssertionError: { a: { b: 1 } } == { a: { b: 1 } }
|
257 |
+
* ```
|
258 |
+
*
|
259 |
+
* If the values are not equal, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is undefined, a default
|
260 |
+
* error message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`.
|
261 |
+
* @since v0.1.21
|
262 |
+
*/
|
263 |
+
function equal(actual: unknown, expected: unknown, message?: string | Error): void;
|
264 |
+
/**
|
265 |
+
* **Strict assertion mode**
|
266 |
+
*
|
267 |
+
* An alias of {@link notStrictEqual}.
|
268 |
+
*
|
269 |
+
* **Legacy assertion mode**
|
270 |
+
*
|
271 |
+
* > Stability: 3 - Legacy: Use {@link notStrictEqual} instead.
|
272 |
+
*
|
273 |
+
* Tests shallow, coercive inequality with the [`!=` operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Inequality). `NaN` is
|
274 |
+
* specially handled and treated as being identical if both sides are `NaN`.
|
275 |
+
*
|
276 |
+
* ```js
|
277 |
+
* import assert from 'assert';
|
278 |
+
*
|
279 |
+
* assert.notEqual(1, 2);
|
280 |
+
* // OK
|
281 |
+
*
|
282 |
+
* assert.notEqual(1, 1);
|
283 |
+
* // AssertionError: 1 != 1
|
284 |
+
*
|
285 |
+
* assert.notEqual(1, '1');
|
286 |
+
* // AssertionError: 1 != '1'
|
287 |
+
* ```
|
288 |
+
*
|
289 |
+
* If the values are equal, an `AssertionError` is thrown with a `message`property set equal to the value of the `message` parameter. If the `message`parameter is undefined, a default error
|
290 |
+
* message is assigned. If the `message`parameter is an instance of an `Error` then it will be thrown instead of the`AssertionError`.
|
291 |
+
* @since v0.1.21
|
292 |
+
*/
|
293 |
+
function notEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
294 |
+
/**
|
295 |
+
* **Strict assertion mode**
|
296 |
+
*
|
297 |
+
* An alias of {@link deepStrictEqual}.
|
298 |
+
*
|
299 |
+
* **Legacy assertion mode**
|
300 |
+
*
|
301 |
+
* > Stability: 3 - Legacy: Use {@link deepStrictEqual} instead.
|
302 |
+
*
|
303 |
+
* Tests for deep equality between the `actual` and `expected` parameters. Consider
|
304 |
+
* using {@link deepStrictEqual} instead. {@link deepEqual} can have
|
305 |
+
* surprising results.
|
306 |
+
*
|
307 |
+
* _Deep equality_ means that the enumerable "own" properties of child objects
|
308 |
+
* are also recursively evaluated by the following rules.
|
309 |
+
* @since v0.1.21
|
310 |
+
*/
|
311 |
+
function deepEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
312 |
+
/**
|
313 |
+
* **Strict assertion mode**
|
314 |
+
*
|
315 |
+
* An alias of {@link notDeepStrictEqual}.
|
316 |
+
*
|
317 |
+
* **Legacy assertion mode**
|
318 |
+
*
|
319 |
+
* > Stability: 3 - Legacy: Use {@link notDeepStrictEqual} instead.
|
320 |
+
*
|
321 |
+
* Tests for any deep inequality. Opposite of {@link deepEqual}.
|
322 |
+
*
|
323 |
+
* ```js
|
324 |
+
* import assert from 'assert';
|
325 |
+
*
|
326 |
+
* const obj1 = {
|
327 |
+
* a: {
|
328 |
+
* b: 1
|
329 |
+
* }
|
330 |
+
* };
|
331 |
+
* const obj2 = {
|
332 |
+
* a: {
|
333 |
+
* b: 2
|
334 |
+
* }
|
335 |
+
* };
|
336 |
+
* const obj3 = {
|
337 |
+
* a: {
|
338 |
+
* b: 1
|
339 |
+
* }
|
340 |
+
* };
|
341 |
+
* const obj4 = Object.create(obj1);
|
342 |
+
*
|
343 |
+
* assert.notDeepEqual(obj1, obj1);
|
344 |
+
* // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
|
345 |
+
*
|
346 |
+
* assert.notDeepEqual(obj1, obj2);
|
347 |
+
* // OK
|
348 |
+
*
|
349 |
+
* assert.notDeepEqual(obj1, obj3);
|
350 |
+
* // AssertionError: { a: { b: 1 } } notDeepEqual { a: { b: 1 } }
|
351 |
+
*
|
352 |
+
* assert.notDeepEqual(obj1, obj4);
|
353 |
+
* // OK
|
354 |
+
* ```
|
355 |
+
*
|
356 |
+
* If the values are deeply equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a default
|
357 |
+
* error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown
|
358 |
+
* instead of the `AssertionError`.
|
359 |
+
* @since v0.1.21
|
360 |
+
*/
|
361 |
+
function notDeepEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
362 |
+
/**
|
363 |
+
* Tests strict equality between the `actual` and `expected` parameters as
|
364 |
+
* determined by [`Object.is()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
|
365 |
+
*
|
366 |
+
* ```js
|
367 |
+
* import assert from 'assert/strict';
|
368 |
+
*
|
369 |
+
* assert.strictEqual(1, 2);
|
370 |
+
* // AssertionError [ERR_ASSERTION]: Expected inputs to be strictly equal:
|
371 |
+
* //
|
372 |
+
* // 1 !== 2
|
373 |
+
*
|
374 |
+
* assert.strictEqual(1, 1);
|
375 |
+
* // OK
|
376 |
+
*
|
377 |
+
* assert.strictEqual('Hello foobar', 'Hello World!');
|
378 |
+
* // AssertionError [ERR_ASSERTION]: Expected inputs to be strictly equal:
|
379 |
+
* // + actual - expected
|
380 |
+
* //
|
381 |
+
* // + 'Hello foobar'
|
382 |
+
* // - 'Hello World!'
|
383 |
+
* // ^
|
384 |
+
*
|
385 |
+
* const apples = 1;
|
386 |
+
* const oranges = 2;
|
387 |
+
* assert.strictEqual(apples, oranges, `apples ${apples} !== oranges ${oranges}`);
|
388 |
+
* // AssertionError [ERR_ASSERTION]: apples 1 !== oranges 2
|
389 |
+
*
|
390 |
+
* assert.strictEqual(1, '1', new TypeError('Inputs are not identical'));
|
391 |
+
* // TypeError: Inputs are not identical
|
392 |
+
* ```
|
393 |
+
*
|
394 |
+
* If the values are not strictly equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a
|
395 |
+
* default error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown
|
396 |
+
* instead of the `AssertionError`.
|
397 |
+
* @since v0.1.21
|
398 |
+
*/
|
399 |
+
function strictEqual<T>(actual: unknown, expected: T, message?: string | Error): asserts actual is T;
|
400 |
+
/**
|
401 |
+
* Tests strict inequality between the `actual` and `expected` parameters as
|
402 |
+
* determined by [`Object.is()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
|
403 |
+
*
|
404 |
+
* ```js
|
405 |
+
* import assert from 'assert/strict';
|
406 |
+
*
|
407 |
+
* assert.notStrictEqual(1, 2);
|
408 |
+
* // OK
|
409 |
+
*
|
410 |
+
* assert.notStrictEqual(1, 1);
|
411 |
+
* // AssertionError [ERR_ASSERTION]: Expected "actual" to be strictly unequal to:
|
412 |
+
* //
|
413 |
+
* // 1
|
414 |
+
*
|
415 |
+
* assert.notStrictEqual(1, '1');
|
416 |
+
* // OK
|
417 |
+
* ```
|
418 |
+
*
|
419 |
+
* If the values are strictly equal, an `AssertionError` is thrown with a`message` property set equal to the value of the `message` parameter. If the`message` parameter is undefined, a
|
420 |
+
* default error message is assigned. If the`message` parameter is an instance of an `Error` then it will be thrown
|
421 |
+
* instead of the `AssertionError`.
|
422 |
+
* @since v0.1.21
|
423 |
+
*/
|
424 |
+
function notStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
425 |
+
/**
|
426 |
+
* Tests for deep equality between the `actual` and `expected` parameters.
|
427 |
+
* "Deep" equality means that the enumerable "own" properties of child objects
|
428 |
+
* are recursively evaluated also by the following rules.
|
429 |
+
* @since v1.2.0
|
430 |
+
*/
|
431 |
+
function deepStrictEqual<T>(actual: unknown, expected: T, message?: string | Error): asserts actual is T;
|
432 |
+
/**
|
433 |
+
* Tests for deep strict inequality. Opposite of {@link deepStrictEqual}.
|
434 |
+
*
|
435 |
+
* ```js
|
436 |
+
* import assert from 'assert/strict';
|
437 |
+
*
|
438 |
+
* assert.notDeepStrictEqual({ a: 1 }, { a: '1' });
|
439 |
+
* // OK
|
440 |
+
* ```
|
441 |
+
*
|
442 |
+
* If the values are deeply and strictly equal, an `AssertionError` is thrown
|
443 |
+
* with a `message` property set equal to the value of the `message` parameter. If
|
444 |
+
* the `message` parameter is undefined, a default error message is assigned. If
|
445 |
+
* the `message` parameter is an instance of an `Error` then it will be thrown
|
446 |
+
* instead of the `AssertionError`.
|
447 |
+
* @since v1.2.0
|
448 |
+
*/
|
449 |
+
function notDeepStrictEqual(actual: unknown, expected: unknown, message?: string | Error): void;
|
450 |
+
/**
|
451 |
+
* Expects the function `fn` to throw an error.
|
452 |
+
*
|
453 |
+
* If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
|
454 |
+
* [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), a validation function,
|
455 |
+
* a validation object where each property will be tested for strict deep equality,
|
456 |
+
* or an instance of error where each property will be tested for strict deep
|
457 |
+
* equality including the non-enumerable `message` and `name` properties. When
|
458 |
+
* using an object, it is also possible to use a regular expression, when
|
459 |
+
* validating against a string property. See below for examples.
|
460 |
+
*
|
461 |
+
* If specified, `message` will be appended to the message provided by the`AssertionError` if the `fn` call fails to throw or in case the error validation
|
462 |
+
* fails.
|
463 |
+
*
|
464 |
+
* Custom validation object/error instance:
|
465 |
+
*
|
466 |
+
* ```js
|
467 |
+
* import assert from 'assert/strict';
|
468 |
+
*
|
469 |
+
* const err = new TypeError('Wrong value');
|
470 |
+
* err.code = 404;
|
471 |
+
* err.foo = 'bar';
|
472 |
+
* err.info = {
|
473 |
+
* nested: true,
|
474 |
+
* baz: 'text'
|
475 |
+
* };
|
476 |
+
* err.reg = /abc/i;
|
477 |
+
*
|
478 |
+
* assert.throws(
|
479 |
+
* () => {
|
480 |
+
* throw err;
|
481 |
+
* },
|
482 |
+
* {
|
483 |
+
* name: 'TypeError',
|
484 |
+
* message: 'Wrong value',
|
485 |
+
* info: {
|
486 |
+
* nested: true,
|
487 |
+
* baz: 'text'
|
488 |
+
* }
|
489 |
+
* // Only properties on the validation object will be tested for.
|
490 |
+
* // Using nested objects requires all properties to be present. Otherwise
|
491 |
+
* // the validation is going to fail.
|
492 |
+
* }
|
493 |
+
* );
|
494 |
+
*
|
495 |
+
* // Using regular expressions to validate error properties:
|
496 |
+
* throws(
|
497 |
+
* () => {
|
498 |
+
* throw err;
|
499 |
+
* },
|
500 |
+
* {
|
501 |
+
* // The `name` and `message` properties are strings and using regular
|
502 |
+
* // expressions on those will match against the string. If they fail, an
|
503 |
+
* // error is thrown.
|
504 |
+
* name: /^TypeError$/,
|
505 |
+
* message: /Wrong/,
|
506 |
+
* foo: 'bar',
|
507 |
+
* info: {
|
508 |
+
* nested: true,
|
509 |
+
* // It is not possible to use regular expressions for nested properties!
|
510 |
+
* baz: 'text'
|
511 |
+
* },
|
512 |
+
* // The `reg` property contains a regular expression and only if the
|
513 |
+
* // validation object contains an identical regular expression, it is going
|
514 |
+
* // to pass.
|
515 |
+
* reg: /abc/i
|
516 |
+
* }
|
517 |
+
* );
|
518 |
+
*
|
519 |
+
* // Fails due to the different `message` and `name` properties:
|
520 |
+
* throws(
|
521 |
+
* () => {
|
522 |
+
* const otherErr = new Error('Not found');
|
523 |
+
* // Copy all enumerable properties from `err` to `otherErr`.
|
524 |
+
* for (const [key, value] of Object.entries(err)) {
|
525 |
+
* otherErr[key] = value;
|
526 |
+
* }
|
527 |
+
* throw otherErr;
|
528 |
+
* },
|
529 |
+
* // The error's `message` and `name` properties will also be checked when using
|
530 |
+
* // an error as validation object.
|
531 |
+
* err
|
532 |
+
* );
|
533 |
+
* ```
|
534 |
+
*
|
535 |
+
* Validate instanceof using constructor:
|
536 |
+
*
|
537 |
+
* ```js
|
538 |
+
* import assert from 'assert/strict';
|
539 |
+
*
|
540 |
+
* assert.throws(
|
541 |
+
* () => {
|
542 |
+
* throw new Error('Wrong value');
|
543 |
+
* },
|
544 |
+
* Error
|
545 |
+
* );
|
546 |
+
* ```
|
547 |
+
*
|
548 |
+
* Validate error message using [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions):
|
549 |
+
*
|
550 |
+
* Using a regular expression runs `.toString` on the error object, and will
|
551 |
+
* therefore also include the error name.
|
552 |
+
*
|
553 |
+
* ```js
|
554 |
+
* import assert from 'assert/strict';
|
555 |
+
*
|
556 |
+
* assert.throws(
|
557 |
+
* () => {
|
558 |
+
* throw new Error('Wrong value');
|
559 |
+
* },
|
560 |
+
* /^Error: Wrong value$/
|
561 |
+
* );
|
562 |
+
* ```
|
563 |
+
*
|
564 |
+
* Custom error validation:
|
565 |
+
*
|
566 |
+
* The function must return `true` to indicate all internal validations passed.
|
567 |
+
* It will otherwise fail with an `AssertionError`.
|
568 |
+
*
|
569 |
+
* ```js
|
570 |
+
* import assert from 'assert/strict';
|
571 |
+
*
|
572 |
+
* assert.throws(
|
573 |
+
* () => {
|
574 |
+
* throw new Error('Wrong value');
|
575 |
+
* },
|
576 |
+
* (err) => {
|
577 |
+
* assert(err instanceof Error);
|
578 |
+
* assert(/value/.test(err));
|
579 |
+
* // Avoid returning anything from validation functions besides `true`.
|
580 |
+
* // Otherwise, it's not clear what part of the validation failed. Instead,
|
581 |
+
* // throw an error about the specific validation that failed (as done in this
|
582 |
+
* // example) and add as much helpful debugging information to that error as
|
583 |
+
* // possible.
|
584 |
+
* return true;
|
585 |
+
* },
|
586 |
+
* 'unexpected error'
|
587 |
+
* );
|
588 |
+
* ```
|
589 |
+
*
|
590 |
+
* `error` cannot be a string. If a string is provided as the second
|
591 |
+
* argument, then `error` is assumed to be omitted and the string will be used for`message` instead. This can lead to easy-to-miss mistakes. Using the same
|
592 |
+
* message as the thrown error message is going to result in an`ERR_AMBIGUOUS_ARGUMENT` error. Please read the example below carefully if using
|
593 |
+
* a string as the second argument gets considered:
|
594 |
+
*
|
595 |
+
* ```js
|
596 |
+
* import assert from 'assert/strict';
|
597 |
+
*
|
598 |
+
* function throwingFirst() {
|
599 |
+
* throw new Error('First');
|
600 |
+
* }
|
601 |
+
*
|
602 |
+
* function throwingSecond() {
|
603 |
+
* throw new Error('Second');
|
604 |
+
* }
|
605 |
+
*
|
606 |
+
* function notThrowing() {}
|
607 |
+
*
|
608 |
+
* // The second argument is a string and the input function threw an Error.
|
609 |
+
* // The first case will not throw as it does not match for the error message
|
610 |
+
* // thrown by the input function!
|
611 |
+
* assert.throws(throwingFirst, 'Second');
|
612 |
+
* // In the next example the message has no benefit over the message from the
|
613 |
+
* // error and since it is not clear if the user intended to actually match
|
614 |
+
* // against the error message, Node.js throws an `ERR_AMBIGUOUS_ARGUMENT` error.
|
615 |
+
* assert.throws(throwingSecond, 'Second');
|
616 |
+
* // TypeError [ERR_AMBIGUOUS_ARGUMENT]
|
617 |
+
*
|
618 |
+
* // The string is only used (as message) in case the function does not throw:
|
619 |
+
* assert.throws(notThrowing, 'Second');
|
620 |
+
* // AssertionError [ERR_ASSERTION]: Missing expected exception: Second
|
621 |
+
*
|
622 |
+
* // If it was intended to match for the error message do this instead:
|
623 |
+
* // It does not throw because the error messages match.
|
624 |
+
* assert.throws(throwingSecond, /Second$/);
|
625 |
+
*
|
626 |
+
* // If the error message does not match, an AssertionError is thrown.
|
627 |
+
* assert.throws(throwingFirst, /Second$/);
|
628 |
+
* // AssertionError [ERR_ASSERTION]
|
629 |
+
* ```
|
630 |
+
*
|
631 |
+
* Due to the confusing error-prone notation, avoid a string as the second
|
632 |
+
* argument.
|
633 |
+
* @since v0.1.21
|
634 |
+
*/
|
635 |
+
function throws(block: () => unknown, message?: string | Error): void;
|
636 |
+
function throws(block: () => unknown, error: AssertPredicate, message?: string | Error): void;
|
637 |
+
/**
|
638 |
+
* Asserts that the function `fn` does not throw an error.
|
639 |
+
*
|
640 |
+
* Using `assert.doesNotThrow()` is actually not useful because there
|
641 |
+
* is no benefit in catching an error and then rethrowing it. Instead, consider
|
642 |
+
* adding a comment next to the specific code path that should not throw and keep
|
643 |
+
* error messages as expressive as possible.
|
644 |
+
*
|
645 |
+
* When `assert.doesNotThrow()` is called, it will immediately call the `fn`function.
|
646 |
+
*
|
647 |
+
* If an error is thrown and it is the same type as that specified by the `error`parameter, then an `AssertionError` is thrown. If the error is of a
|
648 |
+
* different type, or if the `error` parameter is undefined, the error is
|
649 |
+
* propagated back to the caller.
|
650 |
+
*
|
651 |
+
* If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
|
652 |
+
* [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) or a validation
|
653 |
+
* function. See {@link throws} for more details.
|
654 |
+
*
|
655 |
+
* The following, for instance, will throw the `TypeError` because there is no
|
656 |
+
* matching error type in the assertion:
|
657 |
+
*
|
658 |
+
* ```js
|
659 |
+
* import assert from 'assert/strict';
|
660 |
+
*
|
661 |
+
* assert.doesNotThrow(
|
662 |
+
* () => {
|
663 |
+
* throw new TypeError('Wrong value');
|
664 |
+
* },
|
665 |
+
* SyntaxError
|
666 |
+
* );
|
667 |
+
* ```
|
668 |
+
*
|
669 |
+
* However, the following will result in an `AssertionError` with the message
|
670 |
+
* 'Got unwanted exception...':
|
671 |
+
*
|
672 |
+
* ```js
|
673 |
+
* import assert from 'assert/strict';
|
674 |
+
*
|
675 |
+
* assert.doesNotThrow(
|
676 |
+
* () => {
|
677 |
+
* throw new TypeError('Wrong value');
|
678 |
+
* },
|
679 |
+
* TypeError
|
680 |
+
* );
|
681 |
+
* ```
|
682 |
+
*
|
683 |
+
* If an `AssertionError` is thrown and a value is provided for the `message`parameter, the value of `message` will be appended to the `AssertionError` message:
|
684 |
+
*
|
685 |
+
* ```js
|
686 |
+
* import assert from 'assert/strict';
|
687 |
+
*
|
688 |
+
* assert.doesNotThrow(
|
689 |
+
* () => {
|
690 |
+
* throw new TypeError('Wrong value');
|
691 |
+
* },
|
692 |
+
* /Wrong value/,
|
693 |
+
* 'Whoops'
|
694 |
+
* );
|
695 |
+
* // Throws: AssertionError: Got unwanted exception: Whoops
|
696 |
+
* ```
|
697 |
+
* @since v0.1.21
|
698 |
+
*/
|
699 |
+
function doesNotThrow(block: () => unknown, message?: string | Error): void;
|
700 |
+
function doesNotThrow(block: () => unknown, error: AssertPredicate, message?: string | Error): void;
|
701 |
+
/**
|
702 |
+
* Throws `value` if `value` is not `undefined` or `null`. This is useful when
|
703 |
+
* testing the `error` argument in callbacks. The stack trace contains all frames
|
704 |
+
* from the error passed to `ifError()` including the potential new frames for`ifError()` itself.
|
705 |
+
*
|
706 |
+
* ```js
|
707 |
+
* import assert from 'assert/strict';
|
708 |
+
*
|
709 |
+
* assert.ifError(null);
|
710 |
+
* // OK
|
711 |
+
* assert.ifError(0);
|
712 |
+
* // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: 0
|
713 |
+
* assert.ifError('error');
|
714 |
+
* // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: 'error'
|
715 |
+
* assert.ifError(new Error());
|
716 |
+
* // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: Error
|
717 |
+
*
|
718 |
+
* // Create some random error frames.
|
719 |
+
* let err;
|
720 |
+
* (function errorFrame() {
|
721 |
+
* err = new Error('test error');
|
722 |
+
* })();
|
723 |
+
*
|
724 |
+
* (function ifErrorFrame() {
|
725 |
+
* assert.ifError(err);
|
726 |
+
* })();
|
727 |
+
* // AssertionError [ERR_ASSERTION]: ifError got unwanted exception: test error
|
728 |
+
* // at ifErrorFrame
|
729 |
+
* // at errorFrame
|
730 |
+
* ```
|
731 |
+
* @since v0.1.97
|
732 |
+
*/
|
733 |
+
function ifError(value: unknown): asserts value is null | undefined;
|
734 |
+
/**
|
735 |
+
* Awaits the `asyncFn` promise or, if `asyncFn` is a function, immediately
|
736 |
+
* calls the function and awaits the returned promise to complete. It will then
|
737 |
+
* check that the promise is rejected.
|
738 |
+
*
|
739 |
+
* If `asyncFn` is a function and it throws an error synchronously,`assert.rejects()` will return a rejected `Promise` with that error. If the
|
740 |
+
* function does not return a promise, `assert.rejects()` will return a rejected`Promise` with an `ERR_INVALID_RETURN_VALUE` error. In both cases the error
|
741 |
+
* handler is skipped.
|
742 |
+
*
|
743 |
+
* Besides the async nature to await the completion behaves identically to {@link throws}.
|
744 |
+
*
|
745 |
+
* If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
|
746 |
+
* [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions), a validation function,
|
747 |
+
* an object where each property will be tested for, or an instance of error where
|
748 |
+
* each property will be tested for including the non-enumerable `message` and`name` properties.
|
749 |
+
*
|
750 |
+
* If specified, `message` will be the message provided by the `AssertionError` if the `asyncFn` fails to reject.
|
751 |
+
*
|
752 |
+
* ```js
|
753 |
+
* import assert from 'assert/strict';
|
754 |
+
*
|
755 |
+
* await assert.rejects(
|
756 |
+
* async () => {
|
757 |
+
* throw new TypeError('Wrong value');
|
758 |
+
* },
|
759 |
+
* {
|
760 |
+
* name: 'TypeError',
|
761 |
+
* message: 'Wrong value'
|
762 |
+
* }
|
763 |
+
* );
|
764 |
+
* ```
|
765 |
+
*
|
766 |
+
* ```js
|
767 |
+
* import assert from 'assert/strict';
|
768 |
+
*
|
769 |
+
* await assert.rejects(
|
770 |
+
* async () => {
|
771 |
+
* throw new TypeError('Wrong value');
|
772 |
+
* },
|
773 |
+
* (err) => {
|
774 |
+
* assert.strictEqual(err.name, 'TypeError');
|
775 |
+
* assert.strictEqual(err.message, 'Wrong value');
|
776 |
+
* return true;
|
777 |
+
* }
|
778 |
+
* );
|
779 |
+
* ```
|
780 |
+
*
|
781 |
+
* ```js
|
782 |
+
* import assert from 'assert/strict';
|
783 |
+
*
|
784 |
+
* assert.rejects(
|
785 |
+
* Promise.reject(new Error('Wrong value')),
|
786 |
+
* Error
|
787 |
+
* ).then(() => {
|
788 |
+
* // ...
|
789 |
+
* });
|
790 |
+
* ```
|
791 |
+
*
|
792 |
+
* `error` cannot be a string. If a string is provided as the second
|
793 |
+
* argument, then `error` is assumed to be omitted and the string will be used for`message` instead. This can lead to easy-to-miss mistakes. Please read the
|
794 |
+
* example in {@link throws} carefully if using a string as the second
|
795 |
+
* argument gets considered.
|
796 |
+
* @since v10.0.0
|
797 |
+
*/
|
798 |
+
function rejects(block: (() => Promise<unknown>) | Promise<unknown>, message?: string | Error): Promise<void>;
|
799 |
+
function rejects(block: (() => Promise<unknown>) | Promise<unknown>, error: AssertPredicate, message?: string | Error): Promise<void>;
|
800 |
+
/**
|
801 |
+
* Awaits the `asyncFn` promise or, if `asyncFn` is a function, immediately
|
802 |
+
* calls the function and awaits the returned promise to complete. It will then
|
803 |
+
* check that the promise is not rejected.
|
804 |
+
*
|
805 |
+
* If `asyncFn` is a function and it throws an error synchronously,`assert.doesNotReject()` will return a rejected `Promise` with that error. If
|
806 |
+
* the function does not return a promise, `assert.doesNotReject()` will return a
|
807 |
+
* rejected `Promise` with an `ERR_INVALID_RETURN_VALUE` error. In both cases
|
808 |
+
* the error handler is skipped.
|
809 |
+
*
|
810 |
+
* Using `assert.doesNotReject()` is actually not useful because there is little
|
811 |
+
* benefit in catching a rejection and then rejecting it again. Instead, consider
|
812 |
+
* adding a comment next to the specific code path that should not reject and keep
|
813 |
+
* error messages as expressive as possible.
|
814 |
+
*
|
815 |
+
* If specified, `error` can be a [`Class`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes),
|
816 |
+
* [`RegExp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) or a validation
|
817 |
+
* function. See {@link throws} for more details.
|
818 |
+
*
|
819 |
+
* Besides the async nature to await the completion behaves identically to {@link doesNotThrow}.
|
820 |
+
*
|
821 |
+
* ```js
|
822 |
+
* import assert from 'assert/strict';
|
823 |
+
*
|
824 |
+
* await assert.doesNotReject(
|
825 |
+
* async () => {
|
826 |
+
* throw new TypeError('Wrong value');
|
827 |
+
* },
|
828 |
+
* SyntaxError
|
829 |
+
* );
|
830 |
+
* ```
|
831 |
+
*
|
832 |
+
* ```js
|
833 |
+
* import assert from 'assert/strict';
|
834 |
+
*
|
835 |
+
* assert.doesNotReject(Promise.reject(new TypeError('Wrong value')))
|
836 |
+
* .then(() => {
|
837 |
+
* // ...
|
838 |
+
* });
|
839 |
+
* ```
|
840 |
+
* @since v10.0.0
|
841 |
+
*/
|
842 |
+
function doesNotReject(block: (() => Promise<unknown>) | Promise<unknown>, message?: string | Error): Promise<void>;
|
843 |
+
function doesNotReject(block: (() => Promise<unknown>) | Promise<unknown>, error: AssertPredicate, message?: string | Error): Promise<void>;
|
844 |
+
/**
|
845 |
+
* Expects the `string` input to match the regular expression.
|
846 |
+
*
|
847 |
+
* ```js
|
848 |
+
* import assert from 'assert/strict';
|
849 |
+
*
|
850 |
+
* assert.match('I will fail', /pass/);
|
851 |
+
* // AssertionError [ERR_ASSERTION]: The input did not match the regular ...
|
852 |
+
*
|
853 |
+
* assert.match(123, /pass/);
|
854 |
+
* // AssertionError [ERR_ASSERTION]: The "string" argument must be of type string.
|
855 |
+
*
|
856 |
+
* assert.match('I will pass', /pass/);
|
857 |
+
* // OK
|
858 |
+
* ```
|
859 |
+
*
|
860 |
+
* If the values do not match, or if the `string` argument is of another type than`string`, an `AssertionError` is thrown with a `message` property set equal
|
861 |
+
* to the value of the `message` parameter. If the `message` parameter is
|
862 |
+
* undefined, a default error message is assigned. If the `message` parameter is an
|
863 |
+
* instance of an `Error` then it will be thrown instead of the `AssertionError`.
|
864 |
+
* @since v13.6.0, v12.16.0
|
865 |
+
*/
|
866 |
+
function match(value: string, regExp: RegExp, message?: string | Error): void;
|
867 |
+
/**
|
868 |
+
* Expects the `string` input not to match the regular expression.
|
869 |
+
*
|
870 |
+
* ```js
|
871 |
+
* import assert from 'assert/strict';
|
872 |
+
*
|
873 |
+
* assert.doesNotMatch('I will fail', /fail/);
|
874 |
+
* // AssertionError [ERR_ASSERTION]: The input was expected to not match the ...
|
875 |
+
*
|
876 |
+
* assert.doesNotMatch(123, /pass/);
|
877 |
+
* // AssertionError [ERR_ASSERTION]: The "string" argument must be of type string.
|
878 |
+
*
|
879 |
+
* assert.doesNotMatch('I will pass', /different/);
|
880 |
+
* // OK
|
881 |
+
* ```
|
882 |
+
*
|
883 |
+
* If the values do match, or if the `string` argument is of another type than`string`, an `AssertionError` is thrown with a `message` property set equal
|
884 |
+
* to the value of the `message` parameter. If the `message` parameter is
|
885 |
+
* undefined, a default error message is assigned. If the `message` parameter is an
|
886 |
+
* instance of an `Error` then it will be thrown instead of the `AssertionError`.
|
887 |
+
* @since v13.6.0, v12.16.0
|
888 |
+
*/
|
889 |
+
function doesNotMatch(value: string, regExp: RegExp, message?: string | Error): void;
|
890 |
+
const strict: Omit<typeof assert, 'equal' | 'notEqual' | 'deepEqual' | 'notDeepEqual' | 'ok' | 'strictEqual' | 'deepStrictEqual' | 'ifError' | 'strict'> & {
|
891 |
+
(value: unknown, message?: string | Error): asserts value;
|
892 |
+
equal: typeof strictEqual;
|
893 |
+
notEqual: typeof notStrictEqual;
|
894 |
+
deepEqual: typeof deepStrictEqual;
|
895 |
+
notDeepEqual: typeof notDeepStrictEqual;
|
896 |
+
// Mapped types and assertion functions are incompatible?
|
897 |
+
// TS2775: Assertions require every name in the call target
|
898 |
+
// to be declared with an explicit type annotation.
|
899 |
+
ok: typeof ok;
|
900 |
+
strictEqual: typeof strictEqual;
|
901 |
+
deepStrictEqual: typeof deepStrictEqual;
|
902 |
+
ifError: typeof ifError;
|
903 |
+
strict: typeof strict;
|
904 |
+
};
|
905 |
+
}
|
906 |
+
export = assert;
|
907 |
+
}
|
908 |
+
declare module 'node:assert' {
|
909 |
+
import assert = require('assert');
|
910 |
+
export = assert;
|
911 |
+
}
|
igv_component/node_modules/@types/node/assert/strict.d.ts
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
declare module 'assert/strict' {
|
2 |
+
import { strict } from 'node:assert';
|
3 |
+
export = strict;
|
4 |
+
}
|
5 |
+
declare module 'node:assert/strict' {
|
6 |
+
import { strict } from 'node:assert';
|
7 |
+
export = strict;
|
8 |
+
}
|
igv_component/node_modules/@types/node/async_hooks.d.ts
ADDED
@@ -0,0 +1,501 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* The `async_hooks` module provides an API to track asynchronous resources. It
|
3 |
+
* can be accessed using:
|
4 |
+
*
|
5 |
+
* ```js
|
6 |
+
* import async_hooks from 'async_hooks';
|
7 |
+
* ```
|
8 |
+
* @experimental
|
9 |
+
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/async_hooks.js)
|
10 |
+
*/
|
11 |
+
declare module 'async_hooks' {
|
12 |
+
/**
|
13 |
+
* ```js
|
14 |
+
* import { executionAsyncId } from 'async_hooks';
|
15 |
+
*
|
16 |
+
* console.log(executionAsyncId()); // 1 - bootstrap
|
17 |
+
* fs.open(path, 'r', (err, fd) => {
|
18 |
+
* console.log(executionAsyncId()); // 6 - open()
|
19 |
+
* });
|
20 |
+
* ```
|
21 |
+
*
|
22 |
+
* The ID returned from `executionAsyncId()` is related to execution timing, not
|
23 |
+
* causality (which is covered by `triggerAsyncId()`):
|
24 |
+
*
|
25 |
+
* ```js
|
26 |
+
* const server = net.createServer((conn) => {
|
27 |
+
* // Returns the ID of the server, not of the new connection, because the
|
28 |
+
* // callback runs in the execution scope of the server's MakeCallback().
|
29 |
+
* async_hooks.executionAsyncId();
|
30 |
+
*
|
31 |
+
* }).listen(port, () => {
|
32 |
+
* // Returns the ID of a TickObject (process.nextTick()) because all
|
33 |
+
* // callbacks passed to .listen() are wrapped in a nextTick().
|
34 |
+
* async_hooks.executionAsyncId();
|
35 |
+
* });
|
36 |
+
* ```
|
37 |
+
*
|
38 |
+
* Promise contexts may not get precise `executionAsyncIds` by default.
|
39 |
+
* See the section on `promise execution tracking`.
|
40 |
+
* @since v8.1.0
|
41 |
+
* @return The `asyncId` of the current execution context. Useful to track when something calls.
|
42 |
+
*/
|
43 |
+
function executionAsyncId(): number;
|
44 |
+
/**
|
45 |
+
* Resource objects returned by `executionAsyncResource()` are most often internal
|
46 |
+
* Node.js handle objects with undocumented APIs. Using any functions or properties
|
47 |
+
* on the object is likely to crash your application and should be avoided.
|
48 |
+
*
|
49 |
+
* Using `executionAsyncResource()` in the top-level execution context will
|
50 |
+
* return an empty object as there is no handle or request object to use,
|
51 |
+
* but having an object representing the top-level can be helpful.
|
52 |
+
*
|
53 |
+
* ```js
|
54 |
+
* import { open } from 'fs';
|
55 |
+
* import { executionAsyncId, executionAsyncResource } from 'async_hooks';
|
56 |
+
*
|
57 |
+
* console.log(executionAsyncId(), executionAsyncResource()); // 1 {}
|
58 |
+
* open(new URL(import.meta.url), 'r', (err, fd) => {
|
59 |
+
* console.log(executionAsyncId(), executionAsyncResource()); // 7 FSReqWrap
|
60 |
+
* });
|
61 |
+
* ```
|
62 |
+
*
|
63 |
+
* This can be used to implement continuation local storage without the
|
64 |
+
* use of a tracking `Map` to store the metadata:
|
65 |
+
*
|
66 |
+
* ```js
|
67 |
+
* import { createServer } from 'http';
|
68 |
+
* import {
|
69 |
+
* executionAsyncId,
|
70 |
+
* executionAsyncResource,
|
71 |
+
* createHook
|
72 |
+
* } from 'async_hooks';
|
73 |
+
* const sym = Symbol('state'); // Private symbol to avoid pollution
|
74 |
+
*
|
75 |
+
* createHook({
|
76 |
+
* init(asyncId, type, triggerAsyncId, resource) {
|
77 |
+
* const cr = executionAsyncResource();
|
78 |
+
* if (cr) {
|
79 |
+
* resource[sym] = cr[sym];
|
80 |
+
* }
|
81 |
+
* }
|
82 |
+
* }).enable();
|
83 |
+
*
|
84 |
+
* const server = createServer((req, res) => {
|
85 |
+
* executionAsyncResource()[sym] = { state: req.url };
|
86 |
+
* setTimeout(function() {
|
87 |
+
* res.end(JSON.stringify(executionAsyncResource()[sym]));
|
88 |
+
* }, 100);
|
89 |
+
* }).listen(3000);
|
90 |
+
* ```
|
91 |
+
* @since v13.9.0, v12.17.0
|
92 |
+
* @return The resource representing the current execution. Useful to store data within the resource.
|
93 |
+
*/
|
94 |
+
function executionAsyncResource(): object;
|
95 |
+
/**
|
96 |
+
* ```js
|
97 |
+
* const server = net.createServer((conn) => {
|
98 |
+
* // The resource that caused (or triggered) this callback to be called
|
99 |
+
* // was that of the new connection. Thus the return value of triggerAsyncId()
|
100 |
+
* // is the asyncId of "conn".
|
101 |
+
* async_hooks.triggerAsyncId();
|
102 |
+
*
|
103 |
+
* }).listen(port, () => {
|
104 |
+
* // Even though all callbacks passed to .listen() are wrapped in a nextTick()
|
105 |
+
* // the callback itself exists because the call to the server's .listen()
|
106 |
+
* // was made. So the return value would be the ID of the server.
|
107 |
+
* async_hooks.triggerAsyncId();
|
108 |
+
* });
|
109 |
+
* ```
|
110 |
+
*
|
111 |
+
* Promise contexts may not get valid `triggerAsyncId`s by default. See
|
112 |
+
* the section on `promise execution tracking`.
|
113 |
+
* @return The ID of the resource responsible for calling the callback that is currently being executed.
|
114 |
+
*/
|
115 |
+
function triggerAsyncId(): number;
|
116 |
+
interface HookCallbacks {
|
117 |
+
/**
|
118 |
+
* Called when a class is constructed that has the possibility to emit an asynchronous event.
|
119 |
+
* @param asyncId a unique ID for the async resource
|
120 |
+
* @param type the type of the async resource
|
121 |
+
* @param triggerAsyncId the unique ID of the async resource in whose execution context this async resource was created
|
122 |
+
* @param resource reference to the resource representing the async operation, needs to be released during destroy
|
123 |
+
*/
|
124 |
+
init?(asyncId: number, type: string, triggerAsyncId: number, resource: object): void;
|
125 |
+
/**
|
126 |
+
* When an asynchronous operation is initiated or completes a callback is called to notify the user.
|
127 |
+
* The before callback is called just before said callback is executed.
|
128 |
+
* @param asyncId the unique identifier assigned to the resource about to execute the callback.
|
129 |
+
*/
|
130 |
+
before?(asyncId: number): void;
|
131 |
+
/**
|
132 |
+
* Called immediately after the callback specified in before is completed.
|
133 |
+
* @param asyncId the unique identifier assigned to the resource which has executed the callback.
|
134 |
+
*/
|
135 |
+
after?(asyncId: number): void;
|
136 |
+
/**
|
137 |
+
* Called when a promise has resolve() called. This may not be in the same execution id
|
138 |
+
* as the promise itself.
|
139 |
+
* @param asyncId the unique id for the promise that was resolve()d.
|
140 |
+
*/
|
141 |
+
promiseResolve?(asyncId: number): void;
|
142 |
+
/**
|
143 |
+
* Called after the resource corresponding to asyncId is destroyed
|
144 |
+
* @param asyncId a unique ID for the async resource
|
145 |
+
*/
|
146 |
+
destroy?(asyncId: number): void;
|
147 |
+
}
|
148 |
+
interface AsyncHook {
|
149 |
+
/**
|
150 |
+
* Enable the callbacks for a given AsyncHook instance. If no callbacks are provided enabling is a noop.
|
151 |
+
*/
|
152 |
+
enable(): this;
|
153 |
+
/**
|
154 |
+
* Disable the callbacks for a given AsyncHook instance from the global pool of AsyncHook callbacks to be executed. Once a hook has been disabled it will not be called again until enabled.
|
155 |
+
*/
|
156 |
+
disable(): this;
|
157 |
+
}
|
158 |
+
/**
|
159 |
+
* Registers functions to be called for different lifetime events of each async
|
160 |
+
* operation.
|
161 |
+
*
|
162 |
+
* The callbacks `init()`/`before()`/`after()`/`destroy()` are called for the
|
163 |
+
* respective asynchronous event during a resource's lifetime.
|
164 |
+
*
|
165 |
+
* All callbacks are optional. For example, if only resource cleanup needs to
|
166 |
+
* be tracked, then only the `destroy` callback needs to be passed. The
|
167 |
+
* specifics of all functions that can be passed to `callbacks` is in the `Hook Callbacks` section.
|
168 |
+
*
|
169 |
+
* ```js
|
170 |
+
* import { createHook } from 'async_hooks';
|
171 |
+
*
|
172 |
+
* const asyncHook = createHook({
|
173 |
+
* init(asyncId, type, triggerAsyncId, resource) { },
|
174 |
+
* destroy(asyncId) { }
|
175 |
+
* });
|
176 |
+
* ```
|
177 |
+
*
|
178 |
+
* The callbacks will be inherited via the prototype chain:
|
179 |
+
*
|
180 |
+
* ```js
|
181 |
+
* class MyAsyncCallbacks {
|
182 |
+
* init(asyncId, type, triggerAsyncId, resource) { }
|
183 |
+
* destroy(asyncId) {}
|
184 |
+
* }
|
185 |
+
*
|
186 |
+
* class MyAddedCallbacks extends MyAsyncCallbacks {
|
187 |
+
* before(asyncId) { }
|
188 |
+
* after(asyncId) { }
|
189 |
+
* }
|
190 |
+
*
|
191 |
+
* const asyncHook = async_hooks.createHook(new MyAddedCallbacks());
|
192 |
+
* ```
|
193 |
+
*
|
194 |
+
* Because promises are asynchronous resources whose lifecycle is tracked
|
195 |
+
* via the async hooks mechanism, the `init()`, `before()`, `after()`, and`destroy()` callbacks _must not_ be async functions that return promises.
|
196 |
+
* @since v8.1.0
|
197 |
+
* @param callbacks The `Hook Callbacks` to register
|
198 |
+
* @return Instance used for disabling and enabling hooks
|
199 |
+
*/
|
200 |
+
function createHook(callbacks: HookCallbacks): AsyncHook;
|
201 |
+
interface AsyncResourceOptions {
|
202 |
+
/**
|
203 |
+
* The ID of the execution context that created this async event.
|
204 |
+
* @default executionAsyncId()
|
205 |
+
*/
|
206 |
+
triggerAsyncId?: number | undefined;
|
207 |
+
/**
|
208 |
+
* Disables automatic `emitDestroy` when the object is garbage collected.
|
209 |
+
* This usually does not need to be set (even if `emitDestroy` is called
|
210 |
+
* manually), unless the resource's `asyncId` is retrieved and the
|
211 |
+
* sensitive API's `emitDestroy` is called with it.
|
212 |
+
* @default false
|
213 |
+
*/
|
214 |
+
requireManualDestroy?: boolean | undefined;
|
215 |
+
}
|
216 |
+
/**
|
217 |
+
* The class `AsyncResource` is designed to be extended by the embedder's async
|
218 |
+
* resources. Using this, users can easily trigger the lifetime events of their
|
219 |
+
* own resources.
|
220 |
+
*
|
221 |
+
* The `init` hook will trigger when an `AsyncResource` is instantiated.
|
222 |
+
*
|
223 |
+
* The following is an overview of the `AsyncResource` API.
|
224 |
+
*
|
225 |
+
* ```js
|
226 |
+
* import { AsyncResource, executionAsyncId } from 'async_hooks';
|
227 |
+
*
|
228 |
+
* // AsyncResource() is meant to be extended. Instantiating a
|
229 |
+
* // new AsyncResource() also triggers init. If triggerAsyncId is omitted then
|
230 |
+
* // async_hook.executionAsyncId() is used.
|
231 |
+
* const asyncResource = new AsyncResource(
|
232 |
+
* type, { triggerAsyncId: executionAsyncId(), requireManualDestroy: false }
|
233 |
+
* );
|
234 |
+
*
|
235 |
+
* // Run a function in the execution context of the resource. This will
|
236 |
+
* // * establish the context of the resource
|
237 |
+
* // * trigger the AsyncHooks before callbacks
|
238 |
+
* // * call the provided function `fn` with the supplied arguments
|
239 |
+
* // * trigger the AsyncHooks after callbacks
|
240 |
+
* // * restore the original execution context
|
241 |
+
* asyncResource.runInAsyncScope(fn, thisArg, ...args);
|
242 |
+
*
|
243 |
+
* // Call AsyncHooks destroy callbacks.
|
244 |
+
* asyncResource.emitDestroy();
|
245 |
+
*
|
246 |
+
* // Return the unique ID assigned to the AsyncResource instance.
|
247 |
+
* asyncResource.asyncId();
|
248 |
+
*
|
249 |
+
* // Return the trigger ID for the AsyncResource instance.
|
250 |
+
* asyncResource.triggerAsyncId();
|
251 |
+
* ```
|
252 |
+
*/
|
253 |
+
class AsyncResource {
|
254 |
+
/**
|
255 |
+
* AsyncResource() is meant to be extended. Instantiating a
|
256 |
+
* new AsyncResource() also triggers init. If triggerAsyncId is omitted then
|
257 |
+
* async_hook.executionAsyncId() is used.
|
258 |
+
* @param type The type of async event.
|
259 |
+
* @param triggerAsyncId The ID of the execution context that created
|
260 |
+
* this async event (default: `executionAsyncId()`), or an
|
261 |
+
* AsyncResourceOptions object (since v9.3.0)
|
262 |
+
*/
|
263 |
+
constructor(type: string, triggerAsyncId?: number | AsyncResourceOptions);
|
264 |
+
/**
|
265 |
+
* Binds the given function to the current execution context.
|
266 |
+
*
|
267 |
+
* The returned function will have an `asyncResource` property referencing
|
268 |
+
* the `AsyncResource` to which the function is bound.
|
269 |
+
* @since v14.8.0, v12.19.0
|
270 |
+
* @param fn The function to bind to the current execution context.
|
271 |
+
* @param type An optional name to associate with the underlying `AsyncResource`.
|
272 |
+
*/
|
273 |
+
static bind<Func extends (this: ThisArg, ...args: any[]) => any, ThisArg>(
|
274 |
+
fn: Func,
|
275 |
+
type?: string,
|
276 |
+
thisArg?: ThisArg
|
277 |
+
): Func & {
|
278 |
+
asyncResource: AsyncResource;
|
279 |
+
};
|
280 |
+
/**
|
281 |
+
* Binds the given function to execute to this `AsyncResource`'s scope.
|
282 |
+
*
|
283 |
+
* The returned function will have an `asyncResource` property referencing
|
284 |
+
* the `AsyncResource` to which the function is bound.
|
285 |
+
* @since v14.8.0, v12.19.0
|
286 |
+
* @param fn The function to bind to the current `AsyncResource`.
|
287 |
+
*/
|
288 |
+
bind<Func extends (...args: any[]) => any>(
|
289 |
+
fn: Func
|
290 |
+
): Func & {
|
291 |
+
asyncResource: AsyncResource;
|
292 |
+
};
|
293 |
+
/**
|
294 |
+
* Call the provided function with the provided arguments in the execution context
|
295 |
+
* of the async resource. This will establish the context, trigger the AsyncHooks
|
296 |
+
* before callbacks, call the function, trigger the AsyncHooks after callbacks, and
|
297 |
+
* then restore the original execution context.
|
298 |
+
* @since v9.6.0
|
299 |
+
* @param fn The function to call in the execution context of this async resource.
|
300 |
+
* @param thisArg The receiver to be used for the function call.
|
301 |
+
* @param args Optional arguments to pass to the function.
|
302 |
+
*/
|
303 |
+
runInAsyncScope<This, Result>(fn: (this: This, ...args: any[]) => Result, thisArg?: This, ...args: any[]): Result;
|
304 |
+
/**
|
305 |
+
* Call all `destroy` hooks. This should only ever be called once. An error will
|
306 |
+
* be thrown if it is called more than once. This **must** be manually called. If
|
307 |
+
* the resource is left to be collected by the GC then the `destroy` hooks will
|
308 |
+
* never be called.
|
309 |
+
* @return A reference to `asyncResource`.
|
310 |
+
*/
|
311 |
+
emitDestroy(): this;
|
312 |
+
/**
|
313 |
+
* @return The unique `asyncId` assigned to the resource.
|
314 |
+
*/
|
315 |
+
asyncId(): number;
|
316 |
+
/**
|
317 |
+
*
|
318 |
+
* @return The same `triggerAsyncId` that is passed to the `AsyncResource` constructor.
|
319 |
+
*/
|
320 |
+
triggerAsyncId(): number;
|
321 |
+
}
|
322 |
+
/**
|
323 |
+
* This class creates stores that stay coherent through asynchronous operations.
|
324 |
+
*
|
325 |
+
* While you can create your own implementation on top of the `async_hooks` module,`AsyncLocalStorage` should be preferred as it is a performant and memory safe
|
326 |
+
* implementation that involves significant optimizations that are non-obvious to
|
327 |
+
* implement.
|
328 |
+
*
|
329 |
+
* The following example uses `AsyncLocalStorage` to build a simple logger
|
330 |
+
* that assigns IDs to incoming HTTP requests and includes them in messages
|
331 |
+
* logged within each request.
|
332 |
+
*
|
333 |
+
* ```js
|
334 |
+
* import http from 'http';
|
335 |
+
* import { AsyncLocalStorage } from 'async_hooks';
|
336 |
+
*
|
337 |
+
* const asyncLocalStorage = new AsyncLocalStorage();
|
338 |
+
*
|
339 |
+
* function logWithId(msg) {
|
340 |
+
* const id = asyncLocalStorage.getStore();
|
341 |
+
* console.log(`${id !== undefined ? id : '-'}:`, msg);
|
342 |
+
* }
|
343 |
+
*
|
344 |
+
* let idSeq = 0;
|
345 |
+
* http.createServer((req, res) => {
|
346 |
+
* asyncLocalStorage.run(idSeq++, () => {
|
347 |
+
* logWithId('start');
|
348 |
+
* // Imagine any chain of async operations here
|
349 |
+
* setImmediate(() => {
|
350 |
+
* logWithId('finish');
|
351 |
+
* res.end();
|
352 |
+
* });
|
353 |
+
* });
|
354 |
+
* }).listen(8080);
|
355 |
+
*
|
356 |
+
* http.get('http://localhost:8080');
|
357 |
+
* http.get('http://localhost:8080');
|
358 |
+
* // Prints:
|
359 |
+
* // 0: start
|
360 |
+
* // 1: start
|
361 |
+
* // 0: finish
|
362 |
+
* // 1: finish
|
363 |
+
* ```
|
364 |
+
*
|
365 |
+
* Each instance of `AsyncLocalStorage` maintains an independent storage context.
|
366 |
+
* Multiple instances can safely exist simultaneously without risk of interfering
|
367 |
+
* with each other's data.
|
368 |
+
* @since v13.10.0, v12.17.0
|
369 |
+
*/
|
370 |
+
class AsyncLocalStorage<T> {
|
371 |
+
/**
|
372 |
+
* Disables the instance of `AsyncLocalStorage`. All subsequent calls
|
373 |
+
* to `asyncLocalStorage.getStore()` will return `undefined` until`asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()` is called again.
|
374 |
+
*
|
375 |
+
* When calling `asyncLocalStorage.disable()`, all current contexts linked to the
|
376 |
+
* instance will be exited.
|
377 |
+
*
|
378 |
+
* Calling `asyncLocalStorage.disable()` is required before the`asyncLocalStorage` can be garbage collected. This does not apply to stores
|
379 |
+
* provided by the `asyncLocalStorage`, as those objects are garbage collected
|
380 |
+
* along with the corresponding async resources.
|
381 |
+
*
|
382 |
+
* Use this method when the `asyncLocalStorage` is not in use anymore
|
383 |
+
* in the current process.
|
384 |
+
* @since v13.10.0, v12.17.0
|
385 |
+
* @experimental
|
386 |
+
*/
|
387 |
+
disable(): void;
|
388 |
+
/**
|
389 |
+
* Returns the current store.
|
390 |
+
* If called outside of an asynchronous context initialized by
|
391 |
+
* calling `asyncLocalStorage.run()` or `asyncLocalStorage.enterWith()`, it
|
392 |
+
* returns `undefined`.
|
393 |
+
* @since v13.10.0, v12.17.0
|
394 |
+
*/
|
395 |
+
getStore(): T | undefined;
|
396 |
+
/**
|
397 |
+
* Runs a function synchronously within a context and returns its
|
398 |
+
* return value. The store is not accessible outside of the callback function.
|
399 |
+
* The store is accessible to any asynchronous operations created within the
|
400 |
+
* callback.
|
401 |
+
*
|
402 |
+
* The optional `args` are passed to the callback function.
|
403 |
+
*
|
404 |
+
* If the callback function throws an error, the error is thrown by `run()` too.
|
405 |
+
* The stacktrace is not impacted by this call and the context is exited.
|
406 |
+
*
|
407 |
+
* Example:
|
408 |
+
*
|
409 |
+
* ```js
|
410 |
+
* const store = { id: 2 };
|
411 |
+
* try {
|
412 |
+
* asyncLocalStorage.run(store, () => {
|
413 |
+
* asyncLocalStorage.getStore(); // Returns the store object
|
414 |
+
* setTimeout(() => {
|
415 |
+
* asyncLocalStorage.getStore(); // Returns the store object
|
416 |
+
* }, 200);
|
417 |
+
* throw new Error();
|
418 |
+
* });
|
419 |
+
* } catch (e) {
|
420 |
+
* asyncLocalStorage.getStore(); // Returns undefined
|
421 |
+
* // The error will be caught here
|
422 |
+
* }
|
423 |
+
* ```
|
424 |
+
* @since v13.10.0, v12.17.0
|
425 |
+
*/
|
426 |
+
run<R, TArgs extends any[]>(store: T, callback: (...args: TArgs) => R, ...args: TArgs): R;
|
427 |
+
/**
|
428 |
+
* Runs a function synchronously outside of a context and returns its
|
429 |
+
* return value. The store is not accessible within the callback function or
|
430 |
+
* the asynchronous operations created within the callback. Any `getStore()`call done within the callback function will always return `undefined`.
|
431 |
+
*
|
432 |
+
* The optional `args` are passed to the callback function.
|
433 |
+
*
|
434 |
+
* If the callback function throws an error, the error is thrown by `exit()` too.
|
435 |
+
* The stacktrace is not impacted by this call and the context is re-entered.
|
436 |
+
*
|
437 |
+
* Example:
|
438 |
+
*
|
439 |
+
* ```js
|
440 |
+
* // Within a call to run
|
441 |
+
* try {
|
442 |
+
* asyncLocalStorage.getStore(); // Returns the store object or value
|
443 |
+
* asyncLocalStorage.exit(() => {
|
444 |
+
* asyncLocalStorage.getStore(); // Returns undefined
|
445 |
+
* throw new Error();
|
446 |
+
* });
|
447 |
+
* } catch (e) {
|
448 |
+
* asyncLocalStorage.getStore(); // Returns the same object or value
|
449 |
+
* // The error will be caught here
|
450 |
+
* }
|
451 |
+
* ```
|
452 |
+
* @since v13.10.0, v12.17.0
|
453 |
+
* @experimental
|
454 |
+
*/
|
455 |
+
exit<R, TArgs extends any[]>(callback: (...args: TArgs) => R, ...args: TArgs): R;
|
456 |
+
/**
|
457 |
+
* Transitions into the context for the remainder of the current
|
458 |
+
* synchronous execution and then persists the store through any following
|
459 |
+
* asynchronous calls.
|
460 |
+
*
|
461 |
+
* Example:
|
462 |
+
*
|
463 |
+
* ```js
|
464 |
+
* const store = { id: 1 };
|
465 |
+
* // Replaces previous store with the given store object
|
466 |
+
* asyncLocalStorage.enterWith(store);
|
467 |
+
* asyncLocalStorage.getStore(); // Returns the store object
|
468 |
+
* someAsyncOperation(() => {
|
469 |
+
* asyncLocalStorage.getStore(); // Returns the same object
|
470 |
+
* });
|
471 |
+
* ```
|
472 |
+
*
|
473 |
+
* This transition will continue for the _entire_ synchronous execution.
|
474 |
+
* This means that if, for example, the context is entered within an event
|
475 |
+
* handler subsequent event handlers will also run within that context unless
|
476 |
+
* specifically bound to another context with an `AsyncResource`. That is why`run()` should be preferred over `enterWith()` unless there are strong reasons
|
477 |
+
* to use the latter method.
|
478 |
+
*
|
479 |
+
* ```js
|
480 |
+
* const store = { id: 1 };
|
481 |
+
*
|
482 |
+
* emitter.on('my-event', () => {
|
483 |
+
* asyncLocalStorage.enterWith(store);
|
484 |
+
* });
|
485 |
+
* emitter.on('my-event', () => {
|
486 |
+
* asyncLocalStorage.getStore(); // Returns the same object
|
487 |
+
* });
|
488 |
+
*
|
489 |
+
* asyncLocalStorage.getStore(); // Returns undefined
|
490 |
+
* emitter.emit('my-event');
|
491 |
+
* asyncLocalStorage.getStore(); // Returns the same object
|
492 |
+
* ```
|
493 |
+
* @since v13.11.0, v12.17.0
|
494 |
+
* @experimental
|
495 |
+
*/
|
496 |
+
enterWith(store: T): void;
|
497 |
+
}
|
498 |
+
}
|
499 |
+
declare module 'node:async_hooks' {
|
500 |
+
export * from 'async_hooks';
|
501 |
+
}
|
igv_component/node_modules/@types/node/buffer.d.ts
ADDED
The diff for this file is too large to render.
See raw diff
|
|
igv_component/node_modules/@types/node/child_process.d.ts
ADDED
@@ -0,0 +1,1369 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* The `child_process` module provides the ability to spawn subprocesses in
|
3 |
+
* a manner that is similar, but not identical, to [`popen(3)`](http://man7.org/linux/man-pages/man3/popen.3.html). This capability
|
4 |
+
* is primarily provided by the {@link spawn} function:
|
5 |
+
*
|
6 |
+
* ```js
|
7 |
+
* const { spawn } = require('child_process');
|
8 |
+
* const ls = spawn('ls', ['-lh', '/usr']);
|
9 |
+
*
|
10 |
+
* ls.stdout.on('data', (data) => {
|
11 |
+
* console.log(`stdout: ${data}`);
|
12 |
+
* });
|
13 |
+
*
|
14 |
+
* ls.stderr.on('data', (data) => {
|
15 |
+
* console.error(`stderr: ${data}`);
|
16 |
+
* });
|
17 |
+
*
|
18 |
+
* ls.on('close', (code) => {
|
19 |
+
* console.log(`child process exited with code ${code}`);
|
20 |
+
* });
|
21 |
+
* ```
|
22 |
+
*
|
23 |
+
* By default, pipes for `stdin`, `stdout`, and `stderr` are established between
|
24 |
+
* the parent Node.js process and the spawned subprocess. These pipes have
|
25 |
+
* limited (and platform-specific) capacity. If the subprocess writes to
|
26 |
+
* stdout in excess of that limit without the output being captured, the
|
27 |
+
* subprocess blocks waiting for the pipe buffer to accept more data. This is
|
28 |
+
* identical to the behavior of pipes in the shell. Use the `{ stdio: 'ignore' }`option if the output will not be consumed.
|
29 |
+
*
|
30 |
+
* The command lookup is performed using the `options.env.PATH` environment
|
31 |
+
* variable if `env` is in the `options` object. Otherwise, `process.env.PATH` is
|
32 |
+
* used. If `options.env` is set without `PATH`, lookup on Unix is performed
|
33 |
+
* on a default search path search of `/usr/bin:/bin` (see your operating system's
|
34 |
+
* manual for execvpe/execvp), on Windows the current processes environment
|
35 |
+
* variable `PATH` is used.
|
36 |
+
*
|
37 |
+
* On Windows, environment variables are case-insensitive. Node.js
|
38 |
+
* lexicographically sorts the `env` keys and uses the first one that
|
39 |
+
* case-insensitively matches. Only first (in lexicographic order) entry will be
|
40 |
+
* passed to the subprocess. This might lead to issues on Windows when passing
|
41 |
+
* objects to the `env` option that have multiple variants of the same key, such as`PATH` and `Path`.
|
42 |
+
*
|
43 |
+
* The {@link spawn} method spawns the child process asynchronously,
|
44 |
+
* without blocking the Node.js event loop. The {@link spawnSync} function provides equivalent functionality in a synchronous manner that blocks
|
45 |
+
* the event loop until the spawned process either exits or is terminated.
|
46 |
+
*
|
47 |
+
* For convenience, the `child_process` module provides a handful of synchronous
|
48 |
+
* and asynchronous alternatives to {@link spawn} and {@link spawnSync}. Each of these alternatives are implemented on
|
49 |
+
* top of {@link spawn} or {@link spawnSync}.
|
50 |
+
*
|
51 |
+
* * {@link exec}: spawns a shell and runs a command within that
|
52 |
+
* shell, passing the `stdout` and `stderr` to a callback function when
|
53 |
+
* complete.
|
54 |
+
* * {@link execFile}: similar to {@link exec} except
|
55 |
+
* that it spawns the command directly without first spawning a shell by
|
56 |
+
* default.
|
57 |
+
* * {@link fork}: spawns a new Node.js process and invokes a
|
58 |
+
* specified module with an IPC communication channel established that allows
|
59 |
+
* sending messages between parent and child.
|
60 |
+
* * {@link execSync}: a synchronous version of {@link exec} that will block the Node.js event loop.
|
61 |
+
* * {@link execFileSync}: a synchronous version of {@link execFile} that will block the Node.js event loop.
|
62 |
+
*
|
63 |
+
* For certain use cases, such as automating shell scripts, the `synchronous counterparts` may be more convenient. In many cases, however,
|
64 |
+
* the synchronous methods can have significant impact on performance due to
|
65 |
+
* stalling the event loop while spawned processes complete.
|
66 |
+
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/child_process.js)
|
67 |
+
*/
|
68 |
+
declare module 'child_process' {
|
69 |
+
import { ObjectEncodingOptions } from 'node:fs';
|
70 |
+
import { EventEmitter, Abortable } from 'node:events';
|
71 |
+
import * as net from 'node:net';
|
72 |
+
import { Writable, Readable, Stream, Pipe } from 'node:stream';
|
73 |
+
import { URL } from 'node:url';
|
74 |
+
type Serializable = string | object | number | boolean | bigint;
|
75 |
+
type SendHandle = net.Socket | net.Server;
|
76 |
+
/**
|
77 |
+
* Instances of the `ChildProcess` represent spawned child processes.
|
78 |
+
*
|
79 |
+
* Instances of `ChildProcess` are not intended to be created directly. Rather,
|
80 |
+
* use the {@link spawn}, {@link exec},{@link execFile}, or {@link fork} methods to create
|
81 |
+
* instances of `ChildProcess`.
|
82 |
+
* @since v2.2.0
|
83 |
+
*/
|
84 |
+
class ChildProcess extends EventEmitter {
|
85 |
+
/**
|
86 |
+
* A `Writable Stream` that represents the child process's `stdin`.
|
87 |
+
*
|
88 |
+
* If a child process waits to read all of its input, the child will not continue
|
89 |
+
* until this stream has been closed via `end()`.
|
90 |
+
*
|
91 |
+
* If the child was spawned with `stdio[0]` set to anything other than `'pipe'`,
|
92 |
+
* then this will be `null`.
|
93 |
+
*
|
94 |
+
* `subprocess.stdin` is an alias for `subprocess.stdio[0]`. Both properties will
|
95 |
+
* refer to the same value.
|
96 |
+
*
|
97 |
+
* The `subprocess.stdin` property can be `undefined` if the child process could
|
98 |
+
* not be successfully spawned.
|
99 |
+
* @since v0.1.90
|
100 |
+
*/
|
101 |
+
stdin: Writable | null;
|
102 |
+
/**
|
103 |
+
* A `Readable Stream` that represents the child process's `stdout`.
|
104 |
+
*
|
105 |
+
* If the child was spawned with `stdio[1]` set to anything other than `'pipe'`,
|
106 |
+
* then this will be `null`.
|
107 |
+
*
|
108 |
+
* `subprocess.stdout` is an alias for `subprocess.stdio[1]`. Both properties will
|
109 |
+
* refer to the same value.
|
110 |
+
*
|
111 |
+
* ```js
|
112 |
+
* const { spawn } = require('child_process');
|
113 |
+
*
|
114 |
+
* const subprocess = spawn('ls');
|
115 |
+
*
|
116 |
+
* subprocess.stdout.on('data', (data) => {
|
117 |
+
* console.log(`Received chunk ${data}`);
|
118 |
+
* });
|
119 |
+
* ```
|
120 |
+
*
|
121 |
+
* The `subprocess.stdout` property can be `null` if the child process could
|
122 |
+
* not be successfully spawned.
|
123 |
+
* @since v0.1.90
|
124 |
+
*/
|
125 |
+
stdout: Readable | null;
|
126 |
+
/**
|
127 |
+
* A `Readable Stream` that represents the child process's `stderr`.
|
128 |
+
*
|
129 |
+
* If the child was spawned with `stdio[2]` set to anything other than `'pipe'`,
|
130 |
+
* then this will be `null`.
|
131 |
+
*
|
132 |
+
* `subprocess.stderr` is an alias for `subprocess.stdio[2]`. Both properties will
|
133 |
+
* refer to the same value.
|
134 |
+
*
|
135 |
+
* The `subprocess.stderr` property can be `null` if the child process could
|
136 |
+
* not be successfully spawned.
|
137 |
+
* @since v0.1.90
|
138 |
+
*/
|
139 |
+
stderr: Readable | null;
|
140 |
+
/**
|
141 |
+
* The `subprocess.channel` property is a reference to the child's IPC channel. If
|
142 |
+
* no IPC channel currently exists, this property is `undefined`.
|
143 |
+
* @since v7.1.0
|
144 |
+
*/
|
145 |
+
readonly channel?: Pipe | null | undefined;
|
146 |
+
/**
|
147 |
+
* A sparse array of pipes to the child process, corresponding with positions in
|
148 |
+
* the `stdio` option passed to {@link spawn} that have been set
|
149 |
+
* to the value `'pipe'`. `subprocess.stdio[0]`, `subprocess.stdio[1]`, and`subprocess.stdio[2]` are also available as `subprocess.stdin`,`subprocess.stdout`, and `subprocess.stderr`,
|
150 |
+
* respectively.
|
151 |
+
*
|
152 |
+
* In the following example, only the child's fd `1` (stdout) is configured as a
|
153 |
+
* pipe, so only the parent's `subprocess.stdio[1]` is a stream, all other values
|
154 |
+
* in the array are `null`.
|
155 |
+
*
|
156 |
+
* ```js
|
157 |
+
* const assert = require('assert');
|
158 |
+
* const fs = require('fs');
|
159 |
+
* const child_process = require('child_process');
|
160 |
+
*
|
161 |
+
* const subprocess = child_process.spawn('ls', {
|
162 |
+
* stdio: [
|
163 |
+
* 0, // Use parent's stdin for child.
|
164 |
+
* 'pipe', // Pipe child's stdout to parent.
|
165 |
+
* fs.openSync('err.out', 'w'), // Direct child's stderr to a file.
|
166 |
+
* ]
|
167 |
+
* });
|
168 |
+
*
|
169 |
+
* assert.strictEqual(subprocess.stdio[0], null);
|
170 |
+
* assert.strictEqual(subprocess.stdio[0], subprocess.stdin);
|
171 |
+
*
|
172 |
+
* assert(subprocess.stdout);
|
173 |
+
* assert.strictEqual(subprocess.stdio[1], subprocess.stdout);
|
174 |
+
*
|
175 |
+
* assert.strictEqual(subprocess.stdio[2], null);
|
176 |
+
* assert.strictEqual(subprocess.stdio[2], subprocess.stderr);
|
177 |
+
* ```
|
178 |
+
*
|
179 |
+
* The `subprocess.stdio` property can be `undefined` if the child process could
|
180 |
+
* not be successfully spawned.
|
181 |
+
* @since v0.7.10
|
182 |
+
*/
|
183 |
+
readonly stdio: [
|
184 |
+
Writable | null,
|
185 |
+
// stdin
|
186 |
+
Readable | null,
|
187 |
+
// stdout
|
188 |
+
Readable | null,
|
189 |
+
// stderr
|
190 |
+
Readable | Writable | null | undefined,
|
191 |
+
// extra
|
192 |
+
Readable | Writable | null | undefined // extra
|
193 |
+
];
|
194 |
+
/**
|
195 |
+
* The `subprocess.killed` property indicates whether the child process
|
196 |
+
* successfully received a signal from `subprocess.kill()`. The `killed` property
|
197 |
+
* does not indicate that the child process has been terminated.
|
198 |
+
* @since v0.5.10
|
199 |
+
*/
|
200 |
+
readonly killed: boolean;
|
201 |
+
/**
|
202 |
+
* Returns the process identifier (PID) of the child process. If the child process
|
203 |
+
* fails to spawn due to errors, then the value is `undefined` and `error` is
|
204 |
+
* emitted.
|
205 |
+
*
|
206 |
+
* ```js
|
207 |
+
* const { spawn } = require('child_process');
|
208 |
+
* const grep = spawn('grep', ['ssh']);
|
209 |
+
*
|
210 |
+
* console.log(`Spawned child pid: ${grep.pid}`);
|
211 |
+
* grep.stdin.end();
|
212 |
+
* ```
|
213 |
+
* @since v0.1.90
|
214 |
+
*/
|
215 |
+
readonly pid?: number | undefined;
|
216 |
+
/**
|
217 |
+
* The `subprocess.connected` property indicates whether it is still possible to
|
218 |
+
* send and receive messages from a child process. When `subprocess.connected` is`false`, it is no longer possible to send or receive messages.
|
219 |
+
* @since v0.7.2
|
220 |
+
*/
|
221 |
+
readonly connected: boolean;
|
222 |
+
/**
|
223 |
+
* The `subprocess.exitCode` property indicates the exit code of the child process.
|
224 |
+
* If the child process is still running, the field will be `null`.
|
225 |
+
*/
|
226 |
+
readonly exitCode: number | null;
|
227 |
+
/**
|
228 |
+
* The `subprocess.signalCode` property indicates the signal received by
|
229 |
+
* the child process if any, else `null`.
|
230 |
+
*/
|
231 |
+
readonly signalCode: NodeJS.Signals | null;
|
232 |
+
/**
|
233 |
+
* The `subprocess.spawnargs` property represents the full list of command-line
|
234 |
+
* arguments the child process was launched with.
|
235 |
+
*/
|
236 |
+
readonly spawnargs: string[];
|
237 |
+
/**
|
238 |
+
* The `subprocess.spawnfile` property indicates the executable file name of
|
239 |
+
* the child process that is launched.
|
240 |
+
*
|
241 |
+
* For {@link fork}, its value will be equal to `process.execPath`.
|
242 |
+
* For {@link spawn}, its value will be the name of
|
243 |
+
* the executable file.
|
244 |
+
* For {@link exec}, its value will be the name of the shell
|
245 |
+
* in which the child process is launched.
|
246 |
+
*/
|
247 |
+
readonly spawnfile: string;
|
248 |
+
/**
|
249 |
+
* The `subprocess.kill()` method sends a signal to the child process. If no
|
250 |
+
* argument is given, the process will be sent the `'SIGTERM'` signal. See [`signal(7)`](http://man7.org/linux/man-pages/man7/signal.7.html) for a list of available signals. This function
|
251 |
+
* returns `true` if [`kill(2)`](http://man7.org/linux/man-pages/man2/kill.2.html) succeeds, and `false` otherwise.
|
252 |
+
*
|
253 |
+
* ```js
|
254 |
+
* const { spawn } = require('child_process');
|
255 |
+
* const grep = spawn('grep', ['ssh']);
|
256 |
+
*
|
257 |
+
* grep.on('close', (code, signal) => {
|
258 |
+
* console.log(
|
259 |
+
* `child process terminated due to receipt of signal ${signal}`);
|
260 |
+
* });
|
261 |
+
*
|
262 |
+
* // Send SIGHUP to process.
|
263 |
+
* grep.kill('SIGHUP');
|
264 |
+
* ```
|
265 |
+
*
|
266 |
+
* The `ChildProcess` object may emit an `'error'` event if the signal
|
267 |
+
* cannot be delivered. Sending a signal to a child process that has already exited
|
268 |
+
* is not an error but may have unforeseen consequences. Specifically, if the
|
269 |
+
* process identifier (PID) has been reassigned to another process, the signal will
|
270 |
+
* be delivered to that process instead which can have unexpected results.
|
271 |
+
*
|
272 |
+
* While the function is called `kill`, the signal delivered to the child process
|
273 |
+
* may not actually terminate the process.
|
274 |
+
*
|
275 |
+
* See [`kill(2)`](http://man7.org/linux/man-pages/man2/kill.2.html) for reference.
|
276 |
+
*
|
277 |
+
* On Windows, where POSIX signals do not exist, the `signal` argument will be
|
278 |
+
* ignored, and the process will be killed forcefully and abruptly (similar to`'SIGKILL'`).
|
279 |
+
* See `Signal Events` for more details.
|
280 |
+
*
|
281 |
+
* On Linux, child processes of child processes will not be terminated
|
282 |
+
* when attempting to kill their parent. This is likely to happen when running a
|
283 |
+
* new process in a shell or with the use of the `shell` option of `ChildProcess`:
|
284 |
+
*
|
285 |
+
* ```js
|
286 |
+
* 'use strict';
|
287 |
+
* const { spawn } = require('child_process');
|
288 |
+
*
|
289 |
+
* const subprocess = spawn(
|
290 |
+
* 'sh',
|
291 |
+
* [
|
292 |
+
* '-c',
|
293 |
+
* `node -e "setInterval(() => {
|
294 |
+
* console.log(process.pid, 'is alive')
|
295 |
+
* }, 500);"`,
|
296 |
+
* ], {
|
297 |
+
* stdio: ['inherit', 'inherit', 'inherit']
|
298 |
+
* }
|
299 |
+
* );
|
300 |
+
*
|
301 |
+
* setTimeout(() => {
|
302 |
+
* subprocess.kill(); // Does not terminate the Node.js process in the shell.
|
303 |
+
* }, 2000);
|
304 |
+
* ```
|
305 |
+
* @since v0.1.90
|
306 |
+
*/
|
307 |
+
kill(signal?: NodeJS.Signals | number): boolean;
|
308 |
+
/**
|
309 |
+
* When an IPC channel has been established between the parent and child (
|
310 |
+
* i.e. when using {@link fork}), the `subprocess.send()` method can
|
311 |
+
* be used to send messages to the child process. When the child process is a
|
312 |
+
* Node.js instance, these messages can be received via the `'message'` event.
|
313 |
+
*
|
314 |
+
* The message goes through serialization and parsing. The resulting
|
315 |
+
* message might not be the same as what is originally sent.
|
316 |
+
*
|
317 |
+
* For example, in the parent script:
|
318 |
+
*
|
319 |
+
* ```js
|
320 |
+
* const cp = require('child_process');
|
321 |
+
* const n = cp.fork(`${__dirname}/sub.js`);
|
322 |
+
*
|
323 |
+
* n.on('message', (m) => {
|
324 |
+
* console.log('PARENT got message:', m);
|
325 |
+
* });
|
326 |
+
*
|
327 |
+
* // Causes the child to print: CHILD got message: { hello: 'world' }
|
328 |
+
* n.send({ hello: 'world' });
|
329 |
+
* ```
|
330 |
+
*
|
331 |
+
* And then the child script, `'sub.js'` might look like this:
|
332 |
+
*
|
333 |
+
* ```js
|
334 |
+
* process.on('message', (m) => {
|
335 |
+
* console.log('CHILD got message:', m);
|
336 |
+
* });
|
337 |
+
*
|
338 |
+
* // Causes the parent to print: PARENT got message: { foo: 'bar', baz: null }
|
339 |
+
* process.send({ foo: 'bar', baz: NaN });
|
340 |
+
* ```
|
341 |
+
*
|
342 |
+
* Child Node.js processes will have a `process.send()` method of their own
|
343 |
+
* that allows the child to send messages back to the parent.
|
344 |
+
*
|
345 |
+
* There is a special case when sending a `{cmd: 'NODE_foo'}` message. Messages
|
346 |
+
* containing a `NODE_` prefix in the `cmd` property are reserved for use within
|
347 |
+
* Node.js core and will not be emitted in the child's `'message'` event. Rather, such messages are emitted using the`'internalMessage'` event and are consumed internally by Node.js.
|
348 |
+
* Applications should avoid using such messages or listening for`'internalMessage'` events as it is subject to change without notice.
|
349 |
+
*
|
350 |
+
* The optional `sendHandle` argument that may be passed to `subprocess.send()` is
|
351 |
+
* for passing a TCP server or socket object to the child process. The child will
|
352 |
+
* receive the object as the second argument passed to the callback function
|
353 |
+
* registered on the `'message'` event. Any data that is received
|
354 |
+
* and buffered in the socket will not be sent to the child.
|
355 |
+
*
|
356 |
+
* The optional `callback` is a function that is invoked after the message is
|
357 |
+
* sent but before the child may have received it. The function is called with a
|
358 |
+
* single argument: `null` on success, or an `Error` object on failure.
|
359 |
+
*
|
360 |
+
* If no `callback` function is provided and the message cannot be sent, an`'error'` event will be emitted by the `ChildProcess` object. This can
|
361 |
+
* happen, for instance, when the child process has already exited.
|
362 |
+
*
|
363 |
+
* `subprocess.send()` will return `false` if the channel has closed or when the
|
364 |
+
* backlog of unsent messages exceeds a threshold that makes it unwise to send
|
365 |
+
* more. Otherwise, the method returns `true`. The `callback` function can be
|
366 |
+
* used to implement flow control.
|
367 |
+
*
|
368 |
+
* #### Example: sending a server object
|
369 |
+
*
|
370 |
+
* The `sendHandle` argument can be used, for instance, to pass the handle of
|
371 |
+
* a TCP server object to the child process as illustrated in the example below:
|
372 |
+
*
|
373 |
+
* ```js
|
374 |
+
* const subprocess = require('child_process').fork('subprocess.js');
|
375 |
+
*
|
376 |
+
* // Open up the server object and send the handle.
|
377 |
+
* const server = require('net').createServer();
|
378 |
+
* server.on('connection', (socket) => {
|
379 |
+
* socket.end('handled by parent');
|
380 |
+
* });
|
381 |
+
* server.listen(1337, () => {
|
382 |
+
* subprocess.send('server', server);
|
383 |
+
* });
|
384 |
+
* ```
|
385 |
+
*
|
386 |
+
* The child would then receive the server object as:
|
387 |
+
*
|
388 |
+
* ```js
|
389 |
+
* process.on('message', (m, server) => {
|
390 |
+
* if (m === 'server') {
|
391 |
+
* server.on('connection', (socket) => {
|
392 |
+
* socket.end('handled by child');
|
393 |
+
* });
|
394 |
+
* }
|
395 |
+
* });
|
396 |
+
* ```
|
397 |
+
*
|
398 |
+
* Once the server is now shared between the parent and child, some connections
|
399 |
+
* can be handled by the parent and some by the child.
|
400 |
+
*
|
401 |
+
* While the example above uses a server created using the `net` module, `dgram`module servers use exactly the same workflow with the exceptions of listening on
|
402 |
+
* a `'message'` event instead of `'connection'` and using `server.bind()` instead
|
403 |
+
* of `server.listen()`. This is, however, currently only supported on Unix
|
404 |
+
* platforms.
|
405 |
+
*
|
406 |
+
* #### Example: sending a socket object
|
407 |
+
*
|
408 |
+
* Similarly, the `sendHandler` argument can be used to pass the handle of a
|
409 |
+
* socket to the child process. The example below spawns two children that each
|
410 |
+
* handle connections with "normal" or "special" priority:
|
411 |
+
*
|
412 |
+
* ```js
|
413 |
+
* const { fork } = require('child_process');
|
414 |
+
* const normal = fork('subprocess.js', ['normal']);
|
415 |
+
* const special = fork('subprocess.js', ['special']);
|
416 |
+
*
|
417 |
+
* // Open up the server and send sockets to child. Use pauseOnConnect to prevent
|
418 |
+
* // the sockets from being read before they are sent to the child process.
|
419 |
+
* const server = require('net').createServer({ pauseOnConnect: true });
|
420 |
+
* server.on('connection', (socket) => {
|
421 |
+
*
|
422 |
+
* // If this is special priority...
|
423 |
+
* if (socket.remoteAddress === '74.125.127.100') {
|
424 |
+
* special.send('socket', socket);
|
425 |
+
* return;
|
426 |
+
* }
|
427 |
+
* // This is normal priority.
|
428 |
+
* normal.send('socket', socket);
|
429 |
+
* });
|
430 |
+
* server.listen(1337);
|
431 |
+
* ```
|
432 |
+
*
|
433 |
+
* The `subprocess.js` would receive the socket handle as the second argument
|
434 |
+
* passed to the event callback function:
|
435 |
+
*
|
436 |
+
* ```js
|
437 |
+
* process.on('message', (m, socket) => {
|
438 |
+
* if (m === 'socket') {
|
439 |
+
* if (socket) {
|
440 |
+
* // Check that the client socket exists.
|
441 |
+
* // It is possible for the socket to be closed between the time it is
|
442 |
+
* // sent and the time it is received in the child process.
|
443 |
+
* socket.end(`Request handled with ${process.argv[2]} priority`);
|
444 |
+
* }
|
445 |
+
* }
|
446 |
+
* });
|
447 |
+
* ```
|
448 |
+
*
|
449 |
+
* Do not use `.maxConnections` on a socket that has been passed to a subprocess.
|
450 |
+
* The parent cannot track when the socket is destroyed.
|
451 |
+
*
|
452 |
+
* Any `'message'` handlers in the subprocess should verify that `socket` exists,
|
453 |
+
* as the connection may have been closed during the time it takes to send the
|
454 |
+
* connection to the child.
|
455 |
+
* @since v0.5.9
|
456 |
+
* @param options The `options` argument, if present, is an object used to parameterize the sending of certain types of handles. `options` supports the following properties:
|
457 |
+
*/
|
458 |
+
send(message: Serializable, callback?: (error: Error | null) => void): boolean;
|
459 |
+
send(message: Serializable, sendHandle?: SendHandle, callback?: (error: Error | null) => void): boolean;
|
460 |
+
send(message: Serializable, sendHandle?: SendHandle, options?: MessageOptions, callback?: (error: Error | null) => void): boolean;
|
461 |
+
/**
|
462 |
+
* Closes the IPC channel between parent and child, allowing the child to exit
|
463 |
+
* gracefully once there are no other connections keeping it alive. After calling
|
464 |
+
* this method the `subprocess.connected` and `process.connected` properties in
|
465 |
+
* both the parent and child (respectively) will be set to `false`, and it will be
|
466 |
+
* no longer possible to pass messages between the processes.
|
467 |
+
*
|
468 |
+
* The `'disconnect'` event will be emitted when there are no messages in the
|
469 |
+
* process of being received. This will most often be triggered immediately after
|
470 |
+
* calling `subprocess.disconnect()`.
|
471 |
+
*
|
472 |
+
* When the child process is a Node.js instance (e.g. spawned using {@link fork}), the `process.disconnect()` method can be invoked
|
473 |
+
* within the child process to close the IPC channel as well.
|
474 |
+
* @since v0.7.2
|
475 |
+
*/
|
476 |
+
disconnect(): void;
|
477 |
+
/**
|
478 |
+
* By default, the parent will wait for the detached child to exit. To prevent the
|
479 |
+
* parent from waiting for a given `subprocess` to exit, use the`subprocess.unref()` method. Doing so will cause the parent's event loop to not
|
480 |
+
* include the child in its reference count, allowing the parent to exit
|
481 |
+
* independently of the child, unless there is an established IPC channel between
|
482 |
+
* the child and the parent.
|
483 |
+
*
|
484 |
+
* ```js
|
485 |
+
* const { spawn } = require('child_process');
|
486 |
+
*
|
487 |
+
* const subprocess = spawn(process.argv[0], ['child_program.js'], {
|
488 |
+
* detached: true,
|
489 |
+
* stdio: 'ignore'
|
490 |
+
* });
|
491 |
+
*
|
492 |
+
* subprocess.unref();
|
493 |
+
* ```
|
494 |
+
* @since v0.7.10
|
495 |
+
*/
|
496 |
+
unref(): void;
|
497 |
+
/**
|
498 |
+
* Calling `subprocess.ref()` after making a call to `subprocess.unref()` will
|
499 |
+
* restore the removed reference count for the child process, forcing the parent
|
500 |
+
* to wait for the child to exit before exiting itself.
|
501 |
+
*
|
502 |
+
* ```js
|
503 |
+
* const { spawn } = require('child_process');
|
504 |
+
*
|
505 |
+
* const subprocess = spawn(process.argv[0], ['child_program.js'], {
|
506 |
+
* detached: true,
|
507 |
+
* stdio: 'ignore'
|
508 |
+
* });
|
509 |
+
*
|
510 |
+
* subprocess.unref();
|
511 |
+
* subprocess.ref();
|
512 |
+
* ```
|
513 |
+
* @since v0.7.10
|
514 |
+
*/
|
515 |
+
ref(): void;
|
516 |
+
/**
|
517 |
+
* events.EventEmitter
|
518 |
+
* 1. close
|
519 |
+
* 2. disconnect
|
520 |
+
* 3. error
|
521 |
+
* 4. exit
|
522 |
+
* 5. message
|
523 |
+
* 6. spawn
|
524 |
+
*/
|
525 |
+
addListener(event: string, listener: (...args: any[]) => void): this;
|
526 |
+
addListener(event: 'close', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
|
527 |
+
addListener(event: 'disconnect', listener: () => void): this;
|
528 |
+
addListener(event: 'error', listener: (err: Error) => void): this;
|
529 |
+
addListener(event: 'exit', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
|
530 |
+
addListener(event: 'message', listener: (message: Serializable, sendHandle: SendHandle) => void): this;
|
531 |
+
addListener(event: 'spawn', listener: () => void): this;
|
532 |
+
emit(event: string | symbol, ...args: any[]): boolean;
|
533 |
+
emit(event: 'close', code: number | null, signal: NodeJS.Signals | null): boolean;
|
534 |
+
emit(event: 'disconnect'): boolean;
|
535 |
+
emit(event: 'error', err: Error): boolean;
|
536 |
+
emit(event: 'exit', code: number | null, signal: NodeJS.Signals | null): boolean;
|
537 |
+
emit(event: 'message', message: Serializable, sendHandle: SendHandle): boolean;
|
538 |
+
emit(event: 'spawn', listener: () => void): boolean;
|
539 |
+
on(event: string, listener: (...args: any[]) => void): this;
|
540 |
+
on(event: 'close', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
|
541 |
+
on(event: 'disconnect', listener: () => void): this;
|
542 |
+
on(event: 'error', listener: (err: Error) => void): this;
|
543 |
+
on(event: 'exit', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
|
544 |
+
on(event: 'message', listener: (message: Serializable, sendHandle: SendHandle) => void): this;
|
545 |
+
on(event: 'spawn', listener: () => void): this;
|
546 |
+
once(event: string, listener: (...args: any[]) => void): this;
|
547 |
+
once(event: 'close', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
|
548 |
+
once(event: 'disconnect', listener: () => void): this;
|
549 |
+
once(event: 'error', listener: (err: Error) => void): this;
|
550 |
+
once(event: 'exit', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
|
551 |
+
once(event: 'message', listener: (message: Serializable, sendHandle: SendHandle) => void): this;
|
552 |
+
once(event: 'spawn', listener: () => void): this;
|
553 |
+
prependListener(event: string, listener: (...args: any[]) => void): this;
|
554 |
+
prependListener(event: 'close', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
|
555 |
+
prependListener(event: 'disconnect', listener: () => void): this;
|
556 |
+
prependListener(event: 'error', listener: (err: Error) => void): this;
|
557 |
+
prependListener(event: 'exit', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
|
558 |
+
prependListener(event: 'message', listener: (message: Serializable, sendHandle: SendHandle) => void): this;
|
559 |
+
prependListener(event: 'spawn', listener: () => void): this;
|
560 |
+
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
561 |
+
prependOnceListener(event: 'close', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
|
562 |
+
prependOnceListener(event: 'disconnect', listener: () => void): this;
|
563 |
+
prependOnceListener(event: 'error', listener: (err: Error) => void): this;
|
564 |
+
prependOnceListener(event: 'exit', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;
|
565 |
+
prependOnceListener(event: 'message', listener: (message: Serializable, sendHandle: SendHandle) => void): this;
|
566 |
+
prependOnceListener(event: 'spawn', listener: () => void): this;
|
567 |
+
}
|
568 |
+
// return this object when stdio option is undefined or not specified
|
569 |
+
interface ChildProcessWithoutNullStreams extends ChildProcess {
|
570 |
+
stdin: Writable;
|
571 |
+
stdout: Readable;
|
572 |
+
stderr: Readable;
|
573 |
+
readonly stdio: [
|
574 |
+
Writable,
|
575 |
+
Readable,
|
576 |
+
Readable,
|
577 |
+
// stderr
|
578 |
+
Readable | Writable | null | undefined,
|
579 |
+
// extra, no modification
|
580 |
+
Readable | Writable | null | undefined // extra, no modification
|
581 |
+
];
|
582 |
+
}
|
583 |
+
// return this object when stdio option is a tuple of 3
|
584 |
+
interface ChildProcessByStdio<I extends null | Writable, O extends null | Readable, E extends null | Readable> extends ChildProcess {
|
585 |
+
stdin: I;
|
586 |
+
stdout: O;
|
587 |
+
stderr: E;
|
588 |
+
readonly stdio: [
|
589 |
+
I,
|
590 |
+
O,
|
591 |
+
E,
|
592 |
+
Readable | Writable | null | undefined,
|
593 |
+
// extra, no modification
|
594 |
+
Readable | Writable | null | undefined // extra, no modification
|
595 |
+
];
|
596 |
+
}
|
597 |
+
interface MessageOptions {
|
598 |
+
keepOpen?: boolean | undefined;
|
599 |
+
}
|
600 |
+
type IOType = 'overlapped' | 'pipe' | 'ignore' | 'inherit';
|
601 |
+
type StdioOptions = IOType | Array<IOType | 'ipc' | Stream | number | null | undefined>;
|
602 |
+
type SerializationType = 'json' | 'advanced';
|
603 |
+
interface MessagingOptions extends Abortable {
|
604 |
+
/**
|
605 |
+
* Specify the kind of serialization used for sending messages between processes.
|
606 |
+
* @default 'json'
|
607 |
+
*/
|
608 |
+
serialization?: SerializationType | undefined;
|
609 |
+
/**
|
610 |
+
* The signal value to be used when the spawned process will be killed by the abort signal.
|
611 |
+
* @default 'SIGTERM'
|
612 |
+
*/
|
613 |
+
killSignal?: NodeJS.Signals | number | undefined;
|
614 |
+
/**
|
615 |
+
* In milliseconds the maximum amount of time the process is allowed to run.
|
616 |
+
*/
|
617 |
+
timeout?: number | undefined;
|
618 |
+
}
|
619 |
+
interface ProcessEnvOptions {
|
620 |
+
uid?: number | undefined;
|
621 |
+
gid?: number | undefined;
|
622 |
+
cwd?: string | URL | undefined;
|
623 |
+
env?: NodeJS.ProcessEnv | undefined;
|
624 |
+
}
|
625 |
+
interface CommonOptions extends ProcessEnvOptions {
|
626 |
+
/**
|
627 |
+
* @default true
|
628 |
+
*/
|
629 |
+
windowsHide?: boolean | undefined;
|
630 |
+
/**
|
631 |
+
* @default 0
|
632 |
+
*/
|
633 |
+
timeout?: number | undefined;
|
634 |
+
}
|
635 |
+
interface CommonSpawnOptions extends CommonOptions, MessagingOptions, Abortable {
|
636 |
+
argv0?: string | undefined;
|
637 |
+
stdio?: StdioOptions | undefined;
|
638 |
+
shell?: boolean | string | undefined;
|
639 |
+
windowsVerbatimArguments?: boolean | undefined;
|
640 |
+
}
|
641 |
+
interface SpawnOptions extends CommonSpawnOptions {
|
642 |
+
detached?: boolean | undefined;
|
643 |
+
}
|
644 |
+
interface SpawnOptionsWithoutStdio extends SpawnOptions {
|
645 |
+
stdio?: StdioPipeNamed | StdioPipe[] | undefined;
|
646 |
+
}
|
647 |
+
type StdioNull = 'inherit' | 'ignore' | Stream;
|
648 |
+
type StdioPipeNamed = 'pipe' | 'overlapped';
|
649 |
+
type StdioPipe = undefined | null | StdioPipeNamed;
|
650 |
+
interface SpawnOptionsWithStdioTuple<Stdin extends StdioNull | StdioPipe, Stdout extends StdioNull | StdioPipe, Stderr extends StdioNull | StdioPipe> extends SpawnOptions {
|
651 |
+
stdio: [Stdin, Stdout, Stderr];
|
652 |
+
}
|
653 |
+
/**
|
654 |
+
* The `child_process.spawn()` method spawns a new process using the given`command`, with command-line arguments in `args`. If omitted, `args` defaults
|
655 |
+
* to an empty array.
|
656 |
+
*
|
657 |
+
* **If the `shell` option is enabled, do not pass unsanitized user input to this**
|
658 |
+
* **function. Any input containing shell metacharacters may be used to trigger**
|
659 |
+
* **arbitrary command execution.**
|
660 |
+
*
|
661 |
+
* A third argument may be used to specify additional options, with these defaults:
|
662 |
+
*
|
663 |
+
* ```js
|
664 |
+
* const defaults = {
|
665 |
+
* cwd: undefined,
|
666 |
+
* env: process.env
|
667 |
+
* };
|
668 |
+
* ```
|
669 |
+
*
|
670 |
+
* Use `cwd` to specify the working directory from which the process is spawned.
|
671 |
+
* If not given, the default is to inherit the current working directory. If given,
|
672 |
+
* but the path does not exist, the child process emits an `ENOENT` error
|
673 |
+
* and exits immediately. `ENOENT` is also emitted when the command
|
674 |
+
* does not exist.
|
675 |
+
*
|
676 |
+
* Use `env` to specify environment variables that will be visible to the new
|
677 |
+
* process, the default is `process.env`.
|
678 |
+
*
|
679 |
+
* `undefined` values in `env` will be ignored.
|
680 |
+
*
|
681 |
+
* Example of running `ls -lh /usr`, capturing `stdout`, `stderr`, and the
|
682 |
+
* exit code:
|
683 |
+
*
|
684 |
+
* ```js
|
685 |
+
* const { spawn } = require('child_process');
|
686 |
+
* const ls = spawn('ls', ['-lh', '/usr']);
|
687 |
+
*
|
688 |
+
* ls.stdout.on('data', (data) => {
|
689 |
+
* console.log(`stdout: ${data}`);
|
690 |
+
* });
|
691 |
+
*
|
692 |
+
* ls.stderr.on('data', (data) => {
|
693 |
+
* console.error(`stderr: ${data}`);
|
694 |
+
* });
|
695 |
+
*
|
696 |
+
* ls.on('close', (code) => {
|
697 |
+
* console.log(`child process exited with code ${code}`);
|
698 |
+
* });
|
699 |
+
* ```
|
700 |
+
*
|
701 |
+
* Example: A very elaborate way to run `ps ax | grep ssh`
|
702 |
+
*
|
703 |
+
* ```js
|
704 |
+
* const { spawn } = require('child_process');
|
705 |
+
* const ps = spawn('ps', ['ax']);
|
706 |
+
* const grep = spawn('grep', ['ssh']);
|
707 |
+
*
|
708 |
+
* ps.stdout.on('data', (data) => {
|
709 |
+
* grep.stdin.write(data);
|
710 |
+
* });
|
711 |
+
*
|
712 |
+
* ps.stderr.on('data', (data) => {
|
713 |
+
* console.error(`ps stderr: ${data}`);
|
714 |
+
* });
|
715 |
+
*
|
716 |
+
* ps.on('close', (code) => {
|
717 |
+
* if (code !== 0) {
|
718 |
+
* console.log(`ps process exited with code ${code}`);
|
719 |
+
* }
|
720 |
+
* grep.stdin.end();
|
721 |
+
* });
|
722 |
+
*
|
723 |
+
* grep.stdout.on('data', (data) => {
|
724 |
+
* console.log(data.toString());
|
725 |
+
* });
|
726 |
+
*
|
727 |
+
* grep.stderr.on('data', (data) => {
|
728 |
+
* console.error(`grep stderr: ${data}`);
|
729 |
+
* });
|
730 |
+
*
|
731 |
+
* grep.on('close', (code) => {
|
732 |
+
* if (code !== 0) {
|
733 |
+
* console.log(`grep process exited with code ${code}`);
|
734 |
+
* }
|
735 |
+
* });
|
736 |
+
* ```
|
737 |
+
*
|
738 |
+
* Example of checking for failed `spawn`:
|
739 |
+
*
|
740 |
+
* ```js
|
741 |
+
* const { spawn } = require('child_process');
|
742 |
+
* const subprocess = spawn('bad_command');
|
743 |
+
*
|
744 |
+
* subprocess.on('error', (err) => {
|
745 |
+
* console.error('Failed to start subprocess.');
|
746 |
+
* });
|
747 |
+
* ```
|
748 |
+
*
|
749 |
+
* Certain platforms (macOS, Linux) will use the value of `argv[0]` for the process
|
750 |
+
* title while others (Windows, SunOS) will use `command`.
|
751 |
+
*
|
752 |
+
* Node.js currently overwrites `argv[0]` with `process.execPath` on startup, so`process.argv[0]` in a Node.js child process will not match the `argv0`parameter passed to `spawn` from the parent,
|
753 |
+
* retrieve it with the`process.argv0` property instead.
|
754 |
+
*
|
755 |
+
* If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except
|
756 |
+
* the error passed to the callback will be an `AbortError`:
|
757 |
+
*
|
758 |
+
* ```js
|
759 |
+
* const { spawn } = require('child_process');
|
760 |
+
* const controller = new AbortController();
|
761 |
+
* const { signal } = controller;
|
762 |
+
* const grep = spawn('grep', ['ssh'], { signal });
|
763 |
+
* grep.on('error', (err) => {
|
764 |
+
* // This will be called with err being an AbortError if the controller aborts
|
765 |
+
* });
|
766 |
+
* controller.abort(); // Stops the child process
|
767 |
+
* ```
|
768 |
+
* @since v0.1.90
|
769 |
+
* @param command The command to run.
|
770 |
+
* @param args List of string arguments.
|
771 |
+
*/
|
772 |
+
function spawn(command: string, options?: SpawnOptionsWithoutStdio): ChildProcessWithoutNullStreams;
|
773 |
+
function spawn(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>): ChildProcessByStdio<Writable, Readable, Readable>;
|
774 |
+
function spawn(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>): ChildProcessByStdio<Writable, Readable, null>;
|
775 |
+
function spawn(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>): ChildProcessByStdio<Writable, null, Readable>;
|
776 |
+
function spawn(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): ChildProcessByStdio<null, Readable, Readable>;
|
777 |
+
function spawn(command: string, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>): ChildProcessByStdio<Writable, null, null>;
|
778 |
+
function spawn(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>): ChildProcessByStdio<null, Readable, null>;
|
779 |
+
function spawn(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>): ChildProcessByStdio<null, null, Readable>;
|
780 |
+
function spawn(command: string, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>): ChildProcessByStdio<null, null, null>;
|
781 |
+
function spawn(command: string, options: SpawnOptions): ChildProcess;
|
782 |
+
// overloads of spawn with 'args'
|
783 |
+
function spawn(command: string, args?: ReadonlyArray<string>, options?: SpawnOptionsWithoutStdio): ChildProcessWithoutNullStreams;
|
784 |
+
function spawn(command: string, args: ReadonlyArray<string>, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>): ChildProcessByStdio<Writable, Readable, Readable>;
|
785 |
+
function spawn(command: string, args: ReadonlyArray<string>, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>): ChildProcessByStdio<Writable, Readable, null>;
|
786 |
+
function spawn(command: string, args: ReadonlyArray<string>, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>): ChildProcessByStdio<Writable, null, Readable>;
|
787 |
+
function spawn(command: string, args: ReadonlyArray<string>, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>): ChildProcessByStdio<null, Readable, Readable>;
|
788 |
+
function spawn(command: string, args: ReadonlyArray<string>, options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>): ChildProcessByStdio<Writable, null, null>;
|
789 |
+
function spawn(command: string, args: ReadonlyArray<string>, options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>): ChildProcessByStdio<null, Readable, null>;
|
790 |
+
function spawn(command: string, args: ReadonlyArray<string>, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>): ChildProcessByStdio<null, null, Readable>;
|
791 |
+
function spawn(command: string, args: ReadonlyArray<string>, options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>): ChildProcessByStdio<null, null, null>;
|
792 |
+
function spawn(command: string, args: ReadonlyArray<string>, options: SpawnOptions): ChildProcess;
|
793 |
+
interface ExecOptions extends CommonOptions {
|
794 |
+
shell?: string | undefined;
|
795 |
+
signal?: AbortSignal | undefined;
|
796 |
+
maxBuffer?: number | undefined;
|
797 |
+
killSignal?: NodeJS.Signals | number | undefined;
|
798 |
+
}
|
799 |
+
interface ExecOptionsWithStringEncoding extends ExecOptions {
|
800 |
+
encoding: BufferEncoding;
|
801 |
+
}
|
802 |
+
interface ExecOptionsWithBufferEncoding extends ExecOptions {
|
803 |
+
encoding: BufferEncoding | null; // specify `null`.
|
804 |
+
}
|
805 |
+
interface ExecException extends Error {
|
806 |
+
cmd?: string | undefined;
|
807 |
+
killed?: boolean | undefined;
|
808 |
+
code?: number | undefined;
|
809 |
+
signal?: NodeJS.Signals | undefined;
|
810 |
+
}
|
811 |
+
/**
|
812 |
+
* Spawns a shell then executes the `command` within that shell, buffering any
|
813 |
+
* generated output. The `command` string passed to the exec function is processed
|
814 |
+
* directly by the shell and special characters (vary based on [shell](https://en.wikipedia.org/wiki/List_of_command-line_interpreters))
|
815 |
+
* need to be dealt with accordingly:
|
816 |
+
*
|
817 |
+
* ```js
|
818 |
+
* const { exec } = require('child_process');
|
819 |
+
*
|
820 |
+
* exec('"/path/to/test file/test.sh" arg1 arg2');
|
821 |
+
* // Double quotes are used so that the space in the path is not interpreted as
|
822 |
+
* // a delimiter of multiple arguments.
|
823 |
+
*
|
824 |
+
* exec('echo "The \\$HOME variable is $HOME"');
|
825 |
+
* // The $HOME variable is escaped in the first instance, but not in the second.
|
826 |
+
* ```
|
827 |
+
*
|
828 |
+
* **Never pass unsanitized user input to this function. Any input containing shell**
|
829 |
+
* **metacharacters may be used to trigger arbitrary command execution.**
|
830 |
+
*
|
831 |
+
* If a `callback` function is provided, it is called with the arguments`(error, stdout, stderr)`. On success, `error` will be `null`. On error,`error` will be an instance of `Error`. The
|
832 |
+
* `error.code` property will be
|
833 |
+
* the exit code of the process. By convention, any exit code other than `0`indicates an error. `error.signal` will be the signal that terminated the
|
834 |
+
* process.
|
835 |
+
*
|
836 |
+
* The `stdout` and `stderr` arguments passed to the callback will contain the
|
837 |
+
* stdout and stderr output of the child process. By default, Node.js will decode
|
838 |
+
* the output as UTF-8 and pass strings to the callback. The `encoding` option
|
839 |
+
* can be used to specify the character encoding used to decode the stdout and
|
840 |
+
* stderr output. If `encoding` is `'buffer'`, or an unrecognized character
|
841 |
+
* encoding, `Buffer` objects will be passed to the callback instead.
|
842 |
+
*
|
843 |
+
* ```js
|
844 |
+
* const { exec } = require('child_process');
|
845 |
+
* exec('cat *.js missing_file | wc -l', (error, stdout, stderr) => {
|
846 |
+
* if (error) {
|
847 |
+
* console.error(`exec error: ${error}`);
|
848 |
+
* return;
|
849 |
+
* }
|
850 |
+
* console.log(`stdout: ${stdout}`);
|
851 |
+
* console.error(`stderr: ${stderr}`);
|
852 |
+
* });
|
853 |
+
* ```
|
854 |
+
*
|
855 |
+
* If `timeout` is greater than `0`, the parent will send the signal
|
856 |
+
* identified by the `killSignal` property (the default is `'SIGTERM'`) if the
|
857 |
+
* child runs longer than `timeout` milliseconds.
|
858 |
+
*
|
859 |
+
* Unlike the [`exec(3)`](http://man7.org/linux/man-pages/man3/exec.3.html) POSIX system call, `child_process.exec()` does not replace
|
860 |
+
* the existing process and uses a shell to execute the command.
|
861 |
+
*
|
862 |
+
* If this method is invoked as its `util.promisify()` ed version, it returns
|
863 |
+
* a `Promise` for an `Object` with `stdout` and `stderr` properties. The returned`ChildProcess` instance is attached to the `Promise` as a `child` property. In
|
864 |
+
* case of an error (including any error resulting in an exit code other than 0), a
|
865 |
+
* rejected promise is returned, with the same `error` object given in the
|
866 |
+
* callback, but with two additional properties `stdout` and `stderr`.
|
867 |
+
*
|
868 |
+
* ```js
|
869 |
+
* const util = require('util');
|
870 |
+
* const exec = util.promisify(require('child_process').exec);
|
871 |
+
*
|
872 |
+
* async function lsExample() {
|
873 |
+
* const { stdout, stderr } = await exec('ls');
|
874 |
+
* console.log('stdout:', stdout);
|
875 |
+
* console.error('stderr:', stderr);
|
876 |
+
* }
|
877 |
+
* lsExample();
|
878 |
+
* ```
|
879 |
+
*
|
880 |
+
* If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except
|
881 |
+
* the error passed to the callback will be an `AbortError`:
|
882 |
+
*
|
883 |
+
* ```js
|
884 |
+
* const { exec } = require('child_process');
|
885 |
+
* const controller = new AbortController();
|
886 |
+
* const { signal } = controller;
|
887 |
+
* const child = exec('grep ssh', { signal }, (error) => {
|
888 |
+
* console.log(error); // an AbortError
|
889 |
+
* });
|
890 |
+
* controller.abort();
|
891 |
+
* ```
|
892 |
+
* @since v0.1.90
|
893 |
+
* @param command The command to run, with space-separated arguments.
|
894 |
+
* @param callback called with the output when process terminates.
|
895 |
+
*/
|
896 |
+
function exec(command: string, callback?: (error: ExecException | null, stdout: string, stderr: string) => void): ChildProcess;
|
897 |
+
// `options` with `"buffer"` or `null` for `encoding` means stdout/stderr are definitely `Buffer`.
|
898 |
+
function exec(
|
899 |
+
command: string,
|
900 |
+
options: {
|
901 |
+
encoding: 'buffer' | null;
|
902 |
+
} & ExecOptions,
|
903 |
+
callback?: (error: ExecException | null, stdout: Buffer, stderr: Buffer) => void
|
904 |
+
): ChildProcess;
|
905 |
+
// `options` with well known `encoding` means stdout/stderr are definitely `string`.
|
906 |
+
function exec(
|
907 |
+
command: string,
|
908 |
+
options: {
|
909 |
+
encoding: BufferEncoding;
|
910 |
+
} & ExecOptions,
|
911 |
+
callback?: (error: ExecException | null, stdout: string, stderr: string) => void
|
912 |
+
): ChildProcess;
|
913 |
+
// `options` with an `encoding` whose type is `string` means stdout/stderr could either be `Buffer` or `string`.
|
914 |
+
// There is no guarantee the `encoding` is unknown as `string` is a superset of `BufferEncoding`.
|
915 |
+
function exec(
|
916 |
+
command: string,
|
917 |
+
options: {
|
918 |
+
encoding: BufferEncoding;
|
919 |
+
} & ExecOptions,
|
920 |
+
callback?: (error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void
|
921 |
+
): ChildProcess;
|
922 |
+
// `options` without an `encoding` means stdout/stderr are definitely `string`.
|
923 |
+
function exec(command: string, options: ExecOptions, callback?: (error: ExecException | null, stdout: string, stderr: string) => void): ChildProcess;
|
924 |
+
// fallback if nothing else matches. Worst case is always `string | Buffer`.
|
925 |
+
function exec(
|
926 |
+
command: string,
|
927 |
+
options: (ObjectEncodingOptions & ExecOptions) | undefined | null,
|
928 |
+
callback?: (error: ExecException | null, stdout: string | Buffer, stderr: string | Buffer) => void
|
929 |
+
): ChildProcess;
|
930 |
+
interface PromiseWithChild<T> extends Promise<T> {
|
931 |
+
child: ChildProcess;
|
932 |
+
}
|
933 |
+
namespace exec {
|
934 |
+
function __promisify__(command: string): PromiseWithChild<{
|
935 |
+
stdout: string;
|
936 |
+
stderr: string;
|
937 |
+
}>;
|
938 |
+
function __promisify__(
|
939 |
+
command: string,
|
940 |
+
options: {
|
941 |
+
encoding: 'buffer' | null;
|
942 |
+
} & ExecOptions
|
943 |
+
): PromiseWithChild<{
|
944 |
+
stdout: Buffer;
|
945 |
+
stderr: Buffer;
|
946 |
+
}>;
|
947 |
+
function __promisify__(
|
948 |
+
command: string,
|
949 |
+
options: {
|
950 |
+
encoding: BufferEncoding;
|
951 |
+
} & ExecOptions
|
952 |
+
): PromiseWithChild<{
|
953 |
+
stdout: string;
|
954 |
+
stderr: string;
|
955 |
+
}>;
|
956 |
+
function __promisify__(
|
957 |
+
command: string,
|
958 |
+
options: ExecOptions
|
959 |
+
): PromiseWithChild<{
|
960 |
+
stdout: string;
|
961 |
+
stderr: string;
|
962 |
+
}>;
|
963 |
+
function __promisify__(
|
964 |
+
command: string,
|
965 |
+
options?: (ObjectEncodingOptions & ExecOptions) | null
|
966 |
+
): PromiseWithChild<{
|
967 |
+
stdout: string | Buffer;
|
968 |
+
stderr: string | Buffer;
|
969 |
+
}>;
|
970 |
+
}
|
971 |
+
interface ExecFileOptions extends CommonOptions, Abortable {
|
972 |
+
maxBuffer?: number | undefined;
|
973 |
+
killSignal?: NodeJS.Signals | number | undefined;
|
974 |
+
windowsVerbatimArguments?: boolean | undefined;
|
975 |
+
shell?: boolean | string | undefined;
|
976 |
+
signal?: AbortSignal | undefined;
|
977 |
+
}
|
978 |
+
interface ExecFileOptionsWithStringEncoding extends ExecFileOptions {
|
979 |
+
encoding: BufferEncoding;
|
980 |
+
}
|
981 |
+
interface ExecFileOptionsWithBufferEncoding extends ExecFileOptions {
|
982 |
+
encoding: 'buffer' | null;
|
983 |
+
}
|
984 |
+
interface ExecFileOptionsWithOtherEncoding extends ExecFileOptions {
|
985 |
+
encoding: BufferEncoding;
|
986 |
+
}
|
987 |
+
type ExecFileException = ExecException & NodeJS.ErrnoException;
|
988 |
+
/**
|
989 |
+
* The `child_process.execFile()` function is similar to {@link exec} except that it does not spawn a shell by default. Rather, the specified
|
990 |
+
* executable `file` is spawned directly as a new process making it slightly more
|
991 |
+
* efficient than {@link exec}.
|
992 |
+
*
|
993 |
+
* The same options as {@link exec} are supported. Since a shell is
|
994 |
+
* not spawned, behaviors such as I/O redirection and file globbing are not
|
995 |
+
* supported.
|
996 |
+
*
|
997 |
+
* ```js
|
998 |
+
* const { execFile } = require('child_process');
|
999 |
+
* const child = execFile('node', ['--version'], (error, stdout, stderr) => {
|
1000 |
+
* if (error) {
|
1001 |
+
* throw error;
|
1002 |
+
* }
|
1003 |
+
* console.log(stdout);
|
1004 |
+
* });
|
1005 |
+
* ```
|
1006 |
+
*
|
1007 |
+
* The `stdout` and `stderr` arguments passed to the callback will contain the
|
1008 |
+
* stdout and stderr output of the child process. By default, Node.js will decode
|
1009 |
+
* the output as UTF-8 and pass strings to the callback. The `encoding` option
|
1010 |
+
* can be used to specify the character encoding used to decode the stdout and
|
1011 |
+
* stderr output. If `encoding` is `'buffer'`, or an unrecognized character
|
1012 |
+
* encoding, `Buffer` objects will be passed to the callback instead.
|
1013 |
+
*
|
1014 |
+
* If this method is invoked as its `util.promisify()` ed version, it returns
|
1015 |
+
* a `Promise` for an `Object` with `stdout` and `stderr` properties. The returned`ChildProcess` instance is attached to the `Promise` as a `child` property. In
|
1016 |
+
* case of an error (including any error resulting in an exit code other than 0), a
|
1017 |
+
* rejected promise is returned, with the same `error` object given in the
|
1018 |
+
* callback, but with two additional properties `stdout` and `stderr`.
|
1019 |
+
*
|
1020 |
+
* ```js
|
1021 |
+
* const util = require('util');
|
1022 |
+
* const execFile = util.promisify(require('child_process').execFile);
|
1023 |
+
* async function getVersion() {
|
1024 |
+
* const { stdout } = await execFile('node', ['--version']);
|
1025 |
+
* console.log(stdout);
|
1026 |
+
* }
|
1027 |
+
* getVersion();
|
1028 |
+
* ```
|
1029 |
+
*
|
1030 |
+
* **If the `shell` option is enabled, do not pass unsanitized user input to this**
|
1031 |
+
* **function. Any input containing shell metacharacters may be used to trigger**
|
1032 |
+
* **arbitrary command execution.**
|
1033 |
+
*
|
1034 |
+
* If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except
|
1035 |
+
* the error passed to the callback will be an `AbortError`:
|
1036 |
+
*
|
1037 |
+
* ```js
|
1038 |
+
* const { execFile } = require('child_process');
|
1039 |
+
* const controller = new AbortController();
|
1040 |
+
* const { signal } = controller;
|
1041 |
+
* const child = execFile('node', ['--version'], { signal }, (error) => {
|
1042 |
+
* console.log(error); // an AbortError
|
1043 |
+
* });
|
1044 |
+
* controller.abort();
|
1045 |
+
* ```
|
1046 |
+
* @since v0.1.91
|
1047 |
+
* @param file The name or path of the executable file to run.
|
1048 |
+
* @param args List of string arguments.
|
1049 |
+
* @param callback Called with the output when process terminates.
|
1050 |
+
*/
|
1051 |
+
function execFile(file: string): ChildProcess;
|
1052 |
+
function execFile(file: string, options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null): ChildProcess;
|
1053 |
+
function execFile(file: string, args?: ReadonlyArray<string> | null): ChildProcess;
|
1054 |
+
function execFile(file: string, args: ReadonlyArray<string> | undefined | null, options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null): ChildProcess;
|
1055 |
+
// no `options` definitely means stdout/stderr are `string`.
|
1056 |
+
function execFile(file: string, callback: (error: ExecFileException | null, stdout: string, stderr: string) => void): ChildProcess;
|
1057 |
+
function execFile(file: string, args: ReadonlyArray<string> | undefined | null, callback: (error: ExecFileException | null, stdout: string, stderr: string) => void): ChildProcess;
|
1058 |
+
// `options` with `"buffer"` or `null` for `encoding` means stdout/stderr are definitely `Buffer`.
|
1059 |
+
function execFile(file: string, options: ExecFileOptionsWithBufferEncoding, callback: (error: ExecFileException | null, stdout: Buffer, stderr: Buffer) => void): ChildProcess;
|
1060 |
+
function execFile(
|
1061 |
+
file: string,
|
1062 |
+
args: ReadonlyArray<string> | undefined | null,
|
1063 |
+
options: ExecFileOptionsWithBufferEncoding,
|
1064 |
+
callback: (error: ExecFileException | null, stdout: Buffer, stderr: Buffer) => void
|
1065 |
+
): ChildProcess;
|
1066 |
+
// `options` with well known `encoding` means stdout/stderr are definitely `string`.
|
1067 |
+
function execFile(file: string, options: ExecFileOptionsWithStringEncoding, callback: (error: ExecFileException | null, stdout: string, stderr: string) => void): ChildProcess;
|
1068 |
+
function execFile(
|
1069 |
+
file: string,
|
1070 |
+
args: ReadonlyArray<string> | undefined | null,
|
1071 |
+
options: ExecFileOptionsWithStringEncoding,
|
1072 |
+
callback: (error: ExecFileException | null, stdout: string, stderr: string) => void
|
1073 |
+
): ChildProcess;
|
1074 |
+
// `options` with an `encoding` whose type is `string` means stdout/stderr could either be `Buffer` or `string`.
|
1075 |
+
// There is no guarantee the `encoding` is unknown as `string` is a superset of `BufferEncoding`.
|
1076 |
+
function execFile(file: string, options: ExecFileOptionsWithOtherEncoding, callback: (error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void): ChildProcess;
|
1077 |
+
function execFile(
|
1078 |
+
file: string,
|
1079 |
+
args: ReadonlyArray<string> | undefined | null,
|
1080 |
+
options: ExecFileOptionsWithOtherEncoding,
|
1081 |
+
callback: (error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void
|
1082 |
+
): ChildProcess;
|
1083 |
+
// `options` without an `encoding` means stdout/stderr are definitely `string`.
|
1084 |
+
function execFile(file: string, options: ExecFileOptions, callback: (error: ExecFileException | null, stdout: string, stderr: string) => void): ChildProcess;
|
1085 |
+
function execFile(
|
1086 |
+
file: string,
|
1087 |
+
args: ReadonlyArray<string> | undefined | null,
|
1088 |
+
options: ExecFileOptions,
|
1089 |
+
callback: (error: ExecFileException | null, stdout: string, stderr: string) => void
|
1090 |
+
): ChildProcess;
|
1091 |
+
// fallback if nothing else matches. Worst case is always `string | Buffer`.
|
1092 |
+
function execFile(
|
1093 |
+
file: string,
|
1094 |
+
options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
|
1095 |
+
callback: ((error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void) | undefined | null
|
1096 |
+
): ChildProcess;
|
1097 |
+
function execFile(
|
1098 |
+
file: string,
|
1099 |
+
args: ReadonlyArray<string> | undefined | null,
|
1100 |
+
options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null,
|
1101 |
+
callback: ((error: ExecFileException | null, stdout: string | Buffer, stderr: string | Buffer) => void) | undefined | null
|
1102 |
+
): ChildProcess;
|
1103 |
+
namespace execFile {
|
1104 |
+
function __promisify__(file: string): PromiseWithChild<{
|
1105 |
+
stdout: string;
|
1106 |
+
stderr: string;
|
1107 |
+
}>;
|
1108 |
+
function __promisify__(
|
1109 |
+
file: string,
|
1110 |
+
args: ReadonlyArray<string> | undefined | null
|
1111 |
+
): PromiseWithChild<{
|
1112 |
+
stdout: string;
|
1113 |
+
stderr: string;
|
1114 |
+
}>;
|
1115 |
+
function __promisify__(
|
1116 |
+
file: string,
|
1117 |
+
options: ExecFileOptionsWithBufferEncoding
|
1118 |
+
): PromiseWithChild<{
|
1119 |
+
stdout: Buffer;
|
1120 |
+
stderr: Buffer;
|
1121 |
+
}>;
|
1122 |
+
function __promisify__(
|
1123 |
+
file: string,
|
1124 |
+
args: ReadonlyArray<string> | undefined | null,
|
1125 |
+
options: ExecFileOptionsWithBufferEncoding
|
1126 |
+
): PromiseWithChild<{
|
1127 |
+
stdout: Buffer;
|
1128 |
+
stderr: Buffer;
|
1129 |
+
}>;
|
1130 |
+
function __promisify__(
|
1131 |
+
file: string,
|
1132 |
+
options: ExecFileOptionsWithStringEncoding
|
1133 |
+
): PromiseWithChild<{
|
1134 |
+
stdout: string;
|
1135 |
+
stderr: string;
|
1136 |
+
}>;
|
1137 |
+
function __promisify__(
|
1138 |
+
file: string,
|
1139 |
+
args: ReadonlyArray<string> | undefined | null,
|
1140 |
+
options: ExecFileOptionsWithStringEncoding
|
1141 |
+
): PromiseWithChild<{
|
1142 |
+
stdout: string;
|
1143 |
+
stderr: string;
|
1144 |
+
}>;
|
1145 |
+
function __promisify__(
|
1146 |
+
file: string,
|
1147 |
+
options: ExecFileOptionsWithOtherEncoding
|
1148 |
+
): PromiseWithChild<{
|
1149 |
+
stdout: string | Buffer;
|
1150 |
+
stderr: string | Buffer;
|
1151 |
+
}>;
|
1152 |
+
function __promisify__(
|
1153 |
+
file: string,
|
1154 |
+
args: ReadonlyArray<string> | undefined | null,
|
1155 |
+
options: ExecFileOptionsWithOtherEncoding
|
1156 |
+
): PromiseWithChild<{
|
1157 |
+
stdout: string | Buffer;
|
1158 |
+
stderr: string | Buffer;
|
1159 |
+
}>;
|
1160 |
+
function __promisify__(
|
1161 |
+
file: string,
|
1162 |
+
options: ExecFileOptions
|
1163 |
+
): PromiseWithChild<{
|
1164 |
+
stdout: string;
|
1165 |
+
stderr: string;
|
1166 |
+
}>;
|
1167 |
+
function __promisify__(
|
1168 |
+
file: string,
|
1169 |
+
args: ReadonlyArray<string> | undefined | null,
|
1170 |
+
options: ExecFileOptions
|
1171 |
+
): PromiseWithChild<{
|
1172 |
+
stdout: string;
|
1173 |
+
stderr: string;
|
1174 |
+
}>;
|
1175 |
+
function __promisify__(
|
1176 |
+
file: string,
|
1177 |
+
options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null
|
1178 |
+
): PromiseWithChild<{
|
1179 |
+
stdout: string | Buffer;
|
1180 |
+
stderr: string | Buffer;
|
1181 |
+
}>;
|
1182 |
+
function __promisify__(
|
1183 |
+
file: string,
|
1184 |
+
args: ReadonlyArray<string> | undefined | null,
|
1185 |
+
options: (ObjectEncodingOptions & ExecFileOptions) | undefined | null
|
1186 |
+
): PromiseWithChild<{
|
1187 |
+
stdout: string | Buffer;
|
1188 |
+
stderr: string | Buffer;
|
1189 |
+
}>;
|
1190 |
+
}
|
1191 |
+
interface ForkOptions extends ProcessEnvOptions, MessagingOptions, Abortable {
|
1192 |
+
execPath?: string | undefined;
|
1193 |
+
execArgv?: string[] | undefined;
|
1194 |
+
silent?: boolean | undefined;
|
1195 |
+
stdio?: StdioOptions | undefined;
|
1196 |
+
detached?: boolean | undefined;
|
1197 |
+
windowsVerbatimArguments?: boolean | undefined;
|
1198 |
+
}
|
1199 |
+
/**
|
1200 |
+
* The `child_process.fork()` method is a special case of {@link spawn} used specifically to spawn new Node.js processes.
|
1201 |
+
* Like {@link spawn}, a `ChildProcess` object is returned. The
|
1202 |
+
* returned `ChildProcess` will have an additional communication channel
|
1203 |
+
* built-in that allows messages to be passed back and forth between the parent and
|
1204 |
+
* child. See `subprocess.send()` for details.
|
1205 |
+
*
|
1206 |
+
* Keep in mind that spawned Node.js child processes are
|
1207 |
+
* independent of the parent with exception of the IPC communication channel
|
1208 |
+
* that is established between the two. Each process has its own memory, with
|
1209 |
+
* their own V8 instances. Because of the additional resource allocations
|
1210 |
+
* required, spawning a large number of child Node.js processes is not
|
1211 |
+
* recommended.
|
1212 |
+
*
|
1213 |
+
* By default, `child_process.fork()` will spawn new Node.js instances using the `process.execPath` of the parent process. The `execPath` property in the`options` object allows for an alternative
|
1214 |
+
* execution path to be used.
|
1215 |
+
*
|
1216 |
+
* Node.js processes launched with a custom `execPath` will communicate with the
|
1217 |
+
* parent process using the file descriptor (fd) identified using the
|
1218 |
+
* environment variable `NODE_CHANNEL_FD` on the child process.
|
1219 |
+
*
|
1220 |
+
* Unlike the [`fork(2)`](http://man7.org/linux/man-pages/man2/fork.2.html) POSIX system call, `child_process.fork()` does not clone the
|
1221 |
+
* current process.
|
1222 |
+
*
|
1223 |
+
* The `shell` option available in {@link spawn} is not supported by`child_process.fork()` and will be ignored if set.
|
1224 |
+
*
|
1225 |
+
* If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.kill()` on the child process except
|
1226 |
+
* the error passed to the callback will be an `AbortError`:
|
1227 |
+
*
|
1228 |
+
* ```js
|
1229 |
+
* if (process.argv[2] === 'child') {
|
1230 |
+
* setTimeout(() => {
|
1231 |
+
* console.log(`Hello from ${process.argv[2]}!`);
|
1232 |
+
* }, 1_000);
|
1233 |
+
* } else {
|
1234 |
+
* const { fork } = require('child_process');
|
1235 |
+
* const controller = new AbortController();
|
1236 |
+
* const { signal } = controller;
|
1237 |
+
* const child = fork(__filename, ['child'], { signal });
|
1238 |
+
* child.on('error', (err) => {
|
1239 |
+
* // This will be called with err being an AbortError if the controller aborts
|
1240 |
+
* });
|
1241 |
+
* controller.abort(); // Stops the child process
|
1242 |
+
* }
|
1243 |
+
* ```
|
1244 |
+
* @since v0.5.0
|
1245 |
+
* @param modulePath The module to run in the child.
|
1246 |
+
* @param args List of string arguments.
|
1247 |
+
*/
|
1248 |
+
function fork(modulePath: string, options?: ForkOptions): ChildProcess;
|
1249 |
+
function fork(modulePath: string, args?: ReadonlyArray<string>, options?: ForkOptions): ChildProcess;
|
1250 |
+
interface SpawnSyncOptions extends CommonSpawnOptions {
|
1251 |
+
input?: string | NodeJS.ArrayBufferView | undefined;
|
1252 |
+
maxBuffer?: number | undefined;
|
1253 |
+
encoding?: BufferEncoding | 'buffer' | null | undefined;
|
1254 |
+
}
|
1255 |
+
interface SpawnSyncOptionsWithStringEncoding extends SpawnSyncOptions {
|
1256 |
+
encoding: BufferEncoding;
|
1257 |
+
}
|
1258 |
+
interface SpawnSyncOptionsWithBufferEncoding extends SpawnSyncOptions {
|
1259 |
+
encoding?: 'buffer' | null | undefined;
|
1260 |
+
}
|
1261 |
+
interface SpawnSyncReturns<T> {
|
1262 |
+
pid: number;
|
1263 |
+
output: Array<T | null>;
|
1264 |
+
stdout: T;
|
1265 |
+
stderr: T;
|
1266 |
+
status: number | null;
|
1267 |
+
signal: NodeJS.Signals | null;
|
1268 |
+
error?: Error | undefined;
|
1269 |
+
}
|
1270 |
+
/**
|
1271 |
+
* The `child_process.spawnSync()` method is generally identical to {@link spawn} with the exception that the function will not return
|
1272 |
+
* until the child process has fully closed. When a timeout has been encountered
|
1273 |
+
* and `killSignal` is sent, the method won't return until the process has
|
1274 |
+
* completely exited. If the process intercepts and handles the `SIGTERM` signal
|
1275 |
+
* and doesn't exit, the parent process will wait until the child process has
|
1276 |
+
* exited.
|
1277 |
+
*
|
1278 |
+
* **If the `shell` option is enabled, do not pass unsanitized user input to this**
|
1279 |
+
* **function. Any input containing shell metacharacters may be used to trigger**
|
1280 |
+
* **arbitrary command execution.**
|
1281 |
+
* @since v0.11.12
|
1282 |
+
* @param command The command to run.
|
1283 |
+
* @param args List of string arguments.
|
1284 |
+
*/
|
1285 |
+
function spawnSync(command: string): SpawnSyncReturns<Buffer>;
|
1286 |
+
function spawnSync(command: string, options: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns<string>;
|
1287 |
+
function spawnSync(command: string, options: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns<Buffer>;
|
1288 |
+
function spawnSync(command: string, options?: SpawnSyncOptions): SpawnSyncReturns<string | Buffer>;
|
1289 |
+
function spawnSync(command: string, args: ReadonlyArray<string>): SpawnSyncReturns<Buffer>;
|
1290 |
+
function spawnSync(command: string, args: ReadonlyArray<string>, options: SpawnSyncOptionsWithStringEncoding): SpawnSyncReturns<string>;
|
1291 |
+
function spawnSync(command: string, args: ReadonlyArray<string>, options: SpawnSyncOptionsWithBufferEncoding): SpawnSyncReturns<Buffer>;
|
1292 |
+
function spawnSync(command: string, args?: ReadonlyArray<string>, options?: SpawnSyncOptions): SpawnSyncReturns<string | Buffer>;
|
1293 |
+
interface CommonExecOptions extends CommonOptions {
|
1294 |
+
input?: string | NodeJS.ArrayBufferView | undefined;
|
1295 |
+
stdio?: StdioOptions | undefined;
|
1296 |
+
killSignal?: NodeJS.Signals | number | undefined;
|
1297 |
+
maxBuffer?: number | undefined;
|
1298 |
+
encoding?: BufferEncoding | 'buffer' | null | undefined;
|
1299 |
+
}
|
1300 |
+
interface ExecSyncOptions extends CommonExecOptions {
|
1301 |
+
shell?: string | undefined;
|
1302 |
+
}
|
1303 |
+
interface ExecSyncOptionsWithStringEncoding extends ExecSyncOptions {
|
1304 |
+
encoding: BufferEncoding;
|
1305 |
+
}
|
1306 |
+
interface ExecSyncOptionsWithBufferEncoding extends ExecSyncOptions {
|
1307 |
+
encoding?: 'buffer' | null | undefined;
|
1308 |
+
}
|
1309 |
+
/**
|
1310 |
+
* The `child_process.execSync()` method is generally identical to {@link exec} with the exception that the method will not return
|
1311 |
+
* until the child process has fully closed. When a timeout has been encountered
|
1312 |
+
* and `killSignal` is sent, the method won't return until the process has
|
1313 |
+
* completely exited. If the child process intercepts and handles the `SIGTERM`signal and doesn't exit, the parent process will wait until the child process
|
1314 |
+
* has exited.
|
1315 |
+
*
|
1316 |
+
* If the process times out or has a non-zero exit code, this method will throw.
|
1317 |
+
* The `Error` object will contain the entire result from {@link spawnSync}.
|
1318 |
+
*
|
1319 |
+
* **Never pass unsanitized user input to this function. Any input containing shell**
|
1320 |
+
* **metacharacters may be used to trigger arbitrary command execution.**
|
1321 |
+
* @since v0.11.12
|
1322 |
+
* @param command The command to run.
|
1323 |
+
* @return The stdout from the command.
|
1324 |
+
*/
|
1325 |
+
function execSync(command: string): Buffer;
|
1326 |
+
function execSync(command: string, options: ExecSyncOptionsWithStringEncoding): string;
|
1327 |
+
function execSync(command: string, options: ExecSyncOptionsWithBufferEncoding): Buffer;
|
1328 |
+
function execSync(command: string, options?: ExecSyncOptions): string | Buffer;
|
1329 |
+
interface ExecFileSyncOptions extends CommonExecOptions {
|
1330 |
+
shell?: boolean | string | undefined;
|
1331 |
+
}
|
1332 |
+
interface ExecFileSyncOptionsWithStringEncoding extends ExecFileSyncOptions {
|
1333 |
+
encoding: BufferEncoding;
|
1334 |
+
}
|
1335 |
+
interface ExecFileSyncOptionsWithBufferEncoding extends ExecFileSyncOptions {
|
1336 |
+
encoding?: 'buffer' | null; // specify `null`.
|
1337 |
+
}
|
1338 |
+
/**
|
1339 |
+
* The `child_process.execFileSync()` method is generally identical to {@link execFile} with the exception that the method will not
|
1340 |
+
* return until the child process has fully closed. When a timeout has been
|
1341 |
+
* encountered and `killSignal` is sent, the method won't return until the process
|
1342 |
+
* has completely exited.
|
1343 |
+
*
|
1344 |
+
* If the child process intercepts and handles the `SIGTERM` signal and
|
1345 |
+
* does not exit, the parent process will still wait until the child process has
|
1346 |
+
* exited.
|
1347 |
+
*
|
1348 |
+
* If the process times out or has a non-zero exit code, this method will throw an `Error` that will include the full result of the underlying {@link spawnSync}.
|
1349 |
+
*
|
1350 |
+
* **If the `shell` option is enabled, do not pass unsanitized user input to this**
|
1351 |
+
* **function. Any input containing shell metacharacters may be used to trigger**
|
1352 |
+
* **arbitrary command execution.**
|
1353 |
+
* @since v0.11.12
|
1354 |
+
* @param file The name or path of the executable file to run.
|
1355 |
+
* @param args List of string arguments.
|
1356 |
+
* @return The stdout from the command.
|
1357 |
+
*/
|
1358 |
+
function execFileSync(file: string): Buffer;
|
1359 |
+
function execFileSync(file: string, options: ExecFileSyncOptionsWithStringEncoding): string;
|
1360 |
+
function execFileSync(file: string, options: ExecFileSyncOptionsWithBufferEncoding): Buffer;
|
1361 |
+
function execFileSync(file: string, options?: ExecFileSyncOptions): string | Buffer;
|
1362 |
+
function execFileSync(file: string, args: ReadonlyArray<string>): Buffer;
|
1363 |
+
function execFileSync(file: string, args: ReadonlyArray<string>, options: ExecFileSyncOptionsWithStringEncoding): string;
|
1364 |
+
function execFileSync(file: string, args: ReadonlyArray<string>, options: ExecFileSyncOptionsWithBufferEncoding): Buffer;
|
1365 |
+
function execFileSync(file: string, args?: ReadonlyArray<string>, options?: ExecFileSyncOptions): string | Buffer;
|
1366 |
+
}
|
1367 |
+
declare module 'node:child_process' {
|
1368 |
+
export * from 'child_process';
|
1369 |
+
}
|
igv_component/node_modules/@types/node/cluster.d.ts
ADDED
@@ -0,0 +1,410 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Clusters of Node.js processes can be used to run multiple instances of Node.js
|
3 |
+
* that can distribute workloads among their application threads. When process
|
4 |
+
* isolation is not needed, use the `worker_threads` module instead, which
|
5 |
+
* allows running multiple application threads within a single Node.js instance.
|
6 |
+
*
|
7 |
+
* The cluster module allows easy creation of child processes that all share
|
8 |
+
* server ports.
|
9 |
+
*
|
10 |
+
* ```js
|
11 |
+
* import cluster from 'cluster';
|
12 |
+
* import http from 'http';
|
13 |
+
* import { cpus } from 'os';
|
14 |
+
* import process from 'process';
|
15 |
+
*
|
16 |
+
* const numCPUs = cpus().length;
|
17 |
+
*
|
18 |
+
* if (cluster.isPrimary) {
|
19 |
+
* console.log(`Primary ${process.pid} is running`);
|
20 |
+
*
|
21 |
+
* // Fork workers.
|
22 |
+
* for (let i = 0; i < numCPUs; i++) {
|
23 |
+
* cluster.fork();
|
24 |
+
* }
|
25 |
+
*
|
26 |
+
* cluster.on('exit', (worker, code, signal) => {
|
27 |
+
* console.log(`worker ${worker.process.pid} died`);
|
28 |
+
* });
|
29 |
+
* } else {
|
30 |
+
* // Workers can share any TCP connection
|
31 |
+
* // In this case it is an HTTP server
|
32 |
+
* http.createServer((req, res) => {
|
33 |
+
* res.writeHead(200);
|
34 |
+
* res.end('hello world\n');
|
35 |
+
* }).listen(8000);
|
36 |
+
*
|
37 |
+
* console.log(`Worker ${process.pid} started`);
|
38 |
+
* }
|
39 |
+
* ```
|
40 |
+
*
|
41 |
+
* Running Node.js will now share port 8000 between the workers:
|
42 |
+
*
|
43 |
+
* ```console
|
44 |
+
* $ node server.js
|
45 |
+
* Primary 3596 is running
|
46 |
+
* Worker 4324 started
|
47 |
+
* Worker 4520 started
|
48 |
+
* Worker 6056 started
|
49 |
+
* Worker 5644 started
|
50 |
+
* ```
|
51 |
+
*
|
52 |
+
* On Windows, it is not yet possible to set up a named pipe server in a worker.
|
53 |
+
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/cluster.js)
|
54 |
+
*/
|
55 |
+
declare module 'cluster' {
|
56 |
+
import * as child from 'node:child_process';
|
57 |
+
import EventEmitter = require('node:events');
|
58 |
+
import * as net from 'node:net';
|
59 |
+
export interface ClusterSettings {
|
60 |
+
execArgv?: string[] | undefined; // default: process.execArgv
|
61 |
+
exec?: string | undefined;
|
62 |
+
args?: string[] | undefined;
|
63 |
+
silent?: boolean | undefined;
|
64 |
+
stdio?: any[] | undefined;
|
65 |
+
uid?: number | undefined;
|
66 |
+
gid?: number | undefined;
|
67 |
+
inspectPort?: number | (() => number) | undefined;
|
68 |
+
}
|
69 |
+
export interface Address {
|
70 |
+
address: string;
|
71 |
+
port: number;
|
72 |
+
addressType: number | 'udp4' | 'udp6'; // 4, 6, -1, "udp4", "udp6"
|
73 |
+
}
|
74 |
+
/**
|
75 |
+
* A `Worker` object contains all public information and method about a worker.
|
76 |
+
* In the primary it can be obtained using `cluster.workers`. In a worker
|
77 |
+
* it can be obtained using `cluster.worker`.
|
78 |
+
* @since v0.7.0
|
79 |
+
*/
|
80 |
+
export class Worker extends EventEmitter {
|
81 |
+
/**
|
82 |
+
* Each new worker is given its own unique id, this id is stored in the`id`.
|
83 |
+
*
|
84 |
+
* While a worker is alive, this is the key that indexes it in`cluster.workers`.
|
85 |
+
* @since v0.8.0
|
86 |
+
*/
|
87 |
+
id: number;
|
88 |
+
/**
|
89 |
+
* All workers are created using `child_process.fork()`, the returned object
|
90 |
+
* from this function is stored as `.process`. In a worker, the global `process`is stored.
|
91 |
+
*
|
92 |
+
* See: `Child Process module`.
|
93 |
+
*
|
94 |
+
* Workers will call `process.exit(0)` if the `'disconnect'` event occurs
|
95 |
+
* on `process` and `.exitedAfterDisconnect` is not `true`. This protects against
|
96 |
+
* accidental disconnection.
|
97 |
+
* @since v0.7.0
|
98 |
+
*/
|
99 |
+
process: child.ChildProcess;
|
100 |
+
/**
|
101 |
+
* Send a message to a worker or primary, optionally with a handle.
|
102 |
+
*
|
103 |
+
* In the primary, this sends a message to a specific worker. It is identical to `ChildProcess.send()`.
|
104 |
+
*
|
105 |
+
* In a worker, this sends a message to the primary. It is identical to`process.send()`.
|
106 |
+
*
|
107 |
+
* This example will echo back all messages from the primary:
|
108 |
+
*
|
109 |
+
* ```js
|
110 |
+
* if (cluster.isPrimary) {
|
111 |
+
* const worker = cluster.fork();
|
112 |
+
* worker.send('hi there');
|
113 |
+
*
|
114 |
+
* } else if (cluster.isWorker) {
|
115 |
+
* process.on('message', (msg) => {
|
116 |
+
* process.send(msg);
|
117 |
+
* });
|
118 |
+
* }
|
119 |
+
* ```
|
120 |
+
* @since v0.7.0
|
121 |
+
* @param options The `options` argument, if present, is an object used to parameterize the sending of certain types of handles. `options` supports the following properties:
|
122 |
+
*/
|
123 |
+
send(message: child.Serializable, callback?: (error: Error | null) => void): boolean;
|
124 |
+
send(message: child.Serializable, sendHandle: child.SendHandle, callback?: (error: Error | null) => void): boolean;
|
125 |
+
send(message: child.Serializable, sendHandle: child.SendHandle, options?: child.MessageOptions, callback?: (error: Error | null) => void): boolean;
|
126 |
+
/**
|
127 |
+
* This function will kill the worker. In the primary worker, it does this by
|
128 |
+
* disconnecting the `worker.process`, and once disconnected, killing with`signal`. In the worker, it does it by killing the process with `signal`.
|
129 |
+
*
|
130 |
+
* The `kill()` function kills the worker process without waiting for a graceful
|
131 |
+
* disconnect, it has the same behavior as `worker.process.kill()`.
|
132 |
+
*
|
133 |
+
* This method is aliased as `worker.destroy()` for backwards compatibility.
|
134 |
+
*
|
135 |
+
* In a worker, `process.kill()` exists, but it is not this function;
|
136 |
+
* it is `kill()`.
|
137 |
+
* @since v0.9.12
|
138 |
+
* @param [signal='SIGTERM'] Name of the kill signal to send to the worker process.
|
139 |
+
*/
|
140 |
+
kill(signal?: string): void;
|
141 |
+
destroy(signal?: string): void;
|
142 |
+
/**
|
143 |
+
* In a worker, this function will close all servers, wait for the `'close'` event
|
144 |
+
* on those servers, and then disconnect the IPC channel.
|
145 |
+
*
|
146 |
+
* In the primary, an internal message is sent to the worker causing it to call`.disconnect()` on itself.
|
147 |
+
*
|
148 |
+
* Causes `.exitedAfterDisconnect` to be set.
|
149 |
+
*
|
150 |
+
* After a server is closed, it will no longer accept new connections,
|
151 |
+
* but connections may be accepted by any other listening worker. Existing
|
152 |
+
* connections will be allowed to close as usual. When no more connections exist,
|
153 |
+
* see `server.close()`, the IPC channel to the worker will close allowing it
|
154 |
+
* to die gracefully.
|
155 |
+
*
|
156 |
+
* The above applies _only_ to server connections, client connections are not
|
157 |
+
* automatically closed by workers, and disconnect does not wait for them to close
|
158 |
+
* before exiting.
|
159 |
+
*
|
160 |
+
* In a worker, `process.disconnect` exists, but it is not this function;
|
161 |
+
* it is `disconnect()`.
|
162 |
+
*
|
163 |
+
* Because long living server connections may block workers from disconnecting, it
|
164 |
+
* may be useful to send a message, so application specific actions may be taken to
|
165 |
+
* close them. It also may be useful to implement a timeout, killing a worker if
|
166 |
+
* the `'disconnect'` event has not been emitted after some time.
|
167 |
+
*
|
168 |
+
* ```js
|
169 |
+
* if (cluster.isPrimary) {
|
170 |
+
* const worker = cluster.fork();
|
171 |
+
* let timeout;
|
172 |
+
*
|
173 |
+
* worker.on('listening', (address) => {
|
174 |
+
* worker.send('shutdown');
|
175 |
+
* worker.disconnect();
|
176 |
+
* timeout = setTimeout(() => {
|
177 |
+
* worker.kill();
|
178 |
+
* }, 2000);
|
179 |
+
* });
|
180 |
+
*
|
181 |
+
* worker.on('disconnect', () => {
|
182 |
+
* clearTimeout(timeout);
|
183 |
+
* });
|
184 |
+
*
|
185 |
+
* } else if (cluster.isWorker) {
|
186 |
+
* const net = require('net');
|
187 |
+
* const server = net.createServer((socket) => {
|
188 |
+
* // Connections never end
|
189 |
+
* });
|
190 |
+
*
|
191 |
+
* server.listen(8000);
|
192 |
+
*
|
193 |
+
* process.on('message', (msg) => {
|
194 |
+
* if (msg === 'shutdown') {
|
195 |
+
* // Initiate graceful close of any connections to server
|
196 |
+
* }
|
197 |
+
* });
|
198 |
+
* }
|
199 |
+
* ```
|
200 |
+
* @since v0.7.7
|
201 |
+
* @return A reference to `worker`.
|
202 |
+
*/
|
203 |
+
disconnect(): void;
|
204 |
+
/**
|
205 |
+
* This function returns `true` if the worker is connected to its primary via its
|
206 |
+
* IPC channel, `false` otherwise. A worker is connected to its primary after it
|
207 |
+
* has been created. It is disconnected after the `'disconnect'` event is emitted.
|
208 |
+
* @since v0.11.14
|
209 |
+
*/
|
210 |
+
isConnected(): boolean;
|
211 |
+
/**
|
212 |
+
* This function returns `true` if the worker's process has terminated (either
|
213 |
+
* because of exiting or being signaled). Otherwise, it returns `false`.
|
214 |
+
*
|
215 |
+
* ```js
|
216 |
+
* import cluster from 'cluster';
|
217 |
+
* import http from 'http';
|
218 |
+
* import { cpus } from 'os';
|
219 |
+
* import process from 'process';
|
220 |
+
*
|
221 |
+
* const numCPUs = cpus().length;
|
222 |
+
*
|
223 |
+
* if (cluster.isPrimary) {
|
224 |
+
* console.log(`Primary ${process.pid} is running`);
|
225 |
+
*
|
226 |
+
* // Fork workers.
|
227 |
+
* for (let i = 0; i < numCPUs; i++) {
|
228 |
+
* cluster.fork();
|
229 |
+
* }
|
230 |
+
*
|
231 |
+
* cluster.on('fork', (worker) => {
|
232 |
+
* console.log('worker is dead:', worker.isDead());
|
233 |
+
* });
|
234 |
+
*
|
235 |
+
* cluster.on('exit', (worker, code, signal) => {
|
236 |
+
* console.log('worker is dead:', worker.isDead());
|
237 |
+
* });
|
238 |
+
* } else {
|
239 |
+
* // Workers can share any TCP connection. In this case, it is an HTTP server.
|
240 |
+
* http.createServer((req, res) => {
|
241 |
+
* res.writeHead(200);
|
242 |
+
* res.end(`Current process\n ${process.pid}`);
|
243 |
+
* process.kill(process.pid);
|
244 |
+
* }).listen(8000);
|
245 |
+
* }
|
246 |
+
* ```
|
247 |
+
* @since v0.11.14
|
248 |
+
*/
|
249 |
+
isDead(): boolean;
|
250 |
+
/**
|
251 |
+
* This property is `true` if the worker exited due to `.disconnect()`.
|
252 |
+
* If the worker exited any other way, it is `false`. If the
|
253 |
+
* worker has not exited, it is `undefined`.
|
254 |
+
*
|
255 |
+
* The boolean `worker.exitedAfterDisconnect` allows distinguishing between
|
256 |
+
* voluntary and accidental exit, the primary may choose not to respawn a worker
|
257 |
+
* based on this value.
|
258 |
+
*
|
259 |
+
* ```js
|
260 |
+
* cluster.on('exit', (worker, code, signal) => {
|
261 |
+
* if (worker.exitedAfterDisconnect === true) {
|
262 |
+
* console.log('Oh, it was just voluntary – no need to worry');
|
263 |
+
* }
|
264 |
+
* });
|
265 |
+
*
|
266 |
+
* // kill worker
|
267 |
+
* worker.kill();
|
268 |
+
* ```
|
269 |
+
* @since v6.0.0
|
270 |
+
*/
|
271 |
+
exitedAfterDisconnect: boolean;
|
272 |
+
/**
|
273 |
+
* events.EventEmitter
|
274 |
+
* 1. disconnect
|
275 |
+
* 2. error
|
276 |
+
* 3. exit
|
277 |
+
* 4. listening
|
278 |
+
* 5. message
|
279 |
+
* 6. online
|
280 |
+
*/
|
281 |
+
addListener(event: string, listener: (...args: any[]) => void): this;
|
282 |
+
addListener(event: 'disconnect', listener: () => void): this;
|
283 |
+
addListener(event: 'error', listener: (error: Error) => void): this;
|
284 |
+
addListener(event: 'exit', listener: (code: number, signal: string) => void): this;
|
285 |
+
addListener(event: 'listening', listener: (address: Address) => void): this;
|
286 |
+
addListener(event: 'message', listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
287 |
+
addListener(event: 'online', listener: () => void): this;
|
288 |
+
emit(event: string | symbol, ...args: any[]): boolean;
|
289 |
+
emit(event: 'disconnect'): boolean;
|
290 |
+
emit(event: 'error', error: Error): boolean;
|
291 |
+
emit(event: 'exit', code: number, signal: string): boolean;
|
292 |
+
emit(event: 'listening', address: Address): boolean;
|
293 |
+
emit(event: 'message', message: any, handle: net.Socket | net.Server): boolean;
|
294 |
+
emit(event: 'online'): boolean;
|
295 |
+
on(event: string, listener: (...args: any[]) => void): this;
|
296 |
+
on(event: 'disconnect', listener: () => void): this;
|
297 |
+
on(event: 'error', listener: (error: Error) => void): this;
|
298 |
+
on(event: 'exit', listener: (code: number, signal: string) => void): this;
|
299 |
+
on(event: 'listening', listener: (address: Address) => void): this;
|
300 |
+
on(event: 'message', listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
301 |
+
on(event: 'online', listener: () => void): this;
|
302 |
+
once(event: string, listener: (...args: any[]) => void): this;
|
303 |
+
once(event: 'disconnect', listener: () => void): this;
|
304 |
+
once(event: 'error', listener: (error: Error) => void): this;
|
305 |
+
once(event: 'exit', listener: (code: number, signal: string) => void): this;
|
306 |
+
once(event: 'listening', listener: (address: Address) => void): this;
|
307 |
+
once(event: 'message', listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
308 |
+
once(event: 'online', listener: () => void): this;
|
309 |
+
prependListener(event: string, listener: (...args: any[]) => void): this;
|
310 |
+
prependListener(event: 'disconnect', listener: () => void): this;
|
311 |
+
prependListener(event: 'error', listener: (error: Error) => void): this;
|
312 |
+
prependListener(event: 'exit', listener: (code: number, signal: string) => void): this;
|
313 |
+
prependListener(event: 'listening', listener: (address: Address) => void): this;
|
314 |
+
prependListener(event: 'message', listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
315 |
+
prependListener(event: 'online', listener: () => void): this;
|
316 |
+
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
317 |
+
prependOnceListener(event: 'disconnect', listener: () => void): this;
|
318 |
+
prependOnceListener(event: 'error', listener: (error: Error) => void): this;
|
319 |
+
prependOnceListener(event: 'exit', listener: (code: number, signal: string) => void): this;
|
320 |
+
prependOnceListener(event: 'listening', listener: (address: Address) => void): this;
|
321 |
+
prependOnceListener(event: 'message', listener: (message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
322 |
+
prependOnceListener(event: 'online', listener: () => void): this;
|
323 |
+
}
|
324 |
+
export interface Cluster extends EventEmitter {
|
325 |
+
disconnect(callback?: () => void): void;
|
326 |
+
fork(env?: any): Worker;
|
327 |
+
/** @deprecated since v16.0.0 - use isPrimary. */
|
328 |
+
readonly isMaster: boolean;
|
329 |
+
readonly isPrimary: boolean;
|
330 |
+
readonly isWorker: boolean;
|
331 |
+
schedulingPolicy: number;
|
332 |
+
readonly settings: ClusterSettings;
|
333 |
+
/** @deprecated since v16.0.0 - use setupPrimary. */
|
334 |
+
setupMaster(settings?: ClusterSettings): void;
|
335 |
+
/**
|
336 |
+
* `setupPrimary` is used to change the default 'fork' behavior. Once called, the settings will be present in cluster.settings.
|
337 |
+
*/
|
338 |
+
setupPrimary(settings?: ClusterSettings): void;
|
339 |
+
readonly worker?: Worker | undefined;
|
340 |
+
readonly workers?: NodeJS.Dict<Worker> | undefined;
|
341 |
+
readonly SCHED_NONE: number;
|
342 |
+
readonly SCHED_RR: number;
|
343 |
+
/**
|
344 |
+
* events.EventEmitter
|
345 |
+
* 1. disconnect
|
346 |
+
* 2. exit
|
347 |
+
* 3. fork
|
348 |
+
* 4. listening
|
349 |
+
* 5. message
|
350 |
+
* 6. online
|
351 |
+
* 7. setup
|
352 |
+
*/
|
353 |
+
addListener(event: string, listener: (...args: any[]) => void): this;
|
354 |
+
addListener(event: 'disconnect', listener: (worker: Worker) => void): this;
|
355 |
+
addListener(event: 'exit', listener: (worker: Worker, code: number, signal: string) => void): this;
|
356 |
+
addListener(event: 'fork', listener: (worker: Worker) => void): this;
|
357 |
+
addListener(event: 'listening', listener: (worker: Worker, address: Address) => void): this;
|
358 |
+
addListener(event: 'message', listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
359 |
+
addListener(event: 'online', listener: (worker: Worker) => void): this;
|
360 |
+
addListener(event: 'setup', listener: (settings: ClusterSettings) => void): this;
|
361 |
+
emit(event: string | symbol, ...args: any[]): boolean;
|
362 |
+
emit(event: 'disconnect', worker: Worker): boolean;
|
363 |
+
emit(event: 'exit', worker: Worker, code: number, signal: string): boolean;
|
364 |
+
emit(event: 'fork', worker: Worker): boolean;
|
365 |
+
emit(event: 'listening', worker: Worker, address: Address): boolean;
|
366 |
+
emit(event: 'message', worker: Worker, message: any, handle: net.Socket | net.Server): boolean;
|
367 |
+
emit(event: 'online', worker: Worker): boolean;
|
368 |
+
emit(event: 'setup', settings: ClusterSettings): boolean;
|
369 |
+
on(event: string, listener: (...args: any[]) => void): this;
|
370 |
+
on(event: 'disconnect', listener: (worker: Worker) => void): this;
|
371 |
+
on(event: 'exit', listener: (worker: Worker, code: number, signal: string) => void): this;
|
372 |
+
on(event: 'fork', listener: (worker: Worker) => void): this;
|
373 |
+
on(event: 'listening', listener: (worker: Worker, address: Address) => void): this;
|
374 |
+
on(event: 'message', listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
375 |
+
on(event: 'online', listener: (worker: Worker) => void): this;
|
376 |
+
on(event: 'setup', listener: (settings: ClusterSettings) => void): this;
|
377 |
+
once(event: string, listener: (...args: any[]) => void): this;
|
378 |
+
once(event: 'disconnect', listener: (worker: Worker) => void): this;
|
379 |
+
once(event: 'exit', listener: (worker: Worker, code: number, signal: string) => void): this;
|
380 |
+
once(event: 'fork', listener: (worker: Worker) => void): this;
|
381 |
+
once(event: 'listening', listener: (worker: Worker, address: Address) => void): this;
|
382 |
+
once(event: 'message', listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this; // the handle is a net.Socket or net.Server object, or undefined.
|
383 |
+
once(event: 'online', listener: (worker: Worker) => void): this;
|
384 |
+
once(event: 'setup', listener: (settings: ClusterSettings) => void): this;
|
385 |
+
prependListener(event: string, listener: (...args: any[]) => void): this;
|
386 |
+
prependListener(event: 'disconnect', listener: (worker: Worker) => void): this;
|
387 |
+
prependListener(event: 'exit', listener: (worker: Worker, code: number, signal: string) => void): this;
|
388 |
+
prependListener(event: 'fork', listener: (worker: Worker) => void): this;
|
389 |
+
prependListener(event: 'listening', listener: (worker: Worker, address: Address) => void): this;
|
390 |
+
// the handle is a net.Socket or net.Server object, or undefined.
|
391 |
+
prependListener(event: 'message', listener: (worker: Worker, message: any, handle?: net.Socket | net.Server) => void): this;
|
392 |
+
prependListener(event: 'online', listener: (worker: Worker) => void): this;
|
393 |
+
prependListener(event: 'setup', listener: (settings: ClusterSettings) => void): this;
|
394 |
+
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
395 |
+
prependOnceListener(event: 'disconnect', listener: (worker: Worker) => void): this;
|
396 |
+
prependOnceListener(event: 'exit', listener: (worker: Worker, code: number, signal: string) => void): this;
|
397 |
+
prependOnceListener(event: 'fork', listener: (worker: Worker) => void): this;
|
398 |
+
prependOnceListener(event: 'listening', listener: (worker: Worker, address: Address) => void): this;
|
399 |
+
// the handle is a net.Socket or net.Server object, or undefined.
|
400 |
+
prependOnceListener(event: 'message', listener: (worker: Worker, message: any, handle: net.Socket | net.Server) => void): this;
|
401 |
+
prependOnceListener(event: 'online', listener: (worker: Worker) => void): this;
|
402 |
+
prependOnceListener(event: 'setup', listener: (settings: ClusterSettings) => void): this;
|
403 |
+
}
|
404 |
+
const cluster: Cluster;
|
405 |
+
export default cluster;
|
406 |
+
}
|
407 |
+
declare module 'node:cluster' {
|
408 |
+
export * from 'cluster';
|
409 |
+
export { default as default } from 'cluster';
|
410 |
+
}
|
igv_component/node_modules/@types/node/console.d.ts
ADDED
@@ -0,0 +1,412 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* The `console` module provides a simple debugging console that is similar to the
|
3 |
+
* JavaScript console mechanism provided by web browsers.
|
4 |
+
*
|
5 |
+
* The module exports two specific components:
|
6 |
+
*
|
7 |
+
* * A `Console` class with methods such as `console.log()`, `console.error()` and`console.warn()` that can be used to write to any Node.js stream.
|
8 |
+
* * A global `console` instance configured to write to `process.stdout` and `process.stderr`. The global `console` can be used without calling`require('console')`.
|
9 |
+
*
|
10 |
+
* _**Warning**_: The global console object's methods are neither consistently
|
11 |
+
* synchronous like the browser APIs they resemble, nor are they consistently
|
12 |
+
* asynchronous like all other Node.js streams. See the `note on process I/O` for
|
13 |
+
* more information.
|
14 |
+
*
|
15 |
+
* Example using the global `console`:
|
16 |
+
*
|
17 |
+
* ```js
|
18 |
+
* console.log('hello world');
|
19 |
+
* // Prints: hello world, to stdout
|
20 |
+
* console.log('hello %s', 'world');
|
21 |
+
* // Prints: hello world, to stdout
|
22 |
+
* console.error(new Error('Whoops, something bad happened'));
|
23 |
+
* // Prints error message and stack trace to stderr:
|
24 |
+
* // Error: Whoops, something bad happened
|
25 |
+
* // at [eval]:5:15
|
26 |
+
* // at Script.runInThisContext (node:vm:132:18)
|
27 |
+
* // at Object.runInThisContext (node:vm:309:38)
|
28 |
+
* // at node:internal/process/execution:77:19
|
29 |
+
* // at [eval]-wrapper:6:22
|
30 |
+
* // at evalScript (node:internal/process/execution:76:60)
|
31 |
+
* // at node:internal/main/eval_string:23:3
|
32 |
+
*
|
33 |
+
* const name = 'Will Robinson';
|
34 |
+
* console.warn(`Danger ${name}! Danger!`);
|
35 |
+
* // Prints: Danger Will Robinson! Danger!, to stderr
|
36 |
+
* ```
|
37 |
+
*
|
38 |
+
* Example using the `Console` class:
|
39 |
+
*
|
40 |
+
* ```js
|
41 |
+
* const out = getStreamSomehow();
|
42 |
+
* const err = getStreamSomehow();
|
43 |
+
* const myConsole = new console.Console(out, err);
|
44 |
+
*
|
45 |
+
* myConsole.log('hello world');
|
46 |
+
* // Prints: hello world, to out
|
47 |
+
* myConsole.log('hello %s', 'world');
|
48 |
+
* // Prints: hello world, to out
|
49 |
+
* myConsole.error(new Error('Whoops, something bad happened'));
|
50 |
+
* // Prints: [Error: Whoops, something bad happened], to err
|
51 |
+
*
|
52 |
+
* const name = 'Will Robinson';
|
53 |
+
* myConsole.warn(`Danger ${name}! Danger!`);
|
54 |
+
* // Prints: Danger Will Robinson! Danger!, to err
|
55 |
+
* ```
|
56 |
+
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/console.js)
|
57 |
+
*/
|
58 |
+
declare module 'console' {
|
59 |
+
import console = require('node:console');
|
60 |
+
export = console;
|
61 |
+
}
|
62 |
+
declare module 'node:console' {
|
63 |
+
import { InspectOptions } from 'node:util';
|
64 |
+
global {
|
65 |
+
// This needs to be global to avoid TS2403 in case lib.dom.d.ts is present in the same build
|
66 |
+
interface Console {
|
67 |
+
Console: console.ConsoleConstructor;
|
68 |
+
/**
|
69 |
+
* `console.assert()` writes a message if `value` is [falsy](https://developer.mozilla.org/en-US/docs/Glossary/Falsy) or omitted. It only
|
70 |
+
* writes a message and does not otherwise affect execution. The output always
|
71 |
+
* starts with `"Assertion failed"`. If provided, `message` is formatted using `util.format()`.
|
72 |
+
*
|
73 |
+
* If `value` is [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy), nothing happens.
|
74 |
+
*
|
75 |
+
* ```js
|
76 |
+
* console.assert(true, 'does nothing');
|
77 |
+
*
|
78 |
+
* console.assert(false, 'Whoops %s work', 'didn\'t');
|
79 |
+
* // Assertion failed: Whoops didn't work
|
80 |
+
*
|
81 |
+
* console.assert();
|
82 |
+
* // Assertion failed
|
83 |
+
* ```
|
84 |
+
* @since v0.1.101
|
85 |
+
* @param value The value tested for being truthy.
|
86 |
+
* @param message All arguments besides `value` are used as error message.
|
87 |
+
*/
|
88 |
+
assert(value: any, message?: string, ...optionalParams: any[]): void;
|
89 |
+
/**
|
90 |
+
* When `stdout` is a TTY, calling `console.clear()` will attempt to clear the
|
91 |
+
* TTY. When `stdout` is not a TTY, this method does nothing.
|
92 |
+
*
|
93 |
+
* The specific operation of `console.clear()` can vary across operating systems
|
94 |
+
* and terminal types. For most Linux operating systems, `console.clear()`operates similarly to the `clear` shell command. On Windows, `console.clear()`will clear only the output in the
|
95 |
+
* current terminal viewport for the Node.js
|
96 |
+
* binary.
|
97 |
+
* @since v8.3.0
|
98 |
+
*/
|
99 |
+
clear(): void;
|
100 |
+
/**
|
101 |
+
* Maintains an internal counter specific to `label` and outputs to `stdout` the
|
102 |
+
* number of times `console.count()` has been called with the given `label`.
|
103 |
+
*
|
104 |
+
* ```js
|
105 |
+
* > console.count()
|
106 |
+
* default: 1
|
107 |
+
* undefined
|
108 |
+
* > console.count('default')
|
109 |
+
* default: 2
|
110 |
+
* undefined
|
111 |
+
* > console.count('abc')
|
112 |
+
* abc: 1
|
113 |
+
* undefined
|
114 |
+
* > console.count('xyz')
|
115 |
+
* xyz: 1
|
116 |
+
* undefined
|
117 |
+
* > console.count('abc')
|
118 |
+
* abc: 2
|
119 |
+
* undefined
|
120 |
+
* > console.count()
|
121 |
+
* default: 3
|
122 |
+
* undefined
|
123 |
+
* >
|
124 |
+
* ```
|
125 |
+
* @since v8.3.0
|
126 |
+
* @param label The display label for the counter.
|
127 |
+
*/
|
128 |
+
count(label?: string): void;
|
129 |
+
/**
|
130 |
+
* Resets the internal counter specific to `label`.
|
131 |
+
*
|
132 |
+
* ```js
|
133 |
+
* > console.count('abc');
|
134 |
+
* abc: 1
|
135 |
+
* undefined
|
136 |
+
* > console.countReset('abc');
|
137 |
+
* undefined
|
138 |
+
* > console.count('abc');
|
139 |
+
* abc: 1
|
140 |
+
* undefined
|
141 |
+
* >
|
142 |
+
* ```
|
143 |
+
* @since v8.3.0
|
144 |
+
* @param label The display label for the counter.
|
145 |
+
*/
|
146 |
+
countReset(label?: string): void;
|
147 |
+
/**
|
148 |
+
* The `console.debug()` function is an alias for {@link log}.
|
149 |
+
* @since v8.0.0
|
150 |
+
*/
|
151 |
+
debug(message?: any, ...optionalParams: any[]): void;
|
152 |
+
/**
|
153 |
+
* Uses `util.inspect()` on `obj` and prints the resulting string to `stdout`.
|
154 |
+
* This function bypasses any custom `inspect()` function defined on `obj`.
|
155 |
+
* @since v0.1.101
|
156 |
+
*/
|
157 |
+
dir(obj: any, options?: InspectOptions): void;
|
158 |
+
/**
|
159 |
+
* This method calls `console.log()` passing it the arguments received.
|
160 |
+
* This method does not produce any XML formatting.
|
161 |
+
* @since v8.0.0
|
162 |
+
*/
|
163 |
+
dirxml(...data: any[]): void;
|
164 |
+
/**
|
165 |
+
* Prints to `stderr` with newline. Multiple arguments can be passed, with the
|
166 |
+
* first used as the primary message and all additional used as substitution
|
167 |
+
* values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to `util.format()`).
|
168 |
+
*
|
169 |
+
* ```js
|
170 |
+
* const code = 5;
|
171 |
+
* console.error('error #%d', code);
|
172 |
+
* // Prints: error #5, to stderr
|
173 |
+
* console.error('error', code);
|
174 |
+
* // Prints: error 5, to stderr
|
175 |
+
* ```
|
176 |
+
*
|
177 |
+
* If formatting elements (e.g. `%d`) are not found in the first string then `util.inspect()` is called on each argument and the resulting string
|
178 |
+
* values are concatenated. See `util.format()` for more information.
|
179 |
+
* @since v0.1.100
|
180 |
+
*/
|
181 |
+
error(message?: any, ...optionalParams: any[]): void;
|
182 |
+
/**
|
183 |
+
* Increases indentation of subsequent lines by spaces for `groupIndentation`length.
|
184 |
+
*
|
185 |
+
* If one or more `label`s are provided, those are printed first without the
|
186 |
+
* additional indentation.
|
187 |
+
* @since v8.5.0
|
188 |
+
*/
|
189 |
+
group(...label: any[]): void;
|
190 |
+
/**
|
191 |
+
* An alias for {@link group}.
|
192 |
+
* @since v8.5.0
|
193 |
+
*/
|
194 |
+
groupCollapsed(...label: any[]): void;
|
195 |
+
/**
|
196 |
+
* Decreases indentation of subsequent lines by spaces for `groupIndentation`length.
|
197 |
+
* @since v8.5.0
|
198 |
+
*/
|
199 |
+
groupEnd(): void;
|
200 |
+
/**
|
201 |
+
* The `console.info()` function is an alias for {@link log}.
|
202 |
+
* @since v0.1.100
|
203 |
+
*/
|
204 |
+
info(message?: any, ...optionalParams: any[]): void;
|
205 |
+
/**
|
206 |
+
* Prints to `stdout` with newline. Multiple arguments can be passed, with the
|
207 |
+
* first used as the primary message and all additional used as substitution
|
208 |
+
* values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to `util.format()`).
|
209 |
+
*
|
210 |
+
* ```js
|
211 |
+
* const count = 5;
|
212 |
+
* console.log('count: %d', count);
|
213 |
+
* // Prints: count: 5, to stdout
|
214 |
+
* console.log('count:', count);
|
215 |
+
* // Prints: count: 5, to stdout
|
216 |
+
* ```
|
217 |
+
*
|
218 |
+
* See `util.format()` for more information.
|
219 |
+
* @since v0.1.100
|
220 |
+
*/
|
221 |
+
log(message?: any, ...optionalParams: any[]): void;
|
222 |
+
/**
|
223 |
+
* Try to construct a table with the columns of the properties of `tabularData`(or use `properties`) and rows of `tabularData` and log it. Falls back to just
|
224 |
+
* logging the argument if it can’t be parsed as tabular.
|
225 |
+
*
|
226 |
+
* ```js
|
227 |
+
* // These can't be parsed as tabular data
|
228 |
+
* console.table(Symbol());
|
229 |
+
* // Symbol()
|
230 |
+
*
|
231 |
+
* console.table(undefined);
|
232 |
+
* // undefined
|
233 |
+
*
|
234 |
+
* console.table([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }]);
|
235 |
+
* // ┌─────────┬─────┬─────┐
|
236 |
+
* // │ (index) │ a │ b │
|
237 |
+
* // ├─────────┼─────┼─────┤
|
238 |
+
* // │ 0 │ 1 │ 'Y' │
|
239 |
+
* // │ 1 │ 'Z' │ 2 │
|
240 |
+
* // └─────────┴─────┴─────┘
|
241 |
+
*
|
242 |
+
* console.table([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }], ['a']);
|
243 |
+
* // ┌─────────┬─────┐
|
244 |
+
* // │ (index) │ a │
|
245 |
+
* // ├─────────┼─────┤
|
246 |
+
* // │ 0 │ 1 │
|
247 |
+
* // │ 1 │ 'Z' │
|
248 |
+
* // └─────────┴─────┘
|
249 |
+
* ```
|
250 |
+
* @since v10.0.0
|
251 |
+
* @param properties Alternate properties for constructing the table.
|
252 |
+
*/
|
253 |
+
table(tabularData: any, properties?: ReadonlyArray<string>): void;
|
254 |
+
/**
|
255 |
+
* Starts a timer that can be used to compute the duration of an operation. Timers
|
256 |
+
* are identified by a unique `label`. Use the same `label` when calling {@link timeEnd} to stop the timer and output the elapsed time in
|
257 |
+
* suitable time units to `stdout`. For example, if the elapsed
|
258 |
+
* time is 3869ms, `console.timeEnd()` displays "3.869s".
|
259 |
+
* @since v0.1.104
|
260 |
+
*/
|
261 |
+
time(label?: string): void;
|
262 |
+
/**
|
263 |
+
* Stops a timer that was previously started by calling {@link time} and
|
264 |
+
* prints the result to `stdout`:
|
265 |
+
*
|
266 |
+
* ```js
|
267 |
+
* console.time('100-elements');
|
268 |
+
* for (let i = 0; i < 100; i++) {}
|
269 |
+
* console.timeEnd('100-elements');
|
270 |
+
* // prints 100-elements: 225.438ms
|
271 |
+
* ```
|
272 |
+
* @since v0.1.104
|
273 |
+
*/
|
274 |
+
timeEnd(label?: string): void;
|
275 |
+
/**
|
276 |
+
* For a timer that was previously started by calling {@link time}, prints
|
277 |
+
* the elapsed time and other `data` arguments to `stdout`:
|
278 |
+
*
|
279 |
+
* ```js
|
280 |
+
* console.time('process');
|
281 |
+
* const value = expensiveProcess1(); // Returns 42
|
282 |
+
* console.timeLog('process', value);
|
283 |
+
* // Prints "process: 365.227ms 42".
|
284 |
+
* doExpensiveProcess2(value);
|
285 |
+
* console.timeEnd('process');
|
286 |
+
* ```
|
287 |
+
* @since v10.7.0
|
288 |
+
*/
|
289 |
+
timeLog(label?: string, ...data: any[]): void;
|
290 |
+
/**
|
291 |
+
* Prints to `stderr` the string `'Trace: '`, followed by the `util.format()` formatted message and stack trace to the current position in the code.
|
292 |
+
*
|
293 |
+
* ```js
|
294 |
+
* console.trace('Show me');
|
295 |
+
* // Prints: (stack trace will vary based on where trace is called)
|
296 |
+
* // Trace: Show me
|
297 |
+
* // at repl:2:9
|
298 |
+
* // at REPLServer.defaultEval (repl.js:248:27)
|
299 |
+
* // at bound (domain.js:287:14)
|
300 |
+
* // at REPLServer.runBound [as eval] (domain.js:300:12)
|
301 |
+
* // at REPLServer.<anonymous> (repl.js:412:12)
|
302 |
+
* // at emitOne (events.js:82:20)
|
303 |
+
* // at REPLServer.emit (events.js:169:7)
|
304 |
+
* // at REPLServer.Interface._onLine (readline.js:210:10)
|
305 |
+
* // at REPLServer.Interface._line (readline.js:549:8)
|
306 |
+
* // at REPLServer.Interface._ttyWrite (readline.js:826:14)
|
307 |
+
* ```
|
308 |
+
* @since v0.1.104
|
309 |
+
*/
|
310 |
+
trace(message?: any, ...optionalParams: any[]): void;
|
311 |
+
/**
|
312 |
+
* The `console.warn()` function is an alias for {@link error}.
|
313 |
+
* @since v0.1.100
|
314 |
+
*/
|
315 |
+
warn(message?: any, ...optionalParams: any[]): void;
|
316 |
+
// --- Inspector mode only ---
|
317 |
+
/**
|
318 |
+
* This method does not display anything unless used in the inspector.
|
319 |
+
* Starts a JavaScript CPU profile with an optional label.
|
320 |
+
*/
|
321 |
+
profile(label?: string): void;
|
322 |
+
/**
|
323 |
+
* This method does not display anything unless used in the inspector.
|
324 |
+
* Stops the current JavaScript CPU profiling session if one has been started and prints the report to the Profiles panel of the inspector.
|
325 |
+
*/
|
326 |
+
profileEnd(label?: string): void;
|
327 |
+
/**
|
328 |
+
* This method does not display anything unless used in the inspector.
|
329 |
+
* Adds an event with the label `label` to the Timeline panel of the inspector.
|
330 |
+
*/
|
331 |
+
timeStamp(label?: string): void;
|
332 |
+
}
|
333 |
+
/**
|
334 |
+
* The `console` module provides a simple debugging console that is similar to the
|
335 |
+
* JavaScript console mechanism provided by web browsers.
|
336 |
+
*
|
337 |
+
* The module exports two specific components:
|
338 |
+
*
|
339 |
+
* * A `Console` class with methods such as `console.log()`, `console.error()` and`console.warn()` that can be used to write to any Node.js stream.
|
340 |
+
* * A global `console` instance configured to write to `process.stdout` and `process.stderr`. The global `console` can be used without calling`require('console')`.
|
341 |
+
*
|
342 |
+
* _**Warning**_: The global console object's methods are neither consistently
|
343 |
+
* synchronous like the browser APIs they resemble, nor are they consistently
|
344 |
+
* asynchronous like all other Node.js streams. See the `note on process I/O` for
|
345 |
+
* more information.
|
346 |
+
*
|
347 |
+
* Example using the global `console`:
|
348 |
+
*
|
349 |
+
* ```js
|
350 |
+
* console.log('hello world');
|
351 |
+
* // Prints: hello world, to stdout
|
352 |
+
* console.log('hello %s', 'world');
|
353 |
+
* // Prints: hello world, to stdout
|
354 |
+
* console.error(new Error('Whoops, something bad happened'));
|
355 |
+
* // Prints error message and stack trace to stderr:
|
356 |
+
* // Error: Whoops, something bad happened
|
357 |
+
* // at [eval]:5:15
|
358 |
+
* // at Script.runInThisContext (node:vm:132:18)
|
359 |
+
* // at Object.runInThisContext (node:vm:309:38)
|
360 |
+
* // at node:internal/process/execution:77:19
|
361 |
+
* // at [eval]-wrapper:6:22
|
362 |
+
* // at evalScript (node:internal/process/execution:76:60)
|
363 |
+
* // at node:internal/main/eval_string:23:3
|
364 |
+
*
|
365 |
+
* const name = 'Will Robinson';
|
366 |
+
* console.warn(`Danger ${name}! Danger!`);
|
367 |
+
* // Prints: Danger Will Robinson! Danger!, to stderr
|
368 |
+
* ```
|
369 |
+
*
|
370 |
+
* Example using the `Console` class:
|
371 |
+
*
|
372 |
+
* ```js
|
373 |
+
* const out = getStreamSomehow();
|
374 |
+
* const err = getStreamSomehow();
|
375 |
+
* const myConsole = new console.Console(out, err);
|
376 |
+
*
|
377 |
+
* myConsole.log('hello world');
|
378 |
+
* // Prints: hello world, to out
|
379 |
+
* myConsole.log('hello %s', 'world');
|
380 |
+
* // Prints: hello world, to out
|
381 |
+
* myConsole.error(new Error('Whoops, something bad happened'));
|
382 |
+
* // Prints: [Error: Whoops, something bad happened], to err
|
383 |
+
*
|
384 |
+
* const name = 'Will Robinson';
|
385 |
+
* myConsole.warn(`Danger ${name}! Danger!`);
|
386 |
+
* // Prints: Danger Will Robinson! Danger!, to err
|
387 |
+
* ```
|
388 |
+
* @see [source](https://github.com/nodejs/node/blob/v16.4.2/lib/console.js)
|
389 |
+
*/
|
390 |
+
namespace console {
|
391 |
+
interface ConsoleConstructorOptions {
|
392 |
+
stdout: NodeJS.WritableStream;
|
393 |
+
stderr?: NodeJS.WritableStream | undefined;
|
394 |
+
ignoreErrors?: boolean | undefined;
|
395 |
+
colorMode?: boolean | 'auto' | undefined;
|
396 |
+
inspectOptions?: InspectOptions | undefined;
|
397 |
+
/**
|
398 |
+
* Set group indentation
|
399 |
+
* @default 2
|
400 |
+
*/
|
401 |
+
groupIndentation?: number | undefined;
|
402 |
+
}
|
403 |
+
interface ConsoleConstructor {
|
404 |
+
prototype: Console;
|
405 |
+
new (stdout: NodeJS.WritableStream, stderr?: NodeJS.WritableStream, ignoreErrors?: boolean): Console;
|
406 |
+
new (options: ConsoleConstructorOptions): Console;
|
407 |
+
}
|
408 |
+
}
|
409 |
+
var console: Console;
|
410 |
+
}
|
411 |
+
export = globalThis.console;
|
412 |
+
}
|
igv_component/node_modules/@types/node/constants.d.ts
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/** @deprecated since v6.3.0 - use constants property exposed by the relevant module instead. */
|
2 |
+
declare module 'constants' {
|
3 |
+
import { constants as osConstants, SignalConstants } from 'node:os';
|
4 |
+
import { constants as cryptoConstants } from 'node:crypto';
|
5 |
+
import { constants as fsConstants } from 'node:fs';
|
6 |
+
|
7 |
+
const exp: typeof osConstants.errno &
|
8 |
+
typeof osConstants.priority &
|
9 |
+
SignalConstants &
|
10 |
+
typeof cryptoConstants &
|
11 |
+
typeof fsConstants;
|
12 |
+
export = exp;
|
13 |
+
}
|
14 |
+
|
15 |
+
declare module 'node:constants' {
|
16 |
+
import constants = require('constants');
|
17 |
+
export = constants;
|
18 |
+
}
|
igv_component/node_modules/@types/node/crypto.d.ts
ADDED
The diff for this file is too large to render.
See raw diff
|
|
igv_component/node_modules/@types/node/dgram.d.ts
ADDED
@@ -0,0 +1,545 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* The `dgram` module provides an implementation of UDP datagram sockets.
|
3 |
+
*
|
4 |
+
* ```js
|
5 |
+
* import dgram from 'dgram';
|
6 |
+
*
|
7 |
+
* const server = dgram.createSocket('udp4');
|
8 |
+
*
|
9 |
+
* server.on('error', (err) => {
|
10 |
+
* console.log(`server error:\n${err.stack}`);
|
11 |
+
* server.close();
|
12 |
+
* });
|
13 |
+
*
|
14 |
+
* server.on('message', (msg, rinfo) => {
|
15 |
+
* console.log(`server got: ${msg} from ${rinfo.address}:${rinfo.port}`);
|
16 |
+
* });
|
17 |
+
*
|
18 |
+
* server.on('listening', () => {
|
19 |
+
* const address = server.address();
|
20 |
+
* console.log(`server listening ${address.address}:${address.port}`);
|
21 |
+
* });
|
22 |
+
*
|
23 |
+
* server.bind(41234);
|
24 |
+
* // Prints: server listening 0.0.0.0:41234
|
25 |
+
* ```
|
26 |
+
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/dgram.js)
|
27 |
+
*/
|
28 |
+
declare module 'dgram' {
|
29 |
+
import { AddressInfo } from 'node:net';
|
30 |
+
import * as dns from 'node:dns';
|
31 |
+
import { EventEmitter, Abortable } from 'node:events';
|
32 |
+
interface RemoteInfo {
|
33 |
+
address: string;
|
34 |
+
family: 'IPv4' | 'IPv6';
|
35 |
+
port: number;
|
36 |
+
size: number;
|
37 |
+
}
|
38 |
+
interface BindOptions {
|
39 |
+
port?: number | undefined;
|
40 |
+
address?: string | undefined;
|
41 |
+
exclusive?: boolean | undefined;
|
42 |
+
fd?: number | undefined;
|
43 |
+
}
|
44 |
+
type SocketType = 'udp4' | 'udp6';
|
45 |
+
interface SocketOptions extends Abortable {
|
46 |
+
type: SocketType;
|
47 |
+
reuseAddr?: boolean | undefined;
|
48 |
+
/**
|
49 |
+
* @default false
|
50 |
+
*/
|
51 |
+
ipv6Only?: boolean | undefined;
|
52 |
+
recvBufferSize?: number | undefined;
|
53 |
+
sendBufferSize?: number | undefined;
|
54 |
+
lookup?: ((hostname: string, options: dns.LookupOneOptions, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void) => void) | undefined;
|
55 |
+
}
|
56 |
+
/**
|
57 |
+
* Creates a `dgram.Socket` object. Once the socket is created, calling `socket.bind()` will instruct the socket to begin listening for datagram
|
58 |
+
* messages. When `address` and `port` are not passed to `socket.bind()` the
|
59 |
+
* method will bind the socket to the "all interfaces" address on a random port
|
60 |
+
* (it does the right thing for both `udp4` and `udp6` sockets). The bound address
|
61 |
+
* and port can be retrieved using `socket.address().address` and `socket.address().port`.
|
62 |
+
*
|
63 |
+
* If the `signal` option is enabled, calling `.abort()` on the corresponding`AbortController` is similar to calling `.close()` on the socket:
|
64 |
+
*
|
65 |
+
* ```js
|
66 |
+
* const controller = new AbortController();
|
67 |
+
* const { signal } = controller;
|
68 |
+
* const server = dgram.createSocket({ type: 'udp4', signal });
|
69 |
+
* server.on('message', (msg, rinfo) => {
|
70 |
+
* console.log(`server got: ${msg} from ${rinfo.address}:${rinfo.port}`);
|
71 |
+
* });
|
72 |
+
* // Later, when you want to close the server.
|
73 |
+
* controller.abort();
|
74 |
+
* ```
|
75 |
+
* @since v0.11.13
|
76 |
+
* @param options Available options are:
|
77 |
+
* @param callback Attached as a listener for `'message'` events. Optional.
|
78 |
+
*/
|
79 |
+
function createSocket(type: SocketType, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
|
80 |
+
function createSocket(options: SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
|
81 |
+
/**
|
82 |
+
* Encapsulates the datagram functionality.
|
83 |
+
*
|
84 |
+
* New instances of `dgram.Socket` are created using {@link createSocket}.
|
85 |
+
* The `new` keyword is not to be used to create `dgram.Socket` instances.
|
86 |
+
* @since v0.1.99
|
87 |
+
*/
|
88 |
+
class Socket extends EventEmitter {
|
89 |
+
/**
|
90 |
+
* Tells the kernel to join a multicast group at the given `multicastAddress` and`multicastInterface` using the `IP_ADD_MEMBERSHIP` socket option. If the`multicastInterface` argument is not
|
91 |
+
* specified, the operating system will choose
|
92 |
+
* one interface and will add membership to it. To add membership to every
|
93 |
+
* available interface, call `addMembership` multiple times, once per interface.
|
94 |
+
*
|
95 |
+
* When called on an unbound socket, this method will implicitly bind to a random
|
96 |
+
* port, listening on all interfaces.
|
97 |
+
*
|
98 |
+
* When sharing a UDP socket across multiple `cluster` workers, the`socket.addMembership()` function must be called only once or an`EADDRINUSE` error will occur:
|
99 |
+
*
|
100 |
+
* ```js
|
101 |
+
* import cluster from 'cluster';
|
102 |
+
* import dgram from 'dgram';
|
103 |
+
*
|
104 |
+
* if (cluster.isPrimary) {
|
105 |
+
* cluster.fork(); // Works ok.
|
106 |
+
* cluster.fork(); // Fails with EADDRINUSE.
|
107 |
+
* } else {
|
108 |
+
* const s = dgram.createSocket('udp4');
|
109 |
+
* s.bind(1234, () => {
|
110 |
+
* s.addMembership('224.0.0.114');
|
111 |
+
* });
|
112 |
+
* }
|
113 |
+
* ```
|
114 |
+
* @since v0.6.9
|
115 |
+
*/
|
116 |
+
addMembership(multicastAddress: string, multicastInterface?: string): void;
|
117 |
+
/**
|
118 |
+
* Returns an object containing the address information for a socket.
|
119 |
+
* For UDP sockets, this object will contain `address`, `family` and `port`properties.
|
120 |
+
*
|
121 |
+
* This method throws `EBADF` if called on an unbound socket.
|
122 |
+
* @since v0.1.99
|
123 |
+
*/
|
124 |
+
address(): AddressInfo;
|
125 |
+
/**
|
126 |
+
* For UDP sockets, causes the `dgram.Socket` to listen for datagram
|
127 |
+
* messages on a named `port` and optional `address`. If `port` is not
|
128 |
+
* specified or is `0`, the operating system will attempt to bind to a
|
129 |
+
* random port. If `address` is not specified, the operating system will
|
130 |
+
* attempt to listen on all addresses. Once binding is complete, a`'listening'` event is emitted and the optional `callback` function is
|
131 |
+
* called.
|
132 |
+
*
|
133 |
+
* Specifying both a `'listening'` event listener and passing a`callback` to the `socket.bind()` method is not harmful but not very
|
134 |
+
* useful.
|
135 |
+
*
|
136 |
+
* A bound datagram socket keeps the Node.js process running to receive
|
137 |
+
* datagram messages.
|
138 |
+
*
|
139 |
+
* If binding fails, an `'error'` event is generated. In rare case (e.g.
|
140 |
+
* attempting to bind with a closed socket), an `Error` may be thrown.
|
141 |
+
*
|
142 |
+
* Example of a UDP server listening on port 41234:
|
143 |
+
*
|
144 |
+
* ```js
|
145 |
+
* import dgram from 'dgram';
|
146 |
+
*
|
147 |
+
* const server = dgram.createSocket('udp4');
|
148 |
+
*
|
149 |
+
* server.on('error', (err) => {
|
150 |
+
* console.log(`server error:\n${err.stack}`);
|
151 |
+
* server.close();
|
152 |
+
* });
|
153 |
+
*
|
154 |
+
* server.on('message', (msg, rinfo) => {
|
155 |
+
* console.log(`server got: ${msg} from ${rinfo.address}:${rinfo.port}`);
|
156 |
+
* });
|
157 |
+
*
|
158 |
+
* server.on('listening', () => {
|
159 |
+
* const address = server.address();
|
160 |
+
* console.log(`server listening ${address.address}:${address.port}`);
|
161 |
+
* });
|
162 |
+
*
|
163 |
+
* server.bind(41234);
|
164 |
+
* // Prints: server listening 0.0.0.0:41234
|
165 |
+
* ```
|
166 |
+
* @since v0.1.99
|
167 |
+
* @param callback with no parameters. Called when binding is complete.
|
168 |
+
*/
|
169 |
+
bind(port?: number, address?: string, callback?: () => void): this;
|
170 |
+
bind(port?: number, callback?: () => void): this;
|
171 |
+
bind(callback?: () => void): this;
|
172 |
+
bind(options: BindOptions, callback?: () => void): this;
|
173 |
+
/**
|
174 |
+
* Close the underlying socket and stop listening for data on it. If a callback is
|
175 |
+
* provided, it is added as a listener for the `'close'` event.
|
176 |
+
* @since v0.1.99
|
177 |
+
* @param callback Called when the socket has been closed.
|
178 |
+
*/
|
179 |
+
close(callback?: () => void): this;
|
180 |
+
/**
|
181 |
+
* Associates the `dgram.Socket` to a remote address and port. Every
|
182 |
+
* message sent by this handle is automatically sent to that destination. Also,
|
183 |
+
* the socket will only receive messages from that remote peer.
|
184 |
+
* Trying to call `connect()` on an already connected socket will result
|
185 |
+
* in an `ERR_SOCKET_DGRAM_IS_CONNECTED` exception. If `address` is not
|
186 |
+
* provided, `'127.0.0.1'` (for `udp4` sockets) or `'::1'` (for `udp6` sockets)
|
187 |
+
* will be used by default. Once the connection is complete, a `'connect'` event
|
188 |
+
* is emitted and the optional `callback` function is called. In case of failure,
|
189 |
+
* the `callback` is called or, failing this, an `'error'` event is emitted.
|
190 |
+
* @since v12.0.0
|
191 |
+
* @param callback Called when the connection is completed or on error.
|
192 |
+
*/
|
193 |
+
connect(port: number, address?: string, callback?: () => void): void;
|
194 |
+
connect(port: number, callback: () => void): void;
|
195 |
+
/**
|
196 |
+
* A synchronous function that disassociates a connected `dgram.Socket` from
|
197 |
+
* its remote address. Trying to call `disconnect()` on an unbound or already
|
198 |
+
* disconnected socket will result in an `ERR_SOCKET_DGRAM_NOT_CONNECTED` exception.
|
199 |
+
* @since v12.0.0
|
200 |
+
*/
|
201 |
+
disconnect(): void;
|
202 |
+
/**
|
203 |
+
* Instructs the kernel to leave a multicast group at `multicastAddress` using the`IP_DROP_MEMBERSHIP` socket option. This method is automatically called by the
|
204 |
+
* kernel when the socket is closed or the process terminates, so most apps will
|
205 |
+
* never have reason to call this.
|
206 |
+
*
|
207 |
+
* If `multicastInterface` is not specified, the operating system will attempt to
|
208 |
+
* drop membership on all valid interfaces.
|
209 |
+
* @since v0.6.9
|
210 |
+
*/
|
211 |
+
dropMembership(multicastAddress: string, multicastInterface?: string): void;
|
212 |
+
/**
|
213 |
+
* This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket.
|
214 |
+
* @since v8.7.0
|
215 |
+
* @return the `SO_RCVBUF` socket receive buffer size in bytes.
|
216 |
+
*/
|
217 |
+
getRecvBufferSize(): number;
|
218 |
+
/**
|
219 |
+
* This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket.
|
220 |
+
* @since v8.7.0
|
221 |
+
* @return the `SO_SNDBUF` socket send buffer size in bytes.
|
222 |
+
*/
|
223 |
+
getSendBufferSize(): number;
|
224 |
+
/**
|
225 |
+
* By default, binding a socket will cause it to block the Node.js process from
|
226 |
+
* exiting as long as the socket is open. The `socket.unref()` method can be used
|
227 |
+
* to exclude the socket from the reference counting that keeps the Node.js
|
228 |
+
* process active. The `socket.ref()` method adds the socket back to the reference
|
229 |
+
* counting and restores the default behavior.
|
230 |
+
*
|
231 |
+
* Calling `socket.ref()` multiples times will have no additional effect.
|
232 |
+
*
|
233 |
+
* The `socket.ref()` method returns a reference to the socket so calls can be
|
234 |
+
* chained.
|
235 |
+
* @since v0.9.1
|
236 |
+
*/
|
237 |
+
ref(): this;
|
238 |
+
/**
|
239 |
+
* Returns an object containing the `address`, `family`, and `port` of the remote
|
240 |
+
* endpoint. This method throws an `ERR_SOCKET_DGRAM_NOT_CONNECTED` exception
|
241 |
+
* if the socket is not connected.
|
242 |
+
* @since v12.0.0
|
243 |
+
*/
|
244 |
+
remoteAddress(): AddressInfo;
|
245 |
+
/**
|
246 |
+
* Broadcasts a datagram on the socket.
|
247 |
+
* For connectionless sockets, the destination `port` and `address` must be
|
248 |
+
* specified. Connected sockets, on the other hand, will use their associated
|
249 |
+
* remote endpoint, so the `port` and `address` arguments must not be set.
|
250 |
+
*
|
251 |
+
* The `msg` argument contains the message to be sent.
|
252 |
+
* Depending on its type, different behavior can apply. If `msg` is a `Buffer`,
|
253 |
+
* any `TypedArray` or a `DataView`,
|
254 |
+
* the `offset` and `length` specify the offset within the `Buffer` where the
|
255 |
+
* message begins and the number of bytes in the message, respectively.
|
256 |
+
* If `msg` is a `String`, then it is automatically converted to a `Buffer`with `'utf8'` encoding. With messages that
|
257 |
+
* contain multi-byte characters, `offset` and `length` will be calculated with
|
258 |
+
* respect to `byte length` and not the character position.
|
259 |
+
* If `msg` is an array, `offset` and `length` must not be specified.
|
260 |
+
*
|
261 |
+
* The `address` argument is a string. If the value of `address` is a host name,
|
262 |
+
* DNS will be used to resolve the address of the host. If `address` is not
|
263 |
+
* provided or otherwise nullish, `'127.0.0.1'` (for `udp4` sockets) or `'::1'`(for `udp6` sockets) will be used by default.
|
264 |
+
*
|
265 |
+
* If the socket has not been previously bound with a call to `bind`, the socket
|
266 |
+
* is assigned a random port number and is bound to the "all interfaces" address
|
267 |
+
* (`'0.0.0.0'` for `udp4` sockets, `'::0'` for `udp6` sockets.)
|
268 |
+
*
|
269 |
+
* An optional `callback` function may be specified to as a way of reporting
|
270 |
+
* DNS errors or for determining when it is safe to reuse the `buf` object.
|
271 |
+
* DNS lookups delay the time to send for at least one tick of the
|
272 |
+
* Node.js event loop.
|
273 |
+
*
|
274 |
+
* The only way to know for sure that the datagram has been sent is by using a`callback`. If an error occurs and a `callback` is given, the error will be
|
275 |
+
* passed as the first argument to the `callback`. If a `callback` is not given,
|
276 |
+
* the error is emitted as an `'error'` event on the `socket` object.
|
277 |
+
*
|
278 |
+
* Offset and length are optional but both _must_ be set if either are used.
|
279 |
+
* They are supported only when the first argument is a `Buffer`, a `TypedArray`,
|
280 |
+
* or a `DataView`.
|
281 |
+
*
|
282 |
+
* This method throws `ERR_SOCKET_BAD_PORT` if called on an unbound socket.
|
283 |
+
*
|
284 |
+
* Example of sending a UDP packet to a port on `localhost`;
|
285 |
+
*
|
286 |
+
* ```js
|
287 |
+
* import dgram from 'dgram';
|
288 |
+
* import { Buffer } from 'buffer';
|
289 |
+
*
|
290 |
+
* const message = Buffer.from('Some bytes');
|
291 |
+
* const client = dgram.createSocket('udp4');
|
292 |
+
* client.send(message, 41234, 'localhost', (err) => {
|
293 |
+
* client.close();
|
294 |
+
* });
|
295 |
+
* ```
|
296 |
+
*
|
297 |
+
* Example of sending a UDP packet composed of multiple buffers to a port on`127.0.0.1`;
|
298 |
+
*
|
299 |
+
* ```js
|
300 |
+
* import dgram from 'dgram';
|
301 |
+
* import { Buffer } from 'buffer';
|
302 |
+
*
|
303 |
+
* const buf1 = Buffer.from('Some ');
|
304 |
+
* const buf2 = Buffer.from('bytes');
|
305 |
+
* const client = dgram.createSocket('udp4');
|
306 |
+
* client.send([buf1, buf2], 41234, (err) => {
|
307 |
+
* client.close();
|
308 |
+
* });
|
309 |
+
* ```
|
310 |
+
*
|
311 |
+
* Sending multiple buffers might be faster or slower depending on the
|
312 |
+
* application and operating system. Run benchmarks to
|
313 |
+
* determine the optimal strategy on a case-by-case basis. Generally speaking,
|
314 |
+
* however, sending multiple buffers is faster.
|
315 |
+
*
|
316 |
+
* Example of sending a UDP packet using a socket connected to a port on`localhost`:
|
317 |
+
*
|
318 |
+
* ```js
|
319 |
+
* import dgram from 'dgram';
|
320 |
+
* import { Buffer } from 'buffer';
|
321 |
+
*
|
322 |
+
* const message = Buffer.from('Some bytes');
|
323 |
+
* const client = dgram.createSocket('udp4');
|
324 |
+
* client.connect(41234, 'localhost', (err) => {
|
325 |
+
* client.send(message, (err) => {
|
326 |
+
* client.close();
|
327 |
+
* });
|
328 |
+
* });
|
329 |
+
* ```
|
330 |
+
* @since v0.1.99
|
331 |
+
* @param msg Message to be sent.
|
332 |
+
* @param offset Offset in the buffer where the message starts.
|
333 |
+
* @param length Number of bytes in the message.
|
334 |
+
* @param port Destination port.
|
335 |
+
* @param address Destination host name or IP address.
|
336 |
+
* @param callback Called when the message has been sent.
|
337 |
+
*/
|
338 |
+
send(msg: string | Uint8Array | ReadonlyArray<any>, port?: number, address?: string, callback?: (error: Error | null, bytes: number) => void): void;
|
339 |
+
send(msg: string | Uint8Array | ReadonlyArray<any>, port?: number, callback?: (error: Error | null, bytes: number) => void): void;
|
340 |
+
send(msg: string | Uint8Array | ReadonlyArray<any>, callback?: (error: Error | null, bytes: number) => void): void;
|
341 |
+
send(msg: string | Uint8Array, offset: number, length: number, port?: number, address?: string, callback?: (error: Error | null, bytes: number) => void): void;
|
342 |
+
send(msg: string | Uint8Array, offset: number, length: number, port?: number, callback?: (error: Error | null, bytes: number) => void): void;
|
343 |
+
send(msg: string | Uint8Array, offset: number, length: number, callback?: (error: Error | null, bytes: number) => void): void;
|
344 |
+
/**
|
345 |
+
* Sets or clears the `SO_BROADCAST` socket option. When set to `true`, UDP
|
346 |
+
* packets may be sent to a local interface's broadcast address.
|
347 |
+
*
|
348 |
+
* This method throws `EBADF` if called on an unbound socket.
|
349 |
+
* @since v0.6.9
|
350 |
+
*/
|
351 |
+
setBroadcast(flag: boolean): void;
|
352 |
+
/**
|
353 |
+
* _All references to scope in this section are referring to [IPv6 Zone Indices](https://en.wikipedia.org/wiki/IPv6_address#Scoped_literal_IPv6_addresses), which are defined by [RFC
|
354 |
+
* 4007](https://tools.ietf.org/html/rfc4007). In string form, an IP_
|
355 |
+
* _with a scope index is written as `'IP%scope'` where scope is an interface name_
|
356 |
+
* _or interface number._
|
357 |
+
*
|
358 |
+
* Sets the default outgoing multicast interface of the socket to a chosen
|
359 |
+
* interface or back to system interface selection. The `multicastInterface` must
|
360 |
+
* be a valid string representation of an IP from the socket's family.
|
361 |
+
*
|
362 |
+
* For IPv4 sockets, this should be the IP configured for the desired physical
|
363 |
+
* interface. All packets sent to multicast on the socket will be sent on the
|
364 |
+
* interface determined by the most recent successful use of this call.
|
365 |
+
*
|
366 |
+
* For IPv6 sockets, `multicastInterface` should include a scope to indicate the
|
367 |
+
* interface as in the examples that follow. In IPv6, individual `send` calls can
|
368 |
+
* also use explicit scope in addresses, so only packets sent to a multicast
|
369 |
+
* address without specifying an explicit scope are affected by the most recent
|
370 |
+
* successful use of this call.
|
371 |
+
*
|
372 |
+
* This method throws `EBADF` if called on an unbound socket.
|
373 |
+
*
|
374 |
+
* #### Example: IPv6 outgoing multicast interface
|
375 |
+
*
|
376 |
+
* On most systems, where scope format uses the interface name:
|
377 |
+
*
|
378 |
+
* ```js
|
379 |
+
* const socket = dgram.createSocket('udp6');
|
380 |
+
*
|
381 |
+
* socket.bind(1234, () => {
|
382 |
+
* socket.setMulticastInterface('::%eth1');
|
383 |
+
* });
|
384 |
+
* ```
|
385 |
+
*
|
386 |
+
* On Windows, where scope format uses an interface number:
|
387 |
+
*
|
388 |
+
* ```js
|
389 |
+
* const socket = dgram.createSocket('udp6');
|
390 |
+
*
|
391 |
+
* socket.bind(1234, () => {
|
392 |
+
* socket.setMulticastInterface('::%2');
|
393 |
+
* });
|
394 |
+
* ```
|
395 |
+
*
|
396 |
+
* #### Example: IPv4 outgoing multicast interface
|
397 |
+
*
|
398 |
+
* All systems use an IP of the host on the desired physical interface:
|
399 |
+
*
|
400 |
+
* ```js
|
401 |
+
* const socket = dgram.createSocket('udp4');
|
402 |
+
*
|
403 |
+
* socket.bind(1234, () => {
|
404 |
+
* socket.setMulticastInterface('10.0.0.2');
|
405 |
+
* });
|
406 |
+
* ```
|
407 |
+
* @since v8.6.0
|
408 |
+
*/
|
409 |
+
setMulticastInterface(multicastInterface: string): void;
|
410 |
+
/**
|
411 |
+
* Sets or clears the `IP_MULTICAST_LOOP` socket option. When set to `true`,
|
412 |
+
* multicast packets will also be received on the local interface.
|
413 |
+
*
|
414 |
+
* This method throws `EBADF` if called on an unbound socket.
|
415 |
+
* @since v0.3.8
|
416 |
+
*/
|
417 |
+
setMulticastLoopback(flag: boolean): boolean;
|
418 |
+
/**
|
419 |
+
* Sets the `IP_MULTICAST_TTL` socket option. While TTL generally stands for
|
420 |
+
* "Time to Live", in this context it specifies the number of IP hops that a
|
421 |
+
* packet is allowed to travel through, specifically for multicast traffic. Each
|
422 |
+
* router or gateway that forwards a packet decrements the TTL. If the TTL is
|
423 |
+
* decremented to 0 by a router, it will not be forwarded.
|
424 |
+
*
|
425 |
+
* The `ttl` argument may be between 0 and 255\. The default on most systems is `1`.
|
426 |
+
*
|
427 |
+
* This method throws `EBADF` if called on an unbound socket.
|
428 |
+
* @since v0.3.8
|
429 |
+
*/
|
430 |
+
setMulticastTTL(ttl: number): number;
|
431 |
+
/**
|
432 |
+
* Sets the `SO_RCVBUF` socket option. Sets the maximum socket receive buffer
|
433 |
+
* in bytes.
|
434 |
+
*
|
435 |
+
* This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket.
|
436 |
+
* @since v8.7.0
|
437 |
+
*/
|
438 |
+
setRecvBufferSize(size: number): void;
|
439 |
+
/**
|
440 |
+
* Sets the `SO_SNDBUF` socket option. Sets the maximum socket send buffer
|
441 |
+
* in bytes.
|
442 |
+
*
|
443 |
+
* This method throws `ERR_SOCKET_BUFFER_SIZE` if called on an unbound socket.
|
444 |
+
* @since v8.7.0
|
445 |
+
*/
|
446 |
+
setSendBufferSize(size: number): void;
|
447 |
+
/**
|
448 |
+
* Sets the `IP_TTL` socket option. While TTL generally stands for "Time to Live",
|
449 |
+
* in this context it specifies the number of IP hops that a packet is allowed to
|
450 |
+
* travel through. Each router or gateway that forwards a packet decrements the
|
451 |
+
* TTL. If the TTL is decremented to 0 by a router, it will not be forwarded.
|
452 |
+
* Changing TTL values is typically done for network probes or when multicasting.
|
453 |
+
*
|
454 |
+
* The `ttl` argument may be between 1 and 255\. The default on most systems
|
455 |
+
* is 64.
|
456 |
+
*
|
457 |
+
* This method throws `EBADF` if called on an unbound socket.
|
458 |
+
* @since v0.1.101
|
459 |
+
*/
|
460 |
+
setTTL(ttl: number): number;
|
461 |
+
/**
|
462 |
+
* By default, binding a socket will cause it to block the Node.js process from
|
463 |
+
* exiting as long as the socket is open. The `socket.unref()` method can be used
|
464 |
+
* to exclude the socket from the reference counting that keeps the Node.js
|
465 |
+
* process active, allowing the process to exit even if the socket is still
|
466 |
+
* listening.
|
467 |
+
*
|
468 |
+
* Calling `socket.unref()` multiple times will have no addition effect.
|
469 |
+
*
|
470 |
+
* The `socket.unref()` method returns a reference to the socket so calls can be
|
471 |
+
* chained.
|
472 |
+
* @since v0.9.1
|
473 |
+
*/
|
474 |
+
unref(): this;
|
475 |
+
/**
|
476 |
+
* Tells the kernel to join a source-specific multicast channel at the given`sourceAddress` and `groupAddress`, using the `multicastInterface` with the`IP_ADD_SOURCE_MEMBERSHIP` socket
|
477 |
+
* option. If the `multicastInterface` argument
|
478 |
+
* is not specified, the operating system will choose one interface and will add
|
479 |
+
* membership to it. To add membership to every available interface, call`socket.addSourceSpecificMembership()` multiple times, once per interface.
|
480 |
+
*
|
481 |
+
* When called on an unbound socket, this method will implicitly bind to a random
|
482 |
+
* port, listening on all interfaces.
|
483 |
+
* @since v13.1.0, v12.16.0
|
484 |
+
*/
|
485 |
+
addSourceSpecificMembership(sourceAddress: string, groupAddress: string, multicastInterface?: string): void;
|
486 |
+
/**
|
487 |
+
* Instructs the kernel to leave a source-specific multicast channel at the given`sourceAddress` and `groupAddress` using the `IP_DROP_SOURCE_MEMBERSHIP`socket option. This method is
|
488 |
+
* automatically called by the kernel when the
|
489 |
+
* socket is closed or the process terminates, so most apps will never have
|
490 |
+
* reason to call this.
|
491 |
+
*
|
492 |
+
* If `multicastInterface` is not specified, the operating system will attempt to
|
493 |
+
* drop membership on all valid interfaces.
|
494 |
+
* @since v13.1.0, v12.16.0
|
495 |
+
*/
|
496 |
+
dropSourceSpecificMembership(sourceAddress: string, groupAddress: string, multicastInterface?: string): void;
|
497 |
+
/**
|
498 |
+
* events.EventEmitter
|
499 |
+
* 1. close
|
500 |
+
* 2. connect
|
501 |
+
* 3. error
|
502 |
+
* 4. listening
|
503 |
+
* 5. message
|
504 |
+
*/
|
505 |
+
addListener(event: string, listener: (...args: any[]) => void): this;
|
506 |
+
addListener(event: 'close', listener: () => void): this;
|
507 |
+
addListener(event: 'connect', listener: () => void): this;
|
508 |
+
addListener(event: 'error', listener: (err: Error) => void): this;
|
509 |
+
addListener(event: 'listening', listener: () => void): this;
|
510 |
+
addListener(event: 'message', listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
511 |
+
emit(event: string | symbol, ...args: any[]): boolean;
|
512 |
+
emit(event: 'close'): boolean;
|
513 |
+
emit(event: 'connect'): boolean;
|
514 |
+
emit(event: 'error', err: Error): boolean;
|
515 |
+
emit(event: 'listening'): boolean;
|
516 |
+
emit(event: 'message', msg: Buffer, rinfo: RemoteInfo): boolean;
|
517 |
+
on(event: string, listener: (...args: any[]) => void): this;
|
518 |
+
on(event: 'close', listener: () => void): this;
|
519 |
+
on(event: 'connect', listener: () => void): this;
|
520 |
+
on(event: 'error', listener: (err: Error) => void): this;
|
521 |
+
on(event: 'listening', listener: () => void): this;
|
522 |
+
on(event: 'message', listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
523 |
+
once(event: string, listener: (...args: any[]) => void): this;
|
524 |
+
once(event: 'close', listener: () => void): this;
|
525 |
+
once(event: 'connect', listener: () => void): this;
|
526 |
+
once(event: 'error', listener: (err: Error) => void): this;
|
527 |
+
once(event: 'listening', listener: () => void): this;
|
528 |
+
once(event: 'message', listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
529 |
+
prependListener(event: string, listener: (...args: any[]) => void): this;
|
530 |
+
prependListener(event: 'close', listener: () => void): this;
|
531 |
+
prependListener(event: 'connect', listener: () => void): this;
|
532 |
+
prependListener(event: 'error', listener: (err: Error) => void): this;
|
533 |
+
prependListener(event: 'listening', listener: () => void): this;
|
534 |
+
prependListener(event: 'message', listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
535 |
+
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
536 |
+
prependOnceListener(event: 'close', listener: () => void): this;
|
537 |
+
prependOnceListener(event: 'connect', listener: () => void): this;
|
538 |
+
prependOnceListener(event: 'error', listener: (err: Error) => void): this;
|
539 |
+
prependOnceListener(event: 'listening', listener: () => void): this;
|
540 |
+
prependOnceListener(event: 'message', listener: (msg: Buffer, rinfo: RemoteInfo) => void): this;
|
541 |
+
}
|
542 |
+
}
|
543 |
+
declare module 'node:dgram' {
|
544 |
+
export * from 'dgram';
|
545 |
+
}
|
igv_component/node_modules/@types/node/diagnostics_channel.d.ts
ADDED
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* The `diagnostics_channel` module provides an API to create named channels
|
3 |
+
* to report arbitrary message data for diagnostics purposes.
|
4 |
+
*
|
5 |
+
* It can be accessed using:
|
6 |
+
*
|
7 |
+
* ```js
|
8 |
+
* import diagnostics_channel from 'diagnostics_channel';
|
9 |
+
* ```
|
10 |
+
*
|
11 |
+
* It is intended that a module writer wanting to report diagnostics messages
|
12 |
+
* will create one or many top-level channels to report messages through.
|
13 |
+
* Channels may also be acquired at runtime but it is not encouraged
|
14 |
+
* due to the additional overhead of doing so. Channels may be exported for
|
15 |
+
* convenience, but as long as the name is known it can be acquired anywhere.
|
16 |
+
*
|
17 |
+
* If you intend for your module to produce diagnostics data for others to
|
18 |
+
* consume it is recommended that you include documentation of what named
|
19 |
+
* channels are used along with the shape of the message data. Channel names
|
20 |
+
* should generally include the module name to avoid collisions with data from
|
21 |
+
* other modules.
|
22 |
+
* @experimental
|
23 |
+
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/diagnostics_channel.js)
|
24 |
+
*/
|
25 |
+
declare module 'diagnostics_channel' {
|
26 |
+
/**
|
27 |
+
* Check if there are active subscribers to the named channel. This is helpful if
|
28 |
+
* the message you want to send might be expensive to prepare.
|
29 |
+
*
|
30 |
+
* This API is optional but helpful when trying to publish messages from very
|
31 |
+
* performance-sensitive code.
|
32 |
+
*
|
33 |
+
* ```js
|
34 |
+
* import diagnostics_channel from 'diagnostics_channel';
|
35 |
+
*
|
36 |
+
* if (diagnostics_channel.hasSubscribers('my-channel')) {
|
37 |
+
* // There are subscribers, prepare and publish message
|
38 |
+
* }
|
39 |
+
* ```
|
40 |
+
* @since v15.1.0, v14.17.0
|
41 |
+
* @param name The channel name
|
42 |
+
* @return If there are active subscribers
|
43 |
+
*/
|
44 |
+
function hasSubscribers(name: string): boolean;
|
45 |
+
/**
|
46 |
+
* This is the primary entry-point for anyone wanting to interact with a named
|
47 |
+
* channel. It produces a channel object which is optimized to reduce overhead at
|
48 |
+
* publish time as much as possible.
|
49 |
+
*
|
50 |
+
* ```js
|
51 |
+
* import diagnostics_channel from 'diagnostics_channel';
|
52 |
+
*
|
53 |
+
* const channel = diagnostics_channel.channel('my-channel');
|
54 |
+
* ```
|
55 |
+
* @since v15.1.0, v14.17.0
|
56 |
+
* @param name The channel name
|
57 |
+
* @return The named channel object
|
58 |
+
*/
|
59 |
+
function channel(name: string): Channel;
|
60 |
+
type ChannelListener = (message: unknown, name: string) => void;
|
61 |
+
/**
|
62 |
+
* The class `Channel` represents an individual named channel within the data
|
63 |
+
* pipeline. It is use to track subscribers and to publish messages when there
|
64 |
+
* are subscribers present. It exists as a separate object to avoid channel
|
65 |
+
* lookups at publish time, enabling very fast publish speeds and allowing
|
66 |
+
* for heavy use while incurring very minimal cost. Channels are created with {@link channel}, constructing a channel directly
|
67 |
+
* with `new Channel(name)` is not supported.
|
68 |
+
* @since v15.1.0, v14.17.0
|
69 |
+
*/
|
70 |
+
class Channel {
|
71 |
+
readonly name: string;
|
72 |
+
/**
|
73 |
+
* Check if there are active subscribers to this channel. This is helpful if
|
74 |
+
* the message you want to send might be expensive to prepare.
|
75 |
+
*
|
76 |
+
* This API is optional but helpful when trying to publish messages from very
|
77 |
+
* performance-sensitive code.
|
78 |
+
*
|
79 |
+
* ```js
|
80 |
+
* import diagnostics_channel from 'diagnostics_channel';
|
81 |
+
*
|
82 |
+
* const channel = diagnostics_channel.channel('my-channel');
|
83 |
+
*
|
84 |
+
* if (channel.hasSubscribers) {
|
85 |
+
* // There are subscribers, prepare and publish message
|
86 |
+
* }
|
87 |
+
* ```
|
88 |
+
* @since v15.1.0, v14.17.0
|
89 |
+
*/
|
90 |
+
readonly hasSubscribers: boolean;
|
91 |
+
private constructor(name: string);
|
92 |
+
/**
|
93 |
+
* Publish a message to any subscribers to the channel. This will
|
94 |
+
* trigger message handlers synchronously so they will execute within
|
95 |
+
* the same context.
|
96 |
+
*
|
97 |
+
* ```js
|
98 |
+
* import diagnostics_channel from 'diagnostics_channel';
|
99 |
+
*
|
100 |
+
* const channel = diagnostics_channel.channel('my-channel');
|
101 |
+
*
|
102 |
+
* channel.publish({
|
103 |
+
* some: 'message'
|
104 |
+
* });
|
105 |
+
* ```
|
106 |
+
* @since v15.1.0, v14.17.0
|
107 |
+
* @param message The message to send to the channel subscribers
|
108 |
+
*/
|
109 |
+
publish(message: unknown): void;
|
110 |
+
/**
|
111 |
+
* Register a message handler to subscribe to this channel. This message handler
|
112 |
+
* will be run synchronously whenever a message is published to the channel. Any
|
113 |
+
* errors thrown in the message handler will trigger an `'uncaughtException'`.
|
114 |
+
*
|
115 |
+
* ```js
|
116 |
+
* import diagnostics_channel from 'diagnostics_channel';
|
117 |
+
*
|
118 |
+
* const channel = diagnostics_channel.channel('my-channel');
|
119 |
+
*
|
120 |
+
* channel.subscribe((message, name) => {
|
121 |
+
* // Received data
|
122 |
+
* });
|
123 |
+
* ```
|
124 |
+
* @since v15.1.0, v14.17.0
|
125 |
+
* @param onMessage The handler to receive channel messages
|
126 |
+
*/
|
127 |
+
subscribe(onMessage: ChannelListener): void;
|
128 |
+
/**
|
129 |
+
* Remove a message handler previously registered to this channel with `channel.subscribe(onMessage)`.
|
130 |
+
*
|
131 |
+
* ```js
|
132 |
+
* import diagnostics_channel from 'diagnostics_channel';
|
133 |
+
*
|
134 |
+
* const channel = diagnostics_channel.channel('my-channel');
|
135 |
+
*
|
136 |
+
* function onMessage(message, name) {
|
137 |
+
* // Received data
|
138 |
+
* }
|
139 |
+
*
|
140 |
+
* channel.subscribe(onMessage);
|
141 |
+
*
|
142 |
+
* channel.unsubscribe(onMessage);
|
143 |
+
* ```
|
144 |
+
* @since v15.1.0, v14.17.0
|
145 |
+
* @param onMessage The previous subscribed handler to remove
|
146 |
+
* @return `true` if the handler was found, `false` otherwise.
|
147 |
+
*/
|
148 |
+
unsubscribe(onMessage: ChannelListener): void;
|
149 |
+
}
|
150 |
+
}
|
151 |
+
declare module 'node:diagnostics_channel' {
|
152 |
+
export * from 'diagnostics_channel';
|
153 |
+
}
|
igv_component/node_modules/@types/node/dns.d.ts
ADDED
@@ -0,0 +1,659 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* The `dns` module enables name resolution. For example, use it to look up IP
|
3 |
+
* addresses of host names.
|
4 |
+
*
|
5 |
+
* Although named for the [Domain Name System (DNS)](https://en.wikipedia.org/wiki/Domain_Name_System), it does not always use the
|
6 |
+
* DNS protocol for lookups. {@link lookup} uses the operating system
|
7 |
+
* facilities to perform name resolution. It may not need to perform any network
|
8 |
+
* communication. To perform name resolution the way other applications on the same
|
9 |
+
* system do, use {@link lookup}.
|
10 |
+
*
|
11 |
+
* ```js
|
12 |
+
* const dns = require('dns');
|
13 |
+
*
|
14 |
+
* dns.lookup('example.org', (err, address, family) => {
|
15 |
+
* console.log('address: %j family: IPv%s', address, family);
|
16 |
+
* });
|
17 |
+
* // address: "93.184.216.34" family: IPv4
|
18 |
+
* ```
|
19 |
+
*
|
20 |
+
* All other functions in the `dns` module connect to an actual DNS server to
|
21 |
+
* perform name resolution. They will always use the network to perform DNS
|
22 |
+
* queries. These functions do not use the same set of configuration files used by {@link lookup} (e.g. `/etc/hosts`). Use these functions to always perform
|
23 |
+
* DNS queries, bypassing other name-resolution facilities.
|
24 |
+
*
|
25 |
+
* ```js
|
26 |
+
* const dns = require('dns');
|
27 |
+
*
|
28 |
+
* dns.resolve4('archive.org', (err, addresses) => {
|
29 |
+
* if (err) throw err;
|
30 |
+
*
|
31 |
+
* console.log(`addresses: ${JSON.stringify(addresses)}`);
|
32 |
+
*
|
33 |
+
* addresses.forEach((a) => {
|
34 |
+
* dns.reverse(a, (err, hostnames) => {
|
35 |
+
* if (err) {
|
36 |
+
* throw err;
|
37 |
+
* }
|
38 |
+
* console.log(`reverse for ${a}: ${JSON.stringify(hostnames)}`);
|
39 |
+
* });
|
40 |
+
* });
|
41 |
+
* });
|
42 |
+
* ```
|
43 |
+
*
|
44 |
+
* See the `Implementation considerations section` for more information.
|
45 |
+
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/dns.js)
|
46 |
+
*/
|
47 |
+
declare module 'dns' {
|
48 |
+
import * as dnsPromises from 'node:dns/promises';
|
49 |
+
// Supported getaddrinfo flags.
|
50 |
+
export const ADDRCONFIG: number;
|
51 |
+
export const V4MAPPED: number;
|
52 |
+
/**
|
53 |
+
* If `dns.V4MAPPED` is specified, return resolved IPv6 addresses as
|
54 |
+
* well as IPv4 mapped IPv6 addresses.
|
55 |
+
*/
|
56 |
+
export const ALL: number;
|
57 |
+
export interface LookupOptions {
|
58 |
+
family?: number | undefined;
|
59 |
+
hints?: number | undefined;
|
60 |
+
all?: boolean | undefined;
|
61 |
+
/**
|
62 |
+
* @default true
|
63 |
+
*/
|
64 |
+
verbatim?: boolean | undefined;
|
65 |
+
}
|
66 |
+
export interface LookupOneOptions extends LookupOptions {
|
67 |
+
all?: false | undefined;
|
68 |
+
}
|
69 |
+
export interface LookupAllOptions extends LookupOptions {
|
70 |
+
all: true;
|
71 |
+
}
|
72 |
+
export interface LookupAddress {
|
73 |
+
address: string;
|
74 |
+
family: number;
|
75 |
+
}
|
76 |
+
/**
|
77 |
+
* Resolves a host name (e.g. `'nodejs.org'`) into the first found A (IPv4) or
|
78 |
+
* AAAA (IPv6) record. All `option` properties are optional. If `options` is an
|
79 |
+
* integer, then it must be `4` or `6` – if `options` is not provided, then IPv4
|
80 |
+
* and IPv6 addresses are both returned if found.
|
81 |
+
*
|
82 |
+
* With the `all` option set to `true`, the arguments for `callback` change to`(err, addresses)`, with `addresses` being an array of objects with the
|
83 |
+
* properties `address` and `family`.
|
84 |
+
*
|
85 |
+
* On error, `err` is an `Error` object, where `err.code` is the error code.
|
86 |
+
* Keep in mind that `err.code` will be set to `'ENOTFOUND'` not only when
|
87 |
+
* the host name does not exist but also when the lookup fails in other ways
|
88 |
+
* such as no available file descriptors.
|
89 |
+
*
|
90 |
+
* `dns.lookup()` does not necessarily have anything to do with the DNS protocol.
|
91 |
+
* The implementation uses an operating system facility that can associate names
|
92 |
+
* with addresses, and vice versa. This implementation can have subtle but
|
93 |
+
* important consequences on the behavior of any Node.js program. Please take some
|
94 |
+
* time to consult the `Implementation considerations section` before using`dns.lookup()`.
|
95 |
+
*
|
96 |
+
* Example usage:
|
97 |
+
*
|
98 |
+
* ```js
|
99 |
+
* const dns = require('dns');
|
100 |
+
* const options = {
|
101 |
+
* family: 6,
|
102 |
+
* hints: dns.ADDRCONFIG | dns.V4MAPPED,
|
103 |
+
* };
|
104 |
+
* dns.lookup('example.com', options, (err, address, family) =>
|
105 |
+
* console.log('address: %j family: IPv%s', address, family));
|
106 |
+
* // address: "2606:2800:220:1:248:1893:25c8:1946" family: IPv6
|
107 |
+
*
|
108 |
+
* // When options.all is true, the result will be an Array.
|
109 |
+
* options.all = true;
|
110 |
+
* dns.lookup('example.com', options, (err, addresses) =>
|
111 |
+
* console.log('addresses: %j', addresses));
|
112 |
+
* // addresses: [{"address":"2606:2800:220:1:248:1893:25c8:1946","family":6}]
|
113 |
+
* ```
|
114 |
+
*
|
115 |
+
* If this method is invoked as its `util.promisify()` ed version, and `all`is not set to `true`, it returns a `Promise` for an `Object` with `address` and`family` properties.
|
116 |
+
* @since v0.1.90
|
117 |
+
*/
|
118 |
+
export function lookup(hostname: string, family: number, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void): void;
|
119 |
+
export function lookup(hostname: string, options: LookupOneOptions, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void): void;
|
120 |
+
export function lookup(hostname: string, options: LookupAllOptions, callback: (err: NodeJS.ErrnoException | null, addresses: LookupAddress[]) => void): void;
|
121 |
+
export function lookup(hostname: string, options: LookupOptions, callback: (err: NodeJS.ErrnoException | null, address: string | LookupAddress[], family: number) => void): void;
|
122 |
+
export function lookup(hostname: string, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void): void;
|
123 |
+
export namespace lookup {
|
124 |
+
function __promisify__(hostname: string, options: LookupAllOptions): Promise<LookupAddress[]>;
|
125 |
+
function __promisify__(hostname: string, options?: LookupOneOptions | number): Promise<LookupAddress>;
|
126 |
+
function __promisify__(hostname: string, options: LookupOptions): Promise<LookupAddress | LookupAddress[]>;
|
127 |
+
}
|
128 |
+
/**
|
129 |
+
* Resolves the given `address` and `port` into a host name and service using
|
130 |
+
* the operating system's underlying `getnameinfo` implementation.
|
131 |
+
*
|
132 |
+
* If `address` is not a valid IP address, a `TypeError` will be thrown.
|
133 |
+
* The `port` will be coerced to a number. If it is not a legal port, a `TypeError`will be thrown.
|
134 |
+
*
|
135 |
+
* On an error, `err` is an `Error` object, where `err.code` is the error code.
|
136 |
+
*
|
137 |
+
* ```js
|
138 |
+
* const dns = require('dns');
|
139 |
+
* dns.lookupService('127.0.0.1', 22, (err, hostname, service) => {
|
140 |
+
* console.log(hostname, service);
|
141 |
+
* // Prints: localhost ssh
|
142 |
+
* });
|
143 |
+
* ```
|
144 |
+
*
|
145 |
+
* If this method is invoked as its `util.promisify()` ed version, it returns a`Promise` for an `Object` with `hostname` and `service` properties.
|
146 |
+
* @since v0.11.14
|
147 |
+
*/
|
148 |
+
export function lookupService(address: string, port: number, callback: (err: NodeJS.ErrnoException | null, hostname: string, service: string) => void): void;
|
149 |
+
export namespace lookupService {
|
150 |
+
function __promisify__(
|
151 |
+
address: string,
|
152 |
+
port: number
|
153 |
+
): Promise<{
|
154 |
+
hostname: string;
|
155 |
+
service: string;
|
156 |
+
}>;
|
157 |
+
}
|
158 |
+
export interface ResolveOptions {
|
159 |
+
ttl: boolean;
|
160 |
+
}
|
161 |
+
export interface ResolveWithTtlOptions extends ResolveOptions {
|
162 |
+
ttl: true;
|
163 |
+
}
|
164 |
+
export interface RecordWithTtl {
|
165 |
+
address: string;
|
166 |
+
ttl: number;
|
167 |
+
}
|
168 |
+
/** @deprecated Use `AnyARecord` or `AnyAaaaRecord` instead. */
|
169 |
+
export type AnyRecordWithTtl = AnyARecord | AnyAaaaRecord;
|
170 |
+
export interface AnyARecord extends RecordWithTtl {
|
171 |
+
type: 'A';
|
172 |
+
}
|
173 |
+
export interface AnyAaaaRecord extends RecordWithTtl {
|
174 |
+
type: 'AAAA';
|
175 |
+
}
|
176 |
+
export interface CaaRecord {
|
177 |
+
critial: number;
|
178 |
+
issue?: string | undefined;
|
179 |
+
issuewild?: string | undefined;
|
180 |
+
iodef?: string | undefined;
|
181 |
+
contactemail?: string | undefined;
|
182 |
+
contactphone?: string | undefined;
|
183 |
+
}
|
184 |
+
export interface MxRecord {
|
185 |
+
priority: number;
|
186 |
+
exchange: string;
|
187 |
+
}
|
188 |
+
export interface AnyMxRecord extends MxRecord {
|
189 |
+
type: 'MX';
|
190 |
+
}
|
191 |
+
export interface NaptrRecord {
|
192 |
+
flags: string;
|
193 |
+
service: string;
|
194 |
+
regexp: string;
|
195 |
+
replacement: string;
|
196 |
+
order: number;
|
197 |
+
preference: number;
|
198 |
+
}
|
199 |
+
export interface AnyNaptrRecord extends NaptrRecord {
|
200 |
+
type: 'NAPTR';
|
201 |
+
}
|
202 |
+
export interface SoaRecord {
|
203 |
+
nsname: string;
|
204 |
+
hostmaster: string;
|
205 |
+
serial: number;
|
206 |
+
refresh: number;
|
207 |
+
retry: number;
|
208 |
+
expire: number;
|
209 |
+
minttl: number;
|
210 |
+
}
|
211 |
+
export interface AnySoaRecord extends SoaRecord {
|
212 |
+
type: 'SOA';
|
213 |
+
}
|
214 |
+
export interface SrvRecord {
|
215 |
+
priority: number;
|
216 |
+
weight: number;
|
217 |
+
port: number;
|
218 |
+
name: string;
|
219 |
+
}
|
220 |
+
export interface AnySrvRecord extends SrvRecord {
|
221 |
+
type: 'SRV';
|
222 |
+
}
|
223 |
+
export interface AnyTxtRecord {
|
224 |
+
type: 'TXT';
|
225 |
+
entries: string[];
|
226 |
+
}
|
227 |
+
export interface AnyNsRecord {
|
228 |
+
type: 'NS';
|
229 |
+
value: string;
|
230 |
+
}
|
231 |
+
export interface AnyPtrRecord {
|
232 |
+
type: 'PTR';
|
233 |
+
value: string;
|
234 |
+
}
|
235 |
+
export interface AnyCnameRecord {
|
236 |
+
type: 'CNAME';
|
237 |
+
value: string;
|
238 |
+
}
|
239 |
+
export type AnyRecord = AnyARecord | AnyAaaaRecord | AnyCnameRecord | AnyMxRecord | AnyNaptrRecord | AnyNsRecord | AnyPtrRecord | AnySoaRecord | AnySrvRecord | AnyTxtRecord;
|
240 |
+
/**
|
241 |
+
* Uses the DNS protocol to resolve a host name (e.g. `'nodejs.org'`) into an array
|
242 |
+
* of the resource records. The `callback` function has arguments`(err, records)`. When successful, `records` will be an array of resource
|
243 |
+
* records. The type and structure of individual results varies based on `rrtype`:
|
244 |
+
*
|
245 |
+
* <omitted>
|
246 |
+
*
|
247 |
+
* On error, `err` is an `Error` object, where `err.code` is one of the `DNS error codes`.
|
248 |
+
* @since v0.1.27
|
249 |
+
* @param hostname Host name to resolve.
|
250 |
+
* @param [rrtype='A'] Resource record type.
|
251 |
+
*/
|
252 |
+
export function resolve(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
253 |
+
export function resolve(hostname: string, rrtype: 'A', callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
254 |
+
export function resolve(hostname: string, rrtype: 'AAAA', callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
255 |
+
export function resolve(hostname: string, rrtype: 'ANY', callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void): void;
|
256 |
+
export function resolve(hostname: string, rrtype: 'CNAME', callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
257 |
+
export function resolve(hostname: string, rrtype: 'MX', callback: (err: NodeJS.ErrnoException | null, addresses: MxRecord[]) => void): void;
|
258 |
+
export function resolve(hostname: string, rrtype: 'NAPTR', callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void): void;
|
259 |
+
export function resolve(hostname: string, rrtype: 'NS', callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
260 |
+
export function resolve(hostname: string, rrtype: 'PTR', callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
261 |
+
export function resolve(hostname: string, rrtype: 'SOA', callback: (err: NodeJS.ErrnoException | null, addresses: SoaRecord) => void): void;
|
262 |
+
export function resolve(hostname: string, rrtype: 'SRV', callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void): void;
|
263 |
+
export function resolve(hostname: string, rrtype: 'TXT', callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void): void;
|
264 |
+
export function resolve(
|
265 |
+
hostname: string,
|
266 |
+
rrtype: string,
|
267 |
+
callback: (err: NodeJS.ErrnoException | null, addresses: string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]) => void
|
268 |
+
): void;
|
269 |
+
export namespace resolve {
|
270 |
+
function __promisify__(hostname: string, rrtype?: 'A' | 'AAAA' | 'CNAME' | 'NS' | 'PTR'): Promise<string[]>;
|
271 |
+
function __promisify__(hostname: string, rrtype: 'ANY'): Promise<AnyRecord[]>;
|
272 |
+
function __promisify__(hostname: string, rrtype: 'MX'): Promise<MxRecord[]>;
|
273 |
+
function __promisify__(hostname: string, rrtype: 'NAPTR'): Promise<NaptrRecord[]>;
|
274 |
+
function __promisify__(hostname: string, rrtype: 'SOA'): Promise<SoaRecord>;
|
275 |
+
function __promisify__(hostname: string, rrtype: 'SRV'): Promise<SrvRecord[]>;
|
276 |
+
function __promisify__(hostname: string, rrtype: 'TXT'): Promise<string[][]>;
|
277 |
+
function __promisify__(hostname: string, rrtype: string): Promise<string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]>;
|
278 |
+
}
|
279 |
+
/**
|
280 |
+
* Uses the DNS protocol to resolve a IPv4 addresses (`A` records) for the`hostname`. The `addresses` argument passed to the `callback` function
|
281 |
+
* will contain an array of IPv4 addresses (e.g.`['74.125.79.104', '74.125.79.105', '74.125.79.106']`).
|
282 |
+
* @since v0.1.16
|
283 |
+
* @param hostname Host name to resolve.
|
284 |
+
*/
|
285 |
+
export function resolve4(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
286 |
+
export function resolve4(hostname: string, options: ResolveWithTtlOptions, callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void): void;
|
287 |
+
export function resolve4(hostname: string, options: ResolveOptions, callback: (err: NodeJS.ErrnoException | null, addresses: string[] | RecordWithTtl[]) => void): void;
|
288 |
+
export namespace resolve4 {
|
289 |
+
function __promisify__(hostname: string): Promise<string[]>;
|
290 |
+
function __promisify__(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
291 |
+
function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
292 |
+
}
|
293 |
+
/**
|
294 |
+
* Uses the DNS protocol to resolve a IPv6 addresses (`AAAA` records) for the`hostname`. The `addresses` argument passed to the `callback` function
|
295 |
+
* will contain an array of IPv6 addresses.
|
296 |
+
* @since v0.1.16
|
297 |
+
* @param hostname Host name to resolve.
|
298 |
+
*/
|
299 |
+
export function resolve6(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
300 |
+
export function resolve6(hostname: string, options: ResolveWithTtlOptions, callback: (err: NodeJS.ErrnoException | null, addresses: RecordWithTtl[]) => void): void;
|
301 |
+
export function resolve6(hostname: string, options: ResolveOptions, callback: (err: NodeJS.ErrnoException | null, addresses: string[] | RecordWithTtl[]) => void): void;
|
302 |
+
export namespace resolve6 {
|
303 |
+
function __promisify__(hostname: string): Promise<string[]>;
|
304 |
+
function __promisify__(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
305 |
+
function __promisify__(hostname: string, options?: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
306 |
+
}
|
307 |
+
/**
|
308 |
+
* Uses the DNS protocol to resolve `CNAME` records for the `hostname`. The`addresses` argument passed to the `callback` function
|
309 |
+
* will contain an array of canonical name records available for the `hostname`(e.g. `['bar.example.com']`).
|
310 |
+
* @since v0.3.2
|
311 |
+
*/
|
312 |
+
export function resolveCname(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
313 |
+
export namespace resolveCname {
|
314 |
+
function __promisify__(hostname: string): Promise<string[]>;
|
315 |
+
}
|
316 |
+
/**
|
317 |
+
* Uses the DNS protocol to resolve `CAA` records for the `hostname`. The`addresses` argument passed to the `callback` function
|
318 |
+
* will contain an array of certification authority authorization records
|
319 |
+
* available for the `hostname` (e.g. `[{critical: 0, iodef: 'mailto:pki@example.com'}, {critical: 128, issue: 'pki.example.com'}]`).
|
320 |
+
* @since v15.0.0, v14.17.0
|
321 |
+
*/
|
322 |
+
export function resolveCaa(hostname: string, callback: (err: NodeJS.ErrnoException | null, records: CaaRecord[]) => void): void;
|
323 |
+
export namespace resolveCaa {
|
324 |
+
function __promisify__(hostname: string): Promise<CaaRecord[]>;
|
325 |
+
}
|
326 |
+
/**
|
327 |
+
* Uses the DNS protocol to resolve mail exchange records (`MX` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
|
328 |
+
* contain an array of objects containing both a `priority` and `exchange`property (e.g. `[{priority: 10, exchange: 'mx.example.com'}, ...]`).
|
329 |
+
* @since v0.1.27
|
330 |
+
*/
|
331 |
+
export function resolveMx(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: MxRecord[]) => void): void;
|
332 |
+
export namespace resolveMx {
|
333 |
+
function __promisify__(hostname: string): Promise<MxRecord[]>;
|
334 |
+
}
|
335 |
+
/**
|
336 |
+
* Uses the DNS protocol to resolve regular expression based records (`NAPTR`records) for the `hostname`. The `addresses` argument passed to the `callback`function will contain an array of
|
337 |
+
* objects with the following properties:
|
338 |
+
*
|
339 |
+
* * `flags`
|
340 |
+
* * `service`
|
341 |
+
* * `regexp`
|
342 |
+
* * `replacement`
|
343 |
+
* * `order`
|
344 |
+
* * `preference`
|
345 |
+
*
|
346 |
+
* ```js
|
347 |
+
* {
|
348 |
+
* flags: 's',
|
349 |
+
* service: 'SIP+D2U',
|
350 |
+
* regexp: '',
|
351 |
+
* replacement: '_sip._udp.example.com',
|
352 |
+
* order: 30,
|
353 |
+
* preference: 100
|
354 |
+
* }
|
355 |
+
* ```
|
356 |
+
* @since v0.9.12
|
357 |
+
*/
|
358 |
+
export function resolveNaptr(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: NaptrRecord[]) => void): void;
|
359 |
+
export namespace resolveNaptr {
|
360 |
+
function __promisify__(hostname: string): Promise<NaptrRecord[]>;
|
361 |
+
}
|
362 |
+
/**
|
363 |
+
* Uses the DNS protocol to resolve name server records (`NS` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
|
364 |
+
* contain an array of name server records available for `hostname`(e.g. `['ns1.example.com', 'ns2.example.com']`).
|
365 |
+
* @since v0.1.90
|
366 |
+
*/
|
367 |
+
export function resolveNs(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
368 |
+
export namespace resolveNs {
|
369 |
+
function __promisify__(hostname: string): Promise<string[]>;
|
370 |
+
}
|
371 |
+
/**
|
372 |
+
* Uses the DNS protocol to resolve pointer records (`PTR` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
|
373 |
+
* be an array of strings containing the reply records.
|
374 |
+
* @since v6.0.0
|
375 |
+
*/
|
376 |
+
export function resolvePtr(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[]) => void): void;
|
377 |
+
export namespace resolvePtr {
|
378 |
+
function __promisify__(hostname: string): Promise<string[]>;
|
379 |
+
}
|
380 |
+
/**
|
381 |
+
* Uses the DNS protocol to resolve a start of authority record (`SOA` record) for
|
382 |
+
* the `hostname`. The `address` argument passed to the `callback` function will
|
383 |
+
* be an object with the following properties:
|
384 |
+
*
|
385 |
+
* * `nsname`
|
386 |
+
* * `hostmaster`
|
387 |
+
* * `serial`
|
388 |
+
* * `refresh`
|
389 |
+
* * `retry`
|
390 |
+
* * `expire`
|
391 |
+
* * `minttl`
|
392 |
+
*
|
393 |
+
* ```js
|
394 |
+
* {
|
395 |
+
* nsname: 'ns.example.com',
|
396 |
+
* hostmaster: 'root.example.com',
|
397 |
+
* serial: 2013101809,
|
398 |
+
* refresh: 10000,
|
399 |
+
* retry: 2400,
|
400 |
+
* expire: 604800,
|
401 |
+
* minttl: 3600
|
402 |
+
* }
|
403 |
+
* ```
|
404 |
+
* @since v0.11.10
|
405 |
+
*/
|
406 |
+
export function resolveSoa(hostname: string, callback: (err: NodeJS.ErrnoException | null, address: SoaRecord) => void): void;
|
407 |
+
export namespace resolveSoa {
|
408 |
+
function __promisify__(hostname: string): Promise<SoaRecord>;
|
409 |
+
}
|
410 |
+
/**
|
411 |
+
* Uses the DNS protocol to resolve service records (`SRV` records) for the`hostname`. The `addresses` argument passed to the `callback` function will
|
412 |
+
* be an array of objects with the following properties:
|
413 |
+
*
|
414 |
+
* * `priority`
|
415 |
+
* * `weight`
|
416 |
+
* * `port`
|
417 |
+
* * `name`
|
418 |
+
*
|
419 |
+
* ```js
|
420 |
+
* {
|
421 |
+
* priority: 10,
|
422 |
+
* weight: 5,
|
423 |
+
* port: 21223,
|
424 |
+
* name: 'service.example.com'
|
425 |
+
* }
|
426 |
+
* ```
|
427 |
+
* @since v0.1.27
|
428 |
+
*/
|
429 |
+
export function resolveSrv(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: SrvRecord[]) => void): void;
|
430 |
+
export namespace resolveSrv {
|
431 |
+
function __promisify__(hostname: string): Promise<SrvRecord[]>;
|
432 |
+
}
|
433 |
+
/**
|
434 |
+
* Uses the DNS protocol to resolve text queries (`TXT` records) for the`hostname`. The `records` argument passed to the `callback` function is a
|
435 |
+
* two-dimensional array of the text records available for `hostname` (e.g.`[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]`). Each sub-array contains TXT chunks of
|
436 |
+
* one record. Depending on the use case, these could be either joined together or
|
437 |
+
* treated separately.
|
438 |
+
* @since v0.1.27
|
439 |
+
*/
|
440 |
+
export function resolveTxt(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: string[][]) => void): void;
|
441 |
+
export namespace resolveTxt {
|
442 |
+
function __promisify__(hostname: string): Promise<string[][]>;
|
443 |
+
}
|
444 |
+
/**
|
445 |
+
* Uses the DNS protocol to resolve all records (also known as `ANY` or `*` query).
|
446 |
+
* The `ret` argument passed to the `callback` function will be an array containing
|
447 |
+
* various types of records. Each object has a property `type` that indicates the
|
448 |
+
* type of the current record. And depending on the `type`, additional properties
|
449 |
+
* will be present on the object:
|
450 |
+
*
|
451 |
+
* <omitted>
|
452 |
+
*
|
453 |
+
* Here is an example of the `ret` object passed to the callback:
|
454 |
+
*
|
455 |
+
* ```js
|
456 |
+
* [ { type: 'A', address: '127.0.0.1', ttl: 299 },
|
457 |
+
* { type: 'CNAME', value: 'example.com' },
|
458 |
+
* { type: 'MX', exchange: 'alt4.aspmx.l.example.com', priority: 50 },
|
459 |
+
* { type: 'NS', value: 'ns1.example.com' },
|
460 |
+
* { type: 'TXT', entries: [ 'v=spf1 include:_spf.example.com ~all' ] },
|
461 |
+
* { type: 'SOA',
|
462 |
+
* nsname: 'ns1.example.com',
|
463 |
+
* hostmaster: 'admin.example.com',
|
464 |
+
* serial: 156696742,
|
465 |
+
* refresh: 900,
|
466 |
+
* retry: 900,
|
467 |
+
* expire: 1800,
|
468 |
+
* minttl: 60 } ]
|
469 |
+
* ```
|
470 |
+
*
|
471 |
+
* DNS server operators may choose not to respond to `ANY`queries. It may be better to call individual methods like {@link resolve4},{@link resolveMx}, and so on. For more details, see [RFC
|
472 |
+
* 8482](https://tools.ietf.org/html/rfc8482).
|
473 |
+
*/
|
474 |
+
export function resolveAny(hostname: string, callback: (err: NodeJS.ErrnoException | null, addresses: AnyRecord[]) => void): void;
|
475 |
+
export namespace resolveAny {
|
476 |
+
function __promisify__(hostname: string): Promise<AnyRecord[]>;
|
477 |
+
}
|
478 |
+
/**
|
479 |
+
* Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an
|
480 |
+
* array of host names.
|
481 |
+
*
|
482 |
+
* On error, `err` is an `Error` object, where `err.code` is
|
483 |
+
* one of the `DNS error codes`.
|
484 |
+
* @since v0.1.16
|
485 |
+
*/
|
486 |
+
export function reverse(ip: string, callback: (err: NodeJS.ErrnoException | null, hostnames: string[]) => void): void;
|
487 |
+
/**
|
488 |
+
* Sets the IP address and port of servers to be used when performing DNS
|
489 |
+
* resolution. The `servers` argument is an array of [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6) formatted
|
490 |
+
* addresses. If the port is the IANA default DNS port (53) it can be omitted.
|
491 |
+
*
|
492 |
+
* ```js
|
493 |
+
* dns.setServers([
|
494 |
+
* '4.4.4.4',
|
495 |
+
* '[2001:4860:4860::8888]',
|
496 |
+
* '4.4.4.4:1053',
|
497 |
+
* '[2001:4860:4860::8888]:1053',
|
498 |
+
* ]);
|
499 |
+
* ```
|
500 |
+
*
|
501 |
+
* An error will be thrown if an invalid address is provided.
|
502 |
+
*
|
503 |
+
* The `dns.setServers()` method must not be called while a DNS query is in
|
504 |
+
* progress.
|
505 |
+
*
|
506 |
+
* The {@link setServers} method affects only {@link resolve},`dns.resolve*()` and {@link reverse} (and specifically _not_ {@link lookup}).
|
507 |
+
*
|
508 |
+
* This method works much like [resolve.conf](https://man7.org/linux/man-pages/man5/resolv.conf.5.html).
|
509 |
+
* That is, if attempting to resolve with the first server provided results in a`NOTFOUND` error, the `resolve()` method will _not_ attempt to resolve with
|
510 |
+
* subsequent servers provided. Fallback DNS servers will only be used if the
|
511 |
+
* earlier ones time out or result in some other error.
|
512 |
+
* @since v0.11.3
|
513 |
+
* @param servers array of `RFC 5952` formatted addresses
|
514 |
+
*/
|
515 |
+
export function setServers(servers: ReadonlyArray<string>): void;
|
516 |
+
/**
|
517 |
+
* Returns an array of IP address strings, formatted according to [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6),
|
518 |
+
* that are currently configured for DNS resolution. A string will include a port
|
519 |
+
* section if a custom port is used.
|
520 |
+
*
|
521 |
+
* ```js
|
522 |
+
* [
|
523 |
+
* '4.4.4.4',
|
524 |
+
* '2001:4860:4860::8888',
|
525 |
+
* '4.4.4.4:1053',
|
526 |
+
* '[2001:4860:4860::8888]:1053',
|
527 |
+
* ]
|
528 |
+
* ```
|
529 |
+
* @since v0.11.3
|
530 |
+
*/
|
531 |
+
export function getServers(): string[];
|
532 |
+
/**
|
533 |
+
* Set the default value of `verbatim` in {@link lookup} and `dnsPromises.lookup()`. The value could be:
|
534 |
+
*
|
535 |
+
* * `ipv4first`: sets default `verbatim` `false`.
|
536 |
+
* * `verbatim`: sets default `verbatim` `true`.
|
537 |
+
*
|
538 |
+
* The default is `ipv4first` and {@link setDefaultResultOrder} have higher
|
539 |
+
* priority than `--dns-result-order`. When using `worker threads`,{@link setDefaultResultOrder} from the main thread won't affect the default
|
540 |
+
* dns orders in workers.
|
541 |
+
* @since v16.4.0, v14.18.0
|
542 |
+
* @param order must be `'ipv4first'` or `'verbatim'`.
|
543 |
+
*/
|
544 |
+
export function setDefaultResultOrder(order: 'ipv4first' | 'verbatim'): void;
|
545 |
+
// Error codes
|
546 |
+
export const NODATA: string;
|
547 |
+
export const FORMERR: string;
|
548 |
+
export const SERVFAIL: string;
|
549 |
+
export const NOTFOUND: string;
|
550 |
+
export const NOTIMP: string;
|
551 |
+
export const REFUSED: string;
|
552 |
+
export const BADQUERY: string;
|
553 |
+
export const BADNAME: string;
|
554 |
+
export const BADFAMILY: string;
|
555 |
+
export const BADRESP: string;
|
556 |
+
export const CONNREFUSED: string;
|
557 |
+
export const TIMEOUT: string;
|
558 |
+
export const EOF: string;
|
559 |
+
export const FILE: string;
|
560 |
+
export const NOMEM: string;
|
561 |
+
export const DESTRUCTION: string;
|
562 |
+
export const BADSTR: string;
|
563 |
+
export const BADFLAGS: string;
|
564 |
+
export const NONAME: string;
|
565 |
+
export const BADHINTS: string;
|
566 |
+
export const NOTINITIALIZED: string;
|
567 |
+
export const LOADIPHLPAPI: string;
|
568 |
+
export const ADDRGETNETWORKPARAMS: string;
|
569 |
+
export const CANCELLED: string;
|
570 |
+
export interface ResolverOptions {
|
571 |
+
timeout?: number | undefined;
|
572 |
+
/**
|
573 |
+
* @default 4
|
574 |
+
*/
|
575 |
+
tries?: number;
|
576 |
+
}
|
577 |
+
/**
|
578 |
+
* An independent resolver for DNS requests.
|
579 |
+
*
|
580 |
+
* Creating a new resolver uses the default server settings. Setting
|
581 |
+
* the servers used for a resolver using `resolver.setServers()` does not affect
|
582 |
+
* other resolvers:
|
583 |
+
*
|
584 |
+
* ```js
|
585 |
+
* const { Resolver } = require('dns');
|
586 |
+
* const resolver = new Resolver();
|
587 |
+
* resolver.setServers(['4.4.4.4']);
|
588 |
+
*
|
589 |
+
* // This request will use the server at 4.4.4.4, independent of global settings.
|
590 |
+
* resolver.resolve4('example.org', (err, addresses) => {
|
591 |
+
* // ...
|
592 |
+
* });
|
593 |
+
* ```
|
594 |
+
*
|
595 |
+
* The following methods from the `dns` module are available:
|
596 |
+
*
|
597 |
+
* * `resolver.getServers()`
|
598 |
+
* * `resolver.resolve()`
|
599 |
+
* * `resolver.resolve4()`
|
600 |
+
* * `resolver.resolve6()`
|
601 |
+
* * `resolver.resolveAny()`
|
602 |
+
* * `resolver.resolveCaa()`
|
603 |
+
* * `resolver.resolveCname()`
|
604 |
+
* * `resolver.resolveMx()`
|
605 |
+
* * `resolver.resolveNaptr()`
|
606 |
+
* * `resolver.resolveNs()`
|
607 |
+
* * `resolver.resolvePtr()`
|
608 |
+
* * `resolver.resolveSoa()`
|
609 |
+
* * `resolver.resolveSrv()`
|
610 |
+
* * `resolver.resolveTxt()`
|
611 |
+
* * `resolver.reverse()`
|
612 |
+
* * `resolver.setServers()`
|
613 |
+
* @since v8.3.0
|
614 |
+
*/
|
615 |
+
export class Resolver {
|
616 |
+
constructor(options?: ResolverOptions);
|
617 |
+
/**
|
618 |
+
* Cancel all outstanding DNS queries made by this resolver. The corresponding
|
619 |
+
* callbacks will be called with an error with code `ECANCELLED`.
|
620 |
+
* @since v8.3.0
|
621 |
+
*/
|
622 |
+
cancel(): void;
|
623 |
+
getServers: typeof getServers;
|
624 |
+
resolve: typeof resolve;
|
625 |
+
resolve4: typeof resolve4;
|
626 |
+
resolve6: typeof resolve6;
|
627 |
+
resolveAny: typeof resolveAny;
|
628 |
+
resolveCname: typeof resolveCname;
|
629 |
+
resolveMx: typeof resolveMx;
|
630 |
+
resolveNaptr: typeof resolveNaptr;
|
631 |
+
resolveNs: typeof resolveNs;
|
632 |
+
resolvePtr: typeof resolvePtr;
|
633 |
+
resolveSoa: typeof resolveSoa;
|
634 |
+
resolveSrv: typeof resolveSrv;
|
635 |
+
resolveTxt: typeof resolveTxt;
|
636 |
+
reverse: typeof reverse;
|
637 |
+
/**
|
638 |
+
* The resolver instance will send its requests from the specified IP address.
|
639 |
+
* This allows programs to specify outbound interfaces when used on multi-homed
|
640 |
+
* systems.
|
641 |
+
*
|
642 |
+
* If a v4 or v6 address is not specified, it is set to the default, and the
|
643 |
+
* operating system will choose a local address automatically.
|
644 |
+
*
|
645 |
+
* The resolver will use the v4 local address when making requests to IPv4 DNS
|
646 |
+
* servers, and the v6 local address when making requests to IPv6 DNS servers.
|
647 |
+
* The `rrtype` of resolution requests has no impact on the local address used.
|
648 |
+
* @since v15.1.0, v14.17.0
|
649 |
+
* @param [ipv4='0.0.0.0'] A string representation of an IPv4 address.
|
650 |
+
* @param [ipv6='::0'] A string representation of an IPv6 address.
|
651 |
+
*/
|
652 |
+
setLocalAddress(ipv4?: string, ipv6?: string): void;
|
653 |
+
setServers: typeof setServers;
|
654 |
+
}
|
655 |
+
export { dnsPromises as promises };
|
656 |
+
}
|
657 |
+
declare module 'node:dns' {
|
658 |
+
export * from 'dns';
|
659 |
+
}
|
igv_component/node_modules/@types/node/dns/promises.d.ts
ADDED
@@ -0,0 +1,370 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* The `dns.promises` API provides an alternative set of asynchronous DNS methods
|
3 |
+
* that return `Promise` objects rather than using callbacks. The API is accessible
|
4 |
+
* via `require('dns').promises` or `require('dns/promises')`.
|
5 |
+
* @since v10.6.0
|
6 |
+
*/
|
7 |
+
declare module 'dns/promises' {
|
8 |
+
import {
|
9 |
+
LookupAddress,
|
10 |
+
LookupOneOptions,
|
11 |
+
LookupAllOptions,
|
12 |
+
LookupOptions,
|
13 |
+
AnyRecord,
|
14 |
+
CaaRecord,
|
15 |
+
MxRecord,
|
16 |
+
NaptrRecord,
|
17 |
+
SoaRecord,
|
18 |
+
SrvRecord,
|
19 |
+
ResolveWithTtlOptions,
|
20 |
+
RecordWithTtl,
|
21 |
+
ResolveOptions,
|
22 |
+
ResolverOptions,
|
23 |
+
} from 'node:dns';
|
24 |
+
/**
|
25 |
+
* Returns an array of IP address strings, formatted according to [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6),
|
26 |
+
* that are currently configured for DNS resolution. A string will include a port
|
27 |
+
* section if a custom port is used.
|
28 |
+
*
|
29 |
+
* ```js
|
30 |
+
* [
|
31 |
+
* '4.4.4.4',
|
32 |
+
* '2001:4860:4860::8888',
|
33 |
+
* '4.4.4.4:1053',
|
34 |
+
* '[2001:4860:4860::8888]:1053',
|
35 |
+
* ]
|
36 |
+
* ```
|
37 |
+
* @since v10.6.0
|
38 |
+
*/
|
39 |
+
function getServers(): string[];
|
40 |
+
/**
|
41 |
+
* Resolves a host name (e.g. `'nodejs.org'`) into the first found A (IPv4) or
|
42 |
+
* AAAA (IPv6) record. All `option` properties are optional. If `options` is an
|
43 |
+
* integer, then it must be `4` or `6` – if `options` is not provided, then IPv4
|
44 |
+
* and IPv6 addresses are both returned if found.
|
45 |
+
*
|
46 |
+
* With the `all` option set to `true`, the `Promise` is resolved with `addresses`being an array of objects with the properties `address` and `family`.
|
47 |
+
*
|
48 |
+
* On error, the `Promise` is rejected with an `Error` object, where `err.code`is the error code.
|
49 |
+
* Keep in mind that `err.code` will be set to `'ENOTFOUND'` not only when
|
50 |
+
* the host name does not exist but also when the lookup fails in other ways
|
51 |
+
* such as no available file descriptors.
|
52 |
+
*
|
53 |
+
* `dnsPromises.lookup()` does not necessarily have anything to do with the DNS
|
54 |
+
* protocol. The implementation uses an operating system facility that can
|
55 |
+
* associate names with addresses, and vice versa. This implementation can have
|
56 |
+
* subtle but important consequences on the behavior of any Node.js program. Please
|
57 |
+
* take some time to consult the `Implementation considerations section` before
|
58 |
+
* using `dnsPromises.lookup()`.
|
59 |
+
*
|
60 |
+
* Example usage:
|
61 |
+
*
|
62 |
+
* ```js
|
63 |
+
* const dns = require('dns');
|
64 |
+
* const dnsPromises = dns.promises;
|
65 |
+
* const options = {
|
66 |
+
* family: 6,
|
67 |
+
* hints: dns.ADDRCONFIG | dns.V4MAPPED,
|
68 |
+
* };
|
69 |
+
*
|
70 |
+
* dnsPromises.lookup('example.com', options).then((result) => {
|
71 |
+
* console.log('address: %j family: IPv%s', result.address, result.family);
|
72 |
+
* // address: "2606:2800:220:1:248:1893:25c8:1946" family: IPv6
|
73 |
+
* });
|
74 |
+
*
|
75 |
+
* // When options.all is true, the result will be an Array.
|
76 |
+
* options.all = true;
|
77 |
+
* dnsPromises.lookup('example.com', options).then((result) => {
|
78 |
+
* console.log('addresses: %j', result);
|
79 |
+
* // addresses: [{"address":"2606:2800:220:1:248:1893:25c8:1946","family":6}]
|
80 |
+
* });
|
81 |
+
* ```
|
82 |
+
* @since v10.6.0
|
83 |
+
*/
|
84 |
+
function lookup(hostname: string, family: number): Promise<LookupAddress>;
|
85 |
+
function lookup(hostname: string, options: LookupOneOptions): Promise<LookupAddress>;
|
86 |
+
function lookup(hostname: string, options: LookupAllOptions): Promise<LookupAddress[]>;
|
87 |
+
function lookup(hostname: string, options: LookupOptions): Promise<LookupAddress | LookupAddress[]>;
|
88 |
+
function lookup(hostname: string): Promise<LookupAddress>;
|
89 |
+
/**
|
90 |
+
* Resolves the given `address` and `port` into a host name and service using
|
91 |
+
* the operating system's underlying `getnameinfo` implementation.
|
92 |
+
*
|
93 |
+
* If `address` is not a valid IP address, a `TypeError` will be thrown.
|
94 |
+
* The `port` will be coerced to a number. If it is not a legal port, a `TypeError`will be thrown.
|
95 |
+
*
|
96 |
+
* On error, the `Promise` is rejected with an `Error` object, where `err.code`is the error code.
|
97 |
+
*
|
98 |
+
* ```js
|
99 |
+
* const dnsPromises = require('dns').promises;
|
100 |
+
* dnsPromises.lookupService('127.0.0.1', 22).then((result) => {
|
101 |
+
* console.log(result.hostname, result.service);
|
102 |
+
* // Prints: localhost ssh
|
103 |
+
* });
|
104 |
+
* ```
|
105 |
+
* @since v10.6.0
|
106 |
+
*/
|
107 |
+
function lookupService(
|
108 |
+
address: string,
|
109 |
+
port: number
|
110 |
+
): Promise<{
|
111 |
+
hostname: string;
|
112 |
+
service: string;
|
113 |
+
}>;
|
114 |
+
/**
|
115 |
+
* Uses the DNS protocol to resolve a host name (e.g. `'nodejs.org'`) into an array
|
116 |
+
* of the resource records. When successful, the `Promise` is resolved with an
|
117 |
+
* array of resource records. The type and structure of individual results vary
|
118 |
+
* based on `rrtype`:
|
119 |
+
*
|
120 |
+
* <omitted>
|
121 |
+
*
|
122 |
+
* On error, the `Promise` is rejected with an `Error` object, where `err.code`is one of the `DNS error codes`.
|
123 |
+
* @since v10.6.0
|
124 |
+
* @param hostname Host name to resolve.
|
125 |
+
* @param [rrtype='A'] Resource record type.
|
126 |
+
*/
|
127 |
+
function resolve(hostname: string): Promise<string[]>;
|
128 |
+
function resolve(hostname: string, rrtype: 'A'): Promise<string[]>;
|
129 |
+
function resolve(hostname: string, rrtype: 'AAAA'): Promise<string[]>;
|
130 |
+
function resolve(hostname: string, rrtype: 'ANY'): Promise<AnyRecord[]>;
|
131 |
+
function resolve(hostname: string, rrtype: 'CAA'): Promise<CaaRecord[]>;
|
132 |
+
function resolve(hostname: string, rrtype: 'CNAME'): Promise<string[]>;
|
133 |
+
function resolve(hostname: string, rrtype: 'MX'): Promise<MxRecord[]>;
|
134 |
+
function resolve(hostname: string, rrtype: 'NAPTR'): Promise<NaptrRecord[]>;
|
135 |
+
function resolve(hostname: string, rrtype: 'NS'): Promise<string[]>;
|
136 |
+
function resolve(hostname: string, rrtype: 'PTR'): Promise<string[]>;
|
137 |
+
function resolve(hostname: string, rrtype: 'SOA'): Promise<SoaRecord>;
|
138 |
+
function resolve(hostname: string, rrtype: 'SRV'): Promise<SrvRecord[]>;
|
139 |
+
function resolve(hostname: string, rrtype: 'TXT'): Promise<string[][]>;
|
140 |
+
function resolve(hostname: string, rrtype: string): Promise<string[] | MxRecord[] | NaptrRecord[] | SoaRecord | SrvRecord[] | string[][] | AnyRecord[]>;
|
141 |
+
/**
|
142 |
+
* Uses the DNS protocol to resolve IPv4 addresses (`A` records) for the`hostname`. On success, the `Promise` is resolved with an array of IPv4
|
143 |
+
* addresses (e.g. `['74.125.79.104', '74.125.79.105', '74.125.79.106']`).
|
144 |
+
* @since v10.6.0
|
145 |
+
* @param hostname Host name to resolve.
|
146 |
+
*/
|
147 |
+
function resolve4(hostname: string): Promise<string[]>;
|
148 |
+
function resolve4(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
149 |
+
function resolve4(hostname: string, options: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
150 |
+
/**
|
151 |
+
* Uses the DNS protocol to resolve IPv6 addresses (`AAAA` records) for the`hostname`. On success, the `Promise` is resolved with an array of IPv6
|
152 |
+
* addresses.
|
153 |
+
* @since v10.6.0
|
154 |
+
* @param hostname Host name to resolve.
|
155 |
+
*/
|
156 |
+
function resolve6(hostname: string): Promise<string[]>;
|
157 |
+
function resolve6(hostname: string, options: ResolveWithTtlOptions): Promise<RecordWithTtl[]>;
|
158 |
+
function resolve6(hostname: string, options: ResolveOptions): Promise<string[] | RecordWithTtl[]>;
|
159 |
+
/**
|
160 |
+
* Uses the DNS protocol to resolve all records (also known as `ANY` or `*` query).
|
161 |
+
* On success, the `Promise` is resolved with an array containing various types of
|
162 |
+
* records. Each object has a property `type` that indicates the type of the
|
163 |
+
* current record. And depending on the `type`, additional properties will be
|
164 |
+
* present on the object:
|
165 |
+
*
|
166 |
+
* <omitted>
|
167 |
+
*
|
168 |
+
* Here is an example of the result object:
|
169 |
+
*
|
170 |
+
* ```js
|
171 |
+
* [ { type: 'A', address: '127.0.0.1', ttl: 299 },
|
172 |
+
* { type: 'CNAME', value: 'example.com' },
|
173 |
+
* { type: 'MX', exchange: 'alt4.aspmx.l.example.com', priority: 50 },
|
174 |
+
* { type: 'NS', value: 'ns1.example.com' },
|
175 |
+
* { type: 'TXT', entries: [ 'v=spf1 include:_spf.example.com ~all' ] },
|
176 |
+
* { type: 'SOA',
|
177 |
+
* nsname: 'ns1.example.com',
|
178 |
+
* hostmaster: 'admin.example.com',
|
179 |
+
* serial: 156696742,
|
180 |
+
* refresh: 900,
|
181 |
+
* retry: 900,
|
182 |
+
* expire: 1800,
|
183 |
+
* minttl: 60 } ]
|
184 |
+
* ```
|
185 |
+
* @since v10.6.0
|
186 |
+
*/
|
187 |
+
function resolveAny(hostname: string): Promise<AnyRecord[]>;
|
188 |
+
/**
|
189 |
+
* Uses the DNS protocol to resolve `CAA` records for the `hostname`. On success,
|
190 |
+
* the `Promise` is resolved with an array of objects containing available
|
191 |
+
* certification authority authorization records available for the `hostname`(e.g. `[{critical: 0, iodef: 'mailto:pki@example.com'},{critical: 128, issue: 'pki.example.com'}]`).
|
192 |
+
* @since v15.0.0, v14.17.0
|
193 |
+
*/
|
194 |
+
function resolveCaa(hostname: string): Promise<CaaRecord[]>;
|
195 |
+
/**
|
196 |
+
* Uses the DNS protocol to resolve `CNAME` records for the `hostname`. On success,
|
197 |
+
* the `Promise` is resolved with an array of canonical name records available for
|
198 |
+
* the `hostname` (e.g. `['bar.example.com']`).
|
199 |
+
* @since v10.6.0
|
200 |
+
*/
|
201 |
+
function resolveCname(hostname: string): Promise<string[]>;
|
202 |
+
/**
|
203 |
+
* Uses the DNS protocol to resolve mail exchange records (`MX` records) for the`hostname`. On success, the `Promise` is resolved with an array of objects
|
204 |
+
* containing both a `priority` and `exchange` property (e.g.`[{priority: 10, exchange: 'mx.example.com'}, ...]`).
|
205 |
+
* @since v10.6.0
|
206 |
+
*/
|
207 |
+
function resolveMx(hostname: string): Promise<MxRecord[]>;
|
208 |
+
/**
|
209 |
+
* Uses the DNS protocol to resolve regular expression based records (`NAPTR`records) for the `hostname`. On success, the `Promise` is resolved with an array
|
210 |
+
* of objects with the following properties:
|
211 |
+
*
|
212 |
+
* * `flags`
|
213 |
+
* * `service`
|
214 |
+
* * `regexp`
|
215 |
+
* * `replacement`
|
216 |
+
* * `order`
|
217 |
+
* * `preference`
|
218 |
+
*
|
219 |
+
* ```js
|
220 |
+
* {
|
221 |
+
* flags: 's',
|
222 |
+
* service: 'SIP+D2U',
|
223 |
+
* regexp: '',
|
224 |
+
* replacement: '_sip._udp.example.com',
|
225 |
+
* order: 30,
|
226 |
+
* preference: 100
|
227 |
+
* }
|
228 |
+
* ```
|
229 |
+
* @since v10.6.0
|
230 |
+
*/
|
231 |
+
function resolveNaptr(hostname: string): Promise<NaptrRecord[]>;
|
232 |
+
/**
|
233 |
+
* Uses the DNS protocol to resolve name server records (`NS` records) for the`hostname`. On success, the `Promise` is resolved with an array of name server
|
234 |
+
* records available for `hostname` (e.g.`['ns1.example.com', 'ns2.example.com']`).
|
235 |
+
* @since v10.6.0
|
236 |
+
*/
|
237 |
+
function resolveNs(hostname: string): Promise<string[]>;
|
238 |
+
/**
|
239 |
+
* Uses the DNS protocol to resolve pointer records (`PTR` records) for the`hostname`. On success, the `Promise` is resolved with an array of strings
|
240 |
+
* containing the reply records.
|
241 |
+
* @since v10.6.0
|
242 |
+
*/
|
243 |
+
function resolvePtr(hostname: string): Promise<string[]>;
|
244 |
+
/**
|
245 |
+
* Uses the DNS protocol to resolve a start of authority record (`SOA` record) for
|
246 |
+
* the `hostname`. On success, the `Promise` is resolved with an object with the
|
247 |
+
* following properties:
|
248 |
+
*
|
249 |
+
* * `nsname`
|
250 |
+
* * `hostmaster`
|
251 |
+
* * `serial`
|
252 |
+
* * `refresh`
|
253 |
+
* * `retry`
|
254 |
+
* * `expire`
|
255 |
+
* * `minttl`
|
256 |
+
*
|
257 |
+
* ```js
|
258 |
+
* {
|
259 |
+
* nsname: 'ns.example.com',
|
260 |
+
* hostmaster: 'root.example.com',
|
261 |
+
* serial: 2013101809,
|
262 |
+
* refresh: 10000,
|
263 |
+
* retry: 2400,
|
264 |
+
* expire: 604800,
|
265 |
+
* minttl: 3600
|
266 |
+
* }
|
267 |
+
* ```
|
268 |
+
* @since v10.6.0
|
269 |
+
*/
|
270 |
+
function resolveSoa(hostname: string): Promise<SoaRecord>;
|
271 |
+
/**
|
272 |
+
* Uses the DNS protocol to resolve service records (`SRV` records) for the`hostname`. On success, the `Promise` is resolved with an array of objects with
|
273 |
+
* the following properties:
|
274 |
+
*
|
275 |
+
* * `priority`
|
276 |
+
* * `weight`
|
277 |
+
* * `port`
|
278 |
+
* * `name`
|
279 |
+
*
|
280 |
+
* ```js
|
281 |
+
* {
|
282 |
+
* priority: 10,
|
283 |
+
* weight: 5,
|
284 |
+
* port: 21223,
|
285 |
+
* name: 'service.example.com'
|
286 |
+
* }
|
287 |
+
* ```
|
288 |
+
* @since v10.6.0
|
289 |
+
*/
|
290 |
+
function resolveSrv(hostname: string): Promise<SrvRecord[]>;
|
291 |
+
/**
|
292 |
+
* Uses the DNS protocol to resolve text queries (`TXT` records) for the`hostname`. On success, the `Promise` is resolved with a two-dimensional array
|
293 |
+
* of the text records available for `hostname` (e.g.`[ ['v=spf1 ip4:0.0.0.0 ', '~all' ] ]`). Each sub-array contains TXT chunks of
|
294 |
+
* one record. Depending on the use case, these could be either joined together or
|
295 |
+
* treated separately.
|
296 |
+
* @since v10.6.0
|
297 |
+
*/
|
298 |
+
function resolveTxt(hostname: string): Promise<string[][]>;
|
299 |
+
/**
|
300 |
+
* Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an
|
301 |
+
* array of host names.
|
302 |
+
*
|
303 |
+
* On error, the `Promise` is rejected with an `Error` object, where `err.code`is one of the `DNS error codes`.
|
304 |
+
* @since v10.6.0
|
305 |
+
*/
|
306 |
+
function reverse(ip: string): Promise<string[]>;
|
307 |
+
/**
|
308 |
+
* Sets the IP address and port of servers to be used when performing DNS
|
309 |
+
* resolution. The `servers` argument is an array of [RFC 5952](https://tools.ietf.org/html/rfc5952#section-6) formatted
|
310 |
+
* addresses. If the port is the IANA default DNS port (53) it can be omitted.
|
311 |
+
*
|
312 |
+
* ```js
|
313 |
+
* dnsPromises.setServers([
|
314 |
+
* '4.4.4.4',
|
315 |
+
* '[2001:4860:4860::8888]',
|
316 |
+
* '4.4.4.4:1053',
|
317 |
+
* '[2001:4860:4860::8888]:1053',
|
318 |
+
* ]);
|
319 |
+
* ```
|
320 |
+
*
|
321 |
+
* An error will be thrown if an invalid address is provided.
|
322 |
+
*
|
323 |
+
* The `dnsPromises.setServers()` method must not be called while a DNS query is in
|
324 |
+
* progress.
|
325 |
+
*
|
326 |
+
* This method works much like [resolve.conf](https://man7.org/linux/man-pages/man5/resolv.conf.5.html).
|
327 |
+
* That is, if attempting to resolve with the first server provided results in a`NOTFOUND` error, the `resolve()` method will _not_ attempt to resolve with
|
328 |
+
* subsequent servers provided. Fallback DNS servers will only be used if the
|
329 |
+
* earlier ones time out or result in some other error.
|
330 |
+
* @since v10.6.0
|
331 |
+
* @param servers array of `RFC 5952` formatted addresses
|
332 |
+
*/
|
333 |
+
function setServers(servers: ReadonlyArray<string>): void;
|
334 |
+
/**
|
335 |
+
* Set the default value of `verbatim` in `dns.lookup()` and `dnsPromises.lookup()`. The value could be:
|
336 |
+
*
|
337 |
+
* * `ipv4first`: sets default `verbatim` `false`.
|
338 |
+
* * `verbatim`: sets default `verbatim` `true`.
|
339 |
+
*
|
340 |
+
* The default is `ipv4first` and `dnsPromises.setDefaultResultOrder()` have
|
341 |
+
* higher priority than `--dns-result-order`. When using `worker threads`,`dnsPromises.setDefaultResultOrder()` from the main thread won't affect the
|
342 |
+
* default dns orders in workers.
|
343 |
+
* @since v16.4.0, v14.18.0
|
344 |
+
* @param order must be `'ipv4first'` or `'verbatim'`.
|
345 |
+
*/
|
346 |
+
function setDefaultResultOrder(order: 'ipv4first' | 'verbatim'): void;
|
347 |
+
class Resolver {
|
348 |
+
constructor(options?: ResolverOptions);
|
349 |
+
cancel(): void;
|
350 |
+
getServers: typeof getServers;
|
351 |
+
resolve: typeof resolve;
|
352 |
+
resolve4: typeof resolve4;
|
353 |
+
resolve6: typeof resolve6;
|
354 |
+
resolveAny: typeof resolveAny;
|
355 |
+
resolveCname: typeof resolveCname;
|
356 |
+
resolveMx: typeof resolveMx;
|
357 |
+
resolveNaptr: typeof resolveNaptr;
|
358 |
+
resolveNs: typeof resolveNs;
|
359 |
+
resolvePtr: typeof resolvePtr;
|
360 |
+
resolveSoa: typeof resolveSoa;
|
361 |
+
resolveSrv: typeof resolveSrv;
|
362 |
+
resolveTxt: typeof resolveTxt;
|
363 |
+
reverse: typeof reverse;
|
364 |
+
setLocalAddress(ipv4?: string, ipv6?: string): void;
|
365 |
+
setServers: typeof setServers;
|
366 |
+
}
|
367 |
+
}
|
368 |
+
declare module 'node:dns/promises' {
|
369 |
+
export * from 'dns/promises';
|
370 |
+
}
|
igv_component/node_modules/@types/node/domain.d.ts
ADDED
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* **This module is pending deprecation.** Once a replacement API has been
|
3 |
+
* finalized, this module will be fully deprecated. Most developers should
|
4 |
+
* **not** have cause to use this module. Users who absolutely must have
|
5 |
+
* the functionality that domains provide may rely on it for the time being
|
6 |
+
* but should expect to have to migrate to a different solution
|
7 |
+
* in the future.
|
8 |
+
*
|
9 |
+
* Domains provide a way to handle multiple different IO operations as a
|
10 |
+
* single group. If any of the event emitters or callbacks registered to a
|
11 |
+
* domain emit an `'error'` event, or throw an error, then the domain object
|
12 |
+
* will be notified, rather than losing the context of the error in the`process.on('uncaughtException')` handler, or causing the program to
|
13 |
+
* exit immediately with an error code.
|
14 |
+
* @deprecated Since v1.4.2 - Deprecated
|
15 |
+
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/domain.js)
|
16 |
+
*/
|
17 |
+
declare module 'domain' {
|
18 |
+
import EventEmitter = require('node:events');
|
19 |
+
/**
|
20 |
+
* The `Domain` class encapsulates the functionality of routing errors and
|
21 |
+
* uncaught exceptions to the active `Domain` object.
|
22 |
+
*
|
23 |
+
* To handle the errors that it catches, listen to its `'error'` event.
|
24 |
+
*/
|
25 |
+
class Domain extends EventEmitter {
|
26 |
+
/**
|
27 |
+
* An array of timers and event emitters that have been explicitly added
|
28 |
+
* to the domain.
|
29 |
+
*/
|
30 |
+
members: Array<EventEmitter | NodeJS.Timer>;
|
31 |
+
/**
|
32 |
+
* The `enter()` method is plumbing used by the `run()`, `bind()`, and`intercept()` methods to set the active domain. It sets `domain.active` and`process.domain` to the domain, and implicitly
|
33 |
+
* pushes the domain onto the domain
|
34 |
+
* stack managed by the domain module (see {@link exit} for details on the
|
35 |
+
* domain stack). The call to `enter()` delimits the beginning of a chain of
|
36 |
+
* asynchronous calls and I/O operations bound to a domain.
|
37 |
+
*
|
38 |
+
* Calling `enter()` changes only the active domain, and does not alter the domain
|
39 |
+
* itself. `enter()` and `exit()` can be called an arbitrary number of times on a
|
40 |
+
* single domain.
|
41 |
+
*/
|
42 |
+
enter(): void;
|
43 |
+
/**
|
44 |
+
* The `exit()` method exits the current domain, popping it off the domain stack.
|
45 |
+
* Any time execution is going to switch to the context of a different chain of
|
46 |
+
* asynchronous calls, it's important to ensure that the current domain is exited.
|
47 |
+
* The call to `exit()` delimits either the end of or an interruption to the chain
|
48 |
+
* of asynchronous calls and I/O operations bound to a domain.
|
49 |
+
*
|
50 |
+
* If there are multiple, nested domains bound to the current execution context,`exit()` will exit any domains nested within this domain.
|
51 |
+
*
|
52 |
+
* Calling `exit()` changes only the active domain, and does not alter the domain
|
53 |
+
* itself. `enter()` and `exit()` can be called an arbitrary number of times on a
|
54 |
+
* single domain.
|
55 |
+
*/
|
56 |
+
exit(): void;
|
57 |
+
/**
|
58 |
+
* Run the supplied function in the context of the domain, implicitly
|
59 |
+
* binding all event emitters, timers, and lowlevel requests that are
|
60 |
+
* created in that context. Optionally, arguments can be passed to
|
61 |
+
* the function.
|
62 |
+
*
|
63 |
+
* This is the most basic way to use a domain.
|
64 |
+
*
|
65 |
+
* ```js
|
66 |
+
* const domain = require('domain');
|
67 |
+
* const fs = require('fs');
|
68 |
+
* const d = domain.create();
|
69 |
+
* d.on('error', (er) => {
|
70 |
+
* console.error('Caught error!', er);
|
71 |
+
* });
|
72 |
+
* d.run(() => {
|
73 |
+
* process.nextTick(() => {
|
74 |
+
* setTimeout(() => { // Simulating some various async stuff
|
75 |
+
* fs.open('non-existent file', 'r', (er, fd) => {
|
76 |
+
* if (er) throw er;
|
77 |
+
* // proceed...
|
78 |
+
* });
|
79 |
+
* }, 100);
|
80 |
+
* });
|
81 |
+
* });
|
82 |
+
* ```
|
83 |
+
*
|
84 |
+
* In this example, the `d.on('error')` handler will be triggered, rather
|
85 |
+
* than crashing the program.
|
86 |
+
*/
|
87 |
+
run<T>(fn: (...args: any[]) => T, ...args: any[]): T;
|
88 |
+
/**
|
89 |
+
* Explicitly adds an emitter to the domain. If any event handlers called by
|
90 |
+
* the emitter throw an error, or if the emitter emits an `'error'` event, it
|
91 |
+
* will be routed to the domain's `'error'` event, just like with implicit
|
92 |
+
* binding.
|
93 |
+
*
|
94 |
+
* This also works with timers that are returned from `setInterval()` and `setTimeout()`. If their callback function throws, it will be caught by
|
95 |
+
* the domain `'error'` handler.
|
96 |
+
*
|
97 |
+
* If the Timer or `EventEmitter` was already bound to a domain, it is removed
|
98 |
+
* from that one, and bound to this one instead.
|
99 |
+
* @param emitter emitter or timer to be added to the domain
|
100 |
+
*/
|
101 |
+
add(emitter: EventEmitter | NodeJS.Timer): void;
|
102 |
+
/**
|
103 |
+
* The opposite of {@link add}. Removes domain handling from the
|
104 |
+
* specified emitter.
|
105 |
+
* @param emitter emitter or timer to be removed from the domain
|
106 |
+
*/
|
107 |
+
remove(emitter: EventEmitter | NodeJS.Timer): void;
|
108 |
+
/**
|
109 |
+
* The returned function will be a wrapper around the supplied callback
|
110 |
+
* function. When the returned function is called, any errors that are
|
111 |
+
* thrown will be routed to the domain's `'error'` event.
|
112 |
+
*
|
113 |
+
* ```js
|
114 |
+
* const d = domain.create();
|
115 |
+
*
|
116 |
+
* function readSomeFile(filename, cb) {
|
117 |
+
* fs.readFile(filename, 'utf8', d.bind((er, data) => {
|
118 |
+
* // If this throws, it will also be passed to the domain.
|
119 |
+
* return cb(er, data ? JSON.parse(data) : null);
|
120 |
+
* }));
|
121 |
+
* }
|
122 |
+
*
|
123 |
+
* d.on('error', (er) => {
|
124 |
+
* // An error occurred somewhere. If we throw it now, it will crash the program
|
125 |
+
* // with the normal line number and stack message.
|
126 |
+
* });
|
127 |
+
* ```
|
128 |
+
* @param callback The callback function
|
129 |
+
* @return The bound function
|
130 |
+
*/
|
131 |
+
bind<T extends Function>(callback: T): T;
|
132 |
+
/**
|
133 |
+
* This method is almost identical to {@link bind}. However, in
|
134 |
+
* addition to catching thrown errors, it will also intercept `Error` objects sent as the first argument to the function.
|
135 |
+
*
|
136 |
+
* In this way, the common `if (err) return callback(err);` pattern can be replaced
|
137 |
+
* with a single error handler in a single place.
|
138 |
+
*
|
139 |
+
* ```js
|
140 |
+
* const d = domain.create();
|
141 |
+
*
|
142 |
+
* function readSomeFile(filename, cb) {
|
143 |
+
* fs.readFile(filename, 'utf8', d.intercept((data) => {
|
144 |
+
* // Note, the first argument is never passed to the
|
145 |
+
* // callback since it is assumed to be the 'Error' argument
|
146 |
+
* // and thus intercepted by the domain.
|
147 |
+
*
|
148 |
+
* // If this throws, it will also be passed to the domain
|
149 |
+
* // so the error-handling logic can be moved to the 'error'
|
150 |
+
* // event on the domain instead of being repeated throughout
|
151 |
+
* // the program.
|
152 |
+
* return cb(null, JSON.parse(data));
|
153 |
+
* }));
|
154 |
+
* }
|
155 |
+
*
|
156 |
+
* d.on('error', (er) => {
|
157 |
+
* // An error occurred somewhere. If we throw it now, it will crash the program
|
158 |
+
* // with the normal line number and stack message.
|
159 |
+
* });
|
160 |
+
* ```
|
161 |
+
* @param callback The callback function
|
162 |
+
* @return The intercepted function
|
163 |
+
*/
|
164 |
+
intercept<T extends Function>(callback: T): T;
|
165 |
+
}
|
166 |
+
function create(): Domain;
|
167 |
+
}
|
168 |
+
declare module 'node:domain' {
|
169 |
+
export * from 'domain';
|
170 |
+
}
|
igv_component/node_modules/@types/node/events.d.ts
ADDED
@@ -0,0 +1,641 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Much of the Node.js core API is built around an idiomatic asynchronous
|
3 |
+
* event-driven architecture in which certain kinds of objects (called "emitters")
|
4 |
+
* emit named events that cause `Function` objects ("listeners") to be called.
|
5 |
+
*
|
6 |
+
* For instance: a `net.Server` object emits an event each time a peer
|
7 |
+
* connects to it; a `fs.ReadStream` emits an event when the file is opened;
|
8 |
+
* a `stream` emits an event whenever data is available to be read.
|
9 |
+
*
|
10 |
+
* All objects that emit events are instances of the `EventEmitter` class. These
|
11 |
+
* objects expose an `eventEmitter.on()` function that allows one or more
|
12 |
+
* functions to be attached to named events emitted by the object. Typically,
|
13 |
+
* event names are camel-cased strings but any valid JavaScript property key
|
14 |
+
* can be used.
|
15 |
+
*
|
16 |
+
* When the `EventEmitter` object emits an event, all of the functions attached
|
17 |
+
* to that specific event are called _synchronously_. Any values returned by the
|
18 |
+
* called listeners are _ignored_ and discarded.
|
19 |
+
*
|
20 |
+
* The following example shows a simple `EventEmitter` instance with a single
|
21 |
+
* listener. The `eventEmitter.on()` method is used to register listeners, while
|
22 |
+
* the `eventEmitter.emit()` method is used to trigger the event.
|
23 |
+
*
|
24 |
+
* ```js
|
25 |
+
* const EventEmitter = require('events');
|
26 |
+
*
|
27 |
+
* class MyEmitter extends EventEmitter {}
|
28 |
+
*
|
29 |
+
* const myEmitter = new MyEmitter();
|
30 |
+
* myEmitter.on('event', () => {
|
31 |
+
* console.log('an event occurred!');
|
32 |
+
* });
|
33 |
+
* myEmitter.emit('event');
|
34 |
+
* ```
|
35 |
+
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/events.js)
|
36 |
+
*/
|
37 |
+
declare module 'events' {
|
38 |
+
interface EventEmitterOptions {
|
39 |
+
/**
|
40 |
+
* Enables automatic capturing of promise rejection.
|
41 |
+
*/
|
42 |
+
captureRejections?: boolean | undefined;
|
43 |
+
}
|
44 |
+
interface NodeEventTarget {
|
45 |
+
once(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
46 |
+
}
|
47 |
+
interface DOMEventTarget {
|
48 |
+
addEventListener(
|
49 |
+
eventName: string,
|
50 |
+
listener: (...args: any[]) => void,
|
51 |
+
opts?: {
|
52 |
+
once: boolean;
|
53 |
+
}
|
54 |
+
): any;
|
55 |
+
}
|
56 |
+
interface StaticEventEmitterOptions {
|
57 |
+
signal?: AbortSignal | undefined;
|
58 |
+
}
|
59 |
+
interface EventEmitter extends NodeJS.EventEmitter {}
|
60 |
+
/**
|
61 |
+
* The `EventEmitter` class is defined and exposed by the `events` module:
|
62 |
+
*
|
63 |
+
* ```js
|
64 |
+
* const EventEmitter = require('events');
|
65 |
+
* ```
|
66 |
+
*
|
67 |
+
* All `EventEmitter`s emit the event `'newListener'` when new listeners are
|
68 |
+
* added and `'removeListener'` when existing listeners are removed.
|
69 |
+
*
|
70 |
+
* It supports the following option:
|
71 |
+
* @since v0.1.26
|
72 |
+
*/
|
73 |
+
class EventEmitter {
|
74 |
+
constructor(options?: EventEmitterOptions);
|
75 |
+
/**
|
76 |
+
* Creates a `Promise` that is fulfilled when the `EventEmitter` emits the given
|
77 |
+
* event or that is rejected if the `EventEmitter` emits `'error'` while waiting.
|
78 |
+
* The `Promise` will resolve with an array of all the arguments emitted to the
|
79 |
+
* given event.
|
80 |
+
*
|
81 |
+
* This method is intentionally generic and works with the web platform [EventTarget](https://dom.spec.whatwg.org/#interface-eventtarget) interface, which has no special`'error'` event
|
82 |
+
* semantics and does not listen to the `'error'` event.
|
83 |
+
*
|
84 |
+
* ```js
|
85 |
+
* const { once, EventEmitter } = require('events');
|
86 |
+
*
|
87 |
+
* async function run() {
|
88 |
+
* const ee = new EventEmitter();
|
89 |
+
*
|
90 |
+
* process.nextTick(() => {
|
91 |
+
* ee.emit('myevent', 42);
|
92 |
+
* });
|
93 |
+
*
|
94 |
+
* const [value] = await once(ee, 'myevent');
|
95 |
+
* console.log(value);
|
96 |
+
*
|
97 |
+
* const err = new Error('kaboom');
|
98 |
+
* process.nextTick(() => {
|
99 |
+
* ee.emit('error', err);
|
100 |
+
* });
|
101 |
+
*
|
102 |
+
* try {
|
103 |
+
* await once(ee, 'myevent');
|
104 |
+
* } catch (err) {
|
105 |
+
* console.log('error happened', err);
|
106 |
+
* }
|
107 |
+
* }
|
108 |
+
*
|
109 |
+
* run();
|
110 |
+
* ```
|
111 |
+
*
|
112 |
+
* The special handling of the `'error'` event is only used when `events.once()`is used to wait for another event. If `events.once()` is used to wait for the
|
113 |
+
* '`error'` event itself, then it is treated as any other kind of event without
|
114 |
+
* special handling:
|
115 |
+
*
|
116 |
+
* ```js
|
117 |
+
* const { EventEmitter, once } = require('events');
|
118 |
+
*
|
119 |
+
* const ee = new EventEmitter();
|
120 |
+
*
|
121 |
+
* once(ee, 'error')
|
122 |
+
* .then(([err]) => console.log('ok', err.message))
|
123 |
+
* .catch((err) => console.log('error', err.message));
|
124 |
+
*
|
125 |
+
* ee.emit('error', new Error('boom'));
|
126 |
+
*
|
127 |
+
* // Prints: ok boom
|
128 |
+
* ```
|
129 |
+
*
|
130 |
+
* An `AbortSignal` can be used to cancel waiting for the event:
|
131 |
+
*
|
132 |
+
* ```js
|
133 |
+
* const { EventEmitter, once } = require('events');
|
134 |
+
*
|
135 |
+
* const ee = new EventEmitter();
|
136 |
+
* const ac = new AbortController();
|
137 |
+
*
|
138 |
+
* async function foo(emitter, event, signal) {
|
139 |
+
* try {
|
140 |
+
* await once(emitter, event, { signal });
|
141 |
+
* console.log('event emitted!');
|
142 |
+
* } catch (error) {
|
143 |
+
* if (error.name === 'AbortError') {
|
144 |
+
* console.error('Waiting for the event was canceled!');
|
145 |
+
* } else {
|
146 |
+
* console.error('There was an error', error.message);
|
147 |
+
* }
|
148 |
+
* }
|
149 |
+
* }
|
150 |
+
*
|
151 |
+
* foo(ee, 'foo', ac.signal);
|
152 |
+
* ac.abort(); // Abort waiting for the event
|
153 |
+
* ee.emit('foo'); // Prints: Waiting for the event was canceled!
|
154 |
+
* ```
|
155 |
+
* @since v11.13.0, v10.16.0
|
156 |
+
*/
|
157 |
+
static once(emitter: NodeEventTarget, eventName: string | symbol, options?: StaticEventEmitterOptions): Promise<any[]>;
|
158 |
+
static once(emitter: DOMEventTarget, eventName: string, options?: StaticEventEmitterOptions): Promise<any[]>;
|
159 |
+
/**
|
160 |
+
* ```js
|
161 |
+
* const { on, EventEmitter } = require('events');
|
162 |
+
*
|
163 |
+
* (async () => {
|
164 |
+
* const ee = new EventEmitter();
|
165 |
+
*
|
166 |
+
* // Emit later on
|
167 |
+
* process.nextTick(() => {
|
168 |
+
* ee.emit('foo', 'bar');
|
169 |
+
* ee.emit('foo', 42);
|
170 |
+
* });
|
171 |
+
*
|
172 |
+
* for await (const event of on(ee, 'foo')) {
|
173 |
+
* // The execution of this inner block is synchronous and it
|
174 |
+
* // processes one event at a time (even with await). Do not use
|
175 |
+
* // if concurrent execution is required.
|
176 |
+
* console.log(event); // prints ['bar'] [42]
|
177 |
+
* }
|
178 |
+
* // Unreachable here
|
179 |
+
* })();
|
180 |
+
* ```
|
181 |
+
*
|
182 |
+
* Returns an `AsyncIterator` that iterates `eventName` events. It will throw
|
183 |
+
* if the `EventEmitter` emits `'error'`. It removes all listeners when
|
184 |
+
* exiting the loop. The `value` returned by each iteration is an array
|
185 |
+
* composed of the emitted event arguments.
|
186 |
+
*
|
187 |
+
* An `AbortSignal` can be used to cancel waiting on events:
|
188 |
+
*
|
189 |
+
* ```js
|
190 |
+
* const { on, EventEmitter } = require('events');
|
191 |
+
* const ac = new AbortController();
|
192 |
+
*
|
193 |
+
* (async () => {
|
194 |
+
* const ee = new EventEmitter();
|
195 |
+
*
|
196 |
+
* // Emit later on
|
197 |
+
* process.nextTick(() => {
|
198 |
+
* ee.emit('foo', 'bar');
|
199 |
+
* ee.emit('foo', 42);
|
200 |
+
* });
|
201 |
+
*
|
202 |
+
* for await (const event of on(ee, 'foo', { signal: ac.signal })) {
|
203 |
+
* // The execution of this inner block is synchronous and it
|
204 |
+
* // processes one event at a time (even with await). Do not use
|
205 |
+
* // if concurrent execution is required.
|
206 |
+
* console.log(event); // prints ['bar'] [42]
|
207 |
+
* }
|
208 |
+
* // Unreachable here
|
209 |
+
* })();
|
210 |
+
*
|
211 |
+
* process.nextTick(() => ac.abort());
|
212 |
+
* ```
|
213 |
+
* @since v13.6.0, v12.16.0
|
214 |
+
* @param eventName The name of the event being listened for
|
215 |
+
* @return that iterates `eventName` events emitted by the `emitter`
|
216 |
+
*/
|
217 |
+
static on(emitter: NodeJS.EventEmitter, eventName: string, options?: StaticEventEmitterOptions): AsyncIterableIterator<any>;
|
218 |
+
/**
|
219 |
+
* A class method that returns the number of listeners for the given `eventName`registered on the given `emitter`.
|
220 |
+
*
|
221 |
+
* ```js
|
222 |
+
* const { EventEmitter, listenerCount } = require('events');
|
223 |
+
* const myEmitter = new EventEmitter();
|
224 |
+
* myEmitter.on('event', () => {});
|
225 |
+
* myEmitter.on('event', () => {});
|
226 |
+
* console.log(listenerCount(myEmitter, 'event'));
|
227 |
+
* // Prints: 2
|
228 |
+
* ```
|
229 |
+
* @since v0.9.12
|
230 |
+
* @deprecated Since v3.2.0 - Use `listenerCount` instead.
|
231 |
+
* @param emitter The emitter to query
|
232 |
+
* @param eventName The event name
|
233 |
+
*/
|
234 |
+
static listenerCount(emitter: NodeJS.EventEmitter, eventName: string | symbol): number;
|
235 |
+
/**
|
236 |
+
* Returns a copy of the array of listeners for the event named `eventName`.
|
237 |
+
*
|
238 |
+
* For `EventEmitter`s this behaves exactly the same as calling `.listeners` on
|
239 |
+
* the emitter.
|
240 |
+
*
|
241 |
+
* For `EventTarget`s this is the only way to get the event listeners for the
|
242 |
+
* event target. This is useful for debugging and diagnostic purposes.
|
243 |
+
*
|
244 |
+
* ```js
|
245 |
+
* const { getEventListeners, EventEmitter } = require('events');
|
246 |
+
*
|
247 |
+
* {
|
248 |
+
* const ee = new EventEmitter();
|
249 |
+
* const listener = () => console.log('Events are fun');
|
250 |
+
* ee.on('foo', listener);
|
251 |
+
* getEventListeners(ee, 'foo'); // [listener]
|
252 |
+
* }
|
253 |
+
* {
|
254 |
+
* const et = new EventTarget();
|
255 |
+
* const listener = () => console.log('Events are fun');
|
256 |
+
* et.addEventListener('foo', listener);
|
257 |
+
* getEventListeners(et, 'foo'); // [listener]
|
258 |
+
* }
|
259 |
+
* ```
|
260 |
+
* @since v15.2.0, v14.17.0
|
261 |
+
*/
|
262 |
+
static getEventListeners(emitter: DOMEventTarget | NodeJS.EventEmitter, name: string | symbol): Function[];
|
263 |
+
/**
|
264 |
+
* ```js
|
265 |
+
* const {
|
266 |
+
* setMaxListeners,
|
267 |
+
* EventEmitter
|
268 |
+
* } = require('events');
|
269 |
+
*
|
270 |
+
* const target = new EventTarget();
|
271 |
+
* const emitter = new EventEmitter();
|
272 |
+
*
|
273 |
+
* setMaxListeners(5, target, emitter);
|
274 |
+
* ```
|
275 |
+
* @since v15.4.0
|
276 |
+
* @param n A non-negative number. The maximum number of listeners per `EventTarget` event.
|
277 |
+
* @param eventsTargets Zero or more {EventTarget} or {EventEmitter} instances. If none are specified, `n` is set as the default max for all newly created {EventTarget} and {EventEmitter}
|
278 |
+
* objects.
|
279 |
+
*/
|
280 |
+
static setMaxListeners(n?: number, ...eventTargets: Array<DOMEventTarget | NodeJS.EventEmitter>): void;
|
281 |
+
/**
|
282 |
+
* This symbol shall be used to install a listener for only monitoring `'error'`
|
283 |
+
* events. Listeners installed using this symbol are called before the regular
|
284 |
+
* `'error'` listeners are called.
|
285 |
+
*
|
286 |
+
* Installing a listener using this symbol does not change the behavior once an
|
287 |
+
* `'error'` event is emitted, therefore the process will still crash if no
|
288 |
+
* regular `'error'` listener is installed.
|
289 |
+
*/
|
290 |
+
static readonly errorMonitor: unique symbol;
|
291 |
+
static readonly captureRejectionSymbol: unique symbol;
|
292 |
+
/**
|
293 |
+
* Sets or gets the default captureRejection value for all emitters.
|
294 |
+
*/
|
295 |
+
// TODO: These should be described using static getter/setter pairs:
|
296 |
+
static captureRejections: boolean;
|
297 |
+
static defaultMaxListeners: number;
|
298 |
+
}
|
299 |
+
import internal = require('node:events');
|
300 |
+
namespace EventEmitter {
|
301 |
+
// Should just be `export { EventEmitter }`, but that doesn't work in TypeScript 3.4
|
302 |
+
export { internal as EventEmitter };
|
303 |
+
export interface Abortable {
|
304 |
+
/**
|
305 |
+
* When provided the corresponding `AbortController` can be used to cancel an asynchronous action.
|
306 |
+
*/
|
307 |
+
signal?: AbortSignal | undefined;
|
308 |
+
}
|
309 |
+
}
|
310 |
+
global {
|
311 |
+
namespace NodeJS {
|
312 |
+
interface EventEmitter {
|
313 |
+
/**
|
314 |
+
* Alias for `emitter.on(eventName, listener)`.
|
315 |
+
* @since v0.1.26
|
316 |
+
*/
|
317 |
+
addListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
318 |
+
/**
|
319 |
+
* Adds the `listener` function to the end of the listeners array for the
|
320 |
+
* event named `eventName`. No checks are made to see if the `listener` has
|
321 |
+
* already been added. Multiple calls passing the same combination of `eventName`and `listener` will result in the `listener` being added, and called, multiple
|
322 |
+
* times.
|
323 |
+
*
|
324 |
+
* ```js
|
325 |
+
* server.on('connection', (stream) => {
|
326 |
+
* console.log('someone connected!');
|
327 |
+
* });
|
328 |
+
* ```
|
329 |
+
*
|
330 |
+
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
331 |
+
*
|
332 |
+
* By default, event listeners are invoked in the order they are added. The`emitter.prependListener()` method can be used as an alternative to add the
|
333 |
+
* event listener to the beginning of the listeners array.
|
334 |
+
*
|
335 |
+
* ```js
|
336 |
+
* const myEE = new EventEmitter();
|
337 |
+
* myEE.on('foo', () => console.log('a'));
|
338 |
+
* myEE.prependListener('foo', () => console.log('b'));
|
339 |
+
* myEE.emit('foo');
|
340 |
+
* // Prints:
|
341 |
+
* // b
|
342 |
+
* // a
|
343 |
+
* ```
|
344 |
+
* @since v0.1.101
|
345 |
+
* @param eventName The name of the event.
|
346 |
+
* @param listener The callback function
|
347 |
+
*/
|
348 |
+
on(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
349 |
+
/**
|
350 |
+
* Adds a **one-time**`listener` function for the event named `eventName`. The
|
351 |
+
* next time `eventName` is triggered, this listener is removed and then invoked.
|
352 |
+
*
|
353 |
+
* ```js
|
354 |
+
* server.once('connection', (stream) => {
|
355 |
+
* console.log('Ah, we have our first user!');
|
356 |
+
* });
|
357 |
+
* ```
|
358 |
+
*
|
359 |
+
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
360 |
+
*
|
361 |
+
* By default, event listeners are invoked in the order they are added. The`emitter.prependOnceListener()` method can be used as an alternative to add the
|
362 |
+
* event listener to the beginning of the listeners array.
|
363 |
+
*
|
364 |
+
* ```js
|
365 |
+
* const myEE = new EventEmitter();
|
366 |
+
* myEE.once('foo', () => console.log('a'));
|
367 |
+
* myEE.prependOnceListener('foo', () => console.log('b'));
|
368 |
+
* myEE.emit('foo');
|
369 |
+
* // Prints:
|
370 |
+
* // b
|
371 |
+
* // a
|
372 |
+
* ```
|
373 |
+
* @since v0.3.0
|
374 |
+
* @param eventName The name of the event.
|
375 |
+
* @param listener The callback function
|
376 |
+
*/
|
377 |
+
once(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
378 |
+
/**
|
379 |
+
* Removes the specified `listener` from the listener array for the event named`eventName`.
|
380 |
+
*
|
381 |
+
* ```js
|
382 |
+
* const callback = (stream) => {
|
383 |
+
* console.log('someone connected!');
|
384 |
+
* };
|
385 |
+
* server.on('connection', callback);
|
386 |
+
* // ...
|
387 |
+
* server.removeListener('connection', callback);
|
388 |
+
* ```
|
389 |
+
*
|
390 |
+
* `removeListener()` will remove, at most, one instance of a listener from the
|
391 |
+
* listener array. If any single listener has been added multiple times to the
|
392 |
+
* listener array for the specified `eventName`, then `removeListener()` must be
|
393 |
+
* called multiple times to remove each instance.
|
394 |
+
*
|
395 |
+
* Once an event is emitted, all listeners attached to it at the
|
396 |
+
* time of emitting are called in order. This implies that any`removeListener()` or `removeAllListeners()` calls _after_ emitting and _before_ the last listener finishes execution
|
397 |
+
* will not remove them from`emit()` in progress. Subsequent events behave as expected.
|
398 |
+
*
|
399 |
+
* ```js
|
400 |
+
* const myEmitter = new MyEmitter();
|
401 |
+
*
|
402 |
+
* const callbackA = () => {
|
403 |
+
* console.log('A');
|
404 |
+
* myEmitter.removeListener('event', callbackB);
|
405 |
+
* };
|
406 |
+
*
|
407 |
+
* const callbackB = () => {
|
408 |
+
* console.log('B');
|
409 |
+
* };
|
410 |
+
*
|
411 |
+
* myEmitter.on('event', callbackA);
|
412 |
+
*
|
413 |
+
* myEmitter.on('event', callbackB);
|
414 |
+
*
|
415 |
+
* // callbackA removes listener callbackB but it will still be called.
|
416 |
+
* // Internal listener array at time of emit [callbackA, callbackB]
|
417 |
+
* myEmitter.emit('event');
|
418 |
+
* // Prints:
|
419 |
+
* // A
|
420 |
+
* // B
|
421 |
+
*
|
422 |
+
* // callbackB is now removed.
|
423 |
+
* // Internal listener array [callbackA]
|
424 |
+
* myEmitter.emit('event');
|
425 |
+
* // Prints:
|
426 |
+
* // A
|
427 |
+
* ```
|
428 |
+
*
|
429 |
+
* Because listeners are managed using an internal array, calling this will
|
430 |
+
* change the position indices of any listener registered _after_ the listener
|
431 |
+
* being removed. This will not impact the order in which listeners are called,
|
432 |
+
* but it means that any copies of the listener array as returned by
|
433 |
+
* the `emitter.listeners()` method will need to be recreated.
|
434 |
+
*
|
435 |
+
* When a single function has been added as a handler multiple times for a single
|
436 |
+
* event (as in the example below), `removeListener()` will remove the most
|
437 |
+
* recently added instance. In the example the `once('ping')`listener is removed:
|
438 |
+
*
|
439 |
+
* ```js
|
440 |
+
* const ee = new EventEmitter();
|
441 |
+
*
|
442 |
+
* function pong() {
|
443 |
+
* console.log('pong');
|
444 |
+
* }
|
445 |
+
*
|
446 |
+
* ee.on('ping', pong);
|
447 |
+
* ee.once('ping', pong);
|
448 |
+
* ee.removeListener('ping', pong);
|
449 |
+
*
|
450 |
+
* ee.emit('ping');
|
451 |
+
* ee.emit('ping');
|
452 |
+
* ```
|
453 |
+
*
|
454 |
+
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
455 |
+
* @since v0.1.26
|
456 |
+
*/
|
457 |
+
removeListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
458 |
+
/**
|
459 |
+
* Alias for `emitter.removeListener()`.
|
460 |
+
* @since v10.0.0
|
461 |
+
*/
|
462 |
+
off(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
463 |
+
/**
|
464 |
+
* Removes all listeners, or those of the specified `eventName`.
|
465 |
+
*
|
466 |
+
* It is bad practice to remove listeners added elsewhere in the code,
|
467 |
+
* particularly when the `EventEmitter` instance was created by some other
|
468 |
+
* component or module (e.g. sockets or file streams).
|
469 |
+
*
|
470 |
+
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
471 |
+
* @since v0.1.26
|
472 |
+
*/
|
473 |
+
removeAllListeners(event?: string | symbol): this;
|
474 |
+
/**
|
475 |
+
* By default `EventEmitter`s will print a warning if more than `10` listeners are
|
476 |
+
* added for a particular event. This is a useful default that helps finding
|
477 |
+
* memory leaks. The `emitter.setMaxListeners()` method allows the limit to be
|
478 |
+
* modified for this specific `EventEmitter` instance. The value can be set to`Infinity` (or `0`) to indicate an unlimited number of listeners.
|
479 |
+
*
|
480 |
+
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
481 |
+
* @since v0.3.5
|
482 |
+
*/
|
483 |
+
setMaxListeners(n: number): this;
|
484 |
+
/**
|
485 |
+
* Returns the current max listener value for the `EventEmitter` which is either
|
486 |
+
* set by `emitter.setMaxListeners(n)` or defaults to {@link defaultMaxListeners}.
|
487 |
+
* @since v1.0.0
|
488 |
+
*/
|
489 |
+
getMaxListeners(): number;
|
490 |
+
/**
|
491 |
+
* Returns a copy of the array of listeners for the event named `eventName`.
|
492 |
+
*
|
493 |
+
* ```js
|
494 |
+
* server.on('connection', (stream) => {
|
495 |
+
* console.log('someone connected!');
|
496 |
+
* });
|
497 |
+
* console.log(util.inspect(server.listeners('connection')));
|
498 |
+
* // Prints: [ [Function] ]
|
499 |
+
* ```
|
500 |
+
* @since v0.1.26
|
501 |
+
*/
|
502 |
+
listeners(eventName: string | symbol): Function[];
|
503 |
+
/**
|
504 |
+
* Returns a copy of the array of listeners for the event named `eventName`,
|
505 |
+
* including any wrappers (such as those created by `.once()`).
|
506 |
+
*
|
507 |
+
* ```js
|
508 |
+
* const emitter = new EventEmitter();
|
509 |
+
* emitter.once('log', () => console.log('log once'));
|
510 |
+
*
|
511 |
+
* // Returns a new Array with a function `onceWrapper` which has a property
|
512 |
+
* // `listener` which contains the original listener bound above
|
513 |
+
* const listeners = emitter.rawListeners('log');
|
514 |
+
* const logFnWrapper = listeners[0];
|
515 |
+
*
|
516 |
+
* // Logs "log once" to the console and does not unbind the `once` event
|
517 |
+
* logFnWrapper.listener();
|
518 |
+
*
|
519 |
+
* // Logs "log once" to the console and removes the listener
|
520 |
+
* logFnWrapper();
|
521 |
+
*
|
522 |
+
* emitter.on('log', () => console.log('log persistently'));
|
523 |
+
* // Will return a new Array with a single function bound by `.on()` above
|
524 |
+
* const newListeners = emitter.rawListeners('log');
|
525 |
+
*
|
526 |
+
* // Logs "log persistently" twice
|
527 |
+
* newListeners[0]();
|
528 |
+
* emitter.emit('log');
|
529 |
+
* ```
|
530 |
+
* @since v9.4.0
|
531 |
+
*/
|
532 |
+
rawListeners(eventName: string | symbol): Function[];
|
533 |
+
/**
|
534 |
+
* Synchronously calls each of the listeners registered for the event named`eventName`, in the order they were registered, passing the supplied arguments
|
535 |
+
* to each.
|
536 |
+
*
|
537 |
+
* Returns `true` if the event had listeners, `false` otherwise.
|
538 |
+
*
|
539 |
+
* ```js
|
540 |
+
* const EventEmitter = require('events');
|
541 |
+
* const myEmitter = new EventEmitter();
|
542 |
+
*
|
543 |
+
* // First listener
|
544 |
+
* myEmitter.on('event', function firstListener() {
|
545 |
+
* console.log('Helloooo! first listener');
|
546 |
+
* });
|
547 |
+
* // Second listener
|
548 |
+
* myEmitter.on('event', function secondListener(arg1, arg2) {
|
549 |
+
* console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
|
550 |
+
* });
|
551 |
+
* // Third listener
|
552 |
+
* myEmitter.on('event', function thirdListener(...args) {
|
553 |
+
* const parameters = args.join(', ');
|
554 |
+
* console.log(`event with parameters ${parameters} in third listener`);
|
555 |
+
* });
|
556 |
+
*
|
557 |
+
* console.log(myEmitter.listeners('event'));
|
558 |
+
*
|
559 |
+
* myEmitter.emit('event', 1, 2, 3, 4, 5);
|
560 |
+
*
|
561 |
+
* // Prints:
|
562 |
+
* // [
|
563 |
+
* // [Function: firstListener],
|
564 |
+
* // [Function: secondListener],
|
565 |
+
* // [Function: thirdListener]
|
566 |
+
* // ]
|
567 |
+
* // Helloooo! first listener
|
568 |
+
* // event with parameters 1, 2 in second listener
|
569 |
+
* // event with parameters 1, 2, 3, 4, 5 in third listener
|
570 |
+
* ```
|
571 |
+
* @since v0.1.26
|
572 |
+
*/
|
573 |
+
emit(eventName: string | symbol, ...args: any[]): boolean;
|
574 |
+
/**
|
575 |
+
* Returns the number of listeners listening to the event named `eventName`.
|
576 |
+
* @since v3.2.0
|
577 |
+
* @param eventName The name of the event being listened for
|
578 |
+
*/
|
579 |
+
listenerCount(eventName: string | symbol): number;
|
580 |
+
/**
|
581 |
+
* Adds the `listener` function to the _beginning_ of the listeners array for the
|
582 |
+
* event named `eventName`. No checks are made to see if the `listener` has
|
583 |
+
* already been added. Multiple calls passing the same combination of `eventName`and `listener` will result in the `listener` being added, and called, multiple
|
584 |
+
* times.
|
585 |
+
*
|
586 |
+
* ```js
|
587 |
+
* server.prependListener('connection', (stream) => {
|
588 |
+
* console.log('someone connected!');
|
589 |
+
* });
|
590 |
+
* ```
|
591 |
+
*
|
592 |
+
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
593 |
+
* @since v6.0.0
|
594 |
+
* @param eventName The name of the event.
|
595 |
+
* @param listener The callback function
|
596 |
+
*/
|
597 |
+
prependListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
598 |
+
/**
|
599 |
+
* Adds a **one-time**`listener` function for the event named `eventName` to the _beginning_ of the listeners array. The next time `eventName` is triggered, this
|
600 |
+
* listener is removed, and then invoked.
|
601 |
+
*
|
602 |
+
* ```js
|
603 |
+
* server.prependOnceListener('connection', (stream) => {
|
604 |
+
* console.log('Ah, we have our first user!');
|
605 |
+
* });
|
606 |
+
* ```
|
607 |
+
*
|
608 |
+
* Returns a reference to the `EventEmitter`, so that calls can be chained.
|
609 |
+
* @since v6.0.0
|
610 |
+
* @param eventName The name of the event.
|
611 |
+
* @param listener The callback function
|
612 |
+
*/
|
613 |
+
prependOnceListener(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
614 |
+
/**
|
615 |
+
* Returns an array listing the events for which the emitter has registered
|
616 |
+
* listeners. The values in the array are strings or `Symbol`s.
|
617 |
+
*
|
618 |
+
* ```js
|
619 |
+
* const EventEmitter = require('events');
|
620 |
+
* const myEE = new EventEmitter();
|
621 |
+
* myEE.on('foo', () => {});
|
622 |
+
* myEE.on('bar', () => {});
|
623 |
+
*
|
624 |
+
* const sym = Symbol('symbol');
|
625 |
+
* myEE.on(sym, () => {});
|
626 |
+
*
|
627 |
+
* console.log(myEE.eventNames());
|
628 |
+
* // Prints: [ 'foo', 'bar', Symbol(symbol) ]
|
629 |
+
* ```
|
630 |
+
* @since v6.0.0
|
631 |
+
*/
|
632 |
+
eventNames(): Array<string | symbol>;
|
633 |
+
}
|
634 |
+
}
|
635 |
+
}
|
636 |
+
export = EventEmitter;
|
637 |
+
}
|
638 |
+
declare module 'node:events' {
|
639 |
+
import events = require('events');
|
640 |
+
export = events;
|
641 |
+
}
|
igv_component/node_modules/@types/node/fs.d.ts
ADDED
The diff for this file is too large to render.
See raw diff
|
|
igv_component/node_modules/@types/node/fs/promises.d.ts
ADDED
@@ -0,0 +1,1120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* The `fs/promises` API provides asynchronous file system methods that return
|
3 |
+
* promises.
|
4 |
+
*
|
5 |
+
* The promise APIs use the underlying Node.js threadpool to perform file
|
6 |
+
* system operations off the event loop thread. These operations are not
|
7 |
+
* synchronized or threadsafe. Care must be taken when performing multiple
|
8 |
+
* concurrent modifications on the same file or data corruption may occur.
|
9 |
+
* @since v10.0.0
|
10 |
+
*/
|
11 |
+
declare module 'fs/promises' {
|
12 |
+
import { Abortable } from 'node:events';
|
13 |
+
import { Stream } from 'node:stream';
|
14 |
+
import { ReadableStream } from 'node:stream/web';
|
15 |
+
import {
|
16 |
+
BigIntStats,
|
17 |
+
BufferEncodingOption,
|
18 |
+
constants as fsConstants,
|
19 |
+
CopyOptions,
|
20 |
+
Dir,
|
21 |
+
Dirent,
|
22 |
+
MakeDirectoryOptions,
|
23 |
+
Mode,
|
24 |
+
ObjectEncodingOptions,
|
25 |
+
OpenDirOptions,
|
26 |
+
OpenMode,
|
27 |
+
PathLike,
|
28 |
+
ReadStream,
|
29 |
+
ReadVResult,
|
30 |
+
RmDirOptions,
|
31 |
+
RmOptions,
|
32 |
+
StatOptions,
|
33 |
+
Stats,
|
34 |
+
TimeLike,
|
35 |
+
WatchEventType,
|
36 |
+
WatchOptions,
|
37 |
+
WriteStream,
|
38 |
+
WriteVResult,
|
39 |
+
} from 'node:fs';
|
40 |
+
|
41 |
+
interface FileChangeInfo<T extends string | Buffer> {
|
42 |
+
eventType: WatchEventType;
|
43 |
+
filename: T;
|
44 |
+
}
|
45 |
+
interface FlagAndOpenMode {
|
46 |
+
mode?: Mode | undefined;
|
47 |
+
flag?: OpenMode | undefined;
|
48 |
+
}
|
49 |
+
interface FileReadResult<T extends NodeJS.ArrayBufferView> {
|
50 |
+
bytesRead: number;
|
51 |
+
buffer: T;
|
52 |
+
}
|
53 |
+
interface FileReadOptions<T extends NodeJS.ArrayBufferView = Buffer> {
|
54 |
+
/**
|
55 |
+
* @default `Buffer.alloc(0xffff)`
|
56 |
+
*/
|
57 |
+
buffer?: T;
|
58 |
+
/**
|
59 |
+
* @default 0
|
60 |
+
*/
|
61 |
+
offset?: number | null;
|
62 |
+
/**
|
63 |
+
* @default `buffer.byteLength`
|
64 |
+
*/
|
65 |
+
length?: number | null;
|
66 |
+
position?: number | null;
|
67 |
+
}
|
68 |
+
interface CreateReadStreamOptions {
|
69 |
+
encoding?: BufferEncoding | null | undefined;
|
70 |
+
autoClose?: boolean | undefined;
|
71 |
+
emitClose?: boolean | undefined;
|
72 |
+
start?: number | undefined;
|
73 |
+
end?: number | undefined;
|
74 |
+
highWaterMark?: number | undefined;
|
75 |
+
}
|
76 |
+
interface CreateWriteStreamOptions {
|
77 |
+
encoding?: BufferEncoding | null | undefined;
|
78 |
+
autoClose?: boolean | undefined;
|
79 |
+
emitClose?: boolean | undefined;
|
80 |
+
start?: number | undefined;
|
81 |
+
}
|
82 |
+
// TODO: Add `EventEmitter` close
|
83 |
+
interface FileHandle {
|
84 |
+
/**
|
85 |
+
* The numeric file descriptor managed by the {FileHandle} object.
|
86 |
+
* @since v10.0.0
|
87 |
+
*/
|
88 |
+
readonly fd: number;
|
89 |
+
/**
|
90 |
+
* Alias of `filehandle.writeFile()`.
|
91 |
+
*
|
92 |
+
* When operating on file handles, the mode cannot be changed from what it was set
|
93 |
+
* to with `fsPromises.open()`. Therefore, this is equivalent to `filehandle.writeFile()`.
|
94 |
+
* @since v10.0.0
|
95 |
+
* @return Fulfills with `undefined` upon success.
|
96 |
+
*/
|
97 |
+
appendFile(data: string | Uint8Array, options?: (ObjectEncodingOptions & FlagAndOpenMode) | BufferEncoding | null): Promise<void>;
|
98 |
+
/**
|
99 |
+
* Changes the ownership of the file. A wrapper for [`chown(2)`](http://man7.org/linux/man-pages/man2/chown.2.html).
|
100 |
+
* @since v10.0.0
|
101 |
+
* @param uid The file's new owner's user id.
|
102 |
+
* @param gid The file's new group's group id.
|
103 |
+
* @return Fulfills with `undefined` upon success.
|
104 |
+
*/
|
105 |
+
chown(uid: number, gid: number): Promise<void>;
|
106 |
+
/**
|
107 |
+
* Modifies the permissions on the file. See [`chmod(2)`](http://man7.org/linux/man-pages/man2/chmod.2.html).
|
108 |
+
* @since v10.0.0
|
109 |
+
* @param mode the file mode bit mask.
|
110 |
+
* @return Fulfills with `undefined` upon success.
|
111 |
+
*/
|
112 |
+
chmod(mode: Mode): Promise<void>;
|
113 |
+
/**
|
114 |
+
* Unlike the 16 kb default `highWaterMark` for a `stream.Readable`, the stream
|
115 |
+
* returned by this method has a default `highWaterMark` of 64 kb.
|
116 |
+
*
|
117 |
+
* `options` can include `start` and `end` values to read a range of bytes from
|
118 |
+
* the file instead of the entire file. Both `start` and `end` are inclusive and
|
119 |
+
* start counting at 0, allowed values are in the
|
120 |
+
* \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. If `start` is
|
121 |
+
* omitted or `undefined`, `filehandle.createReadStream()` reads sequentially from
|
122 |
+
* the current file position. The `encoding` can be any one of those accepted by `Buffer`.
|
123 |
+
*
|
124 |
+
* If the `FileHandle` points to a character device that only supports blocking
|
125 |
+
* reads (such as keyboard or sound card), read operations do not finish until data
|
126 |
+
* is available. This can prevent the process from exiting and the stream from
|
127 |
+
* closing naturally.
|
128 |
+
*
|
129 |
+
* By default, the stream will emit a `'close'` event after it has been
|
130 |
+
* destroyed. Set the `emitClose` option to `false` to change this behavior.
|
131 |
+
*
|
132 |
+
* ```js
|
133 |
+
* import { open } from 'fs/promises';
|
134 |
+
*
|
135 |
+
* const fd = await open('/dev/input/event0');
|
136 |
+
* // Create a stream from some character device.
|
137 |
+
* const stream = fd.createReadStream();
|
138 |
+
* setTimeout(() => {
|
139 |
+
* stream.close(); // This may not close the stream.
|
140 |
+
* // Artificially marking end-of-stream, as if the underlying resource had
|
141 |
+
* // indicated end-of-file by itself, allows the stream to close.
|
142 |
+
* // This does not cancel pending read operations, and if there is such an
|
143 |
+
* // operation, the process may still not be able to exit successfully
|
144 |
+
* // until it finishes.
|
145 |
+
* stream.push(null);
|
146 |
+
* stream.read(0);
|
147 |
+
* }, 100);
|
148 |
+
* ```
|
149 |
+
*
|
150 |
+
* If `autoClose` is false, then the file descriptor won't be closed, even if
|
151 |
+
* there's an error. It is the application's responsibility to close it and make
|
152 |
+
* sure there's no file descriptor leak. If `autoClose` is set to true (default
|
153 |
+
* behavior), on `'error'` or `'end'` the file descriptor will be closed
|
154 |
+
* automatically.
|
155 |
+
*
|
156 |
+
* An example to read the last 10 bytes of a file which is 100 bytes long:
|
157 |
+
*
|
158 |
+
* ```js
|
159 |
+
* import { open } from 'fs/promises';
|
160 |
+
*
|
161 |
+
* const fd = await open('sample.txt');
|
162 |
+
* fd.createReadStream({ start: 90, end: 99 });
|
163 |
+
* ```
|
164 |
+
* @since v16.11.0
|
165 |
+
*/
|
166 |
+
createReadStream(options?: CreateReadStreamOptions): ReadStream;
|
167 |
+
/**
|
168 |
+
* `options` may also include a `start` option to allow writing data at some
|
169 |
+
* position past the beginning of the file, allowed values are in the
|
170 |
+
* \[0, [`Number.MAX_SAFE_INTEGER`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER)\] range. Modifying a file rather than
|
171 |
+
* replacing it may require the `flags` `open` option to be set to `r+` rather than
|
172 |
+
* the default `r`. The `encoding` can be any one of those accepted by `Buffer`.
|
173 |
+
*
|
174 |
+
* If `autoClose` is set to true (default behavior) on `'error'` or `'finish'`the file descriptor will be closed automatically. If `autoClose` is false,
|
175 |
+
* then the file descriptor won't be closed, even if there's an error.
|
176 |
+
* It is the application's responsibility to close it and make sure there's no
|
177 |
+
* file descriptor leak.
|
178 |
+
*
|
179 |
+
* By default, the stream will emit a `'close'` event after it has been
|
180 |
+
* destroyed. Set the `emitClose` option to `false` to change this behavior.
|
181 |
+
* @since v16.11.0
|
182 |
+
*/
|
183 |
+
createWriteStream(options?: CreateWriteStreamOptions): WriteStream;
|
184 |
+
/**
|
185 |
+
* Forces all currently queued I/O operations associated with the file to the
|
186 |
+
* 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.
|
187 |
+
*
|
188 |
+
* Unlike `filehandle.sync` this method does not flush modified metadata.
|
189 |
+
* @since v10.0.0
|
190 |
+
* @return Fulfills with `undefined` upon success.
|
191 |
+
*/
|
192 |
+
datasync(): Promise<void>;
|
193 |
+
/**
|
194 |
+
* Request that all data for the open file descriptor is flushed to the storage
|
195 |
+
* device. The specific implementation is operating system and device specific.
|
196 |
+
* Refer to the POSIX [`fsync(2)`](http://man7.org/linux/man-pages/man2/fsync.2.html) documentation for more detail.
|
197 |
+
* @since v10.0.0
|
198 |
+
* @return Fufills with `undefined` upon success.
|
199 |
+
*/
|
200 |
+
sync(): Promise<void>;
|
201 |
+
/**
|
202 |
+
* Reads data from the file and stores that in the given buffer.
|
203 |
+
*
|
204 |
+
* If the file is not modified concurrently, the end-of-file is reached when the
|
205 |
+
* number of bytes read is zero.
|
206 |
+
* @since v10.0.0
|
207 |
+
* @param buffer A buffer that will be filled with the file data read.
|
208 |
+
* @param offset The location in the buffer at which to start filling.
|
209 |
+
* @param length The number of bytes to read.
|
210 |
+
* @param position The location where to begin reading data from the file. If `null`, data will be read from the current file position, and the position will be updated. If `position` is an
|
211 |
+
* integer, the current file position will remain unchanged.
|
212 |
+
* @return Fulfills upon success with an object with two properties:
|
213 |
+
*/
|
214 |
+
read<T extends NodeJS.ArrayBufferView>(buffer: T, offset?: number | null, length?: number | null, position?: number | null): Promise<FileReadResult<T>>;
|
215 |
+
read<T extends NodeJS.ArrayBufferView = Buffer>(options?: FileReadOptions<T>): Promise<FileReadResult<T>>;
|
216 |
+
/**
|
217 |
+
* Returns a `ReadableStream` that may be used to read the files data.
|
218 |
+
*
|
219 |
+
* An error will be thrown if this method is called more than once or is called after the `FileHandle` is closed
|
220 |
+
* or closing.
|
221 |
+
*
|
222 |
+
* ```js
|
223 |
+
* import { open } from 'node:fs/promises';
|
224 |
+
*
|
225 |
+
* const file = await open('./some/file/to/read');
|
226 |
+
*
|
227 |
+
* for await (const chunk of file.readableWebStream())
|
228 |
+
* console.log(chunk);
|
229 |
+
*
|
230 |
+
* await file.close();
|
231 |
+
* ```
|
232 |
+
*
|
233 |
+
* While the `ReadableStream` will read the file to completion, it will not close the `FileHandle` automatically. User code must still call the `fileHandle.close()` method.
|
234 |
+
*
|
235 |
+
* @since v17.0.0
|
236 |
+
* @experimental
|
237 |
+
*/
|
238 |
+
readableWebStream(): ReadableStream;
|
239 |
+
/**
|
240 |
+
* Asynchronously reads the entire contents of a file.
|
241 |
+
*
|
242 |
+
* If `options` is a string, then it specifies the `encoding`.
|
243 |
+
*
|
244 |
+
* The `FileHandle` has to support reading.
|
245 |
+
*
|
246 |
+
* If one or more `filehandle.read()` calls are made on a file handle and then a`filehandle.readFile()` call is made, the data will be read from the current
|
247 |
+
* position till the end of the file. It doesn't always read from the beginning
|
248 |
+
* of the file.
|
249 |
+
* @since v10.0.0
|
250 |
+
* @return Fulfills upon a successful read with the contents of the file. If no encoding is specified (using `options.encoding`), the data is returned as a {Buffer} object. Otherwise, the
|
251 |
+
* data will be a string.
|
252 |
+
*/
|
253 |
+
readFile(
|
254 |
+
options?: {
|
255 |
+
encoding?: null | undefined;
|
256 |
+
flag?: OpenMode | undefined;
|
257 |
+
} | null
|
258 |
+
): Promise<Buffer>;
|
259 |
+
/**
|
260 |
+
* Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
|
261 |
+
* The `FileHandle` must have been opened for reading.
|
262 |
+
* @param options An object that may contain an optional flag.
|
263 |
+
* If a flag is not provided, it defaults to `'r'`.
|
264 |
+
*/
|
265 |
+
readFile(
|
266 |
+
options:
|
267 |
+
| {
|
268 |
+
encoding: BufferEncoding;
|
269 |
+
flag?: OpenMode | undefined;
|
270 |
+
}
|
271 |
+
| BufferEncoding
|
272 |
+
): Promise<string>;
|
273 |
+
/**
|
274 |
+
* Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
|
275 |
+
* The `FileHandle` must have been opened for reading.
|
276 |
+
* @param options An object that may contain an optional flag.
|
277 |
+
* If a flag is not provided, it defaults to `'r'`.
|
278 |
+
*/
|
279 |
+
readFile(
|
280 |
+
options?:
|
281 |
+
| (ObjectEncodingOptions & {
|
282 |
+
flag?: OpenMode | undefined;
|
283 |
+
})
|
284 |
+
| BufferEncoding
|
285 |
+
| null
|
286 |
+
): Promise<string | Buffer>;
|
287 |
+
/**
|
288 |
+
* @since v10.0.0
|
289 |
+
* @return Fulfills with an {fs.Stats} for the file.
|
290 |
+
*/
|
291 |
+
stat(
|
292 |
+
opts?: StatOptions & {
|
293 |
+
bigint?: false | undefined;
|
294 |
+
}
|
295 |
+
): Promise<Stats>;
|
296 |
+
stat(
|
297 |
+
opts: StatOptions & {
|
298 |
+
bigint: true;
|
299 |
+
}
|
300 |
+
): Promise<BigIntStats>;
|
301 |
+
stat(opts?: StatOptions): Promise<Stats | BigIntStats>;
|
302 |
+
/**
|
303 |
+
* Truncates the file.
|
304 |
+
*
|
305 |
+
* If the file was larger than `len` bytes, only the first `len` bytes will be
|
306 |
+
* retained in the file.
|
307 |
+
*
|
308 |
+
* The following example retains only the first four bytes of the file:
|
309 |
+
*
|
310 |
+
* ```js
|
311 |
+
* import { open } from 'fs/promises';
|
312 |
+
*
|
313 |
+
* let filehandle = null;
|
314 |
+
* try {
|
315 |
+
* filehandle = await open('temp.txt', 'r+');
|
316 |
+
* await filehandle.truncate(4);
|
317 |
+
* } finally {
|
318 |
+
* await filehandle?.close();
|
319 |
+
* }
|
320 |
+
* ```
|
321 |
+
*
|
322 |
+
* If the file previously was shorter than `len` bytes, it is extended, and the
|
323 |
+
* extended part is filled with null bytes (`'\0'`):
|
324 |
+
*
|
325 |
+
* If `len` is negative then `0` will be used.
|
326 |
+
* @since v10.0.0
|
327 |
+
* @param [len=0]
|
328 |
+
* @return Fulfills with `undefined` upon success.
|
329 |
+
*/
|
330 |
+
truncate(len?: number): Promise<void>;
|
331 |
+
/**
|
332 |
+
* Change the file system timestamps of the object referenced by the `FileHandle` then resolves the promise with no arguments upon success.
|
333 |
+
* @since v10.0.0
|
334 |
+
*/
|
335 |
+
utimes(atime: TimeLike, mtime: TimeLike): Promise<void>;
|
336 |
+
/**
|
337 |
+
* Asynchronously writes data to a file, replacing the file if it already exists.`data` can be a string, a buffer, an
|
338 |
+
* [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface) or
|
339 |
+
* [Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol) object.
|
340 |
+
* The promise is resolved with no arguments upon success.
|
341 |
+
*
|
342 |
+
* If `options` is a string, then it specifies the `encoding`.
|
343 |
+
*
|
344 |
+
* The `FileHandle` has to support writing.
|
345 |
+
*
|
346 |
+
* It is unsafe to use `filehandle.writeFile()` multiple times on the same file
|
347 |
+
* without waiting for the promise to be resolved (or rejected).
|
348 |
+
*
|
349 |
+
* If one or more `filehandle.write()` calls are made on a file handle and then a`filehandle.writeFile()` call is made, the data will be written from the
|
350 |
+
* current position till the end of the file. It doesn't always write from the
|
351 |
+
* beginning of the file.
|
352 |
+
* @since v10.0.0
|
353 |
+
*/
|
354 |
+
writeFile(data: string | Uint8Array, options?: (ObjectEncodingOptions & FlagAndOpenMode & Abortable) | BufferEncoding | null): Promise<void>;
|
355 |
+
/**
|
356 |
+
* Write `buffer` to the file.
|
357 |
+
*
|
358 |
+
* The promise is resolved with an object containing two properties:
|
359 |
+
*
|
360 |
+
* It is unsafe to use `filehandle.write()` multiple times on the same file
|
361 |
+
* without waiting for the promise to be resolved (or rejected). For this
|
362 |
+
* scenario, use `filehandle.createWriteStream()`.
|
363 |
+
*
|
364 |
+
* On Linux, positional writes do not work when the file is opened in append mode.
|
365 |
+
* The kernel ignores the position argument and always appends the data to
|
366 |
+
* the end of the file.
|
367 |
+
* @since v10.0.0
|
368 |
+
* @param [offset=0] The start position from within `buffer` where the data to write begins.
|
369 |
+
* @param [length=buffer.byteLength - offset] The number of bytes from `buffer` to write.
|
370 |
+
* @param position The offset from the beginning of the file where the data from `buffer` should be written. If `position` is not a `number`, the data will be written at the current position.
|
371 |
+
* See the POSIX pwrite(2) documentation for more detail.
|
372 |
+
*/
|
373 |
+
write<TBuffer extends Uint8Array>(
|
374 |
+
buffer: TBuffer,
|
375 |
+
offset?: number | null,
|
376 |
+
length?: number | null,
|
377 |
+
position?: number | null
|
378 |
+
): Promise<{
|
379 |
+
bytesWritten: number;
|
380 |
+
buffer: TBuffer;
|
381 |
+
}>;
|
382 |
+
write(
|
383 |
+
data: string,
|
384 |
+
position?: number | null,
|
385 |
+
encoding?: BufferEncoding | null
|
386 |
+
): Promise<{
|
387 |
+
bytesWritten: number;
|
388 |
+
buffer: string;
|
389 |
+
}>;
|
390 |
+
/**
|
391 |
+
* Write an array of [ArrayBufferView](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView) s to the file.
|
392 |
+
*
|
393 |
+
* The promise is resolved with an object containing a two properties:
|
394 |
+
*
|
395 |
+
* It is unsafe to call `writev()` multiple times on the same file without waiting
|
396 |
+
* for the promise to be resolved (or rejected).
|
397 |
+
*
|
398 |
+
* On Linux, positional writes don't work when the file is opened in append mode.
|
399 |
+
* The kernel ignores the position argument and always appends the data to
|
400 |
+
* the end of the file.
|
401 |
+
* @since v12.9.0
|
402 |
+
* @param position The offset from the beginning of the file where the data from `buffers` should be written. If `position` is not a `number`, the data will be written at the current
|
403 |
+
* position.
|
404 |
+
*/
|
405 |
+
writev(buffers: ReadonlyArray<NodeJS.ArrayBufferView>, position?: number): Promise<WriteVResult>;
|
406 |
+
/**
|
407 |
+
* Read from a file and write to an array of [ArrayBufferView](https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView) s
|
408 |
+
* @since v13.13.0, v12.17.0
|
409 |
+
* @param position The offset from the beginning of the file where the data should be read from. If `position` is not a `number`, the data will be read from the current position.
|
410 |
+
* @return Fulfills upon success an object containing two properties:
|
411 |
+
*/
|
412 |
+
readv(buffers: ReadonlyArray<NodeJS.ArrayBufferView>, position?: number): Promise<ReadVResult>;
|
413 |
+
/**
|
414 |
+
* Closes the file handle after waiting for any pending operation on the handle to
|
415 |
+
* complete.
|
416 |
+
*
|
417 |
+
* ```js
|
418 |
+
* import { open } from 'fs/promises';
|
419 |
+
*
|
420 |
+
* let filehandle;
|
421 |
+
* try {
|
422 |
+
* filehandle = await open('thefile.txt', 'r');
|
423 |
+
* } finally {
|
424 |
+
* await filehandle?.close();
|
425 |
+
* }
|
426 |
+
* ```
|
427 |
+
* @since v10.0.0
|
428 |
+
* @return Fulfills with `undefined` upon success.
|
429 |
+
*/
|
430 |
+
close(): Promise<void>;
|
431 |
+
}
|
432 |
+
|
433 |
+
const constants: typeof fsConstants;
|
434 |
+
|
435 |
+
/**
|
436 |
+
* Tests a user's permissions for the file or directory specified by `path`.
|
437 |
+
* The `mode` argument is an optional integer that specifies the accessibility
|
438 |
+
* checks to be performed. `mode` should be either the value `fs.constants.F_OK`or a mask consisting of the bitwise OR of any of `fs.constants.R_OK`,`fs.constants.W_OK`, and `fs.constants.X_OK`
|
439 |
+
* (e.g.`fs.constants.W_OK | fs.constants.R_OK`). Check `File access constants` for
|
440 |
+
* possible values of `mode`.
|
441 |
+
*
|
442 |
+
* If the accessibility check is successful, the promise is resolved with no
|
443 |
+
* value. If any of the accessibility checks fail, the promise is rejected
|
444 |
+
* with an [Error](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) object. The following example checks if the file`/etc/passwd` can be read and
|
445 |
+
* written by the current process.
|
446 |
+
*
|
447 |
+
* ```js
|
448 |
+
* import { access } from 'fs/promises';
|
449 |
+
* import { constants } from 'fs';
|
450 |
+
*
|
451 |
+
* try {
|
452 |
+
* await access('/etc/passwd', constants.R_OK | constants.W_OK);
|
453 |
+
* console.log('can access');
|
454 |
+
* } catch {
|
455 |
+
* console.error('cannot access');
|
456 |
+
* }
|
457 |
+
* ```
|
458 |
+
*
|
459 |
+
* Using `fsPromises.access()` to check for the accessibility of a file before
|
460 |
+
* calling `fsPromises.open()` is not recommended. Doing so introduces a race
|
461 |
+
* condition, since other processes may change the file's state between the two
|
462 |
+
* calls. Instead, user code should open/read/write the file directly and handle
|
463 |
+
* the error raised if the file is not accessible.
|
464 |
+
* @since v10.0.0
|
465 |
+
* @param [mode=fs.constants.F_OK]
|
466 |
+
* @return Fulfills with `undefined` upon success.
|
467 |
+
*/
|
468 |
+
function access(path: PathLike, mode?: number): Promise<void>;
|
469 |
+
/**
|
470 |
+
* Asynchronously copies `src` to `dest`. By default, `dest` is overwritten if it
|
471 |
+
* already exists.
|
472 |
+
*
|
473 |
+
* No guarantees are made about the atomicity of the copy operation. If an
|
474 |
+
* error occurs after the destination file has been opened for writing, an attempt
|
475 |
+
* will be made to remove the destination.
|
476 |
+
*
|
477 |
+
* ```js
|
478 |
+
* import { constants } from 'fs';
|
479 |
+
* import { copyFile } from 'fs/promises';
|
480 |
+
*
|
481 |
+
* try {
|
482 |
+
* await copyFile('source.txt', 'destination.txt');
|
483 |
+
* console.log('source.txt was copied to destination.txt');
|
484 |
+
* } catch {
|
485 |
+
* console.log('The file could not be copied');
|
486 |
+
* }
|
487 |
+
*
|
488 |
+
* // By using COPYFILE_EXCL, the operation will fail if destination.txt exists.
|
489 |
+
* try {
|
490 |
+
* await copyFile('source.txt', 'destination.txt', constants.COPYFILE_EXCL);
|
491 |
+
* console.log('source.txt was copied to destination.txt');
|
492 |
+
* } catch {
|
493 |
+
* console.log('The file could not be copied');
|
494 |
+
* }
|
495 |
+
* ```
|
496 |
+
* @since v10.0.0
|
497 |
+
* @param src source filename to copy
|
498 |
+
* @param dest destination filename of the copy operation
|
499 |
+
* @param [mode=0] Optional modifiers that specify the behavior of the copy operation. It is possible to create a mask consisting of the bitwise OR of two or more values (e.g.
|
500 |
+
* `fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE`)
|
501 |
+
* @return Fulfills with `undefined` upon success.
|
502 |
+
*/
|
503 |
+
function copyFile(src: PathLike, dest: PathLike, mode?: number): Promise<void>;
|
504 |
+
/**
|
505 |
+
* Opens a `FileHandle`.
|
506 |
+
*
|
507 |
+
* Refer to the POSIX [`open(2)`](http://man7.org/linux/man-pages/man2/open.2.html) documentation for more detail.
|
508 |
+
*
|
509 |
+
* Some characters (`< > : " / \ | ? *`) are reserved under Windows as documented
|
510 |
+
* by [Naming Files, Paths, and Namespaces](https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file). Under NTFS, if the filename contains
|
511 |
+
* a colon, Node.js will open a file system stream, as described by [this MSDN page](https://docs.microsoft.com/en-us/windows/desktop/FileIO/using-streams).
|
512 |
+
* @since v10.0.0
|
513 |
+
* @param [flags='r'] See `support of file system `flags``.
|
514 |
+
* @param [mode=0o666] Sets the file mode (permission and sticky bits) if the file is created.
|
515 |
+
* @return Fulfills with a {FileHandle} object.
|
516 |
+
*/
|
517 |
+
function open(path: PathLike, flags?: string | number, mode?: Mode): Promise<FileHandle>;
|
518 |
+
/**
|
519 |
+
* Renames `oldPath` to `newPath`.
|
520 |
+
* @since v10.0.0
|
521 |
+
* @return Fulfills with `undefined` upon success.
|
522 |
+
*/
|
523 |
+
function rename(oldPath: PathLike, newPath: PathLike): Promise<void>;
|
524 |
+
/**
|
525 |
+
* Truncates (shortens or extends the length) of the content at `path` to `len`bytes.
|
526 |
+
* @since v10.0.0
|
527 |
+
* @param [len=0]
|
528 |
+
* @return Fulfills with `undefined` upon success.
|
529 |
+
*/
|
530 |
+
function truncate(path: PathLike, len?: number): Promise<void>;
|
531 |
+
/**
|
532 |
+
* Removes the directory identified by `path`.
|
533 |
+
*
|
534 |
+
* Using `fsPromises.rmdir()` on a file (not a directory) results in the
|
535 |
+
* promise being rejected with an `ENOENT` error on Windows and an `ENOTDIR`error on POSIX.
|
536 |
+
*
|
537 |
+
* To get a behavior similar to the `rm -rf` Unix command, use `fsPromises.rm()` with options `{ recursive: true, force: true }`.
|
538 |
+
* @since v10.0.0
|
539 |
+
* @return Fulfills with `undefined` upon success.
|
540 |
+
*/
|
541 |
+
function rmdir(path: PathLike, options?: RmDirOptions): Promise<void>;
|
542 |
+
/**
|
543 |
+
* Removes files and directories (modeled on the standard POSIX `rm` utility).
|
544 |
+
* @since v14.14.0
|
545 |
+
* @return Fulfills with `undefined` upon success.
|
546 |
+
*/
|
547 |
+
function rm(path: PathLike, options?: RmOptions): Promise<void>;
|
548 |
+
/**
|
549 |
+
* Asynchronously creates a directory.
|
550 |
+
*
|
551 |
+
* The optional `options` argument can be an integer specifying `mode` (permission
|
552 |
+
* and sticky bits), or an object with a `mode` property and a `recursive`property indicating whether parent directories should be created. Calling`fsPromises.mkdir()` when `path` is a directory
|
553 |
+
* that exists results in a
|
554 |
+
* rejection only when `recursive` is false.
|
555 |
+
* @since v10.0.0
|
556 |
+
* @return Upon success, fulfills with `undefined` if `recursive` is `false`, or the first directory path created if `recursive` is `true`.
|
557 |
+
*/
|
558 |
+
function mkdir(
|
559 |
+
path: PathLike,
|
560 |
+
options: MakeDirectoryOptions & {
|
561 |
+
recursive: true;
|
562 |
+
}
|
563 |
+
): Promise<string | undefined>;
|
564 |
+
/**
|
565 |
+
* Asynchronous mkdir(2) - create a directory.
|
566 |
+
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
567 |
+
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
|
568 |
+
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
|
569 |
+
*/
|
570 |
+
function mkdir(
|
571 |
+
path: PathLike,
|
572 |
+
options?:
|
573 |
+
| Mode
|
574 |
+
| (MakeDirectoryOptions & {
|
575 |
+
recursive?: false | undefined;
|
576 |
+
})
|
577 |
+
| null
|
578 |
+
): Promise<void>;
|
579 |
+
/**
|
580 |
+
* Asynchronous mkdir(2) - create a directory.
|
581 |
+
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
582 |
+
* @param options Either the file mode, or an object optionally specifying the file mode and whether parent folders
|
583 |
+
* should be created. If a string is passed, it is parsed as an octal integer. If not specified, defaults to `0o777`.
|
584 |
+
*/
|
585 |
+
function mkdir(path: PathLike, options?: Mode | MakeDirectoryOptions | null): Promise<string | undefined>;
|
586 |
+
/**
|
587 |
+
* Reads the contents of a directory.
|
588 |
+
*
|
589 |
+
* The optional `options` argument can be a string specifying an encoding, or an
|
590 |
+
* object with an `encoding` property specifying the character encoding to use for
|
591 |
+
* the filenames. If the `encoding` is set to `'buffer'`, the filenames returned
|
592 |
+
* will be passed as `Buffer` objects.
|
593 |
+
*
|
594 |
+
* If `options.withFileTypes` is set to `true`, the resolved array will contain `fs.Dirent` objects.
|
595 |
+
*
|
596 |
+
* ```js
|
597 |
+
* import { readdir } from 'fs/promises';
|
598 |
+
*
|
599 |
+
* try {
|
600 |
+
* const files = await readdir(path);
|
601 |
+
* for (const file of files)
|
602 |
+
* console.log(file);
|
603 |
+
* } catch (err) {
|
604 |
+
* console.error(err);
|
605 |
+
* }
|
606 |
+
* ```
|
607 |
+
* @since v10.0.0
|
608 |
+
* @return Fulfills with an array of the names of the files in the directory excluding `'.'` and `'..'`.
|
609 |
+
*/
|
610 |
+
function readdir(
|
611 |
+
path: PathLike,
|
612 |
+
options?:
|
613 |
+
| (ObjectEncodingOptions & {
|
614 |
+
withFileTypes?: false | undefined;
|
615 |
+
})
|
616 |
+
| BufferEncoding
|
617 |
+
| null
|
618 |
+
): Promise<string[]>;
|
619 |
+
/**
|
620 |
+
* Asynchronous readdir(3) - read a directory.
|
621 |
+
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
622 |
+
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
623 |
+
*/
|
624 |
+
function readdir(
|
625 |
+
path: PathLike,
|
626 |
+
options:
|
627 |
+
| {
|
628 |
+
encoding: 'buffer';
|
629 |
+
withFileTypes?: false | undefined;
|
630 |
+
}
|
631 |
+
| 'buffer'
|
632 |
+
): Promise<Buffer[]>;
|
633 |
+
/**
|
634 |
+
* Asynchronous readdir(3) - read a directory.
|
635 |
+
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
636 |
+
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
637 |
+
*/
|
638 |
+
function readdir(
|
639 |
+
path: PathLike,
|
640 |
+
options?:
|
641 |
+
| (ObjectEncodingOptions & {
|
642 |
+
withFileTypes?: false | undefined;
|
643 |
+
})
|
644 |
+
| BufferEncoding
|
645 |
+
| null
|
646 |
+
): Promise<string[] | Buffer[]>;
|
647 |
+
/**
|
648 |
+
* Asynchronous readdir(3) - read a directory.
|
649 |
+
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
650 |
+
* @param options If called with `withFileTypes: true` the result data will be an array of Dirent.
|
651 |
+
*/
|
652 |
+
function readdir(
|
653 |
+
path: PathLike,
|
654 |
+
options: ObjectEncodingOptions & {
|
655 |
+
withFileTypes: true;
|
656 |
+
}
|
657 |
+
): Promise<Dirent[]>;
|
658 |
+
/**
|
659 |
+
* Reads the contents of the symbolic link referred to by `path`. See the POSIX [`readlink(2)`](http://man7.org/linux/man-pages/man2/readlink.2.html) documentation for more detail. The promise is
|
660 |
+
* resolved with the`linkString` upon success.
|
661 |
+
*
|
662 |
+
* The optional `options` argument can be a string specifying an encoding, or an
|
663 |
+
* object with an `encoding` property specifying the character encoding to use for
|
664 |
+
* the link path returned. If the `encoding` is set to `'buffer'`, the link path
|
665 |
+
* returned will be passed as a `Buffer` object.
|
666 |
+
* @since v10.0.0
|
667 |
+
* @return Fulfills with the `linkString` upon success.
|
668 |
+
*/
|
669 |
+
function readlink(path: PathLike, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string>;
|
670 |
+
/**
|
671 |
+
* Asynchronous readlink(2) - read value of a symbolic link.
|
672 |
+
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
673 |
+
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
674 |
+
*/
|
675 |
+
function readlink(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;
|
676 |
+
/**
|
677 |
+
* Asynchronous readlink(2) - read value of a symbolic link.
|
678 |
+
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
679 |
+
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
680 |
+
*/
|
681 |
+
function readlink(path: PathLike, options?: ObjectEncodingOptions | string | null): Promise<string | Buffer>;
|
682 |
+
/**
|
683 |
+
* Creates a symbolic link.
|
684 |
+
*
|
685 |
+
* The `type` argument is only used on Windows platforms and can be one of `'dir'`,`'file'`, or `'junction'`. Windows junction points require the destination path
|
686 |
+
* to be absolute. When using `'junction'`, the `target` argument will
|
687 |
+
* automatically be normalized to absolute path.
|
688 |
+
* @since v10.0.0
|
689 |
+
* @param [type='file']
|
690 |
+
* @return Fulfills with `undefined` upon success.
|
691 |
+
*/
|
692 |
+
function symlink(target: PathLike, path: PathLike, type?: string | null): Promise<void>;
|
693 |
+
/**
|
694 |
+
* Equivalent to `fsPromises.stat()` unless `path` refers to a symbolic link,
|
695 |
+
* in which case the link itself is stat-ed, not the file that it refers to.
|
696 |
+
* Refer to the POSIX [`lstat(2)`](http://man7.org/linux/man-pages/man2/lstat.2.html) document for more detail.
|
697 |
+
* @since v10.0.0
|
698 |
+
* @return Fulfills with the {fs.Stats} object for the given symbolic link `path`.
|
699 |
+
*/
|
700 |
+
function lstat(
|
701 |
+
path: PathLike,
|
702 |
+
opts?: StatOptions & {
|
703 |
+
bigint?: false | undefined;
|
704 |
+
}
|
705 |
+
): Promise<Stats>;
|
706 |
+
function lstat(
|
707 |
+
path: PathLike,
|
708 |
+
opts: StatOptions & {
|
709 |
+
bigint: true;
|
710 |
+
}
|
711 |
+
): Promise<BigIntStats>;
|
712 |
+
function lstat(path: PathLike, opts?: StatOptions): Promise<Stats | BigIntStats>;
|
713 |
+
/**
|
714 |
+
* @since v10.0.0
|
715 |
+
* @return Fulfills with the {fs.Stats} object for the given `path`.
|
716 |
+
*/
|
717 |
+
function stat(
|
718 |
+
path: PathLike,
|
719 |
+
opts?: StatOptions & {
|
720 |
+
bigint?: false | undefined;
|
721 |
+
}
|
722 |
+
): Promise<Stats>;
|
723 |
+
function stat(
|
724 |
+
path: PathLike,
|
725 |
+
opts: StatOptions & {
|
726 |
+
bigint: true;
|
727 |
+
}
|
728 |
+
): Promise<BigIntStats>;
|
729 |
+
function stat(path: PathLike, opts?: StatOptions): Promise<Stats | BigIntStats>;
|
730 |
+
/**
|
731 |
+
* Creates a new link from the `existingPath` to the `newPath`. See the POSIX [`link(2)`](http://man7.org/linux/man-pages/man2/link.2.html) documentation for more detail.
|
732 |
+
* @since v10.0.0
|
733 |
+
* @return Fulfills with `undefined` upon success.
|
734 |
+
*/
|
735 |
+
function link(existingPath: PathLike, newPath: PathLike): Promise<void>;
|
736 |
+
/**
|
737 |
+
* If `path` refers to a symbolic link, then the link is removed without affecting
|
738 |
+
* the file or directory to which that link refers. If the `path` refers to a file
|
739 |
+
* path that is not a symbolic link, the file is deleted. See the POSIX [`unlink(2)`](http://man7.org/linux/man-pages/man2/unlink.2.html) documentation for more detail.
|
740 |
+
* @since v10.0.0
|
741 |
+
* @return Fulfills with `undefined` upon success.
|
742 |
+
*/
|
743 |
+
function unlink(path: PathLike): Promise<void>;
|
744 |
+
/**
|
745 |
+
* Changes the permissions of a file.
|
746 |
+
* @since v10.0.0
|
747 |
+
* @return Fulfills with `undefined` upon success.
|
748 |
+
*/
|
749 |
+
function chmod(path: PathLike, mode: Mode): Promise<void>;
|
750 |
+
/**
|
751 |
+
* Changes the permissions on a symbolic link.
|
752 |
+
*
|
753 |
+
* This method is only implemented on macOS.
|
754 |
+
* @deprecated Since v10.0.0
|
755 |
+
* @return Fulfills with `undefined` upon success.
|
756 |
+
*/
|
757 |
+
function lchmod(path: PathLike, mode: Mode): Promise<void>;
|
758 |
+
/**
|
759 |
+
* Changes the ownership on a symbolic link.
|
760 |
+
* @since v10.0.0
|
761 |
+
* @return Fulfills with `undefined` upon success.
|
762 |
+
*/
|
763 |
+
function lchown(path: PathLike, uid: number, gid: number): Promise<void>;
|
764 |
+
/**
|
765 |
+
* Changes the access and modification times of a file in the same way as `fsPromises.utimes()`, with the difference that if the path refers to a
|
766 |
+
* symbolic link, then the link is not dereferenced: instead, the timestamps of
|
767 |
+
* the symbolic link itself are changed.
|
768 |
+
* @since v14.5.0, v12.19.0
|
769 |
+
* @return Fulfills with `undefined` upon success.
|
770 |
+
*/
|
771 |
+
function lutimes(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise<void>;
|
772 |
+
/**
|
773 |
+
* Changes the ownership of a file.
|
774 |
+
* @since v10.0.0
|
775 |
+
* @return Fulfills with `undefined` upon success.
|
776 |
+
*/
|
777 |
+
function chown(path: PathLike, uid: number, gid: number): Promise<void>;
|
778 |
+
/**
|
779 |
+
* Change the file system timestamps of the object referenced by `path`.
|
780 |
+
*
|
781 |
+
* The `atime` and `mtime` arguments follow these rules:
|
782 |
+
*
|
783 |
+
* * Values can be either numbers representing Unix epoch time, `Date`s, or a
|
784 |
+
* numeric string like `'123456789.0'`.
|
785 |
+
* * If the value can not be converted to a number, or is `NaN`, `Infinity` or`-Infinity`, an `Error` will be thrown.
|
786 |
+
* @since v10.0.0
|
787 |
+
* @return Fulfills with `undefined` upon success.
|
788 |
+
*/
|
789 |
+
function utimes(path: PathLike, atime: TimeLike, mtime: TimeLike): Promise<void>;
|
790 |
+
/**
|
791 |
+
* Determines the actual location of `path` using the same semantics as the`fs.realpath.native()` function.
|
792 |
+
*
|
793 |
+
* Only paths that can be converted to UTF8 strings are supported.
|
794 |
+
*
|
795 |
+
* The optional `options` argument can be a string specifying an encoding, or an
|
796 |
+
* object with an `encoding` property specifying the character encoding to use for
|
797 |
+
* the path. If the `encoding` is set to `'buffer'`, the path returned will be
|
798 |
+
* passed as a `Buffer` object.
|
799 |
+
*
|
800 |
+
* On Linux, when Node.js is linked against musl libc, the procfs file system must
|
801 |
+
* be mounted on `/proc` in order for this function to work. Glibc does not have
|
802 |
+
* this restriction.
|
803 |
+
* @since v10.0.0
|
804 |
+
* @return Fulfills with the resolved path upon success.
|
805 |
+
*/
|
806 |
+
function realpath(path: PathLike, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string>;
|
807 |
+
/**
|
808 |
+
* Asynchronous realpath(3) - return the canonicalized absolute pathname.
|
809 |
+
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
810 |
+
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
811 |
+
*/
|
812 |
+
function realpath(path: PathLike, options: BufferEncodingOption): Promise<Buffer>;
|
813 |
+
/**
|
814 |
+
* Asynchronous realpath(3) - return the canonicalized absolute pathname.
|
815 |
+
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
816 |
+
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
817 |
+
*/
|
818 |
+
function realpath(path: PathLike, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string | Buffer>;
|
819 |
+
/**
|
820 |
+
* Creates a unique temporary directory. A unique directory name is generated by
|
821 |
+
* appending six random characters to the end of the provided `prefix`. Due to
|
822 |
+
* platform inconsistencies, avoid trailing `X` characters in `prefix`. Some
|
823 |
+
* platforms, notably the BSDs, can return more than six random characters, and
|
824 |
+
* replace trailing `X` characters in `prefix` with random characters.
|
825 |
+
*
|
826 |
+
* The optional `options` argument can be a string specifying an encoding, or an
|
827 |
+
* object with an `encoding` property specifying the character encoding to use.
|
828 |
+
*
|
829 |
+
* ```js
|
830 |
+
* import { mkdtemp } from 'fs/promises';
|
831 |
+
*
|
832 |
+
* try {
|
833 |
+
* await mkdtemp(path.join(os.tmpdir(), 'foo-'));
|
834 |
+
* } catch (err) {
|
835 |
+
* console.error(err);
|
836 |
+
* }
|
837 |
+
* ```
|
838 |
+
*
|
839 |
+
* The `fsPromises.mkdtemp()` method will append the six randomly selected
|
840 |
+
* characters directly to the `prefix` string. For instance, given a directory`/tmp`, if the intention is to create a temporary directory _within_`/tmp`, the`prefix` must end with a trailing
|
841 |
+
* platform-specific path separator
|
842 |
+
* (`require('path').sep`).
|
843 |
+
* @since v10.0.0
|
844 |
+
* @return Fulfills with a string containing the filesystem path of the newly created temporary directory.
|
845 |
+
*/
|
846 |
+
function mkdtemp(prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string>;
|
847 |
+
/**
|
848 |
+
* Asynchronously creates a unique temporary directory.
|
849 |
+
* Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
|
850 |
+
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
851 |
+
*/
|
852 |
+
function mkdtemp(prefix: string, options: BufferEncodingOption): Promise<Buffer>;
|
853 |
+
/**
|
854 |
+
* Asynchronously creates a unique temporary directory.
|
855 |
+
* Generates six random characters to be appended behind a required `prefix` to create a unique temporary directory.
|
856 |
+
* @param options The encoding (or an object specifying the encoding), used as the encoding of the result. If not provided, `'utf8'` is used.
|
857 |
+
*/
|
858 |
+
function mkdtemp(prefix: string, options?: ObjectEncodingOptions | BufferEncoding | null): Promise<string | Buffer>;
|
859 |
+
/**
|
860 |
+
* Asynchronously writes data to a file, replacing the file if it already exists.`data` can be a string, a buffer, an
|
861 |
+
* [AsyncIterable](https://tc39.github.io/ecma262/#sec-asynciterable-interface) or
|
862 |
+
* [Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#The_iterable_protocol) object.
|
863 |
+
*
|
864 |
+
* The `encoding` option is ignored if `data` is a buffer.
|
865 |
+
*
|
866 |
+
* If `options` is a string, then it specifies the encoding.
|
867 |
+
*
|
868 |
+
* The `mode` option only affects the newly created file. See `fs.open()` for more details.
|
869 |
+
*
|
870 |
+
* Any specified `FileHandle` has to support writing.
|
871 |
+
*
|
872 |
+
* It is unsafe to use `fsPromises.writeFile()` multiple times on the same file
|
873 |
+
* without waiting for the promise to be settled.
|
874 |
+
*
|
875 |
+
* Similarly to `fsPromises.readFile` \- `fsPromises.writeFile` is a convenience
|
876 |
+
* method that performs multiple `write` calls internally to write the buffer
|
877 |
+
* passed to it. For performance sensitive code consider using `fs.createWriteStream()` or `filehandle.createWriteStream()`.
|
878 |
+
*
|
879 |
+
* It is possible to use an `AbortSignal` to cancel an `fsPromises.writeFile()`.
|
880 |
+
* Cancelation is "best effort", and some amount of data is likely still
|
881 |
+
* to be written.
|
882 |
+
*
|
883 |
+
* ```js
|
884 |
+
* import { writeFile } from 'fs/promises';
|
885 |
+
* import { Buffer } from 'buffer';
|
886 |
+
*
|
887 |
+
* try {
|
888 |
+
* const controller = new AbortController();
|
889 |
+
* const { signal } = controller;
|
890 |
+
* const data = new Uint8Array(Buffer.from('Hello Node.js'));
|
891 |
+
* const promise = writeFile('message.txt', data, { signal });
|
892 |
+
*
|
893 |
+
* // Abort the request before the promise settles.
|
894 |
+
* controller.abort();
|
895 |
+
*
|
896 |
+
* await promise;
|
897 |
+
* } catch (err) {
|
898 |
+
* // When a request is aborted - err is an AbortError
|
899 |
+
* console.error(err);
|
900 |
+
* }
|
901 |
+
* ```
|
902 |
+
*
|
903 |
+
* Aborting an ongoing request does not abort individual operating
|
904 |
+
* system requests but rather the internal buffering `fs.writeFile` performs.
|
905 |
+
* @since v10.0.0
|
906 |
+
* @param file filename or `FileHandle`
|
907 |
+
* @return Fulfills with `undefined` upon success.
|
908 |
+
*/
|
909 |
+
function writeFile(
|
910 |
+
file: PathLike | FileHandle,
|
911 |
+
data: string | NodeJS.ArrayBufferView | Iterable<string | NodeJS.ArrayBufferView> | AsyncIterable<string | NodeJS.ArrayBufferView> | Stream,
|
912 |
+
options?:
|
913 |
+
| (ObjectEncodingOptions & {
|
914 |
+
mode?: Mode | undefined;
|
915 |
+
flag?: OpenMode | undefined;
|
916 |
+
} & Abortable)
|
917 |
+
| BufferEncoding
|
918 |
+
| null
|
919 |
+
): Promise<void>;
|
920 |
+
/**
|
921 |
+
* Asynchronously append data to a file, creating the file if it does not yet
|
922 |
+
* exist. `data` can be a string or a `Buffer`.
|
923 |
+
*
|
924 |
+
* If `options` is a string, then it specifies the `encoding`.
|
925 |
+
*
|
926 |
+
* The `mode` option only affects the newly created file. See `fs.open()` for more details.
|
927 |
+
*
|
928 |
+
* The `path` may be specified as a `FileHandle` that has been opened
|
929 |
+
* for appending (using `fsPromises.open()`).
|
930 |
+
* @since v10.0.0
|
931 |
+
* @param path filename or {FileHandle}
|
932 |
+
* @return Fulfills with `undefined` upon success.
|
933 |
+
*/
|
934 |
+
function appendFile(path: PathLike | FileHandle, data: string | Uint8Array, options?: (ObjectEncodingOptions & FlagAndOpenMode) | BufferEncoding | null): Promise<void>;
|
935 |
+
/**
|
936 |
+
* Asynchronously reads the entire contents of a file.
|
937 |
+
*
|
938 |
+
* If no encoding is specified (using `options.encoding`), the data is returned
|
939 |
+
* as a `Buffer` object. Otherwise, the data will be a string.
|
940 |
+
*
|
941 |
+
* If `options` is a string, then it specifies the encoding.
|
942 |
+
*
|
943 |
+
* When the `path` is a directory, the behavior of `fsPromises.readFile()` is
|
944 |
+
* platform-specific. On macOS, Linux, and Windows, the promise will be rejected
|
945 |
+
* with an error. On FreeBSD, a representation of the directory's contents will be
|
946 |
+
* returned.
|
947 |
+
*
|
948 |
+
* It is possible to abort an ongoing `readFile` using an `AbortSignal`. If a
|
949 |
+
* request is aborted the promise returned is rejected with an `AbortError`:
|
950 |
+
*
|
951 |
+
* ```js
|
952 |
+
* import { readFile } from 'fs/promises';
|
953 |
+
*
|
954 |
+
* try {
|
955 |
+
* const controller = new AbortController();
|
956 |
+
* const { signal } = controller;
|
957 |
+
* const promise = readFile(fileName, { signal });
|
958 |
+
*
|
959 |
+
* // Abort the request before the promise settles.
|
960 |
+
* controller.abort();
|
961 |
+
*
|
962 |
+
* await promise;
|
963 |
+
* } catch (err) {
|
964 |
+
* // When a request is aborted - err is an AbortError
|
965 |
+
* console.error(err);
|
966 |
+
* }
|
967 |
+
* ```
|
968 |
+
*
|
969 |
+
* Aborting an ongoing request does not abort individual operating
|
970 |
+
* system requests but rather the internal buffering `fs.readFile` performs.
|
971 |
+
*
|
972 |
+
* Any specified `FileHandle` has to support reading.
|
973 |
+
* @since v10.0.0
|
974 |
+
* @param path filename or `FileHandle`
|
975 |
+
* @return Fulfills with the contents of the file.
|
976 |
+
*/
|
977 |
+
function readFile(
|
978 |
+
path: PathLike | FileHandle,
|
979 |
+
options?:
|
980 |
+
| ({
|
981 |
+
encoding?: null | undefined;
|
982 |
+
flag?: OpenMode | undefined;
|
983 |
+
} & Abortable)
|
984 |
+
| null
|
985 |
+
): Promise<Buffer>;
|
986 |
+
/**
|
987 |
+
* Asynchronously reads the entire contents of a file.
|
988 |
+
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
989 |
+
* If a `FileHandle` is provided, the underlying file will _not_ be closed automatically.
|
990 |
+
* @param options An object that may contain an optional flag.
|
991 |
+
* If a flag is not provided, it defaults to `'r'`.
|
992 |
+
*/
|
993 |
+
function readFile(
|
994 |
+
path: PathLike | FileHandle,
|
995 |
+
options:
|
996 |
+
| ({
|
997 |
+
encoding: BufferEncoding;
|
998 |
+
flag?: OpenMode | undefined;
|
999 |
+
} & Abortable)
|
1000 |
+
| BufferEncoding
|
1001 |
+
): Promise<string>;
|
1002 |
+
/**
|
1003 |
+
* Asynchronously reads the entire contents of a file.
|
1004 |
+
* @param path A path to a file. If a URL is provided, it must use the `file:` protocol.
|
1005 |
+
* If a `FileHandle` is provided, the underlying file will _not_ be closed automatically.
|
1006 |
+
* @param options An object that may contain an optional flag.
|
1007 |
+
* If a flag is not provided, it defaults to `'r'`.
|
1008 |
+
*/
|
1009 |
+
function readFile(
|
1010 |
+
path: PathLike | FileHandle,
|
1011 |
+
options?:
|
1012 |
+
| (ObjectEncodingOptions &
|
1013 |
+
Abortable & {
|
1014 |
+
flag?: OpenMode | undefined;
|
1015 |
+
})
|
1016 |
+
| BufferEncoding
|
1017 |
+
| null
|
1018 |
+
): Promise<string | Buffer>;
|
1019 |
+
/**
|
1020 |
+
* Asynchronously open a directory for iterative scanning. See the POSIX [`opendir(3)`](http://man7.org/linux/man-pages/man3/opendir.3.html) documentation for more detail.
|
1021 |
+
*
|
1022 |
+
* Creates an `fs.Dir`, which contains all further functions for reading from
|
1023 |
+
* and cleaning up the directory.
|
1024 |
+
*
|
1025 |
+
* The `encoding` option sets the encoding for the `path` while opening the
|
1026 |
+
* directory and subsequent read operations.
|
1027 |
+
*
|
1028 |
+
* Example using async iteration:
|
1029 |
+
*
|
1030 |
+
* ```js
|
1031 |
+
* import { opendir } from 'fs/promises';
|
1032 |
+
*
|
1033 |
+
* try {
|
1034 |
+
* const dir = await opendir('./');
|
1035 |
+
* for await (const dirent of dir)
|
1036 |
+
* console.log(dirent.name);
|
1037 |
+
* } catch (err) {
|
1038 |
+
* console.error(err);
|
1039 |
+
* }
|
1040 |
+
* ```
|
1041 |
+
*
|
1042 |
+
* When using the async iterator, the `fs.Dir` object will be automatically
|
1043 |
+
* closed after the iterator exits.
|
1044 |
+
* @since v12.12.0
|
1045 |
+
* @return Fulfills with an {fs.Dir}.
|
1046 |
+
*/
|
1047 |
+
function opendir(path: PathLike, options?: OpenDirOptions): Promise<Dir>;
|
1048 |
+
/**
|
1049 |
+
* Returns an async iterator that watches for changes on `filename`, where `filename`is either a file or a directory.
|
1050 |
+
*
|
1051 |
+
* ```js
|
1052 |
+
* const { watch } = require('fs/promises');
|
1053 |
+
*
|
1054 |
+
* const ac = new AbortController();
|
1055 |
+
* const { signal } = ac;
|
1056 |
+
* setTimeout(() => ac.abort(), 10000);
|
1057 |
+
*
|
1058 |
+
* (async () => {
|
1059 |
+
* try {
|
1060 |
+
* const watcher = watch(__filename, { signal });
|
1061 |
+
* for await (const event of watcher)
|
1062 |
+
* console.log(event);
|
1063 |
+
* } catch (err) {
|
1064 |
+
* if (err.name === 'AbortError')
|
1065 |
+
* return;
|
1066 |
+
* throw err;
|
1067 |
+
* }
|
1068 |
+
* })();
|
1069 |
+
* ```
|
1070 |
+
*
|
1071 |
+
* On most platforms, `'rename'` is emitted whenever a filename appears or
|
1072 |
+
* disappears in the directory.
|
1073 |
+
*
|
1074 |
+
* All the `caveats` for `fs.watch()` also apply to `fsPromises.watch()`.
|
1075 |
+
* @since v15.9.0, v14.18.0
|
1076 |
+
* @return of objects with the properties:
|
1077 |
+
*/
|
1078 |
+
function watch(
|
1079 |
+
filename: PathLike,
|
1080 |
+
options:
|
1081 |
+
| (WatchOptions & {
|
1082 |
+
encoding: 'buffer';
|
1083 |
+
})
|
1084 |
+
| 'buffer'
|
1085 |
+
): AsyncIterable<FileChangeInfo<Buffer>>;
|
1086 |
+
/**
|
1087 |
+
* Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
|
1088 |
+
* @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
|
1089 |
+
* @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
|
1090 |
+
* If `encoding` is not supplied, the default of `'utf8'` is used.
|
1091 |
+
* If `persistent` is not supplied, the default of `true` is used.
|
1092 |
+
* If `recursive` is not supplied, the default of `false` is used.
|
1093 |
+
*/
|
1094 |
+
function watch(filename: PathLike, options?: WatchOptions | BufferEncoding): AsyncIterable<FileChangeInfo<string>>;
|
1095 |
+
/**
|
1096 |
+
* Watch for changes on `filename`, where `filename` is either a file or a directory, returning an `FSWatcher`.
|
1097 |
+
* @param filename A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
|
1098 |
+
* @param options Either the encoding for the filename provided to the listener, or an object optionally specifying encoding, persistent, and recursive options.
|
1099 |
+
* If `encoding` is not supplied, the default of `'utf8'` is used.
|
1100 |
+
* If `persistent` is not supplied, the default of `true` is used.
|
1101 |
+
* If `recursive` is not supplied, the default of `false` is used.
|
1102 |
+
*/
|
1103 |
+
function watch(filename: PathLike, options: WatchOptions | string): AsyncIterable<FileChangeInfo<string>> | AsyncIterable<FileChangeInfo<Buffer>>;
|
1104 |
+
/**
|
1105 |
+
* Asynchronously copies the entire directory structure from `src` to `dest`,
|
1106 |
+
* including subdirectories and files.
|
1107 |
+
*
|
1108 |
+
* When copying a directory to another directory, globs are not supported and
|
1109 |
+
* behavior is similar to `cp dir1/ dir2/`.
|
1110 |
+
* @since v16.7.0
|
1111 |
+
* @experimental
|
1112 |
+
* @param src source path to copy.
|
1113 |
+
* @param dest destination path to copy to.
|
1114 |
+
* @return Fulfills with `undefined` upon success.
|
1115 |
+
*/
|
1116 |
+
function cp(source: string | URL, destination: string | URL, opts?: CopyOptions): Promise<void>;
|
1117 |
+
}
|
1118 |
+
declare module 'node:fs/promises' {
|
1119 |
+
export * from 'fs/promises';
|
1120 |
+
}
|
igv_component/node_modules/@types/node/globals.d.ts
ADDED
@@ -0,0 +1,296 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// Declare "static" methods in Error
|
2 |
+
interface ErrorConstructor {
|
3 |
+
/** Create .stack property on a target object */
|
4 |
+
captureStackTrace(targetObject: object, constructorOpt?: Function): void;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Optional override for formatting stack traces
|
8 |
+
*
|
9 |
+
* @see https://v8.dev/docs/stack-trace-api#customizing-stack-traces
|
10 |
+
*/
|
11 |
+
prepareStackTrace?: ((err: Error, stackTraces: NodeJS.CallSite[]) => any) | undefined;
|
12 |
+
|
13 |
+
stackTraceLimit: number;
|
14 |
+
}
|
15 |
+
|
16 |
+
/*-----------------------------------------------*
|
17 |
+
* *
|
18 |
+
* GLOBAL *
|
19 |
+
* *
|
20 |
+
------------------------------------------------*/
|
21 |
+
|
22 |
+
// For backwards compability
|
23 |
+
interface NodeRequire extends NodeJS.Require { }
|
24 |
+
interface RequireResolve extends NodeJS.RequireResolve { }
|
25 |
+
interface NodeModule extends NodeJS.Module { }
|
26 |
+
|
27 |
+
declare var process: NodeJS.Process;
|
28 |
+
declare var console: Console;
|
29 |
+
|
30 |
+
declare var __filename: string;
|
31 |
+
declare var __dirname: string;
|
32 |
+
|
33 |
+
declare var require: NodeRequire;
|
34 |
+
declare var module: NodeModule;
|
35 |
+
|
36 |
+
// Same as module.exports
|
37 |
+
declare var exports: any;
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Only available if `--expose-gc` is passed to the process.
|
41 |
+
*/
|
42 |
+
declare var gc: undefined | (() => void);
|
43 |
+
|
44 |
+
//#region borrowed
|
45 |
+
// from https://github.com/microsoft/TypeScript/blob/38da7c600c83e7b31193a62495239a0fe478cb67/lib/lib.webworker.d.ts#L633 until moved to separate lib
|
46 |
+
/** A controller object that allows you to abort one or more DOM requests as and when desired. */
|
47 |
+
interface AbortController {
|
48 |
+
/**
|
49 |
+
* Returns the AbortSignal object associated with this object.
|
50 |
+
*/
|
51 |
+
|
52 |
+
readonly signal: AbortSignal;
|
53 |
+
/**
|
54 |
+
* Invoking this method will set this object's AbortSignal's aborted flag and signal to any observers that the associated activity is to be aborted.
|
55 |
+
*/
|
56 |
+
abort(): void;
|
57 |
+
}
|
58 |
+
|
59 |
+
/** A signal object that allows you to communicate with a DOM request (such as a Fetch) and abort it if required via an AbortController object. */
|
60 |
+
interface AbortSignal {
|
61 |
+
/**
|
62 |
+
* Returns true if this AbortSignal's AbortController has signaled to abort, and false otherwise.
|
63 |
+
*/
|
64 |
+
readonly aborted: boolean;
|
65 |
+
}
|
66 |
+
|
67 |
+
declare var AbortController: {
|
68 |
+
prototype: AbortController;
|
69 |
+
new(): AbortController;
|
70 |
+
};
|
71 |
+
|
72 |
+
declare var AbortSignal: {
|
73 |
+
prototype: AbortSignal;
|
74 |
+
new(): AbortSignal;
|
75 |
+
// TODO: Add abort() static
|
76 |
+
timeout(milliseconds: number): AbortSignal;
|
77 |
+
};
|
78 |
+
//#endregion borrowed
|
79 |
+
|
80 |
+
//#region ArrayLike.at()
|
81 |
+
interface RelativeIndexable<T> {
|
82 |
+
/**
|
83 |
+
* Takes an integer value and returns the item at that index,
|
84 |
+
* allowing for positive and negative integers.
|
85 |
+
* Negative integers count back from the last item in the array.
|
86 |
+
*/
|
87 |
+
at(index: number): T | undefined;
|
88 |
+
}
|
89 |
+
interface String extends RelativeIndexable<string> {}
|
90 |
+
interface Array<T> extends RelativeIndexable<T> {}
|
91 |
+
interface ReadonlyArray<T> extends RelativeIndexable<T> {}
|
92 |
+
interface Int8Array extends RelativeIndexable<number> {}
|
93 |
+
interface Uint8Array extends RelativeIndexable<number> {}
|
94 |
+
interface Uint8ClampedArray extends RelativeIndexable<number> {}
|
95 |
+
interface Int16Array extends RelativeIndexable<number> {}
|
96 |
+
interface Uint16Array extends RelativeIndexable<number> {}
|
97 |
+
interface Int32Array extends RelativeIndexable<number> {}
|
98 |
+
interface Uint32Array extends RelativeIndexable<number> {}
|
99 |
+
interface Float32Array extends RelativeIndexable<number> {}
|
100 |
+
interface Float64Array extends RelativeIndexable<number> {}
|
101 |
+
interface BigInt64Array extends RelativeIndexable<bigint> {}
|
102 |
+
interface BigUint64Array extends RelativeIndexable<bigint> {}
|
103 |
+
//#endregion ArrayLike.at() end
|
104 |
+
|
105 |
+
/**
|
106 |
+
* @since v17.0.0
|
107 |
+
*
|
108 |
+
* Creates a deep clone of an object.
|
109 |
+
*/
|
110 |
+
declare function structuredClone<T>(
|
111 |
+
value: T,
|
112 |
+
transfer?: { transfer: ReadonlyArray<import('worker_threads').TransferListItem> },
|
113 |
+
): T;
|
114 |
+
|
115 |
+
/*----------------------------------------------*
|
116 |
+
* *
|
117 |
+
* GLOBAL INTERFACES *
|
118 |
+
* *
|
119 |
+
*-----------------------------------------------*/
|
120 |
+
declare namespace NodeJS {
|
121 |
+
interface CallSite {
|
122 |
+
/**
|
123 |
+
* Value of "this"
|
124 |
+
*/
|
125 |
+
getThis(): unknown;
|
126 |
+
|
127 |
+
/**
|
128 |
+
* Type of "this" as a string.
|
129 |
+
* This is the name of the function stored in the constructor field of
|
130 |
+
* "this", if available. Otherwise the object's [[Class]] internal
|
131 |
+
* property.
|
132 |
+
*/
|
133 |
+
getTypeName(): string | null;
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Current function
|
137 |
+
*/
|
138 |
+
getFunction(): Function | undefined;
|
139 |
+
|
140 |
+
/**
|
141 |
+
* Name of the current function, typically its name property.
|
142 |
+
* If a name property is not available an attempt will be made to try
|
143 |
+
* to infer a name from the function's context.
|
144 |
+
*/
|
145 |
+
getFunctionName(): string | null;
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Name of the property [of "this" or one of its prototypes] that holds
|
149 |
+
* the current function
|
150 |
+
*/
|
151 |
+
getMethodName(): string | null;
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Name of the script [if this function was defined in a script]
|
155 |
+
*/
|
156 |
+
getFileName(): string | null;
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Current line number [if this function was defined in a script]
|
160 |
+
*/
|
161 |
+
getLineNumber(): number | null;
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Current column number [if this function was defined in a script]
|
165 |
+
*/
|
166 |
+
getColumnNumber(): number | null;
|
167 |
+
|
168 |
+
/**
|
169 |
+
* A call site object representing the location where eval was called
|
170 |
+
* [if this function was created using a call to eval]
|
171 |
+
*/
|
172 |
+
getEvalOrigin(): string | undefined;
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Is this a toplevel invocation, that is, is "this" the global object?
|
176 |
+
*/
|
177 |
+
isToplevel(): boolean;
|
178 |
+
|
179 |
+
/**
|
180 |
+
* Does this call take place in code defined by a call to eval?
|
181 |
+
*/
|
182 |
+
isEval(): boolean;
|
183 |
+
|
184 |
+
/**
|
185 |
+
* Is this call in native V8 code?
|
186 |
+
*/
|
187 |
+
isNative(): boolean;
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Is this a constructor call?
|
191 |
+
*/
|
192 |
+
isConstructor(): boolean;
|
193 |
+
}
|
194 |
+
|
195 |
+
interface ErrnoException extends Error {
|
196 |
+
errno?: number | undefined;
|
197 |
+
code?: string | undefined;
|
198 |
+
path?: string | undefined;
|
199 |
+
syscall?: string | undefined;
|
200 |
+
}
|
201 |
+
|
202 |
+
interface ReadableStream extends EventEmitter {
|
203 |
+
readable: boolean;
|
204 |
+
read(size?: number): string | Buffer;
|
205 |
+
setEncoding(encoding: BufferEncoding): this;
|
206 |
+
pause(): this;
|
207 |
+
resume(): this;
|
208 |
+
isPaused(): boolean;
|
209 |
+
pipe<T extends WritableStream>(destination: T, options?: { end?: boolean | undefined; }): T;
|
210 |
+
unpipe(destination?: WritableStream): this;
|
211 |
+
unshift(chunk: string | Uint8Array, encoding?: BufferEncoding): void;
|
212 |
+
wrap(oldStream: ReadableStream): this;
|
213 |
+
[Symbol.asyncIterator](): AsyncIterableIterator<string | Buffer>;
|
214 |
+
}
|
215 |
+
|
216 |
+
interface WritableStream extends EventEmitter {
|
217 |
+
writable: boolean;
|
218 |
+
write(buffer: Uint8Array | string, cb?: (err?: Error | null) => void): boolean;
|
219 |
+
write(str: string, encoding?: BufferEncoding, cb?: (err?: Error | null) => void): boolean;
|
220 |
+
end(cb?: () => void): this;
|
221 |
+
end(data: string | Uint8Array, cb?: () => void): this;
|
222 |
+
end(str: string, encoding?: BufferEncoding, cb?: () => void): this;
|
223 |
+
}
|
224 |
+
|
225 |
+
interface ReadWriteStream extends ReadableStream, WritableStream { }
|
226 |
+
|
227 |
+
interface RefCounted {
|
228 |
+
ref(): this;
|
229 |
+
unref(): this;
|
230 |
+
}
|
231 |
+
|
232 |
+
type TypedArray =
|
233 |
+
| Uint8Array
|
234 |
+
| Uint8ClampedArray
|
235 |
+
| Uint16Array
|
236 |
+
| Uint32Array
|
237 |
+
| Int8Array
|
238 |
+
| Int16Array
|
239 |
+
| Int32Array
|
240 |
+
| BigUint64Array
|
241 |
+
| BigInt64Array
|
242 |
+
| Float32Array
|
243 |
+
| Float64Array;
|
244 |
+
type ArrayBufferView = TypedArray | DataView;
|
245 |
+
|
246 |
+
interface Require {
|
247 |
+
(id: string): any;
|
248 |
+
resolve: RequireResolve;
|
249 |
+
cache: Dict<NodeModule>;
|
250 |
+
/**
|
251 |
+
* @deprecated
|
252 |
+
*/
|
253 |
+
extensions: RequireExtensions;
|
254 |
+
main: Module | undefined;
|
255 |
+
}
|
256 |
+
|
257 |
+
interface RequireResolve {
|
258 |
+
(id: string, options?: { paths?: string[] | undefined; }): string;
|
259 |
+
paths(request: string): string[] | null;
|
260 |
+
}
|
261 |
+
|
262 |
+
interface RequireExtensions extends Dict<(m: Module, filename: string) => any> {
|
263 |
+
'.js': (m: Module, filename: string) => any;
|
264 |
+
'.json': (m: Module, filename: string) => any;
|
265 |
+
'.node': (m: Module, filename: string) => any;
|
266 |
+
}
|
267 |
+
interface Module {
|
268 |
+
/**
|
269 |
+
* `true` if the module is running during the Node.js preload
|
270 |
+
*/
|
271 |
+
isPreloading: boolean;
|
272 |
+
exports: any;
|
273 |
+
require: Require;
|
274 |
+
id: string;
|
275 |
+
filename: string;
|
276 |
+
loaded: boolean;
|
277 |
+
/** @deprecated since v14.6.0 Please use `require.main` and `module.children` instead. */
|
278 |
+
parent: Module | null | undefined;
|
279 |
+
children: Module[];
|
280 |
+
/**
|
281 |
+
* @since v11.14.0
|
282 |
+
*
|
283 |
+
* The directory name of the module. This is usually the same as the path.dirname() of the module.id.
|
284 |
+
*/
|
285 |
+
path: string;
|
286 |
+
paths: string[];
|
287 |
+
}
|
288 |
+
|
289 |
+
interface Dict<T> {
|
290 |
+
[key: string]: T | undefined;
|
291 |
+
}
|
292 |
+
|
293 |
+
interface ReadOnlyDict<T> {
|
294 |
+
readonly [key: string]: T | undefined;
|
295 |
+
}
|
296 |
+
}
|
igv_component/node_modules/@types/node/globals.global.d.ts
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
declare var global: typeof globalThis;
|
igv_component/node_modules/@types/node/http.d.ts
ADDED
@@ -0,0 +1,1553 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* To use the HTTP server and client one must `require('http')`.
|
3 |
+
*
|
4 |
+
* The HTTP interfaces in Node.js are designed to support many features
|
5 |
+
* of the protocol which have been traditionally difficult to use.
|
6 |
+
* In particular, large, possibly chunk-encoded, messages. The interface is
|
7 |
+
* careful to never buffer entire requests or responses, so the
|
8 |
+
* user is able to stream data.
|
9 |
+
*
|
10 |
+
* HTTP message headers are represented by an object like this:
|
11 |
+
*
|
12 |
+
* ```js
|
13 |
+
* { 'content-length': '123',
|
14 |
+
* 'content-type': 'text/plain',
|
15 |
+
* 'connection': 'keep-alive',
|
16 |
+
* 'host': 'example.com',
|
17 |
+
* 'accept': '*' }
|
18 |
+
* ```
|
19 |
+
*
|
20 |
+
* Keys are lowercased. Values are not modified.
|
21 |
+
*
|
22 |
+
* In order to support the full spectrum of possible HTTP applications, the Node.js
|
23 |
+
* HTTP API is very low-level. It deals with stream handling and message
|
24 |
+
* parsing only. It parses a message into headers and body but it does not
|
25 |
+
* parse the actual headers or the body.
|
26 |
+
*
|
27 |
+
* See `message.headers` for details on how duplicate headers are handled.
|
28 |
+
*
|
29 |
+
* The raw headers as they were received are retained in the `rawHeaders`property, which is an array of `[key, value, key2, value2, ...]`. For
|
30 |
+
* example, the previous message header object might have a `rawHeaders`list like the following:
|
31 |
+
*
|
32 |
+
* ```js
|
33 |
+
* [ 'ConTent-Length', '123456',
|
34 |
+
* 'content-LENGTH', '123',
|
35 |
+
* 'content-type', 'text/plain',
|
36 |
+
* 'CONNECTION', 'keep-alive',
|
37 |
+
* 'Host', 'example.com',
|
38 |
+
* 'accepT', '*' ]
|
39 |
+
* ```
|
40 |
+
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/http.js)
|
41 |
+
*/
|
42 |
+
declare module 'http' {
|
43 |
+
import * as stream from 'node:stream';
|
44 |
+
import { URL } from 'node:url';
|
45 |
+
import { TcpSocketConnectOpts, Socket, Server as NetServer, LookupFunction } from 'node:net';
|
46 |
+
// incoming headers will never contain number
|
47 |
+
interface IncomingHttpHeaders extends NodeJS.Dict<string | string[]> {
|
48 |
+
accept?: string | undefined;
|
49 |
+
'accept-language'?: string | undefined;
|
50 |
+
'accept-patch'?: string | undefined;
|
51 |
+
'accept-ranges'?: string | undefined;
|
52 |
+
'access-control-allow-credentials'?: string | undefined;
|
53 |
+
'access-control-allow-headers'?: string | undefined;
|
54 |
+
'access-control-allow-methods'?: string | undefined;
|
55 |
+
'access-control-allow-origin'?: string | undefined;
|
56 |
+
'access-control-expose-headers'?: string | undefined;
|
57 |
+
'access-control-max-age'?: string | undefined;
|
58 |
+
'access-control-request-headers'?: string | undefined;
|
59 |
+
'access-control-request-method'?: string | undefined;
|
60 |
+
age?: string | undefined;
|
61 |
+
allow?: string | undefined;
|
62 |
+
'alt-svc'?: string | undefined;
|
63 |
+
authorization?: string | undefined;
|
64 |
+
'cache-control'?: string | undefined;
|
65 |
+
connection?: string | undefined;
|
66 |
+
'content-disposition'?: string | undefined;
|
67 |
+
'content-encoding'?: string | undefined;
|
68 |
+
'content-language'?: string | undefined;
|
69 |
+
'content-length'?: string | undefined;
|
70 |
+
'content-location'?: string | undefined;
|
71 |
+
'content-range'?: string | undefined;
|
72 |
+
'content-type'?: string | undefined;
|
73 |
+
cookie?: string | undefined;
|
74 |
+
date?: string | undefined;
|
75 |
+
etag?: string | undefined;
|
76 |
+
expect?: string | undefined;
|
77 |
+
expires?: string | undefined;
|
78 |
+
forwarded?: string | undefined;
|
79 |
+
from?: string | undefined;
|
80 |
+
host?: string | undefined;
|
81 |
+
'if-match'?: string | undefined;
|
82 |
+
'if-modified-since'?: string | undefined;
|
83 |
+
'if-none-match'?: string | undefined;
|
84 |
+
'if-unmodified-since'?: string | undefined;
|
85 |
+
'last-modified'?: string | undefined;
|
86 |
+
location?: string | undefined;
|
87 |
+
origin?: string | undefined;
|
88 |
+
pragma?: string | undefined;
|
89 |
+
'proxy-authenticate'?: string | undefined;
|
90 |
+
'proxy-authorization'?: string | undefined;
|
91 |
+
'public-key-pins'?: string | undefined;
|
92 |
+
range?: string | undefined;
|
93 |
+
referer?: string | undefined;
|
94 |
+
'retry-after'?: string | undefined;
|
95 |
+
'sec-websocket-accept'?: string | undefined;
|
96 |
+
'sec-websocket-extensions'?: string | undefined;
|
97 |
+
'sec-websocket-key'?: string | undefined;
|
98 |
+
'sec-websocket-protocol'?: string | undefined;
|
99 |
+
'sec-websocket-version'?: string | undefined;
|
100 |
+
'set-cookie'?: string[] | undefined;
|
101 |
+
'strict-transport-security'?: string | undefined;
|
102 |
+
tk?: string | undefined;
|
103 |
+
trailer?: string | undefined;
|
104 |
+
'transfer-encoding'?: string | undefined;
|
105 |
+
upgrade?: string | undefined;
|
106 |
+
'user-agent'?: string | undefined;
|
107 |
+
vary?: string | undefined;
|
108 |
+
via?: string | undefined;
|
109 |
+
warning?: string | undefined;
|
110 |
+
'www-authenticate'?: string | undefined;
|
111 |
+
}
|
112 |
+
// outgoing headers allows numbers (as they are converted internally to strings)
|
113 |
+
type OutgoingHttpHeader = number | string | string[];
|
114 |
+
interface OutgoingHttpHeaders extends NodeJS.Dict<OutgoingHttpHeader> {}
|
115 |
+
interface ClientRequestArgs {
|
116 |
+
signal?: AbortSignal | undefined;
|
117 |
+
protocol?: string | null | undefined;
|
118 |
+
host?: string | null | undefined;
|
119 |
+
hostname?: string | null | undefined;
|
120 |
+
family?: number | undefined;
|
121 |
+
port?: number | string | null | undefined;
|
122 |
+
defaultPort?: number | string | undefined;
|
123 |
+
localAddress?: string | undefined;
|
124 |
+
socketPath?: string | undefined;
|
125 |
+
/**
|
126 |
+
* @default 8192
|
127 |
+
*/
|
128 |
+
maxHeaderSize?: number | undefined;
|
129 |
+
method?: string | undefined;
|
130 |
+
path?: string | null | undefined;
|
131 |
+
headers?: OutgoingHttpHeaders | undefined;
|
132 |
+
auth?: string | null | undefined;
|
133 |
+
agent?: Agent | boolean | undefined;
|
134 |
+
_defaultAgent?: Agent | undefined;
|
135 |
+
timeout?: number | undefined;
|
136 |
+
setHost?: boolean | undefined;
|
137 |
+
// https://github.com/nodejs/node/blob/master/lib/_http_client.js#L278
|
138 |
+
createConnection?:
|
139 |
+
| ((options: ClientRequestArgs, oncreate: (err: Error, socket: Socket) => void) => Socket)
|
140 |
+
| undefined;
|
141 |
+
lookup?: LookupFunction | undefined;
|
142 |
+
}
|
143 |
+
interface ServerOptions<
|
144 |
+
Request extends typeof IncomingMessage = typeof IncomingMessage,
|
145 |
+
Response extends typeof ServerResponse = typeof ServerResponse,
|
146 |
+
> {
|
147 |
+
IncomingMessage?: Request | undefined;
|
148 |
+
ServerResponse?: Response | undefined;
|
149 |
+
/**
|
150 |
+
* Optionally overrides the value of
|
151 |
+
* `--max-http-header-size` for requests received by this server, i.e.
|
152 |
+
* the maximum length of request headers in bytes.
|
153 |
+
* @default 8192
|
154 |
+
*/
|
155 |
+
maxHeaderSize?: number | undefined;
|
156 |
+
/**
|
157 |
+
* Use an insecure HTTP parser that accepts invalid HTTP headers when true.
|
158 |
+
* Using the insecure parser should be avoided.
|
159 |
+
* See --insecure-http-parser for more information.
|
160 |
+
* @default false
|
161 |
+
*/
|
162 |
+
insecureHTTPParser?: boolean | undefined;
|
163 |
+
/**
|
164 |
+
* If set to `true`, it disables the use of Nagle's algorithm immediately after a new incoming connection is received.
|
165 |
+
* @default false
|
166 |
+
* @since v16.5.0
|
167 |
+
*/
|
168 |
+
noDelay?: boolean | undefined;
|
169 |
+
/**
|
170 |
+
* If set to `true`, it enables keep-alive functionality on the socket immediately after a new incoming connection is received,
|
171 |
+
* similarly on what is done in `socket.setKeepAlive([enable][, initialDelay])`.
|
172 |
+
* @default false
|
173 |
+
* @since v16.5.0
|
174 |
+
*/
|
175 |
+
keepAlive?: boolean | undefined;
|
176 |
+
/**
|
177 |
+
* If set to a positive number, it sets the initial delay before the first keepalive probe is sent on an idle socket.
|
178 |
+
* @default 0
|
179 |
+
* @since v16.5.0
|
180 |
+
*/
|
181 |
+
keepAliveInitialDelay?: number | undefined;
|
182 |
+
}
|
183 |
+
type RequestListener<
|
184 |
+
Request extends typeof IncomingMessage = typeof IncomingMessage,
|
185 |
+
Response extends typeof ServerResponse = typeof ServerResponse,
|
186 |
+
> = (req: InstanceType<Request>, res: InstanceType<Response> & { req: InstanceType<Request> }) => void;
|
187 |
+
/**
|
188 |
+
* @since v0.1.17
|
189 |
+
*/
|
190 |
+
class Server<
|
191 |
+
Request extends typeof IncomingMessage = typeof IncomingMessage,
|
192 |
+
Response extends typeof ServerResponse = typeof ServerResponse,
|
193 |
+
> extends NetServer {
|
194 |
+
constructor(requestListener?: RequestListener<Request, Response>);
|
195 |
+
constructor(options: ServerOptions<Request, Response>, requestListener?: RequestListener<Request, Response>);
|
196 |
+
/**
|
197 |
+
* Sets the timeout value for sockets, and emits a `'timeout'` event on
|
198 |
+
* the Server object, passing the socket as an argument, if a timeout
|
199 |
+
* occurs.
|
200 |
+
*
|
201 |
+
* If there is a `'timeout'` event listener on the Server object, then it
|
202 |
+
* will be called with the timed-out socket as an argument.
|
203 |
+
*
|
204 |
+
* By default, the Server does not timeout sockets. However, if a callback
|
205 |
+
* is assigned to the Server's `'timeout'` event, timeouts must be handled
|
206 |
+
* explicitly.
|
207 |
+
* @since v0.9.12
|
208 |
+
* @param [msecs=0 (no timeout)]
|
209 |
+
*/
|
210 |
+
setTimeout(msecs?: number, callback?: () => void): this;
|
211 |
+
setTimeout(callback: () => void): this;
|
212 |
+
/**
|
213 |
+
* Limits maximum incoming headers count. If set to 0, no limit will be applied.
|
214 |
+
* @since v0.7.0
|
215 |
+
*/
|
216 |
+
maxHeadersCount: number | null;
|
217 |
+
/**
|
218 |
+
* The maximum number of requests socket can handle
|
219 |
+
* before closing keep alive connection.
|
220 |
+
*
|
221 |
+
* A value of `0` will disable the limit.
|
222 |
+
*
|
223 |
+
* When the limit is reached it will set the `Connection` header value to `close`,
|
224 |
+
* but will not actually close the connection, subsequent requests sent
|
225 |
+
* after the limit is reached will get `503 Service Unavailable` as a response.
|
226 |
+
* @since v16.10.0
|
227 |
+
*/
|
228 |
+
maxRequestsPerSocket: number | null;
|
229 |
+
/**
|
230 |
+
* The number of milliseconds of inactivity before a socket is presumed
|
231 |
+
* to have timed out.
|
232 |
+
*
|
233 |
+
* A value of `0` will disable the timeout behavior on incoming connections.
|
234 |
+
*
|
235 |
+
* The socket timeout logic is set up on connection, so changing this
|
236 |
+
* value only affects new connections to the server, not any existing connections.
|
237 |
+
* @since v0.9.12
|
238 |
+
*/
|
239 |
+
timeout: number;
|
240 |
+
/**
|
241 |
+
* Limit the amount of time the parser will wait to receive the complete HTTP
|
242 |
+
* headers.
|
243 |
+
*
|
244 |
+
* If the timeout expires, the server responds with status 408 without
|
245 |
+
* forwarding the request to the request listener and then closes the connection.
|
246 |
+
*
|
247 |
+
* It must be set to a non-zero value (e.g. 120 seconds) to protect against
|
248 |
+
* potential Denial-of-Service attacks in case the server is deployed without a
|
249 |
+
* reverse proxy in front.
|
250 |
+
* @since v11.3.0, v10.14.0
|
251 |
+
*/
|
252 |
+
headersTimeout: number;
|
253 |
+
/**
|
254 |
+
* The number of milliseconds of inactivity a server needs to wait for additional
|
255 |
+
* incoming data, after it has finished writing the last response, before a socket
|
256 |
+
* will be destroyed. If the server receives new data before the keep-alive
|
257 |
+
* timeout has fired, it will reset the regular inactivity timeout, i.e.,`server.timeout`.
|
258 |
+
*
|
259 |
+
* A value of `0` will disable the keep-alive timeout behavior on incoming
|
260 |
+
* connections.
|
261 |
+
* A value of `0` makes the http server behave similarly to Node.js versions prior
|
262 |
+
* to 8.0.0, which did not have a keep-alive timeout.
|
263 |
+
*
|
264 |
+
* The socket timeout logic is set up on connection, so changing this value only
|
265 |
+
* affects new connections to the server, not any existing connections.
|
266 |
+
* @since v8.0.0
|
267 |
+
*/
|
268 |
+
keepAliveTimeout: number;
|
269 |
+
/**
|
270 |
+
* Sets the timeout value in milliseconds for receiving the entire request from
|
271 |
+
* the client.
|
272 |
+
*
|
273 |
+
* If the timeout expires, the server responds with status 408 without
|
274 |
+
* forwarding the request to the request listener and then closes the connection.
|
275 |
+
*
|
276 |
+
* It must be set to a non-zero value (e.g. 120 seconds) to protect against
|
277 |
+
* potential Denial-of-Service attacks in case the server is deployed without a
|
278 |
+
* reverse proxy in front.
|
279 |
+
* @since v14.11.0
|
280 |
+
*/
|
281 |
+
requestTimeout: number;
|
282 |
+
/**
|
283 |
+
* Closes all connections connected to this server.
|
284 |
+
* @since v18.2.0
|
285 |
+
*/
|
286 |
+
closeAllConnections(): void;
|
287 |
+
/**
|
288 |
+
* Closes all connections connected to this server which are not sending a request or waiting for a response.
|
289 |
+
* @since v18.2.0
|
290 |
+
*/
|
291 |
+
closeIdleConnections(): void;
|
292 |
+
addListener(event: string, listener: (...args: any[]) => void): this;
|
293 |
+
addListener(event: 'close', listener: () => void): this;
|
294 |
+
addListener(event: 'connection', listener: (socket: Socket) => void): this;
|
295 |
+
addListener(event: 'error', listener: (err: Error) => void): this;
|
296 |
+
addListener(event: 'listening', listener: () => void): this;
|
297 |
+
addListener(event: 'checkContinue', listener: RequestListener<Request, Response>): this;
|
298 |
+
addListener(event: 'checkExpectation', listener: RequestListener<Request, Response>): this;
|
299 |
+
addListener(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this;
|
300 |
+
addListener(
|
301 |
+
event: 'connect',
|
302 |
+
listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
|
303 |
+
): this;
|
304 |
+
addListener(event: 'request', listener: RequestListener<Request, Response>): this;
|
305 |
+
addListener(
|
306 |
+
event: 'upgrade',
|
307 |
+
listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
|
308 |
+
): this;
|
309 |
+
emit(event: string, ...args: any[]): boolean;
|
310 |
+
emit(event: 'close'): boolean;
|
311 |
+
emit(event: 'connection', socket: Socket): boolean;
|
312 |
+
emit(event: 'error', err: Error): boolean;
|
313 |
+
emit(event: 'listening'): boolean;
|
314 |
+
emit(
|
315 |
+
event: 'checkContinue',
|
316 |
+
req: InstanceType<Request>,
|
317 |
+
res: InstanceType<Response> & { req: InstanceType<Request> },
|
318 |
+
): boolean;
|
319 |
+
emit(
|
320 |
+
event: 'checkExpectation',
|
321 |
+
req: InstanceType<Request>,
|
322 |
+
res: InstanceType<Response> & { req: InstanceType<Request> },
|
323 |
+
): boolean;
|
324 |
+
emit(event: 'clientError', err: Error, socket: stream.Duplex): boolean;
|
325 |
+
emit(event: 'connect', req: InstanceType<Request>, socket: stream.Duplex, head: Buffer): boolean;
|
326 |
+
emit(
|
327 |
+
event: 'request',
|
328 |
+
req: InstanceType<Request>,
|
329 |
+
res: InstanceType<Response> & { req: InstanceType<Request> },
|
330 |
+
): boolean;
|
331 |
+
emit(event: 'upgrade', req: InstanceType<Request>, socket: stream.Duplex, head: Buffer): boolean;
|
332 |
+
on(event: string, listener: (...args: any[]) => void): this;
|
333 |
+
on(event: 'close', listener: () => void): this;
|
334 |
+
on(event: 'connection', listener: (socket: Socket) => void): this;
|
335 |
+
on(event: 'error', listener: (err: Error) => void): this;
|
336 |
+
on(event: 'listening', listener: () => void): this;
|
337 |
+
on(event: 'checkContinue', listener: RequestListener<Request, Response>): this;
|
338 |
+
on(event: 'checkExpectation', listener: RequestListener<Request, Response>): this;
|
339 |
+
on(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this;
|
340 |
+
on(event: 'connect', listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
|
341 |
+
on(event: 'request', listener: RequestListener<Request, Response>): this;
|
342 |
+
on(event: 'upgrade', listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void): this;
|
343 |
+
once(event: string, listener: (...args: any[]) => void): this;
|
344 |
+
once(event: 'close', listener: () => void): this;
|
345 |
+
once(event: 'connection', listener: (socket: Socket) => void): this;
|
346 |
+
once(event: 'error', listener: (err: Error) => void): this;
|
347 |
+
once(event: 'listening', listener: () => void): this;
|
348 |
+
once(event: 'checkContinue', listener: RequestListener<Request, Response>): this;
|
349 |
+
once(event: 'checkExpectation', listener: RequestListener<Request, Response>): this;
|
350 |
+
once(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this;
|
351 |
+
once(
|
352 |
+
event: 'connect',
|
353 |
+
listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
|
354 |
+
): this;
|
355 |
+
once(event: 'request', listener: RequestListener<Request, Response>): this;
|
356 |
+
once(
|
357 |
+
event: 'upgrade',
|
358 |
+
listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
|
359 |
+
): this;
|
360 |
+
prependListener(event: string, listener: (...args: any[]) => void): this;
|
361 |
+
prependListener(event: 'close', listener: () => void): this;
|
362 |
+
prependListener(event: 'connection', listener: (socket: Socket) => void): this;
|
363 |
+
prependListener(event: 'error', listener: (err: Error) => void): this;
|
364 |
+
prependListener(event: 'listening', listener: () => void): this;
|
365 |
+
prependListener(event: 'checkContinue', listener: RequestListener<Request, Response>): this;
|
366 |
+
prependListener(event: 'checkExpectation', listener: RequestListener<Request, Response>): this;
|
367 |
+
prependListener(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this;
|
368 |
+
prependListener(
|
369 |
+
event: 'connect',
|
370 |
+
listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
|
371 |
+
): this;
|
372 |
+
prependListener(event: 'request', listener: RequestListener<Request, Response>): this;
|
373 |
+
prependListener(
|
374 |
+
event: 'upgrade',
|
375 |
+
listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
|
376 |
+
): this;
|
377 |
+
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
378 |
+
prependOnceListener(event: 'close', listener: () => void): this;
|
379 |
+
prependOnceListener(event: 'connection', listener: (socket: Socket) => void): this;
|
380 |
+
prependOnceListener(event: 'error', listener: (err: Error) => void): this;
|
381 |
+
prependOnceListener(event: 'listening', listener: () => void): this;
|
382 |
+
prependOnceListener(event: 'checkContinue', listener: RequestListener<Request, Response>): this;
|
383 |
+
prependOnceListener(event: 'checkExpectation', listener: RequestListener<Request, Response>): this;
|
384 |
+
prependOnceListener(event: 'clientError', listener: (err: Error, socket: stream.Duplex) => void): this;
|
385 |
+
prependOnceListener(
|
386 |
+
event: 'connect',
|
387 |
+
listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
|
388 |
+
): this;
|
389 |
+
prependOnceListener(event: 'request', listener: RequestListener<Request, Response>): this;
|
390 |
+
prependOnceListener(
|
391 |
+
event: 'upgrade',
|
392 |
+
listener: (req: InstanceType<Request>, socket: stream.Duplex, head: Buffer) => void,
|
393 |
+
): this;
|
394 |
+
}
|
395 |
+
/**
|
396 |
+
* This class serves as the parent class of {@link ClientRequest} and {@link ServerResponse}. It is an abstract of outgoing message from
|
397 |
+
* the perspective of the participants of HTTP transaction.
|
398 |
+
* @since v0.1.17
|
399 |
+
*/
|
400 |
+
class OutgoingMessage<Request extends IncomingMessage = IncomingMessage> extends stream.Writable {
|
401 |
+
readonly req: Request;
|
402 |
+
chunkedEncoding: boolean;
|
403 |
+
shouldKeepAlive: boolean;
|
404 |
+
useChunkedEncodingByDefault: boolean;
|
405 |
+
sendDate: boolean;
|
406 |
+
/**
|
407 |
+
* @deprecated Use `writableEnded` instead.
|
408 |
+
*/
|
409 |
+
finished: boolean;
|
410 |
+
/**
|
411 |
+
* Read-only. `true` if the headers were sent, otherwise `false`.
|
412 |
+
* @since v0.9.3
|
413 |
+
*/
|
414 |
+
readonly headersSent: boolean;
|
415 |
+
/**
|
416 |
+
* Aliases of `outgoingMessage.socket`
|
417 |
+
* @since v0.3.0
|
418 |
+
* @deprecated Since v15.12.0,v14.17.1 - Use `socket` instead.
|
419 |
+
*/
|
420 |
+
readonly connection: Socket | null;
|
421 |
+
/**
|
422 |
+
* Reference to the underlying socket. Usually, users will not want to access
|
423 |
+
* this property.
|
424 |
+
*
|
425 |
+
* After calling `outgoingMessage.end()`, this property will be nulled.
|
426 |
+
* @since v0.3.0
|
427 |
+
*/
|
428 |
+
readonly socket: Socket | null;
|
429 |
+
constructor();
|
430 |
+
/**
|
431 |
+
* Once a socket is associated with the message and is connected,`socket.setTimeout()` will be called with `msecs` as the first parameter.
|
432 |
+
* @since v0.9.12
|
433 |
+
* @param callback Optional function to be called when a timeout occurs. Same as binding to the `timeout` event.
|
434 |
+
*/
|
435 |
+
setTimeout(msecs: number, callback?: () => void): this;
|
436 |
+
/**
|
437 |
+
* Sets a single header value for the header object.
|
438 |
+
* @since v0.4.0
|
439 |
+
* @param name Header name
|
440 |
+
* @param value Header value
|
441 |
+
*/
|
442 |
+
setHeader(name: string, value: number | string | ReadonlyArray<string>): this;
|
443 |
+
/**
|
444 |
+
* Gets the value of HTTP header with the given name. If such a name doesn't
|
445 |
+
* exist in message, it will be `undefined`.
|
446 |
+
* @since v0.4.0
|
447 |
+
* @param name Name of header
|
448 |
+
*/
|
449 |
+
getHeader(name: string): number | string | string[] | undefined;
|
450 |
+
/**
|
451 |
+
* Returns a shallow copy of the current outgoing headers. Since a shallow
|
452 |
+
* copy is used, array values may be mutated without additional calls to
|
453 |
+
* various header-related HTTP module methods. The keys of the returned
|
454 |
+
* object are the header names and the values are the respective header
|
455 |
+
* values. All header names are lowercase.
|
456 |
+
*
|
457 |
+
* The object returned by the `outgoingMessage.getHeaders()` method does
|
458 |
+
* not prototypically inherit from the JavaScript Object. This means that
|
459 |
+
* typical Object methods such as `obj.toString()`, `obj.hasOwnProperty()`,
|
460 |
+
* and others are not defined and will not work.
|
461 |
+
*
|
462 |
+
* ```js
|
463 |
+
* outgoingMessage.setHeader('Foo', 'bar');
|
464 |
+
* outgoingMessage.setHeader('Set-Cookie', ['foo=bar', 'bar=baz']);
|
465 |
+
*
|
466 |
+
* const headers = outgoingMessage.getHeaders();
|
467 |
+
* // headers === { foo: 'bar', 'set-cookie': ['foo=bar', 'bar=baz'] }
|
468 |
+
* ```
|
469 |
+
* @since v7.7.0
|
470 |
+
*/
|
471 |
+
getHeaders(): OutgoingHttpHeaders;
|
472 |
+
/**
|
473 |
+
* Returns an array of names of headers of the outgoing outgoingMessage. All
|
474 |
+
* names are lowercase.
|
475 |
+
* @since v7.7.0
|
476 |
+
*/
|
477 |
+
getHeaderNames(): string[];
|
478 |
+
/**
|
479 |
+
* Returns `true` if the header identified by `name` is currently set in the
|
480 |
+
* outgoing headers. The header name is case-insensitive.
|
481 |
+
*
|
482 |
+
* ```js
|
483 |
+
* const hasContentType = outgoingMessage.hasHeader('content-type');
|
484 |
+
* ```
|
485 |
+
* @since v7.7.0
|
486 |
+
*/
|
487 |
+
hasHeader(name: string): boolean;
|
488 |
+
/**
|
489 |
+
* Removes a header that is queued for implicit sending.
|
490 |
+
*
|
491 |
+
* ```js
|
492 |
+
* outgoingMessage.removeHeader('Content-Encoding');
|
493 |
+
* ```
|
494 |
+
* @since v0.4.0
|
495 |
+
* @param name Header name
|
496 |
+
*/
|
497 |
+
removeHeader(name: string): void;
|
498 |
+
/**
|
499 |
+
* Adds HTTP trailers (headers but at the end of the message) to the message.
|
500 |
+
*
|
501 |
+
* Trailers are **only** be emitted if the message is chunked encoded. If not,
|
502 |
+
* the trailer will be silently discarded.
|
503 |
+
*
|
504 |
+
* HTTP requires the `Trailer` header to be sent to emit trailers,
|
505 |
+
* with a list of header fields in its value, e.g.
|
506 |
+
*
|
507 |
+
* ```js
|
508 |
+
* message.writeHead(200, { 'Content-Type': 'text/plain',
|
509 |
+
* 'Trailer': 'Content-MD5' });
|
510 |
+
* message.write(fileData);
|
511 |
+
* message.addTrailers({ 'Content-MD5': '7895bf4b8828b55ceaf47747b4bca667' });
|
512 |
+
* message.end();
|
513 |
+
* ```
|
514 |
+
*
|
515 |
+
* Attempting to set a header field name or value that contains invalid characters
|
516 |
+
* will result in a `TypeError` being thrown.
|
517 |
+
* @since v0.3.0
|
518 |
+
*/
|
519 |
+
addTrailers(headers: OutgoingHttpHeaders | ReadonlyArray<[string, string]>): void;
|
520 |
+
/**
|
521 |
+
* Compulsorily flushes the message headers
|
522 |
+
*
|
523 |
+
* For efficiency reason, Node.js normally buffers the message headers
|
524 |
+
* until `outgoingMessage.end()` is called or the first chunk of message data
|
525 |
+
* is written. It then tries to pack the headers and data into a single TCP
|
526 |
+
* packet.
|
527 |
+
*
|
528 |
+
* It is usually desired (it saves a TCP round-trip), but not when the first
|
529 |
+
* data is not sent until possibly much later. `outgoingMessage.flushHeaders()`bypasses the optimization and kickstarts the request.
|
530 |
+
* @since v1.6.0
|
531 |
+
*/
|
532 |
+
flushHeaders(): void;
|
533 |
+
}
|
534 |
+
/**
|
535 |
+
* This object is created internally by an HTTP server, not by the user. It is
|
536 |
+
* passed as the second parameter to the `'request'` event.
|
537 |
+
* @since v0.1.17
|
538 |
+
*/
|
539 |
+
class ServerResponse<Request extends IncomingMessage = IncomingMessage> extends OutgoingMessage<Request> {
|
540 |
+
/**
|
541 |
+
* When using implicit headers (not calling `response.writeHead()` explicitly),
|
542 |
+
* this property controls the status code that will be sent to the client when
|
543 |
+
* the headers get flushed.
|
544 |
+
*
|
545 |
+
* ```js
|
546 |
+
* response.statusCode = 404;
|
547 |
+
* ```
|
548 |
+
*
|
549 |
+
* After response header was sent to the client, this property indicates the
|
550 |
+
* status code which was sent out.
|
551 |
+
* @since v0.4.0
|
552 |
+
*/
|
553 |
+
statusCode: number;
|
554 |
+
/**
|
555 |
+
* When using implicit headers (not calling `response.writeHead()` explicitly),
|
556 |
+
* this property controls the status message that will be sent to the client when
|
557 |
+
* the headers get flushed. If this is left as `undefined` then the standard
|
558 |
+
* message for the status code will be used.
|
559 |
+
*
|
560 |
+
* ```js
|
561 |
+
* response.statusMessage = 'Not found';
|
562 |
+
* ```
|
563 |
+
*
|
564 |
+
* After response header was sent to the client, this property indicates the
|
565 |
+
* status message which was sent out.
|
566 |
+
* @since v0.11.8
|
567 |
+
*/
|
568 |
+
statusMessage: string;
|
569 |
+
constructor(req: Request);
|
570 |
+
assignSocket(socket: Socket): void;
|
571 |
+
detachSocket(socket: Socket): void;
|
572 |
+
/**
|
573 |
+
* Sends a HTTP/1.1 100 Continue message to the client, indicating that
|
574 |
+
* the request body should be sent. See the `'checkContinue'` event on`Server`.
|
575 |
+
* @since v0.3.0
|
576 |
+
*/
|
577 |
+
writeContinue(callback?: () => void): void;
|
578 |
+
/**
|
579 |
+
* Sends a response header to the request. The status code is a 3-digit HTTP
|
580 |
+
* status code, like `404`. The last argument, `headers`, are the response headers.
|
581 |
+
* Optionally one can give a human-readable `statusMessage` as the second
|
582 |
+
* argument.
|
583 |
+
*
|
584 |
+
* `headers` may be an `Array` where the keys and values are in the same list.
|
585 |
+
* It is _not_ a list of tuples. So, the even-numbered offsets are key values,
|
586 |
+
* and the odd-numbered offsets are the associated values. The array is in the same
|
587 |
+
* format as `request.rawHeaders`.
|
588 |
+
*
|
589 |
+
* Returns a reference to the `ServerResponse`, so that calls can be chained.
|
590 |
+
*
|
591 |
+
* ```js
|
592 |
+
* const body = 'hello world';
|
593 |
+
* response
|
594 |
+
* .writeHead(200, {
|
595 |
+
* 'Content-Length': Buffer.byteLength(body),
|
596 |
+
* 'Content-Type': 'text/plain'
|
597 |
+
* })
|
598 |
+
* .end(body);
|
599 |
+
* ```
|
600 |
+
*
|
601 |
+
* This method must only be called once on a message and it must
|
602 |
+
* be called before `response.end()` is called.
|
603 |
+
*
|
604 |
+
* If `response.write()` or `response.end()` are called before calling
|
605 |
+
* this, the implicit/mutable headers will be calculated and call this function.
|
606 |
+
*
|
607 |
+
* When headers have been set with `response.setHeader()`, they will be merged
|
608 |
+
* with any headers passed to `response.writeHead()`, with the headers passed
|
609 |
+
* to `response.writeHead()` given precedence.
|
610 |
+
*
|
611 |
+
* If this method is called and `response.setHeader()` has not been called,
|
612 |
+
* it will directly write the supplied header values onto the network channel
|
613 |
+
* without caching internally, and the `response.getHeader()` on the header
|
614 |
+
* will not yield the expected result. If progressive population of headers is
|
615 |
+
* desired with potential future retrieval and modification, use `response.setHeader()` instead.
|
616 |
+
*
|
617 |
+
* ```js
|
618 |
+
* // Returns content-type = text/plain
|
619 |
+
* const server = http.createServer((req, res) => {
|
620 |
+
* res.setHeader('Content-Type', 'text/html');
|
621 |
+
* res.setHeader('X-Foo', 'bar');
|
622 |
+
* res.writeHead(200, { 'Content-Type': 'text/plain' });
|
623 |
+
* res.end('ok');
|
624 |
+
* });
|
625 |
+
* ```
|
626 |
+
*
|
627 |
+
* `Content-Length` is given in bytes, not characters. Use `Buffer.byteLength()` to determine the length of the body in bytes. Node.js
|
628 |
+
* does not check whether `Content-Length` and the length of the body which has
|
629 |
+
* been transmitted are equal or not.
|
630 |
+
*
|
631 |
+
* Attempting to set a header field name or value that contains invalid characters
|
632 |
+
* will result in a `TypeError` being thrown.
|
633 |
+
* @since v0.1.30
|
634 |
+
*/
|
635 |
+
writeHead(
|
636 |
+
statusCode: number,
|
637 |
+
statusMessage?: string,
|
638 |
+
headers?: OutgoingHttpHeaders | OutgoingHttpHeader[],
|
639 |
+
): this;
|
640 |
+
writeHead(statusCode: number, headers?: OutgoingHttpHeaders | OutgoingHttpHeader[]): this;
|
641 |
+
/**
|
642 |
+
* Sends a HTTP/1.1 102 Processing message to the client, indicating that
|
643 |
+
* the request body should be sent.
|
644 |
+
* @since v10.0.0
|
645 |
+
*/
|
646 |
+
writeProcessing(): void;
|
647 |
+
}
|
648 |
+
interface InformationEvent {
|
649 |
+
statusCode: number;
|
650 |
+
statusMessage: string;
|
651 |
+
httpVersion: string;
|
652 |
+
httpVersionMajor: number;
|
653 |
+
httpVersionMinor: number;
|
654 |
+
headers: IncomingHttpHeaders;
|
655 |
+
rawHeaders: string[];
|
656 |
+
}
|
657 |
+
/**
|
658 |
+
* This object is created internally and returned from {@link request}. It
|
659 |
+
* represents an _in-progress_ request whose header has already been queued. The
|
660 |
+
* header is still mutable using the `setHeader(name, value)`,`getHeader(name)`, `removeHeader(name)` API. The actual header will
|
661 |
+
* be sent along with the first data chunk or when calling `request.end()`.
|
662 |
+
*
|
663 |
+
* To get the response, add a listener for `'response'` to the request object.`'response'` will be emitted from the request object when the response
|
664 |
+
* headers have been received. The `'response'` event is executed with one
|
665 |
+
* argument which is an instance of {@link IncomingMessage}.
|
666 |
+
*
|
667 |
+
* During the `'response'` event, one can add listeners to the
|
668 |
+
* response object; particularly to listen for the `'data'` event.
|
669 |
+
*
|
670 |
+
* If no `'response'` handler is added, then the response will be
|
671 |
+
* entirely discarded. However, if a `'response'` event handler is added,
|
672 |
+
* then the data from the response object **must** be consumed, either by
|
673 |
+
* calling `response.read()` whenever there is a `'readable'` event, or
|
674 |
+
* by adding a `'data'` handler, or by calling the `.resume()` method.
|
675 |
+
* Until the data is consumed, the `'end'` event will not fire. Also, until
|
676 |
+
* the data is read it will consume memory that can eventually lead to a
|
677 |
+
* 'process out of memory' error.
|
678 |
+
*
|
679 |
+
* For backward compatibility, `res` will only emit `'error'` if there is an`'error'` listener registered.
|
680 |
+
*
|
681 |
+
* Node.js does not check whether Content-Length and the length of the
|
682 |
+
* body which has been transmitted are equal or not.
|
683 |
+
* @since v0.1.17
|
684 |
+
*/
|
685 |
+
class ClientRequest extends OutgoingMessage {
|
686 |
+
/**
|
687 |
+
* The `request.aborted` property will be `true` if the request has
|
688 |
+
* been aborted.
|
689 |
+
* @since v0.11.14
|
690 |
+
* @deprecated Since v17.0.0,v16.12.0 - Check `destroyed` instead.
|
691 |
+
*/
|
692 |
+
aborted: boolean;
|
693 |
+
/**
|
694 |
+
* The request host.
|
695 |
+
* @since v14.5.0, v12.19.0
|
696 |
+
*/
|
697 |
+
host: string;
|
698 |
+
/**
|
699 |
+
* The request protocol.
|
700 |
+
* @since v14.5.0, v12.19.0
|
701 |
+
*/
|
702 |
+
protocol: string;
|
703 |
+
/**
|
704 |
+
* When sending request through a keep-alive enabled agent, the underlying socket
|
705 |
+
* might be reused. But if server closes connection at unfortunate time, client
|
706 |
+
* may run into a 'ECONNRESET' error.
|
707 |
+
*
|
708 |
+
* ```js
|
709 |
+
* const http = require('http');
|
710 |
+
*
|
711 |
+
* // Server has a 5 seconds keep-alive timeout by default
|
712 |
+
* http
|
713 |
+
* .createServer((req, res) => {
|
714 |
+
* res.write('hello\n');
|
715 |
+
* res.end();
|
716 |
+
* })
|
717 |
+
* .listen(3000);
|
718 |
+
*
|
719 |
+
* setInterval(() => {
|
720 |
+
* // Adapting a keep-alive agent
|
721 |
+
* http.get('http://localhost:3000', { agent }, (res) => {
|
722 |
+
* res.on('data', (data) => {
|
723 |
+
* // Do nothing
|
724 |
+
* });
|
725 |
+
* });
|
726 |
+
* }, 5000); // Sending request on 5s interval so it's easy to hit idle timeout
|
727 |
+
* ```
|
728 |
+
*
|
729 |
+
* By marking a request whether it reused socket or not, we can do
|
730 |
+
* automatic error retry base on it.
|
731 |
+
*
|
732 |
+
* ```js
|
733 |
+
* const http = require('http');
|
734 |
+
* const agent = new http.Agent({ keepAlive: true });
|
735 |
+
*
|
736 |
+
* function retriableRequest() {
|
737 |
+
* const req = http
|
738 |
+
* .get('http://localhost:3000', { agent }, (res) => {
|
739 |
+
* // ...
|
740 |
+
* })
|
741 |
+
* .on('error', (err) => {
|
742 |
+
* // Check if retry is needed
|
743 |
+
* if (req.reusedSocket && err.code === 'ECONNRESET') {
|
744 |
+
* retriableRequest();
|
745 |
+
* }
|
746 |
+
* });
|
747 |
+
* }
|
748 |
+
*
|
749 |
+
* retriableRequest();
|
750 |
+
* ```
|
751 |
+
* @since v13.0.0, v12.16.0
|
752 |
+
*/
|
753 |
+
reusedSocket: boolean;
|
754 |
+
/**
|
755 |
+
* Limits maximum response headers count. If set to 0, no limit will be applied.
|
756 |
+
*/
|
757 |
+
maxHeadersCount: number;
|
758 |
+
constructor(url: string | URL | ClientRequestArgs, cb?: (res: IncomingMessage) => void);
|
759 |
+
/**
|
760 |
+
* The request method.
|
761 |
+
* @since v0.1.97
|
762 |
+
*/
|
763 |
+
method: string;
|
764 |
+
/**
|
765 |
+
* The request path.
|
766 |
+
* @since v0.4.0
|
767 |
+
*/
|
768 |
+
path: string;
|
769 |
+
/**
|
770 |
+
* Marks the request as aborting. Calling this will cause remaining data
|
771 |
+
* in the response to be dropped and the socket to be destroyed.
|
772 |
+
* @since v0.3.8
|
773 |
+
* @deprecated Since v14.1.0,v13.14.0 - Use `destroy` instead.
|
774 |
+
*/
|
775 |
+
abort(): void;
|
776 |
+
onSocket(socket: Socket): void;
|
777 |
+
/**
|
778 |
+
* Once a socket is assigned to this request and is connected `socket.setTimeout()` will be called.
|
779 |
+
* @since v0.5.9
|
780 |
+
* @param timeout Milliseconds before a request times out.
|
781 |
+
* @param callback Optional function to be called when a timeout occurs. Same as binding to the `'timeout'` event.
|
782 |
+
*/
|
783 |
+
setTimeout(timeout: number, callback?: () => void): this;
|
784 |
+
/**
|
785 |
+
* Once a socket is assigned to this request and is connected `socket.setNoDelay()` will be called.
|
786 |
+
* @since v0.5.9
|
787 |
+
*/
|
788 |
+
setNoDelay(noDelay?: boolean): void;
|
789 |
+
/**
|
790 |
+
* Once a socket is assigned to this request and is connected `socket.setKeepAlive()` will be called.
|
791 |
+
* @since v0.5.9
|
792 |
+
*/
|
793 |
+
setSocketKeepAlive(enable?: boolean, initialDelay?: number): void;
|
794 |
+
/**
|
795 |
+
* Returns an array containing the unique names of the current outgoing raw
|
796 |
+
* headers. Header names are returned with their exact casing being set.
|
797 |
+
*
|
798 |
+
* ```js
|
799 |
+
* request.setHeader('Foo', 'bar');
|
800 |
+
* request.setHeader('Set-Cookie', ['foo=bar', 'bar=baz']);
|
801 |
+
*
|
802 |
+
* const headerNames = request.getRawHeaderNames();
|
803 |
+
* // headerNames === ['Foo', 'Set-Cookie']
|
804 |
+
* ```
|
805 |
+
* @since v15.13.0, v14.17.0
|
806 |
+
*/
|
807 |
+
getRawHeaderNames(): string[];
|
808 |
+
/**
|
809 |
+
* @deprecated
|
810 |
+
*/
|
811 |
+
addListener(event: 'abort', listener: () => void): this;
|
812 |
+
addListener(
|
813 |
+
event: 'connect',
|
814 |
+
listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
|
815 |
+
): this;
|
816 |
+
addListener(event: 'continue', listener: () => void): this;
|
817 |
+
addListener(event: 'information', listener: (info: InformationEvent) => void): this;
|
818 |
+
addListener(event: 'response', listener: (response: IncomingMessage) => void): this;
|
819 |
+
addListener(event: 'socket', listener: (socket: Socket) => void): this;
|
820 |
+
addListener(event: 'timeout', listener: () => void): this;
|
821 |
+
addListener(
|
822 |
+
event: 'upgrade',
|
823 |
+
listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
|
824 |
+
): this;
|
825 |
+
addListener(event: 'close', listener: () => void): this;
|
826 |
+
addListener(event: 'drain', listener: () => void): this;
|
827 |
+
addListener(event: 'error', listener: (err: Error) => void): this;
|
828 |
+
addListener(event: 'finish', listener: () => void): this;
|
829 |
+
addListener(event: 'pipe', listener: (src: stream.Readable) => void): this;
|
830 |
+
addListener(event: 'unpipe', listener: (src: stream.Readable) => void): this;
|
831 |
+
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
832 |
+
/**
|
833 |
+
* @deprecated
|
834 |
+
*/
|
835 |
+
on(event: 'abort', listener: () => void): this;
|
836 |
+
on(event: 'connect', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
|
837 |
+
on(event: 'continue', listener: () => void): this;
|
838 |
+
on(event: 'information', listener: (info: InformationEvent) => void): this;
|
839 |
+
on(event: 'response', listener: (response: IncomingMessage) => void): this;
|
840 |
+
on(event: 'socket', listener: (socket: Socket) => void): this;
|
841 |
+
on(event: 'timeout', listener: () => void): this;
|
842 |
+
on(event: 'upgrade', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
|
843 |
+
on(event: 'close', listener: () => void): this;
|
844 |
+
on(event: 'drain', listener: () => void): this;
|
845 |
+
on(event: 'error', listener: (err: Error) => void): this;
|
846 |
+
on(event: 'finish', listener: () => void): this;
|
847 |
+
on(event: 'pipe', listener: (src: stream.Readable) => void): this;
|
848 |
+
on(event: 'unpipe', listener: (src: stream.Readable) => void): this;
|
849 |
+
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
850 |
+
/**
|
851 |
+
* @deprecated
|
852 |
+
*/
|
853 |
+
once(event: 'abort', listener: () => void): this;
|
854 |
+
once(event: 'connect', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
|
855 |
+
once(event: 'continue', listener: () => void): this;
|
856 |
+
once(event: 'information', listener: (info: InformationEvent) => void): this;
|
857 |
+
once(event: 'response', listener: (response: IncomingMessage) => void): this;
|
858 |
+
once(event: 'socket', listener: (socket: Socket) => void): this;
|
859 |
+
once(event: 'timeout', listener: () => void): this;
|
860 |
+
once(event: 'upgrade', listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void): this;
|
861 |
+
once(event: 'close', listener: () => void): this;
|
862 |
+
once(event: 'drain', listener: () => void): this;
|
863 |
+
once(event: 'error', listener: (err: Error) => void): this;
|
864 |
+
once(event: 'finish', listener: () => void): this;
|
865 |
+
once(event: 'pipe', listener: (src: stream.Readable) => void): this;
|
866 |
+
once(event: 'unpipe', listener: (src: stream.Readable) => void): this;
|
867 |
+
once(event: string | symbol, listener: (...args: any[]) => void): this;
|
868 |
+
/**
|
869 |
+
* @deprecated
|
870 |
+
*/
|
871 |
+
prependListener(event: 'abort', listener: () => void): this;
|
872 |
+
prependListener(
|
873 |
+
event: 'connect',
|
874 |
+
listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
|
875 |
+
): this;
|
876 |
+
prependListener(event: 'continue', listener: () => void): this;
|
877 |
+
prependListener(event: 'information', listener: (info: InformationEvent) => void): this;
|
878 |
+
prependListener(event: 'response', listener: (response: IncomingMessage) => void): this;
|
879 |
+
prependListener(event: 'socket', listener: (socket: Socket) => void): this;
|
880 |
+
prependListener(event: 'timeout', listener: () => void): this;
|
881 |
+
prependListener(
|
882 |
+
event: 'upgrade',
|
883 |
+
listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
|
884 |
+
): this;
|
885 |
+
prependListener(event: 'close', listener: () => void): this;
|
886 |
+
prependListener(event: 'drain', listener: () => void): this;
|
887 |
+
prependListener(event: 'error', listener: (err: Error) => void): this;
|
888 |
+
prependListener(event: 'finish', listener: () => void): this;
|
889 |
+
prependListener(event: 'pipe', listener: (src: stream.Readable) => void): this;
|
890 |
+
prependListener(event: 'unpipe', listener: (src: stream.Readable) => void): this;
|
891 |
+
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
892 |
+
/**
|
893 |
+
* @deprecated
|
894 |
+
*/
|
895 |
+
prependOnceListener(event: 'abort', listener: () => void): this;
|
896 |
+
prependOnceListener(
|
897 |
+
event: 'connect',
|
898 |
+
listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
|
899 |
+
): this;
|
900 |
+
prependOnceListener(event: 'continue', listener: () => void): this;
|
901 |
+
prependOnceListener(event: 'information', listener: (info: InformationEvent) => void): this;
|
902 |
+
prependOnceListener(event: 'response', listener: (response: IncomingMessage) => void): this;
|
903 |
+
prependOnceListener(event: 'socket', listener: (socket: Socket) => void): this;
|
904 |
+
prependOnceListener(event: 'timeout', listener: () => void): this;
|
905 |
+
prependOnceListener(
|
906 |
+
event: 'upgrade',
|
907 |
+
listener: (response: IncomingMessage, socket: Socket, head: Buffer) => void,
|
908 |
+
): this;
|
909 |
+
prependOnceListener(event: 'close', listener: () => void): this;
|
910 |
+
prependOnceListener(event: 'drain', listener: () => void): this;
|
911 |
+
prependOnceListener(event: 'error', listener: (err: Error) => void): this;
|
912 |
+
prependOnceListener(event: 'finish', listener: () => void): this;
|
913 |
+
prependOnceListener(event: 'pipe', listener: (src: stream.Readable) => void): this;
|
914 |
+
prependOnceListener(event: 'unpipe', listener: (src: stream.Readable) => void): this;
|
915 |
+
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
|
916 |
+
}
|
917 |
+
/**
|
918 |
+
* An `IncomingMessage` object is created by {@link Server} or {@link ClientRequest} and passed as the first argument to the `'request'` and `'response'` event respectively. It may be used to
|
919 |
+
* access response
|
920 |
+
* status, headers and data.
|
921 |
+
*
|
922 |
+
* Different from its `socket` value which is a subclass of `stream.Duplex`, the`IncomingMessage` itself extends `stream.Readable` and is created separately to
|
923 |
+
* parse and emit the incoming HTTP headers and payload, as the underlying socket
|
924 |
+
* may be reused multiple times in case of keep-alive.
|
925 |
+
* @since v0.1.17
|
926 |
+
*/
|
927 |
+
class IncomingMessage extends stream.Readable {
|
928 |
+
constructor(socket: Socket);
|
929 |
+
/**
|
930 |
+
* The `message.aborted` property will be `true` if the request has
|
931 |
+
* been aborted.
|
932 |
+
* @since v10.1.0
|
933 |
+
* @deprecated Since v17.0.0,v16.12.0 - Check `message.destroyed` from <a href="stream.html#class-streamreadable" class="type">stream.Readable</a>.
|
934 |
+
*/
|
935 |
+
aborted: boolean;
|
936 |
+
/**
|
937 |
+
* In case of server request, the HTTP version sent by the client. In the case of
|
938 |
+
* client response, the HTTP version of the connected-to server.
|
939 |
+
* Probably either `'1.1'` or `'1.0'`.
|
940 |
+
*
|
941 |
+
* Also `message.httpVersionMajor` is the first integer and`message.httpVersionMinor` is the second.
|
942 |
+
* @since v0.1.1
|
943 |
+
*/
|
944 |
+
httpVersion: string;
|
945 |
+
httpVersionMajor: number;
|
946 |
+
httpVersionMinor: number;
|
947 |
+
/**
|
948 |
+
* The `message.complete` property will be `true` if a complete HTTP message has
|
949 |
+
* been received and successfully parsed.
|
950 |
+
*
|
951 |
+
* This property is particularly useful as a means of determining if a client or
|
952 |
+
* server fully transmitted a message before a connection was terminated:
|
953 |
+
*
|
954 |
+
* ```js
|
955 |
+
* const req = http.request({
|
956 |
+
* host: '127.0.0.1',
|
957 |
+
* port: 8080,
|
958 |
+
* method: 'POST'
|
959 |
+
* }, (res) => {
|
960 |
+
* res.resume();
|
961 |
+
* res.on('end', () => {
|
962 |
+
* if (!res.complete)
|
963 |
+
* console.error(
|
964 |
+
* 'The connection was terminated while the message was still being sent');
|
965 |
+
* });
|
966 |
+
* });
|
967 |
+
* ```
|
968 |
+
* @since v0.3.0
|
969 |
+
*/
|
970 |
+
complete: boolean;
|
971 |
+
/**
|
972 |
+
* Alias for `message.socket`.
|
973 |
+
* @since v0.1.90
|
974 |
+
* @deprecated Since v16.0.0 - Use `socket`.
|
975 |
+
*/
|
976 |
+
connection: Socket;
|
977 |
+
/**
|
978 |
+
* The `net.Socket` object associated with the connection.
|
979 |
+
*
|
980 |
+
* With HTTPS support, use `request.socket.getPeerCertificate()` to obtain the
|
981 |
+
* client's authentication details.
|
982 |
+
*
|
983 |
+
* This property is guaranteed to be an instance of the `net.Socket` class,
|
984 |
+
* a subclass of `stream.Duplex`, unless the user specified a socket
|
985 |
+
* type other than `net.Socket` or internally nulled.
|
986 |
+
* @since v0.3.0
|
987 |
+
*/
|
988 |
+
socket: Socket;
|
989 |
+
/**
|
990 |
+
* The request/response headers object.
|
991 |
+
*
|
992 |
+
* Key-value pairs of header names and values. Header names are lower-cased.
|
993 |
+
*
|
994 |
+
* ```js
|
995 |
+
* // Prints something like:
|
996 |
+
* //
|
997 |
+
* // { 'user-agent': 'curl/7.22.0',
|
998 |
+
* // host: '127.0.0.1:8000',
|
999 |
+
* // accept: '*' }
|
1000 |
+
* console.log(request.getHeaders());
|
1001 |
+
* ```
|
1002 |
+
*
|
1003 |
+
* Duplicates in raw headers are handled in the following ways, depending on the
|
1004 |
+
* header name:
|
1005 |
+
*
|
1006 |
+
* * Duplicates of `age`, `authorization`, `content-length`, `content-type`,`etag`, `expires`, `from`, `host`, `if-modified-since`, `if-unmodified-since`,`last-modified`, `location`,
|
1007 |
+
* `max-forwards`, `proxy-authorization`, `referer`,`retry-after`, `server`, or `user-agent` are discarded.
|
1008 |
+
* * `set-cookie` is always an array. Duplicates are added to the array.
|
1009 |
+
* * For duplicate `cookie` headers, the values are joined together with '; '.
|
1010 |
+
* * For all other headers, the values are joined together with ', '.
|
1011 |
+
* @since v0.1.5
|
1012 |
+
*/
|
1013 |
+
headers: IncomingHttpHeaders;
|
1014 |
+
/**
|
1015 |
+
* The raw request/response headers list exactly as they were received.
|
1016 |
+
*
|
1017 |
+
* The keys and values are in the same list. It is _not_ a
|
1018 |
+
* list of tuples. So, the even-numbered offsets are key values, and the
|
1019 |
+
* odd-numbered offsets are the associated values.
|
1020 |
+
*
|
1021 |
+
* Header names are not lowercased, and duplicates are not merged.
|
1022 |
+
*
|
1023 |
+
* ```js
|
1024 |
+
* // Prints something like:
|
1025 |
+
* //
|
1026 |
+
* // [ 'user-agent',
|
1027 |
+
* // 'this is invalid because there can be only one',
|
1028 |
+
* // 'User-Agent',
|
1029 |
+
* // 'curl/7.22.0',
|
1030 |
+
* // 'Host',
|
1031 |
+
* // '127.0.0.1:8000',
|
1032 |
+
* // 'ACCEPT',
|
1033 |
+
* // '*' ]
|
1034 |
+
* console.log(request.rawHeaders);
|
1035 |
+
* ```
|
1036 |
+
* @since v0.11.6
|
1037 |
+
*/
|
1038 |
+
rawHeaders: string[];
|
1039 |
+
/**
|
1040 |
+
* The request/response trailers object. Only populated at the `'end'` event.
|
1041 |
+
* @since v0.3.0
|
1042 |
+
*/
|
1043 |
+
trailers: NodeJS.Dict<string>;
|
1044 |
+
/**
|
1045 |
+
* The raw request/response trailer keys and values exactly as they were
|
1046 |
+
* received. Only populated at the `'end'` event.
|
1047 |
+
* @since v0.11.6
|
1048 |
+
*/
|
1049 |
+
rawTrailers: string[];
|
1050 |
+
/**
|
1051 |
+
* Calls `message.socket.setTimeout(msecs, callback)`.
|
1052 |
+
* @since v0.5.9
|
1053 |
+
*/
|
1054 |
+
setTimeout(msecs: number, callback?: () => void): this;
|
1055 |
+
/**
|
1056 |
+
* **Only valid for request obtained from {@link Server}.**
|
1057 |
+
*
|
1058 |
+
* The request method as a string. Read only. Examples: `'GET'`, `'DELETE'`.
|
1059 |
+
* @since v0.1.1
|
1060 |
+
*/
|
1061 |
+
method?: string | undefined;
|
1062 |
+
/**
|
1063 |
+
* **Only valid for request obtained from {@link Server}.**
|
1064 |
+
*
|
1065 |
+
* Request URL string. This contains only the URL that is present in the actual
|
1066 |
+
* HTTP request. Take the following request:
|
1067 |
+
*
|
1068 |
+
* ```http
|
1069 |
+
* GET /status?name=ryan HTTP/1.1
|
1070 |
+
* Accept: text/plain
|
1071 |
+
* ```
|
1072 |
+
*
|
1073 |
+
* To parse the URL into its parts:
|
1074 |
+
*
|
1075 |
+
* ```js
|
1076 |
+
* new URL(request.url, `http://${request.getHeaders().host}`);
|
1077 |
+
* ```
|
1078 |
+
*
|
1079 |
+
* When `request.url` is `'/status?name=ryan'` and`request.getHeaders().host` is `'localhost:3000'`:
|
1080 |
+
*
|
1081 |
+
* ```console
|
1082 |
+
* $ node
|
1083 |
+
* > new URL(request.url, `http://${request.getHeaders().host}`)
|
1084 |
+
* URL {
|
1085 |
+
* href: 'http://localhost:3000/status?name=ryan',
|
1086 |
+
* origin: 'http://localhost:3000',
|
1087 |
+
* protocol: 'http:',
|
1088 |
+
* username: '',
|
1089 |
+
* password: '',
|
1090 |
+
* host: 'localhost:3000',
|
1091 |
+
* hostname: 'localhost',
|
1092 |
+
* port: '3000',
|
1093 |
+
* pathname: '/status',
|
1094 |
+
* search: '?name=ryan',
|
1095 |
+
* searchParams: URLSearchParams { 'name' => 'ryan' },
|
1096 |
+
* hash: ''
|
1097 |
+
* }
|
1098 |
+
* ```
|
1099 |
+
* @since v0.1.90
|
1100 |
+
*/
|
1101 |
+
url?: string | undefined;
|
1102 |
+
/**
|
1103 |
+
* **Only valid for response obtained from {@link ClientRequest}.**
|
1104 |
+
*
|
1105 |
+
* The 3-digit HTTP response status code. E.G. `404`.
|
1106 |
+
* @since v0.1.1
|
1107 |
+
*/
|
1108 |
+
statusCode?: number | undefined;
|
1109 |
+
/**
|
1110 |
+
* **Only valid for response obtained from {@link ClientRequest}.**
|
1111 |
+
*
|
1112 |
+
* The HTTP response status message (reason phrase). E.G. `OK` or `Internal Server Error`.
|
1113 |
+
* @since v0.11.10
|
1114 |
+
*/
|
1115 |
+
statusMessage?: string | undefined;
|
1116 |
+
/**
|
1117 |
+
* Calls `destroy()` on the socket that received the `IncomingMessage`. If `error`is provided, an `'error'` event is emitted on the socket and `error` is passed
|
1118 |
+
* as an argument to any listeners on the event.
|
1119 |
+
* @since v0.3.0
|
1120 |
+
*/
|
1121 |
+
destroy(error?: Error): this;
|
1122 |
+
}
|
1123 |
+
interface AgentOptions extends Partial<TcpSocketConnectOpts> {
|
1124 |
+
/**
|
1125 |
+
* Keep sockets around in a pool to be used by other requests in the future. Default = false
|
1126 |
+
*/
|
1127 |
+
keepAlive?: boolean | undefined;
|
1128 |
+
/**
|
1129 |
+
* When using HTTP KeepAlive, how often to send TCP KeepAlive packets over sockets being kept alive. Default = 1000.
|
1130 |
+
* Only relevant if keepAlive is set to true.
|
1131 |
+
*/
|
1132 |
+
keepAliveMsecs?: number | undefined;
|
1133 |
+
/**
|
1134 |
+
* Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity
|
1135 |
+
*/
|
1136 |
+
maxSockets?: number | undefined;
|
1137 |
+
/**
|
1138 |
+
* Maximum number of sockets allowed for all hosts in total. Each request will use a new socket until the maximum is reached. Default: Infinity.
|
1139 |
+
*/
|
1140 |
+
maxTotalSockets?: number | undefined;
|
1141 |
+
/**
|
1142 |
+
* Maximum number of sockets to leave open in a free state. Only relevant if keepAlive is set to true. Default = 256.
|
1143 |
+
*/
|
1144 |
+
maxFreeSockets?: number | undefined;
|
1145 |
+
/**
|
1146 |
+
* Socket timeout in milliseconds. This will set the timeout after the socket is connected.
|
1147 |
+
*/
|
1148 |
+
timeout?: number | undefined;
|
1149 |
+
/**
|
1150 |
+
* Scheduling strategy to apply when picking the next free socket to use.
|
1151 |
+
* @default `lifo`
|
1152 |
+
*/
|
1153 |
+
scheduling?: 'fifo' | 'lifo' | undefined;
|
1154 |
+
}
|
1155 |
+
/**
|
1156 |
+
* An `Agent` is responsible for managing connection persistence
|
1157 |
+
* and reuse for HTTP clients. It maintains a queue of pending requests
|
1158 |
+
* for a given host and port, reusing a single socket connection for each
|
1159 |
+
* until the queue is empty, at which time the socket is either destroyed
|
1160 |
+
* or put into a pool where it is kept to be used again for requests to the
|
1161 |
+
* same host and port. Whether it is destroyed or pooled depends on the`keepAlive` `option`.
|
1162 |
+
*
|
1163 |
+
* Pooled connections have TCP Keep-Alive enabled for them, but servers may
|
1164 |
+
* still close idle connections, in which case they will be removed from the
|
1165 |
+
* pool and a new connection will be made when a new HTTP request is made for
|
1166 |
+
* that host and port. Servers may also refuse to allow multiple requests
|
1167 |
+
* over the same connection, in which case the connection will have to be
|
1168 |
+
* remade for every request and cannot be pooled. The `Agent` will still make
|
1169 |
+
* the requests to that server, but each one will occur over a new connection.
|
1170 |
+
*
|
1171 |
+
* When a connection is closed by the client or the server, it is removed
|
1172 |
+
* from the pool. Any unused sockets in the pool will be unrefed so as not
|
1173 |
+
* to keep the Node.js process running when there are no outstanding requests.
|
1174 |
+
* (see `socket.unref()`).
|
1175 |
+
*
|
1176 |
+
* It is good practice, to `destroy()` an `Agent` instance when it is no
|
1177 |
+
* longer in use, because unused sockets consume OS resources.
|
1178 |
+
*
|
1179 |
+
* Sockets are removed from an agent when the socket emits either
|
1180 |
+
* a `'close'` event or an `'agentRemove'` event. When intending to keep one
|
1181 |
+
* HTTP request open for a long time without keeping it in the agent, something
|
1182 |
+
* like the following may be done:
|
1183 |
+
*
|
1184 |
+
* ```js
|
1185 |
+
* http.get(options, (res) => {
|
1186 |
+
* // Do stuff
|
1187 |
+
* }).on('socket', (socket) => {
|
1188 |
+
* socket.emit('agentRemove');
|
1189 |
+
* });
|
1190 |
+
* ```
|
1191 |
+
*
|
1192 |
+
* An agent may also be used for an individual request. By providing`{agent: false}` as an option to the `http.get()` or `http.request()`functions, a one-time use `Agent` with default options
|
1193 |
+
* will be used
|
1194 |
+
* for the client connection.
|
1195 |
+
*
|
1196 |
+
* `agent:false`:
|
1197 |
+
*
|
1198 |
+
* ```js
|
1199 |
+
* http.get({
|
1200 |
+
* hostname: 'localhost',
|
1201 |
+
* port: 80,
|
1202 |
+
* path: '/',
|
1203 |
+
* agent: false // Create a new agent just for this one request
|
1204 |
+
* }, (res) => {
|
1205 |
+
* // Do stuff with response
|
1206 |
+
* });
|
1207 |
+
* ```
|
1208 |
+
* @since v0.3.4
|
1209 |
+
*/
|
1210 |
+
class Agent {
|
1211 |
+
/**
|
1212 |
+
* By default set to 256\. For agents with `keepAlive` enabled, this
|
1213 |
+
* sets the maximum number of sockets that will be left open in the free
|
1214 |
+
* state.
|
1215 |
+
* @since v0.11.7
|
1216 |
+
*/
|
1217 |
+
maxFreeSockets: number;
|
1218 |
+
/**
|
1219 |
+
* By default set to `Infinity`. Determines how many concurrent sockets the agent
|
1220 |
+
* can have open per origin. Origin is the returned value of `agent.getName()`.
|
1221 |
+
* @since v0.3.6
|
1222 |
+
*/
|
1223 |
+
maxSockets: number;
|
1224 |
+
/**
|
1225 |
+
* By default set to `Infinity`. Determines how many concurrent sockets the agent
|
1226 |
+
* can have open. Unlike `maxSockets`, this parameter applies across all origins.
|
1227 |
+
* @since v14.5.0, v12.19.0
|
1228 |
+
*/
|
1229 |
+
maxTotalSockets: number;
|
1230 |
+
/**
|
1231 |
+
* An object which contains arrays of sockets currently awaiting use by
|
1232 |
+
* the agent when `keepAlive` is enabled. Do not modify.
|
1233 |
+
*
|
1234 |
+
* Sockets in the `freeSockets` list will be automatically destroyed and
|
1235 |
+
* removed from the array on `'timeout'`.
|
1236 |
+
* @since v0.11.4
|
1237 |
+
*/
|
1238 |
+
readonly freeSockets: NodeJS.ReadOnlyDict<Socket[]>;
|
1239 |
+
/**
|
1240 |
+
* An object which contains arrays of sockets currently in use by the
|
1241 |
+
* agent. Do not modify.
|
1242 |
+
* @since v0.3.6
|
1243 |
+
*/
|
1244 |
+
readonly sockets: NodeJS.ReadOnlyDict<Socket[]>;
|
1245 |
+
/**
|
1246 |
+
* An object which contains queues of requests that have not yet been assigned to
|
1247 |
+
* sockets. Do not modify.
|
1248 |
+
* @since v0.5.9
|
1249 |
+
*/
|
1250 |
+
readonly requests: NodeJS.ReadOnlyDict<IncomingMessage[]>;
|
1251 |
+
constructor(opts?: AgentOptions);
|
1252 |
+
/**
|
1253 |
+
* Destroy any sockets that are currently in use by the agent.
|
1254 |
+
*
|
1255 |
+
* It is usually not necessary to do this. However, if using an
|
1256 |
+
* agent with `keepAlive` enabled, then it is best to explicitly shut down
|
1257 |
+
* the agent when it is no longer needed. Otherwise,
|
1258 |
+
* sockets might stay open for quite a long time before the server
|
1259 |
+
* terminates them.
|
1260 |
+
* @since v0.11.4
|
1261 |
+
*/
|
1262 |
+
destroy(): void;
|
1263 |
+
}
|
1264 |
+
const METHODS: string[];
|
1265 |
+
const STATUS_CODES: {
|
1266 |
+
[errorCode: number]: string | undefined;
|
1267 |
+
[errorCode: string]: string | undefined;
|
1268 |
+
};
|
1269 |
+
/**
|
1270 |
+
* Returns a new instance of {@link Server}.
|
1271 |
+
*
|
1272 |
+
* The `requestListener` is a function which is automatically
|
1273 |
+
* added to the `'request'` event.
|
1274 |
+
* @since v0.1.13
|
1275 |
+
*/
|
1276 |
+
function createServer<
|
1277 |
+
Request extends typeof IncomingMessage = typeof IncomingMessage,
|
1278 |
+
Response extends typeof ServerResponse = typeof ServerResponse,
|
1279 |
+
>(requestListener?: RequestListener<Request, Response>): Server<Request, Response>;
|
1280 |
+
function createServer<
|
1281 |
+
Request extends typeof IncomingMessage = typeof IncomingMessage,
|
1282 |
+
Response extends typeof ServerResponse = typeof ServerResponse,
|
1283 |
+
>(
|
1284 |
+
options: ServerOptions<Request, Response>,
|
1285 |
+
requestListener?: RequestListener<Request, Response>,
|
1286 |
+
): Server<Request, Response>;
|
1287 |
+
// although RequestOptions are passed as ClientRequestArgs to ClientRequest directly,
|
1288 |
+
// create interface RequestOptions would make the naming more clear to developers
|
1289 |
+
interface RequestOptions extends ClientRequestArgs {}
|
1290 |
+
/**
|
1291 |
+
* `options` in `socket.connect()` are also supported.
|
1292 |
+
*
|
1293 |
+
* Node.js maintains several connections per server to make HTTP requests.
|
1294 |
+
* This function allows one to transparently issue requests.
|
1295 |
+
*
|
1296 |
+
* `url` can be a string or a `URL` object. If `url` is a
|
1297 |
+
* string, it is automatically parsed with `new URL()`. If it is a `URL` object, it will be automatically converted to an ordinary `options` object.
|
1298 |
+
*
|
1299 |
+
* If both `url` and `options` are specified, the objects are merged, with the`options` properties taking precedence.
|
1300 |
+
*
|
1301 |
+
* The optional `callback` parameter will be added as a one-time listener for
|
1302 |
+
* the `'response'` event.
|
1303 |
+
*
|
1304 |
+
* `http.request()` returns an instance of the {@link ClientRequest} class. The `ClientRequest` instance is a writable stream. If one needs to
|
1305 |
+
* upload a file with a POST request, then write to the `ClientRequest` object.
|
1306 |
+
*
|
1307 |
+
* ```js
|
1308 |
+
* const http = require('http');
|
1309 |
+
*
|
1310 |
+
* const postData = JSON.stringify({
|
1311 |
+
* 'msg': 'Hello World!'
|
1312 |
+
* });
|
1313 |
+
*
|
1314 |
+
* const options = {
|
1315 |
+
* hostname: 'www.google.com',
|
1316 |
+
* port: 80,
|
1317 |
+
* path: '/upload',
|
1318 |
+
* method: 'POST',
|
1319 |
+
* headers: {
|
1320 |
+
* 'Content-Type': 'application/json',
|
1321 |
+
* 'Content-Length': Buffer.byteLength(postData)
|
1322 |
+
* }
|
1323 |
+
* };
|
1324 |
+
*
|
1325 |
+
* const req = http.request(options, (res) => {
|
1326 |
+
* console.log(`STATUS: ${res.statusCode}`);
|
1327 |
+
* console.log(`HEADERS: ${JSON.stringify(res.headers)}`);
|
1328 |
+
* res.setEncoding('utf8');
|
1329 |
+
* res.on('data', (chunk) => {
|
1330 |
+
* console.log(`BODY: ${chunk}`);
|
1331 |
+
* });
|
1332 |
+
* res.on('end', () => {
|
1333 |
+
* console.log('No more data in response.');
|
1334 |
+
* });
|
1335 |
+
* });
|
1336 |
+
*
|
1337 |
+
* req.on('error', (e) => {
|
1338 |
+
* console.error(`problem with request: ${e.message}`);
|
1339 |
+
* });
|
1340 |
+
*
|
1341 |
+
* // Write data to request body
|
1342 |
+
* req.write(postData);
|
1343 |
+
* req.end();
|
1344 |
+
* ```
|
1345 |
+
*
|
1346 |
+
* In the example `req.end()` was called. With `http.request()` one
|
1347 |
+
* must always call `req.end()` to signify the end of the request -
|
1348 |
+
* even if there is no data being written to the request body.
|
1349 |
+
*
|
1350 |
+
* If any error is encountered during the request (be that with DNS resolution,
|
1351 |
+
* TCP level errors, or actual HTTP parse errors) an `'error'` event is emitted
|
1352 |
+
* on the returned request object. As with all `'error'` events, if no listeners
|
1353 |
+
* are registered the error will be thrown.
|
1354 |
+
*
|
1355 |
+
* There are a few special headers that should be noted.
|
1356 |
+
*
|
1357 |
+
* * Sending a 'Connection: keep-alive' will notify Node.js that the connection to
|
1358 |
+
* the server should be persisted until the next request.
|
1359 |
+
* * Sending a 'Content-Length' header will disable the default chunked encoding.
|
1360 |
+
* * Sending an 'Expect' header will immediately send the request headers.
|
1361 |
+
* Usually, when sending 'Expect: 100-continue', both a timeout and a listener
|
1362 |
+
* for the `'continue'` event should be set. See RFC 2616 Section 8.2.3 for more
|
1363 |
+
* information.
|
1364 |
+
* * Sending an Authorization header will override using the `auth` option
|
1365 |
+
* to compute basic authentication.
|
1366 |
+
*
|
1367 |
+
* Example using a `URL` as `options`:
|
1368 |
+
*
|
1369 |
+
* ```js
|
1370 |
+
* const options = new URL('http://abc:xyz@example.com');
|
1371 |
+
*
|
1372 |
+
* const req = http.request(options, (res) => {
|
1373 |
+
* // ...
|
1374 |
+
* });
|
1375 |
+
* ```
|
1376 |
+
*
|
1377 |
+
* In a successful request, the following events will be emitted in the following
|
1378 |
+
* order:
|
1379 |
+
*
|
1380 |
+
* * `'socket'`
|
1381 |
+
* * `'response'`
|
1382 |
+
* * `'data'` any number of times, on the `res` object
|
1383 |
+
* (`'data'` will not be emitted at all if the response body is empty, for
|
1384 |
+
* instance, in most redirects)
|
1385 |
+
* * `'end'` on the `res` object
|
1386 |
+
* * `'close'`
|
1387 |
+
*
|
1388 |
+
* In the case of a connection error, the following events will be emitted:
|
1389 |
+
*
|
1390 |
+
* * `'socket'`
|
1391 |
+
* * `'error'`
|
1392 |
+
* * `'close'`
|
1393 |
+
*
|
1394 |
+
* In the case of a premature connection close before the response is received,
|
1395 |
+
* the following events will be emitted in the following order:
|
1396 |
+
*
|
1397 |
+
* * `'socket'`
|
1398 |
+
* * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`
|
1399 |
+
* * `'close'`
|
1400 |
+
*
|
1401 |
+
* In the case of a premature connection close after the response is received,
|
1402 |
+
* the following events will be emitted in the following order:
|
1403 |
+
*
|
1404 |
+
* * `'socket'`
|
1405 |
+
* * `'response'`
|
1406 |
+
* * `'data'` any number of times, on the `res` object
|
1407 |
+
* * (connection closed here)
|
1408 |
+
* * `'aborted'` on the `res` object
|
1409 |
+
* * `'error'` on the `res` object with an error with message`'Error: aborted'` and code `'ECONNRESET'`.
|
1410 |
+
* * `'close'`
|
1411 |
+
* * `'close'` on the `res` object
|
1412 |
+
*
|
1413 |
+
* If `req.destroy()` is called before a socket is assigned, the following
|
1414 |
+
* events will be emitted in the following order:
|
1415 |
+
*
|
1416 |
+
* * (`req.destroy()` called here)
|
1417 |
+
* * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`
|
1418 |
+
* * `'close'`
|
1419 |
+
*
|
1420 |
+
* If `req.destroy()` is called before the connection succeeds, the following
|
1421 |
+
* events will be emitted in the following order:
|
1422 |
+
*
|
1423 |
+
* * `'socket'`
|
1424 |
+
* * (`req.destroy()` called here)
|
1425 |
+
* * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`
|
1426 |
+
* * `'close'`
|
1427 |
+
*
|
1428 |
+
* If `req.destroy()` is called after the response is received, the following
|
1429 |
+
* events will be emitted in the following order:
|
1430 |
+
*
|
1431 |
+
* * `'socket'`
|
1432 |
+
* * `'response'`
|
1433 |
+
* * `'data'` any number of times, on the `res` object
|
1434 |
+
* * (`req.destroy()` called here)
|
1435 |
+
* * `'aborted'` on the `res` object
|
1436 |
+
* * `'error'` on the `res` object with an error with message`'Error: aborted'` and code `'ECONNRESET'`.
|
1437 |
+
* * `'close'`
|
1438 |
+
* * `'close'` on the `res` object
|
1439 |
+
*
|
1440 |
+
* If `req.abort()` is called before a socket is assigned, the following
|
1441 |
+
* events will be emitted in the following order:
|
1442 |
+
*
|
1443 |
+
* * (`req.abort()` called here)
|
1444 |
+
* * `'abort'`
|
1445 |
+
* * `'close'`
|
1446 |
+
*
|
1447 |
+
* If `req.abort()` is called before the connection succeeds, the following
|
1448 |
+
* events will be emitted in the following order:
|
1449 |
+
*
|
1450 |
+
* * `'socket'`
|
1451 |
+
* * (`req.abort()` called here)
|
1452 |
+
* * `'abort'`
|
1453 |
+
* * `'error'` with an error with message `'Error: socket hang up'` and code`'ECONNRESET'`
|
1454 |
+
* * `'close'`
|
1455 |
+
*
|
1456 |
+
* If `req.abort()` is called after the response is received, the following
|
1457 |
+
* events will be emitted in the following order:
|
1458 |
+
*
|
1459 |
+
* * `'socket'`
|
1460 |
+
* * `'response'`
|
1461 |
+
* * `'data'` any number of times, on the `res` object
|
1462 |
+
* * (`req.abort()` called here)
|
1463 |
+
* * `'abort'`
|
1464 |
+
* * `'aborted'` on the `res` object
|
1465 |
+
* * `'error'` on the `res` object with an error with message`'Error: aborted'` and code `'ECONNRESET'`.
|
1466 |
+
* * `'close'`
|
1467 |
+
* * `'close'` on the `res` object
|
1468 |
+
*
|
1469 |
+
* Setting the `timeout` option or using the `setTimeout()` function will
|
1470 |
+
* not abort the request or do anything besides add a `'timeout'` event.
|
1471 |
+
*
|
1472 |
+
* Passing an `AbortSignal` and then calling `abort` on the corresponding`AbortController` will behave the same way as calling `.destroy()` on the
|
1473 |
+
* request itself.
|
1474 |
+
* @since v0.3.6
|
1475 |
+
*/
|
1476 |
+
function request(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest;
|
1477 |
+
function request(
|
1478 |
+
url: string | URL,
|
1479 |
+
options: RequestOptions,
|
1480 |
+
callback?: (res: IncomingMessage) => void,
|
1481 |
+
): ClientRequest;
|
1482 |
+
/**
|
1483 |
+
* Since most requests are GET requests without bodies, Node.js provides this
|
1484 |
+
* convenience method. The only difference between this method and {@link request} is that it sets the method to GET and calls `req.end()`automatically. The callback must take care to consume the
|
1485 |
+
* response
|
1486 |
+
* data for reasons stated in {@link ClientRequest} section.
|
1487 |
+
*
|
1488 |
+
* The `callback` is invoked with a single argument that is an instance of {@link IncomingMessage}.
|
1489 |
+
*
|
1490 |
+
* JSON fetching example:
|
1491 |
+
*
|
1492 |
+
* ```js
|
1493 |
+
* http.get('http://localhost:8000/', (res) => {
|
1494 |
+
* const { statusCode } = res;
|
1495 |
+
* const contentType = res.headers['content-type'];
|
1496 |
+
*
|
1497 |
+
* let error;
|
1498 |
+
* // Any 2xx status code signals a successful response but
|
1499 |
+
* // here we're only checking for 200.
|
1500 |
+
* if (statusCode !== 200) {
|
1501 |
+
* error = new Error('Request Failed.\n' +
|
1502 |
+
* `Status Code: ${statusCode}`);
|
1503 |
+
* } else if (!/^application\/json/.test(contentType)) {
|
1504 |
+
* error = new Error('Invalid content-type.\n' +
|
1505 |
+
* `Expected application/json but received ${contentType}`);
|
1506 |
+
* }
|
1507 |
+
* if (error) {
|
1508 |
+
* console.error(error.message);
|
1509 |
+
* // Consume response data to free up memory
|
1510 |
+
* res.resume();
|
1511 |
+
* return;
|
1512 |
+
* }
|
1513 |
+
*
|
1514 |
+
* res.setEncoding('utf8');
|
1515 |
+
* let rawData = '';
|
1516 |
+
* res.on('data', (chunk) => { rawData += chunk; });
|
1517 |
+
* res.on('end', () => {
|
1518 |
+
* try {
|
1519 |
+
* const parsedData = JSON.parse(rawData);
|
1520 |
+
* console.log(parsedData);
|
1521 |
+
* } catch (e) {
|
1522 |
+
* console.error(e.message);
|
1523 |
+
* }
|
1524 |
+
* });
|
1525 |
+
* }).on('error', (e) => {
|
1526 |
+
* console.error(`Got error: ${e.message}`);
|
1527 |
+
* });
|
1528 |
+
*
|
1529 |
+
* // Create a local server to receive data from
|
1530 |
+
* const server = http.createServer((req, res) => {
|
1531 |
+
* res.writeHead(200, { 'Content-Type': 'application/json' });
|
1532 |
+
* res.end(JSON.stringify({
|
1533 |
+
* data: 'Hello World!'
|
1534 |
+
* }));
|
1535 |
+
* });
|
1536 |
+
*
|
1537 |
+
* server.listen(8000);
|
1538 |
+
* ```
|
1539 |
+
* @since v0.3.6
|
1540 |
+
* @param options Accepts the same `options` as {@link request}, with the `method` always set to `GET`. Properties that are inherited from the prototype are ignored.
|
1541 |
+
*/
|
1542 |
+
function get(options: RequestOptions | string | URL, callback?: (res: IncomingMessage) => void): ClientRequest;
|
1543 |
+
function get(url: string | URL, options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest;
|
1544 |
+
let globalAgent: Agent;
|
1545 |
+
/**
|
1546 |
+
* Read-only property specifying the maximum allowed size of HTTP headers in bytes.
|
1547 |
+
* Defaults to 16KB. Configurable using the `--max-http-header-size` CLI option.
|
1548 |
+
*/
|
1549 |
+
const maxHeaderSize: number;
|
1550 |
+
}
|
1551 |
+
declare module 'node:http' {
|
1552 |
+
export * from 'http';
|
1553 |
+
}
|
igv_component/node_modules/@types/node/http2.d.ts
ADDED
The diff for this file is too large to render.
See raw diff
|
|
igv_component/node_modules/@types/node/https.d.ts
ADDED
@@ -0,0 +1,541 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* HTTPS is the HTTP protocol over TLS/SSL. In Node.js this is implemented as a
|
3 |
+
* separate module.
|
4 |
+
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/https.js)
|
5 |
+
*/
|
6 |
+
declare module 'https' {
|
7 |
+
import { Duplex } from 'node:stream';
|
8 |
+
import * as tls from 'node:tls';
|
9 |
+
import * as http from 'node:http';
|
10 |
+
import { URL } from 'node:url';
|
11 |
+
type ServerOptions<
|
12 |
+
Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
|
13 |
+
Response extends typeof http.ServerResponse = typeof http.ServerResponse,
|
14 |
+
> = tls.SecureContextOptions & tls.TlsOptions & http.ServerOptions<Request, Response>;
|
15 |
+
type RequestOptions = http.RequestOptions &
|
16 |
+
tls.SecureContextOptions & {
|
17 |
+
rejectUnauthorized?: boolean | undefined; // Defaults to true
|
18 |
+
servername?: string | undefined; // SNI TLS Extension
|
19 |
+
};
|
20 |
+
interface AgentOptions extends http.AgentOptions, tls.ConnectionOptions {
|
21 |
+
rejectUnauthorized?: boolean | undefined;
|
22 |
+
maxCachedSessions?: number | undefined;
|
23 |
+
}
|
24 |
+
/**
|
25 |
+
* An `Agent` object for HTTPS similar to `http.Agent`. See {@link request} for more information.
|
26 |
+
* @since v0.4.5
|
27 |
+
*/
|
28 |
+
class Agent extends http.Agent {
|
29 |
+
constructor(options?: AgentOptions);
|
30 |
+
options: AgentOptions;
|
31 |
+
}
|
32 |
+
interface Server<
|
33 |
+
Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
|
34 |
+
Response extends typeof http.ServerResponse = typeof http.ServerResponse,
|
35 |
+
> extends http.Server<Request, Response> {}
|
36 |
+
/**
|
37 |
+
* See `http.Server` for more information.
|
38 |
+
* @since v0.3.4
|
39 |
+
*/
|
40 |
+
class Server<
|
41 |
+
Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
|
42 |
+
Response extends typeof http.ServerResponse = typeof http.ServerResponse,
|
43 |
+
> extends tls.Server {
|
44 |
+
constructor(requestListener?: http.RequestListener<Request, Response>);
|
45 |
+
constructor(
|
46 |
+
options: ServerOptions<Request, Response>,
|
47 |
+
requestListener?: http.RequestListener<Request, Response>,
|
48 |
+
);
|
49 |
+
/**
|
50 |
+
* Closes all connections connected to this server.
|
51 |
+
* @since v18.2.0
|
52 |
+
*/
|
53 |
+
closeAllConnections(): void;
|
54 |
+
/**
|
55 |
+
* Closes all connections connected to this server which are not sending a request or waiting for a response.
|
56 |
+
* @since v18.2.0
|
57 |
+
*/
|
58 |
+
closeIdleConnections(): void;
|
59 |
+
addListener(event: string, listener: (...args: any[]) => void): this;
|
60 |
+
addListener(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
|
61 |
+
addListener(
|
62 |
+
event: 'newSession',
|
63 |
+
listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void,
|
64 |
+
): this;
|
65 |
+
addListener(
|
66 |
+
event: 'OCSPRequest',
|
67 |
+
listener: (
|
68 |
+
certificate: Buffer,
|
69 |
+
issuer: Buffer,
|
70 |
+
callback: (err: Error | null, resp: Buffer) => void,
|
71 |
+
) => void,
|
72 |
+
): this;
|
73 |
+
addListener(
|
74 |
+
event: 'resumeSession',
|
75 |
+
listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void,
|
76 |
+
): this;
|
77 |
+
addListener(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this;
|
78 |
+
addListener(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
|
79 |
+
addListener(event: 'close', listener: () => void): this;
|
80 |
+
addListener(event: 'connection', listener: (socket: Duplex) => void): this;
|
81 |
+
addListener(event: 'error', listener: (err: Error) => void): this;
|
82 |
+
addListener(event: 'listening', listener: () => void): this;
|
83 |
+
addListener(event: 'checkContinue', listener: http.RequestListener<Request, Response>): this;
|
84 |
+
addListener(event: 'checkExpectation', listener: http.RequestListener<Request, Response>): this;
|
85 |
+
addListener(event: 'clientError', listener: (err: Error, socket: Duplex) => void): this;
|
86 |
+
addListener(
|
87 |
+
event: 'connect',
|
88 |
+
listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
|
89 |
+
): this;
|
90 |
+
addListener(event: 'request', listener: http.RequestListener<Request, Response>): this;
|
91 |
+
addListener(
|
92 |
+
event: 'upgrade',
|
93 |
+
listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
|
94 |
+
): this;
|
95 |
+
emit(event: string, ...args: any[]): boolean;
|
96 |
+
emit(event: 'keylog', line: Buffer, tlsSocket: tls.TLSSocket): boolean;
|
97 |
+
emit(
|
98 |
+
event: 'newSession',
|
99 |
+
sessionId: Buffer,
|
100 |
+
sessionData: Buffer,
|
101 |
+
callback: (err: Error, resp: Buffer) => void,
|
102 |
+
): boolean;
|
103 |
+
emit(
|
104 |
+
event: 'OCSPRequest',
|
105 |
+
certificate: Buffer,
|
106 |
+
issuer: Buffer,
|
107 |
+
callback: (err: Error | null, resp: Buffer) => void,
|
108 |
+
): boolean;
|
109 |
+
emit(event: 'resumeSession', sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void): boolean;
|
110 |
+
emit(event: 'secureConnection', tlsSocket: tls.TLSSocket): boolean;
|
111 |
+
emit(event: 'tlsClientError', err: Error, tlsSocket: tls.TLSSocket): boolean;
|
112 |
+
emit(event: 'close'): boolean;
|
113 |
+
emit(event: 'connection', socket: Duplex): boolean;
|
114 |
+
emit(event: 'error', err: Error): boolean;
|
115 |
+
emit(event: 'listening'): boolean;
|
116 |
+
emit(
|
117 |
+
event: 'checkContinue',
|
118 |
+
req: InstanceType<Request>,
|
119 |
+
res: InstanceType<Response> & { req: InstanceType<Request> },
|
120 |
+
): boolean;
|
121 |
+
emit(
|
122 |
+
event: 'checkExpectation',
|
123 |
+
req: InstanceType<Request>,
|
124 |
+
res: InstanceType<Response> & { req: InstanceType<Request> },
|
125 |
+
): boolean;
|
126 |
+
emit(event: 'clientError', err: Error, socket: Duplex): boolean;
|
127 |
+
emit(event: 'connect', req: InstanceType<Request>, socket: Duplex, head: Buffer): boolean;
|
128 |
+
emit(
|
129 |
+
event: 'request',
|
130 |
+
req: InstanceType<Request>,
|
131 |
+
res: InstanceType<Response> & { req: InstanceType<Request> },
|
132 |
+
): boolean;
|
133 |
+
emit(event: 'upgrade', req: InstanceType<Request>, socket: Duplex, head: Buffer): boolean;
|
134 |
+
on(event: string, listener: (...args: any[]) => void): this;
|
135 |
+
on(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
|
136 |
+
on(
|
137 |
+
event: 'newSession',
|
138 |
+
listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void,
|
139 |
+
): this;
|
140 |
+
on(
|
141 |
+
event: 'OCSPRequest',
|
142 |
+
listener: (
|
143 |
+
certificate: Buffer,
|
144 |
+
issuer: Buffer,
|
145 |
+
callback: (err: Error | null, resp: Buffer) => void,
|
146 |
+
) => void,
|
147 |
+
): this;
|
148 |
+
on(
|
149 |
+
event: 'resumeSession',
|
150 |
+
listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void,
|
151 |
+
): this;
|
152 |
+
on(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this;
|
153 |
+
on(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
|
154 |
+
on(event: 'close', listener: () => void): this;
|
155 |
+
on(event: 'connection', listener: (socket: Duplex) => void): this;
|
156 |
+
on(event: 'error', listener: (err: Error) => void): this;
|
157 |
+
on(event: 'listening', listener: () => void): this;
|
158 |
+
on(event: 'checkContinue', listener: http.RequestListener<Request, Response>): this;
|
159 |
+
on(event: 'checkExpectation', listener: http.RequestListener<Request, Response>): this;
|
160 |
+
on(event: 'clientError', listener: (err: Error, socket: Duplex) => void): this;
|
161 |
+
on(event: 'connect', listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void): this;
|
162 |
+
on(event: 'request', listener: http.RequestListener<Request, Response>): this;
|
163 |
+
on(event: 'upgrade', listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void): this;
|
164 |
+
once(event: string, listener: (...args: any[]) => void): this;
|
165 |
+
once(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
|
166 |
+
once(
|
167 |
+
event: 'newSession',
|
168 |
+
listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void,
|
169 |
+
): this;
|
170 |
+
once(
|
171 |
+
event: 'OCSPRequest',
|
172 |
+
listener: (
|
173 |
+
certificate: Buffer,
|
174 |
+
issuer: Buffer,
|
175 |
+
callback: (err: Error | null, resp: Buffer) => void,
|
176 |
+
) => void,
|
177 |
+
): this;
|
178 |
+
once(
|
179 |
+
event: 'resumeSession',
|
180 |
+
listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void,
|
181 |
+
): this;
|
182 |
+
once(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this;
|
183 |
+
once(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
|
184 |
+
once(event: 'close', listener: () => void): this;
|
185 |
+
once(event: 'connection', listener: (socket: Duplex) => void): this;
|
186 |
+
once(event: 'error', listener: (err: Error) => void): this;
|
187 |
+
once(event: 'listening', listener: () => void): this;
|
188 |
+
once(event: 'checkContinue', listener: http.RequestListener<Request, Response>): this;
|
189 |
+
once(event: 'checkExpectation', listener: http.RequestListener<Request, Response>): this;
|
190 |
+
once(event: 'clientError', listener: (err: Error, socket: Duplex) => void): this;
|
191 |
+
once(event: 'connect', listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void): this;
|
192 |
+
once(event: 'request', listener: http.RequestListener<Request, Response>): this;
|
193 |
+
once(event: 'upgrade', listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void): this;
|
194 |
+
prependListener(event: string, listener: (...args: any[]) => void): this;
|
195 |
+
prependListener(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
|
196 |
+
prependListener(
|
197 |
+
event: 'newSession',
|
198 |
+
listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void,
|
199 |
+
): this;
|
200 |
+
prependListener(
|
201 |
+
event: 'OCSPRequest',
|
202 |
+
listener: (
|
203 |
+
certificate: Buffer,
|
204 |
+
issuer: Buffer,
|
205 |
+
callback: (err: Error | null, resp: Buffer) => void,
|
206 |
+
) => void,
|
207 |
+
): this;
|
208 |
+
prependListener(
|
209 |
+
event: 'resumeSession',
|
210 |
+
listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void,
|
211 |
+
): this;
|
212 |
+
prependListener(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this;
|
213 |
+
prependListener(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
|
214 |
+
prependListener(event: 'close', listener: () => void): this;
|
215 |
+
prependListener(event: 'connection', listener: (socket: Duplex) => void): this;
|
216 |
+
prependListener(event: 'error', listener: (err: Error) => void): this;
|
217 |
+
prependListener(event: 'listening', listener: () => void): this;
|
218 |
+
prependListener(event: 'checkContinue', listener: http.RequestListener<Request, Response>): this;
|
219 |
+
prependListener(event: 'checkExpectation', listener: http.RequestListener<Request, Response>): this;
|
220 |
+
prependListener(event: 'clientError', listener: (err: Error, socket: Duplex) => void): this;
|
221 |
+
prependListener(
|
222 |
+
event: 'connect',
|
223 |
+
listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
|
224 |
+
): this;
|
225 |
+
prependListener(event: 'request', listener: http.RequestListener<Request, Response>): this;
|
226 |
+
prependListener(
|
227 |
+
event: 'upgrade',
|
228 |
+
listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
|
229 |
+
): this;
|
230 |
+
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
231 |
+
prependOnceListener(event: 'keylog', listener: (line: Buffer, tlsSocket: tls.TLSSocket) => void): this;
|
232 |
+
prependOnceListener(
|
233 |
+
event: 'newSession',
|
234 |
+
listener: (sessionId: Buffer, sessionData: Buffer, callback: (err: Error, resp: Buffer) => void) => void,
|
235 |
+
): this;
|
236 |
+
prependOnceListener(
|
237 |
+
event: 'OCSPRequest',
|
238 |
+
listener: (
|
239 |
+
certificate: Buffer,
|
240 |
+
issuer: Buffer,
|
241 |
+
callback: (err: Error | null, resp: Buffer) => void,
|
242 |
+
) => void,
|
243 |
+
): this;
|
244 |
+
prependOnceListener(
|
245 |
+
event: 'resumeSession',
|
246 |
+
listener: (sessionId: Buffer, callback: (err: Error, sessionData: Buffer) => void) => void,
|
247 |
+
): this;
|
248 |
+
prependOnceListener(event: 'secureConnection', listener: (tlsSocket: tls.TLSSocket) => void): this;
|
249 |
+
prependOnceListener(event: 'tlsClientError', listener: (err: Error, tlsSocket: tls.TLSSocket) => void): this;
|
250 |
+
prependOnceListener(event: 'close', listener: () => void): this;
|
251 |
+
prependOnceListener(event: 'connection', listener: (socket: Duplex) => void): this;
|
252 |
+
prependOnceListener(event: 'error', listener: (err: Error) => void): this;
|
253 |
+
prependOnceListener(event: 'listening', listener: () => void): this;
|
254 |
+
prependOnceListener(event: 'checkContinue', listener: http.RequestListener<Request, Response>): this;
|
255 |
+
prependOnceListener(event: 'checkExpectation', listener: http.RequestListener<Request, Response>): this;
|
256 |
+
prependOnceListener(event: 'clientError', listener: (err: Error, socket: Duplex) => void): this;
|
257 |
+
prependOnceListener(
|
258 |
+
event: 'connect',
|
259 |
+
listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
|
260 |
+
): this;
|
261 |
+
prependOnceListener(event: 'request', listener: http.RequestListener<Request, Response>): this;
|
262 |
+
prependOnceListener(
|
263 |
+
event: 'upgrade',
|
264 |
+
listener: (req: InstanceType<Request>, socket: Duplex, head: Buffer) => void,
|
265 |
+
): this;
|
266 |
+
}
|
267 |
+
/**
|
268 |
+
* ```js
|
269 |
+
* // curl -k https://localhost:8000/
|
270 |
+
* const https = require('https');
|
271 |
+
* const fs = require('fs');
|
272 |
+
*
|
273 |
+
* const options = {
|
274 |
+
* key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
|
275 |
+
* cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem')
|
276 |
+
* };
|
277 |
+
*
|
278 |
+
* https.createServer(options, (req, res) => {
|
279 |
+
* res.writeHead(200);
|
280 |
+
* res.end('hello world\n');
|
281 |
+
* }).listen(8000);
|
282 |
+
* ```
|
283 |
+
*
|
284 |
+
* Or
|
285 |
+
*
|
286 |
+
* ```js
|
287 |
+
* const https = require('https');
|
288 |
+
* const fs = require('fs');
|
289 |
+
*
|
290 |
+
* const options = {
|
291 |
+
* pfx: fs.readFileSync('test/fixtures/test_cert.pfx'),
|
292 |
+
* passphrase: 'sample'
|
293 |
+
* };
|
294 |
+
*
|
295 |
+
* https.createServer(options, (req, res) => {
|
296 |
+
* res.writeHead(200);
|
297 |
+
* res.end('hello world\n');
|
298 |
+
* }).listen(8000);
|
299 |
+
* ```
|
300 |
+
* @since v0.3.4
|
301 |
+
* @param options Accepts `options` from `createServer`, `createSecureContext` and `createServer`.
|
302 |
+
* @param requestListener A listener to be added to the `'request'` event.
|
303 |
+
*/
|
304 |
+
function createServer<
|
305 |
+
Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
|
306 |
+
Response extends typeof http.ServerResponse = typeof http.ServerResponse,
|
307 |
+
>(requestListener?: http.RequestListener<Request, Response>): Server<Request, Response>;
|
308 |
+
function createServer<
|
309 |
+
Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
|
310 |
+
Response extends typeof http.ServerResponse = typeof http.ServerResponse,
|
311 |
+
>(
|
312 |
+
options: ServerOptions<Request, Response>,
|
313 |
+
requestListener?: http.RequestListener<Request, Response>,
|
314 |
+
): Server<Request, Response>;
|
315 |
+
/**
|
316 |
+
* Makes a request to a secure web server.
|
317 |
+
*
|
318 |
+
* The following additional `options` from `tls.connect()` are also accepted:`ca`, `cert`, `ciphers`, `clientCertEngine`, `crl`, `dhparam`, `ecdhCurve`,`honorCipherOrder`, `key`, `passphrase`,
|
319 |
+
* `pfx`, `rejectUnauthorized`,`secureOptions`, `secureProtocol`, `servername`, `sessionIdContext`,`highWaterMark`.
|
320 |
+
*
|
321 |
+
* `options` can be an object, a string, or a `URL` object. If `options` is a
|
322 |
+
* string, it is automatically parsed with `new URL()`. If it is a `URL` object, it will be automatically converted to an ordinary `options` object.
|
323 |
+
*
|
324 |
+
* `https.request()` returns an instance of the `http.ClientRequest` class. The `ClientRequest` instance is a writable stream. If one needs to
|
325 |
+
* upload a file with a POST request, then write to the `ClientRequest` object.
|
326 |
+
*
|
327 |
+
* ```js
|
328 |
+
* const https = require('https');
|
329 |
+
*
|
330 |
+
* const options = {
|
331 |
+
* hostname: 'encrypted.google.com',
|
332 |
+
* port: 443,
|
333 |
+
* path: '/',
|
334 |
+
* method: 'GET'
|
335 |
+
* };
|
336 |
+
*
|
337 |
+
* const req = https.request(options, (res) => {
|
338 |
+
* console.log('statusCode:', res.statusCode);
|
339 |
+
* console.log('headers:', res.headers);
|
340 |
+
*
|
341 |
+
* res.on('data', (d) => {
|
342 |
+
* process.stdout.write(d);
|
343 |
+
* });
|
344 |
+
* });
|
345 |
+
*
|
346 |
+
* req.on('error', (e) => {
|
347 |
+
* console.error(e);
|
348 |
+
* });
|
349 |
+
* req.end();
|
350 |
+
* ```
|
351 |
+
*
|
352 |
+
* Example using options from `tls.connect()`:
|
353 |
+
*
|
354 |
+
* ```js
|
355 |
+
* const options = {
|
356 |
+
* hostname: 'encrypted.google.com',
|
357 |
+
* port: 443,
|
358 |
+
* path: '/',
|
359 |
+
* method: 'GET',
|
360 |
+
* key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
|
361 |
+
* cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem')
|
362 |
+
* };
|
363 |
+
* options.agent = new https.Agent(options);
|
364 |
+
*
|
365 |
+
* const req = https.request(options, (res) => {
|
366 |
+
* // ...
|
367 |
+
* });
|
368 |
+
* ```
|
369 |
+
*
|
370 |
+
* Alternatively, opt out of connection pooling by not using an `Agent`.
|
371 |
+
*
|
372 |
+
* ```js
|
373 |
+
* const options = {
|
374 |
+
* hostname: 'encrypted.google.com',
|
375 |
+
* port: 443,
|
376 |
+
* path: '/',
|
377 |
+
* method: 'GET',
|
378 |
+
* key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
|
379 |
+
* cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'),
|
380 |
+
* agent: false
|
381 |
+
* };
|
382 |
+
*
|
383 |
+
* const req = https.request(options, (res) => {
|
384 |
+
* // ...
|
385 |
+
* });
|
386 |
+
* ```
|
387 |
+
*
|
388 |
+
* Example using a `URL` as `options`:
|
389 |
+
*
|
390 |
+
* ```js
|
391 |
+
* const options = new URL('https://abc:xyz@example.com');
|
392 |
+
*
|
393 |
+
* const req = https.request(options, (res) => {
|
394 |
+
* // ...
|
395 |
+
* });
|
396 |
+
* ```
|
397 |
+
*
|
398 |
+
* Example pinning on certificate fingerprint, or the public key (similar to`pin-sha256`):
|
399 |
+
*
|
400 |
+
* ```js
|
401 |
+
* const tls = require('tls');
|
402 |
+
* const https = require('https');
|
403 |
+
* const crypto = require('crypto');
|
404 |
+
*
|
405 |
+
* function sha256(s) {
|
406 |
+
* return crypto.createHash('sha256').update(s).digest('base64');
|
407 |
+
* }
|
408 |
+
* const options = {
|
409 |
+
* hostname: 'github.com',
|
410 |
+
* port: 443,
|
411 |
+
* path: '/',
|
412 |
+
* method: 'GET',
|
413 |
+
* checkServerIdentity: function(host, cert) {
|
414 |
+
* // Make sure the certificate is issued to the host we are connected to
|
415 |
+
* const err = tls.checkServerIdentity(host, cert);
|
416 |
+
* if (err) {
|
417 |
+
* return err;
|
418 |
+
* }
|
419 |
+
*
|
420 |
+
* // Pin the public key, similar to HPKP pin-sha25 pinning
|
421 |
+
* const pubkey256 = 'pL1+qb9HTMRZJmuC/bB/ZI9d302BYrrqiVuRyW+DGrU=';
|
422 |
+
* if (sha256(cert.pubkey) !== pubkey256) {
|
423 |
+
* const msg = 'Certificate verification error: ' +
|
424 |
+
* `The public key of '${cert.subject.CN}' ` +
|
425 |
+
* 'does not match our pinned fingerprint';
|
426 |
+
* return new Error(msg);
|
427 |
+
* }
|
428 |
+
*
|
429 |
+
* // Pin the exact certificate, rather than the pub key
|
430 |
+
* const cert256 = '25:FE:39:32:D9:63:8C:8A:FC:A1:9A:29:87:' +
|
431 |
+
* 'D8:3E:4C:1D:98:DB:71:E4:1A:48:03:98:EA:22:6A:BD:8B:93:16';
|
432 |
+
* if (cert.fingerprint256 !== cert256) {
|
433 |
+
* const msg = 'Certificate verification error: ' +
|
434 |
+
* `The certificate of '${cert.subject.CN}' ` +
|
435 |
+
* 'does not match our pinned fingerprint';
|
436 |
+
* return new Error(msg);
|
437 |
+
* }
|
438 |
+
*
|
439 |
+
* // This loop is informational only.
|
440 |
+
* // Print the certificate and public key fingerprints of all certs in the
|
441 |
+
* // chain. Its common to pin the public key of the issuer on the public
|
442 |
+
* // internet, while pinning the public key of the service in sensitive
|
443 |
+
* // environments.
|
444 |
+
* do {
|
445 |
+
* console.log('Subject Common Name:', cert.subject.CN);
|
446 |
+
* console.log(' Certificate SHA256 fingerprint:', cert.fingerprint256);
|
447 |
+
*
|
448 |
+
* hash = crypto.createHash('sha256');
|
449 |
+
* console.log(' Public key ping-sha256:', sha256(cert.pubkey));
|
450 |
+
*
|
451 |
+
* lastprint256 = cert.fingerprint256;
|
452 |
+
* cert = cert.issuerCertificate;
|
453 |
+
* } while (cert.fingerprint256 !== lastprint256);
|
454 |
+
*
|
455 |
+
* },
|
456 |
+
* };
|
457 |
+
*
|
458 |
+
* options.agent = new https.Agent(options);
|
459 |
+
* const req = https.request(options, (res) => {
|
460 |
+
* console.log('All OK. Server matched our pinned cert or public key');
|
461 |
+
* console.log('statusCode:', res.statusCode);
|
462 |
+
* // Print the HPKP values
|
463 |
+
* console.log('headers:', res.headers['public-key-pins']);
|
464 |
+
*
|
465 |
+
* res.on('data', (d) => {});
|
466 |
+
* });
|
467 |
+
*
|
468 |
+
* req.on('error', (e) => {
|
469 |
+
* console.error(e.message);
|
470 |
+
* });
|
471 |
+
* req.end();
|
472 |
+
* ```
|
473 |
+
*
|
474 |
+
* Outputs for example:
|
475 |
+
*
|
476 |
+
* ```text
|
477 |
+
* Subject Common Name: github.com
|
478 |
+
* Certificate SHA256 fingerprint: 25:FE:39:32:D9:63:8C:8A:FC:A1:9A:29:87:D8:3E:4C:1D:98:DB:71:E4:1A:48:03:98:EA:22:6A:BD:8B:93:16
|
479 |
+
* Public key ping-sha256: pL1+qb9HTMRZJmuC/bB/ZI9d302BYrrqiVuRyW+DGrU=
|
480 |
+
* Subject Common Name: DigiCert SHA2 Extended Validation Server CA
|
481 |
+
* Certificate SHA256 fingerprint: 40:3E:06:2A:26:53:05:91:13:28:5B:AF:80:A0:D4:AE:42:2C:84:8C:9F:78:FA:D0:1F:C9:4B:C5:B8:7F:EF:1A
|
482 |
+
* Public key ping-sha256: RRM1dGqnDFsCJXBTHky16vi1obOlCgFFn/yOhI/y+ho=
|
483 |
+
* Subject Common Name: DigiCert High Assurance EV Root CA
|
484 |
+
* Certificate SHA256 fingerprint: 74:31:E5:F4:C3:C1:CE:46:90:77:4F:0B:61:E0:54:40:88:3B:A9:A0:1E:D0:0B:A6:AB:D7:80:6E:D3:B1:18:CF
|
485 |
+
* Public key ping-sha256: WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18=
|
486 |
+
* All OK. Server matched our pinned cert or public key
|
487 |
+
* statusCode: 200
|
488 |
+
* headers: max-age=0; pin-sha256="WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18="; pin-sha256="RRM1dGqnDFsCJXBTHky16vi1obOlCgFFn/yOhI/y+ho=";
|
489 |
+
* pin-sha256="k2v657xBsOVe1PQRwOsHsw3bsGT2VzIqz5K+59sNQws="; pin-sha256="K87oWBWM9UZfyddvDfoxL+8lpNyoUB2ptGtn0fv6G2Q="; pin-sha256="IQBnNBEiFuhj+8x6X8XLgh01V9Ic5/V3IRQLNFFc7v4=";
|
490 |
+
* pin-sha256="iie1VXtL7HzAMF+/PVPR9xzT80kQxdZeJ+zduCB3uj0="; pin-sha256="LvRiGEjRqfzurezaWuj8Wie2gyHMrW5Q06LspMnox7A="; includeSubDomains
|
491 |
+
* ```
|
492 |
+
* @since v0.3.6
|
493 |
+
* @param options Accepts all `options` from `request`, with some differences in default values:
|
494 |
+
*/
|
495 |
+
function request(
|
496 |
+
options: RequestOptions | string | URL,
|
497 |
+
callback?: (res: http.IncomingMessage) => void,
|
498 |
+
): http.ClientRequest;
|
499 |
+
function request(
|
500 |
+
url: string | URL,
|
501 |
+
options: RequestOptions,
|
502 |
+
callback?: (res: http.IncomingMessage) => void,
|
503 |
+
): http.ClientRequest;
|
504 |
+
/**
|
505 |
+
* Like `http.get()` but for HTTPS.
|
506 |
+
*
|
507 |
+
* `options` can be an object, a string, or a `URL` object. If `options` is a
|
508 |
+
* string, it is automatically parsed with `new URL()`. If it is a `URL` object, it will be automatically converted to an ordinary `options` object.
|
509 |
+
*
|
510 |
+
* ```js
|
511 |
+
* const https = require('https');
|
512 |
+
*
|
513 |
+
* https.get('https://encrypted.google.com/', (res) => {
|
514 |
+
* console.log('statusCode:', res.statusCode);
|
515 |
+
* console.log('headers:', res.headers);
|
516 |
+
*
|
517 |
+
* res.on('data', (d) => {
|
518 |
+
* process.stdout.write(d);
|
519 |
+
* });
|
520 |
+
*
|
521 |
+
* }).on('error', (e) => {
|
522 |
+
* console.error(e);
|
523 |
+
* });
|
524 |
+
* ```
|
525 |
+
* @since v0.3.6
|
526 |
+
* @param options Accepts the same `options` as {@link request}, with the `method` always set to `GET`.
|
527 |
+
*/
|
528 |
+
function get(
|
529 |
+
options: RequestOptions | string | URL,
|
530 |
+
callback?: (res: http.IncomingMessage) => void,
|
531 |
+
): http.ClientRequest;
|
532 |
+
function get(
|
533 |
+
url: string | URL,
|
534 |
+
options: RequestOptions,
|
535 |
+
callback?: (res: http.IncomingMessage) => void,
|
536 |
+
): http.ClientRequest;
|
537 |
+
let globalAgent: Agent;
|
538 |
+
}
|
539 |
+
declare module 'node:https' {
|
540 |
+
export * from 'https';
|
541 |
+
}
|
igv_component/node_modules/@types/node/index.d.ts
ADDED
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// Type definitions for non-npm package Node.js 18.7
|
2 |
+
// Project: https://nodejs.org/
|
3 |
+
// Definitions by: Microsoft TypeScript <https://github.com/Microsoft>
|
4 |
+
// DefinitelyTyped <https://github.com/DefinitelyTyped>
|
5 |
+
// Alberto Schiabel <https://github.com/jkomyno>
|
6 |
+
// Alvis HT Tang <https://github.com/alvis>
|
7 |
+
// Andrew Makarov <https://github.com/r3nya>
|
8 |
+
// Benjamin Toueg <https://github.com/btoueg>
|
9 |
+
// Chigozirim C. <https://github.com/smac89>
|
10 |
+
// David Junger <https://github.com/touffy>
|
11 |
+
// Deividas Bakanas <https://github.com/DeividasBakanas>
|
12 |
+
// Eugene Y. Q. Shen <https://github.com/eyqs>
|
13 |
+
// Hannes Magnusson <https://github.com/Hannes-Magnusson-CK>
|
14 |
+
// Huw <https://github.com/hoo29>
|
15 |
+
// Kelvin Jin <https://github.com/kjin>
|
16 |
+
// Klaus Meinhardt <https://github.com/ajafff>
|
17 |
+
// Lishude <https://github.com/islishude>
|
18 |
+
// Mariusz Wiktorczyk <https://github.com/mwiktorczyk>
|
19 |
+
// Mohsen Azimi <https://github.com/mohsen1>
|
20 |
+
// Nicolas Even <https://github.com/n-e>
|
21 |
+
// Nikita Galkin <https://github.com/galkin>
|
22 |
+
// Parambir Singh <https://github.com/parambirs>
|
23 |
+
// Sebastian Silbermann <https://github.com/eps1lon>
|
24 |
+
// Simon Schick <https://github.com/SimonSchick>
|
25 |
+
// Thomas den Hollander <https://github.com/ThomasdenH>
|
26 |
+
// Wilco Bakker <https://github.com/WilcoBakker>
|
27 |
+
// wwwy3y3 <https://github.com/wwwy3y3>
|
28 |
+
// Samuel Ainsworth <https://github.com/samuela>
|
29 |
+
// Kyle Uehlein <https://github.com/kuehlein>
|
30 |
+
// Thanik Bhongbhibhat <https://github.com/bhongy>
|
31 |
+
// Marcin Kopacz <https://github.com/chyzwar>
|
32 |
+
// Trivikram Kamat <https://github.com/trivikr>
|
33 |
+
// Junxiao Shi <https://github.com/yoursunny>
|
34 |
+
// Ilia Baryshnikov <https://github.com/qwelias>
|
35 |
+
// ExE Boss <https://github.com/ExE-Boss>
|
36 |
+
// Piotr Błażejewicz <https://github.com/peterblazejewicz>
|
37 |
+
// Anna Henningsen <https://github.com/addaleax>
|
38 |
+
// Victor Perin <https://github.com/victorperin>
|
39 |
+
// Yongsheng Zhang <https://github.com/ZYSzys>
|
40 |
+
// NodeJS Contributors <https://github.com/NodeJS>
|
41 |
+
// Linus Unnebäck <https://github.com/LinusU>
|
42 |
+
// wafuwafu13 <https://github.com/wafuwafu13>
|
43 |
+
// Matteo Collina <https://github.com/mcollina>
|
44 |
+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
45 |
+
|
46 |
+
/**
|
47 |
+
* License for programmatically and manually incorporated
|
48 |
+
* documentation aka. `JSDoc` from https://github.com/nodejs/node/tree/master/doc
|
49 |
+
*
|
50 |
+
* Copyright Node.js contributors. All rights reserved.
|
51 |
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
52 |
+
* of this software and associated documentation files (the "Software"), to
|
53 |
+
* deal in the Software without restriction, including without limitation the
|
54 |
+
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
55 |
+
* sell copies of the Software, and to permit persons to whom the Software is
|
56 |
+
* furnished to do so, subject to the following conditions:
|
57 |
+
*
|
58 |
+
* The above copyright notice and this permission notice shall be included in
|
59 |
+
* all copies or substantial portions of the Software.
|
60 |
+
*
|
61 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
62 |
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
63 |
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
64 |
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
65 |
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
66 |
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
67 |
+
* IN THE SOFTWARE.
|
68 |
+
*/
|
69 |
+
|
70 |
+
// NOTE: These definitions support NodeJS and TypeScript 4.9+.
|
71 |
+
|
72 |
+
// Reference required types from the default lib:
|
73 |
+
/// <reference lib="es2020" />
|
74 |
+
/// <reference lib="esnext.asynciterable" />
|
75 |
+
/// <reference lib="esnext.intl" />
|
76 |
+
/// <reference lib="esnext.bigint" />
|
77 |
+
|
78 |
+
// Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
|
79 |
+
/// <reference path="assert.d.ts" />
|
80 |
+
/// <reference path="assert/strict.d.ts" />
|
81 |
+
/// <reference path="globals.d.ts" />
|
82 |
+
/// <reference path="async_hooks.d.ts" />
|
83 |
+
/// <reference path="buffer.d.ts" />
|
84 |
+
/// <reference path="child_process.d.ts" />
|
85 |
+
/// <reference path="cluster.d.ts" />
|
86 |
+
/// <reference path="console.d.ts" />
|
87 |
+
/// <reference path="constants.d.ts" />
|
88 |
+
/// <reference path="crypto.d.ts" />
|
89 |
+
/// <reference path="dgram.d.ts" />
|
90 |
+
/// <reference path="diagnostics_channel.d.ts" />
|
91 |
+
/// <reference path="dns.d.ts" />
|
92 |
+
/// <reference path="dns/promises.d.ts" />
|
93 |
+
/// <reference path="dns/promises.d.ts" />
|
94 |
+
/// <reference path="domain.d.ts" />
|
95 |
+
/// <reference path="events.d.ts" />
|
96 |
+
/// <reference path="fs.d.ts" />
|
97 |
+
/// <reference path="fs/promises.d.ts" />
|
98 |
+
/// <reference path="http.d.ts" />
|
99 |
+
/// <reference path="http2.d.ts" />
|
100 |
+
/// <reference path="https.d.ts" />
|
101 |
+
/// <reference path="inspector.d.ts" />
|
102 |
+
/// <reference path="module.d.ts" />
|
103 |
+
/// <reference path="net.d.ts" />
|
104 |
+
/// <reference path="os.d.ts" />
|
105 |
+
/// <reference path="path.d.ts" />
|
106 |
+
/// <reference path="perf_hooks.d.ts" />
|
107 |
+
/// <reference path="process.d.ts" />
|
108 |
+
/// <reference path="punycode.d.ts" />
|
109 |
+
/// <reference path="querystring.d.ts" />
|
110 |
+
/// <reference path="readline.d.ts" />
|
111 |
+
/// <reference path="readline/promises.d.ts" />
|
112 |
+
/// <reference path="repl.d.ts" />
|
113 |
+
/// <reference path="stream.d.ts" />
|
114 |
+
/// <reference path="stream/promises.d.ts" />
|
115 |
+
/// <reference path="stream/consumers.d.ts" />
|
116 |
+
/// <reference path="stream/web.d.ts" />
|
117 |
+
/// <reference path="string_decoder.d.ts" />
|
118 |
+
/// <reference path="test.d.ts" />
|
119 |
+
/// <reference path="timers.d.ts" />
|
120 |
+
/// <reference path="timers/promises.d.ts" />
|
121 |
+
/// <reference path="tls.d.ts" />
|
122 |
+
/// <reference path="trace_events.d.ts" />
|
123 |
+
/// <reference path="tty.d.ts" />
|
124 |
+
/// <reference path="url.d.ts" />
|
125 |
+
/// <reference path="util.d.ts" />
|
126 |
+
/// <reference path="v8.d.ts" />
|
127 |
+
/// <reference path="vm.d.ts" />
|
128 |
+
/// <reference path="wasi.d.ts" />
|
129 |
+
/// <reference path="worker_threads.d.ts" />
|
130 |
+
/// <reference path="zlib.d.ts" />
|
131 |
+
|
132 |
+
/// <reference path="globals.global.d.ts" />
|
igv_component/node_modules/@types/node/inspector.d.ts
ADDED
The diff for this file is too large to render.
See raw diff
|
|
igv_component/node_modules/@types/node/module.d.ts
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* @since v0.3.7
|
3 |
+
*/
|
4 |
+
declare module 'module' {
|
5 |
+
import { URL } from 'node:url';
|
6 |
+
namespace Module {
|
7 |
+
/**
|
8 |
+
* The `module.syncBuiltinESMExports()` method updates all the live bindings for
|
9 |
+
* builtin `ES Modules` to match the properties of the `CommonJS` exports. It
|
10 |
+
* does not add or remove exported names from the `ES Modules`.
|
11 |
+
*
|
12 |
+
* ```js
|
13 |
+
* const fs = require('fs');
|
14 |
+
* const assert = require('assert');
|
15 |
+
* const { syncBuiltinESMExports } = require('module');
|
16 |
+
*
|
17 |
+
* fs.readFile = newAPI;
|
18 |
+
*
|
19 |
+
* delete fs.readFileSync;
|
20 |
+
*
|
21 |
+
* function newAPI() {
|
22 |
+
* // ...
|
23 |
+
* }
|
24 |
+
*
|
25 |
+
* fs.newAPI = newAPI;
|
26 |
+
*
|
27 |
+
* syncBuiltinESMExports();
|
28 |
+
*
|
29 |
+
* import('fs').then((esmFS) => {
|
30 |
+
* // It syncs the existing readFile property with the new value
|
31 |
+
* assert.strictEqual(esmFS.readFile, newAPI);
|
32 |
+
* // readFileSync has been deleted from the required fs
|
33 |
+
* assert.strictEqual('readFileSync' in fs, false);
|
34 |
+
* // syncBuiltinESMExports() does not remove readFileSync from esmFS
|
35 |
+
* assert.strictEqual('readFileSync' in esmFS, true);
|
36 |
+
* // syncBuiltinESMExports() does not add names
|
37 |
+
* assert.strictEqual(esmFS.newAPI, undefined);
|
38 |
+
* });
|
39 |
+
* ```
|
40 |
+
* @since v12.12.0
|
41 |
+
*/
|
42 |
+
function syncBuiltinESMExports(): void;
|
43 |
+
/**
|
44 |
+
* `path` is the resolved path for the file for which a corresponding source map
|
45 |
+
* should be fetched.
|
46 |
+
* @since v13.7.0, v12.17.0
|
47 |
+
*/
|
48 |
+
function findSourceMap(path: string, error?: Error): SourceMap;
|
49 |
+
interface SourceMapPayload {
|
50 |
+
file: string;
|
51 |
+
version: number;
|
52 |
+
sources: string[];
|
53 |
+
sourcesContent: string[];
|
54 |
+
names: string[];
|
55 |
+
mappings: string;
|
56 |
+
sourceRoot: string;
|
57 |
+
}
|
58 |
+
interface SourceMapping {
|
59 |
+
generatedLine: number;
|
60 |
+
generatedColumn: number;
|
61 |
+
originalSource: string;
|
62 |
+
originalLine: number;
|
63 |
+
originalColumn: number;
|
64 |
+
}
|
65 |
+
/**
|
66 |
+
* @since v13.7.0, v12.17.0
|
67 |
+
*/
|
68 |
+
class SourceMap {
|
69 |
+
/**
|
70 |
+
* Getter for the payload used to construct the `SourceMap` instance.
|
71 |
+
*/
|
72 |
+
readonly payload: SourceMapPayload;
|
73 |
+
constructor(payload: SourceMapPayload);
|
74 |
+
/**
|
75 |
+
* Given a line number and column number in the generated source file, returns
|
76 |
+
* an object representing the position in the original file. The object returned
|
77 |
+
* consists of the following keys:
|
78 |
+
*/
|
79 |
+
findEntry(line: number, column: number): SourceMapping;
|
80 |
+
}
|
81 |
+
}
|
82 |
+
interface Module extends NodeModule {}
|
83 |
+
class Module {
|
84 |
+
static runMain(): void;
|
85 |
+
static wrap(code: string): string;
|
86 |
+
static createRequire(path: string | URL): NodeRequire;
|
87 |
+
static builtinModules: string[];
|
88 |
+
static Module: typeof Module;
|
89 |
+
constructor(id: string, parent?: Module);
|
90 |
+
}
|
91 |
+
global {
|
92 |
+
interface ImportMeta {
|
93 |
+
url: string;
|
94 |
+
/**
|
95 |
+
* @experimental
|
96 |
+
* This feature is only available with the `--experimental-import-meta-resolve`
|
97 |
+
* command flag enabled.
|
98 |
+
*
|
99 |
+
* Provides a module-relative resolution function scoped to each module, returning
|
100 |
+
* the URL string.
|
101 |
+
*
|
102 |
+
* @param specified The module specifier to resolve relative to `parent`.
|
103 |
+
* @param parent The absolute parent module URL to resolve from. If none
|
104 |
+
* is specified, the value of `import.meta.url` is used as the default.
|
105 |
+
*/
|
106 |
+
resolve?(specified: string, parent?: string | URL): Promise<string>;
|
107 |
+
}
|
108 |
+
}
|
109 |
+
export = Module;
|
110 |
+
}
|
111 |
+
declare module 'node:module' {
|
112 |
+
import module = require('module');
|
113 |
+
export = module;
|
114 |
+
}
|
igv_component/node_modules/@types/node/net.d.ts
ADDED
@@ -0,0 +1,838 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* > Stability: 2 - Stable
|
3 |
+
*
|
4 |
+
* The `net` module provides an asynchronous network API for creating stream-based
|
5 |
+
* TCP or `IPC` servers ({@link createServer}) and clients
|
6 |
+
* ({@link createConnection}).
|
7 |
+
*
|
8 |
+
* It can be accessed using:
|
9 |
+
*
|
10 |
+
* ```js
|
11 |
+
* const net = require('net');
|
12 |
+
* ```
|
13 |
+
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/net.js)
|
14 |
+
*/
|
15 |
+
declare module 'net' {
|
16 |
+
import * as stream from 'node:stream';
|
17 |
+
import { Abortable, EventEmitter } from 'node:events';
|
18 |
+
import * as dns from 'node:dns';
|
19 |
+
type LookupFunction = (hostname: string, options: dns.LookupOneOptions, callback: (err: NodeJS.ErrnoException | null, address: string, family: number) => void) => void;
|
20 |
+
interface AddressInfo {
|
21 |
+
address: string;
|
22 |
+
family: string;
|
23 |
+
port: number;
|
24 |
+
}
|
25 |
+
interface SocketConstructorOpts {
|
26 |
+
fd?: number | undefined;
|
27 |
+
allowHalfOpen?: boolean | undefined;
|
28 |
+
readable?: boolean | undefined;
|
29 |
+
writable?: boolean | undefined;
|
30 |
+
signal?: AbortSignal;
|
31 |
+
}
|
32 |
+
interface OnReadOpts {
|
33 |
+
buffer: Uint8Array | (() => Uint8Array);
|
34 |
+
/**
|
35 |
+
* This function is called for every chunk of incoming data.
|
36 |
+
* Two arguments are passed to it: the number of bytes written to buffer and a reference to buffer.
|
37 |
+
* Return false from this function to implicitly pause() the socket.
|
38 |
+
*/
|
39 |
+
callback(bytesWritten: number, buf: Uint8Array): boolean;
|
40 |
+
}
|
41 |
+
interface ConnectOpts {
|
42 |
+
/**
|
43 |
+
* If specified, incoming data is stored in a single buffer and passed to the supplied callback when data arrives on the socket.
|
44 |
+
* Note: this will cause the streaming functionality to not provide any data, however events like 'error', 'end', and 'close' will
|
45 |
+
* still be emitted as normal and methods like pause() and resume() will also behave as expected.
|
46 |
+
*/
|
47 |
+
onread?: OnReadOpts | undefined;
|
48 |
+
}
|
49 |
+
interface TcpSocketConnectOpts extends ConnectOpts {
|
50 |
+
port: number;
|
51 |
+
host?: string | undefined;
|
52 |
+
localAddress?: string | undefined;
|
53 |
+
localPort?: number | undefined;
|
54 |
+
hints?: number | undefined;
|
55 |
+
family?: number | undefined;
|
56 |
+
lookup?: LookupFunction | undefined;
|
57 |
+
noDelay?: boolean | undefined;
|
58 |
+
keepAlive?: boolean | undefined;
|
59 |
+
keepAliveInitialDelay?: number | undefined;
|
60 |
+
}
|
61 |
+
interface IpcSocketConnectOpts extends ConnectOpts {
|
62 |
+
path: string;
|
63 |
+
}
|
64 |
+
type SocketConnectOpts = TcpSocketConnectOpts | IpcSocketConnectOpts;
|
65 |
+
type SocketReadyState = 'opening' | 'open' | 'readOnly' | 'writeOnly' | 'closed';
|
66 |
+
/**
|
67 |
+
* This class is an abstraction of a TCP socket or a streaming `IPC` endpoint
|
68 |
+
* (uses named pipes on Windows, and Unix domain sockets otherwise). It is also
|
69 |
+
* an `EventEmitter`.
|
70 |
+
*
|
71 |
+
* A `net.Socket` can be created by the user and used directly to interact with
|
72 |
+
* a server. For example, it is returned by {@link createConnection},
|
73 |
+
* so the user can use it to talk to the server.
|
74 |
+
*
|
75 |
+
* It can also be created by Node.js and passed to the user when a connection
|
76 |
+
* is received. For example, it is passed to the listeners of a `'connection'` event emitted on a {@link Server}, so the user can use
|
77 |
+
* it to interact with the client.
|
78 |
+
* @since v0.3.4
|
79 |
+
*/
|
80 |
+
class Socket extends stream.Duplex {
|
81 |
+
constructor(options?: SocketConstructorOpts);
|
82 |
+
/**
|
83 |
+
* Sends data on the socket. The second parameter specifies the encoding in the
|
84 |
+
* case of a string. It defaults to UTF8 encoding.
|
85 |
+
*
|
86 |
+
* Returns `true` if the entire data was flushed successfully to the kernel
|
87 |
+
* buffer. Returns `false` if all or part of the data was queued in user memory.`'drain'` will be emitted when the buffer is again free.
|
88 |
+
*
|
89 |
+
* The optional `callback` parameter will be executed when the data is finally
|
90 |
+
* written out, which may not be immediately.
|
91 |
+
*
|
92 |
+
* See `Writable` stream `write()` method for more
|
93 |
+
* information.
|
94 |
+
* @since v0.1.90
|
95 |
+
* @param [encoding='utf8'] Only used when data is `string`.
|
96 |
+
*/
|
97 |
+
write(buffer: Uint8Array | string, cb?: (err?: Error) => void): boolean;
|
98 |
+
write(str: Uint8Array | string, encoding?: BufferEncoding, cb?: (err?: Error) => void): boolean;
|
99 |
+
/**
|
100 |
+
* Initiate a connection on a given socket.
|
101 |
+
*
|
102 |
+
* Possible signatures:
|
103 |
+
*
|
104 |
+
* * `socket.connect(options[, connectListener])`
|
105 |
+
* * `socket.connect(path[, connectListener])` for `IPC` connections.
|
106 |
+
* * `socket.connect(port[, host][, connectListener])` for TCP connections.
|
107 |
+
* * Returns: `net.Socket` The socket itself.
|
108 |
+
*
|
109 |
+
* This function is asynchronous. When the connection is established, the `'connect'` event will be emitted. If there is a problem connecting,
|
110 |
+
* instead of a `'connect'` event, an `'error'` event will be emitted with
|
111 |
+
* the error passed to the `'error'` listener.
|
112 |
+
* The last parameter `connectListener`, if supplied, will be added as a listener
|
113 |
+
* for the `'connect'` event **once**.
|
114 |
+
*
|
115 |
+
* This function should only be used for reconnecting a socket after`'close'` has been emitted or otherwise it may lead to undefined
|
116 |
+
* behavior.
|
117 |
+
*/
|
118 |
+
connect(options: SocketConnectOpts, connectionListener?: () => void): this;
|
119 |
+
connect(port: number, host: string, connectionListener?: () => void): this;
|
120 |
+
connect(port: number, connectionListener?: () => void): this;
|
121 |
+
connect(path: string, connectionListener?: () => void): this;
|
122 |
+
/**
|
123 |
+
* Set the encoding for the socket as a `Readable Stream`. See `readable.setEncoding()` for more information.
|
124 |
+
* @since v0.1.90
|
125 |
+
* @return The socket itself.
|
126 |
+
*/
|
127 |
+
setEncoding(encoding?: BufferEncoding): this;
|
128 |
+
/**
|
129 |
+
* Pauses the reading of data. That is, `'data'` events will not be emitted.
|
130 |
+
* Useful to throttle back an upload.
|
131 |
+
* @return The socket itself.
|
132 |
+
*/
|
133 |
+
pause(): this;
|
134 |
+
/**
|
135 |
+
* Resumes reading after a call to `socket.pause()`.
|
136 |
+
* @return The socket itself.
|
137 |
+
*/
|
138 |
+
resume(): this;
|
139 |
+
/**
|
140 |
+
* Sets the socket to timeout after `timeout` milliseconds of inactivity on
|
141 |
+
* the socket. By default `net.Socket` do not have a timeout.
|
142 |
+
*
|
143 |
+
* When an idle timeout is triggered the socket will receive a `'timeout'` event but the connection will not be severed. The user must manually call `socket.end()` or `socket.destroy()` to
|
144 |
+
* end the connection.
|
145 |
+
*
|
146 |
+
* ```js
|
147 |
+
* socket.setTimeout(3000);
|
148 |
+
* socket.on('timeout', () => {
|
149 |
+
* console.log('socket timeout');
|
150 |
+
* socket.end();
|
151 |
+
* });
|
152 |
+
* ```
|
153 |
+
*
|
154 |
+
* If `timeout` is 0, then the existing idle timeout is disabled.
|
155 |
+
*
|
156 |
+
* The optional `callback` parameter will be added as a one-time listener for the `'timeout'` event.
|
157 |
+
* @since v0.1.90
|
158 |
+
* @return The socket itself.
|
159 |
+
*/
|
160 |
+
setTimeout(timeout: number, callback?: () => void): this;
|
161 |
+
/**
|
162 |
+
* Enable/disable the use of Nagle's algorithm.
|
163 |
+
*
|
164 |
+
* When a TCP connection is created, it will have Nagle's algorithm enabled.
|
165 |
+
*
|
166 |
+
* Nagle's algorithm delays data before it is sent via the network. It attempts
|
167 |
+
* to optimize throughput at the expense of latency.
|
168 |
+
*
|
169 |
+
* Passing `true` for `noDelay` or not passing an argument will disable Nagle's
|
170 |
+
* algorithm for the socket. Passing `false` for `noDelay` will enable Nagle's
|
171 |
+
* algorithm.
|
172 |
+
* @since v0.1.90
|
173 |
+
* @param [noDelay=true]
|
174 |
+
* @return The socket itself.
|
175 |
+
*/
|
176 |
+
setNoDelay(noDelay?: boolean): this;
|
177 |
+
/**
|
178 |
+
* Enable/disable keep-alive functionality, and optionally set the initial
|
179 |
+
* delay before the first keepalive probe is sent on an idle socket.
|
180 |
+
*
|
181 |
+
* Set `initialDelay` (in milliseconds) to set the delay between the last
|
182 |
+
* data packet received and the first keepalive probe. Setting `0` for`initialDelay` will leave the value unchanged from the default
|
183 |
+
* (or previous) setting.
|
184 |
+
*
|
185 |
+
* Enabling the keep-alive functionality will set the following socket options:
|
186 |
+
*
|
187 |
+
* * `SO_KEEPALIVE=1`
|
188 |
+
* * `TCP_KEEPIDLE=initialDelay`
|
189 |
+
* * `TCP_KEEPCNT=10`
|
190 |
+
* * `TCP_KEEPINTVL=1`
|
191 |
+
* @since v0.1.92
|
192 |
+
* @param [enable=false]
|
193 |
+
* @param [initialDelay=0]
|
194 |
+
* @return The socket itself.
|
195 |
+
*/
|
196 |
+
setKeepAlive(enable?: boolean, initialDelay?: number): this;
|
197 |
+
/**
|
198 |
+
* Returns the bound `address`, the address `family` name and `port` of the
|
199 |
+
* socket as reported by the operating system:`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`
|
200 |
+
* @since v0.1.90
|
201 |
+
*/
|
202 |
+
address(): AddressInfo | {};
|
203 |
+
/**
|
204 |
+
* Calling `unref()` on a socket will allow the program to exit if this is the only
|
205 |
+
* active socket in the event system. If the socket is already `unref`ed calling`unref()` again will have no effect.
|
206 |
+
* @since v0.9.1
|
207 |
+
* @return The socket itself.
|
208 |
+
*/
|
209 |
+
unref(): this;
|
210 |
+
/**
|
211 |
+
* Opposite of `unref()`, calling `ref()` on a previously `unref`ed socket will _not_ let the program exit if it's the only socket left (the default behavior).
|
212 |
+
* If the socket is `ref`ed calling `ref` again will have no effect.
|
213 |
+
* @since v0.9.1
|
214 |
+
* @return The socket itself.
|
215 |
+
*/
|
216 |
+
ref(): this;
|
217 |
+
/**
|
218 |
+
* This property shows the number of characters buffered for writing. The buffer
|
219 |
+
* may contain strings whose length after encoding is not yet known. So this number
|
220 |
+
* is only an approximation of the number of bytes in the buffer.
|
221 |
+
*
|
222 |
+
* `net.Socket` has the property that `socket.write()` always works. This is to
|
223 |
+
* help users get up and running quickly. The computer cannot always keep up
|
224 |
+
* with the amount of data that is written to a socket. The network connection
|
225 |
+
* simply might be too slow. Node.js will internally queue up the data written to a
|
226 |
+
* socket and send it out over the wire when it is possible.
|
227 |
+
*
|
228 |
+
* The consequence of this internal buffering is that memory may grow.
|
229 |
+
* Users who experience large or growing `bufferSize` should attempt to
|
230 |
+
* "throttle" the data flows in their program with `socket.pause()` and `socket.resume()`.
|
231 |
+
* @since v0.3.8
|
232 |
+
* @deprecated Since v14.6.0 - Use `writableLength` instead.
|
233 |
+
*/
|
234 |
+
readonly bufferSize: number;
|
235 |
+
/**
|
236 |
+
* The amount of received bytes.
|
237 |
+
* @since v0.5.3
|
238 |
+
*/
|
239 |
+
readonly bytesRead: number;
|
240 |
+
/**
|
241 |
+
* The amount of bytes sent.
|
242 |
+
* @since v0.5.3
|
243 |
+
*/
|
244 |
+
readonly bytesWritten: number;
|
245 |
+
/**
|
246 |
+
* If `true`,`socket.connect(options[, connectListener])` was
|
247 |
+
* called and has not yet finished. It will stay `true` until the socket becomes
|
248 |
+
* connected, then it is set to `false` and the `'connect'` event is emitted. Note
|
249 |
+
* that the `socket.connect(options[, connectListener])` callback is a listener for the `'connect'` event.
|
250 |
+
* @since v6.1.0
|
251 |
+
*/
|
252 |
+
readonly connecting: boolean;
|
253 |
+
/**
|
254 |
+
* See `writable.destroyed` for further details.
|
255 |
+
*/
|
256 |
+
readonly destroyed: boolean;
|
257 |
+
/**
|
258 |
+
* The string representation of the local IP address the remote client is
|
259 |
+
* connecting on. For example, in a server listening on `'0.0.0.0'`, if a client
|
260 |
+
* connects on `'192.168.1.1'`, the value of `socket.localAddress` would be`'192.168.1.1'`.
|
261 |
+
* @since v0.9.6
|
262 |
+
*/
|
263 |
+
readonly localAddress?: string;
|
264 |
+
/**
|
265 |
+
* The numeric representation of the local port. For example, `80` or `21`.
|
266 |
+
* @since v0.9.6
|
267 |
+
*/
|
268 |
+
readonly localPort?: number;
|
269 |
+
/**
|
270 |
+
* This property represents the state of the connection as a string.
|
271 |
+
* @see {https://nodejs.org/api/net.html#socketreadystate}
|
272 |
+
* @since v0.5.0
|
273 |
+
*/
|
274 |
+
readonly readyState: SocketReadyState;
|
275 |
+
/**
|
276 |
+
* The string representation of the remote IP address. For example,`'74.125.127.100'` or `'2001:4860:a005::68'`. Value may be `undefined` if
|
277 |
+
* the socket is destroyed (for example, if the client disconnected).
|
278 |
+
* @since v0.5.10
|
279 |
+
*/
|
280 |
+
readonly remoteAddress?: string | undefined;
|
281 |
+
/**
|
282 |
+
* The string representation of the remote IP family. `'IPv4'` or `'IPv6'`.
|
283 |
+
* @since v0.11.14
|
284 |
+
*/
|
285 |
+
readonly remoteFamily?: string | undefined;
|
286 |
+
/**
|
287 |
+
* The numeric representation of the remote port. For example, `80` or `21`.
|
288 |
+
* @since v0.5.10
|
289 |
+
*/
|
290 |
+
readonly remotePort?: number | undefined;
|
291 |
+
/**
|
292 |
+
* The socket timeout in milliseconds as set by socket.setTimeout(). It is undefined if a timeout has not been set.
|
293 |
+
* @since v10.7.0
|
294 |
+
*/
|
295 |
+
readonly timeout?: number | undefined;
|
296 |
+
/**
|
297 |
+
* Half-closes the socket. i.e., it sends a FIN packet. It is possible the
|
298 |
+
* server will still send some data.
|
299 |
+
*
|
300 |
+
* See `writable.end()` for further details.
|
301 |
+
* @since v0.1.90
|
302 |
+
* @param [encoding='utf8'] Only used when data is `string`.
|
303 |
+
* @param callback Optional callback for when the socket is finished.
|
304 |
+
* @return The socket itself.
|
305 |
+
*/
|
306 |
+
end(callback?: () => void): this;
|
307 |
+
end(buffer: Uint8Array | string, callback?: () => void): this;
|
308 |
+
end(str: Uint8Array | string, encoding?: BufferEncoding, callback?: () => void): this;
|
309 |
+
/**
|
310 |
+
* events.EventEmitter
|
311 |
+
* 1. close
|
312 |
+
* 2. connect
|
313 |
+
* 3. data
|
314 |
+
* 4. drain
|
315 |
+
* 5. end
|
316 |
+
* 6. error
|
317 |
+
* 7. lookup
|
318 |
+
* 8. timeout
|
319 |
+
*/
|
320 |
+
addListener(event: string, listener: (...args: any[]) => void): this;
|
321 |
+
addListener(event: 'close', listener: (hadError: boolean) => void): this;
|
322 |
+
addListener(event: 'connect', listener: () => void): this;
|
323 |
+
addListener(event: 'data', listener: (data: Buffer) => void): this;
|
324 |
+
addListener(event: 'drain', listener: () => void): this;
|
325 |
+
addListener(event: 'end', listener: () => void): this;
|
326 |
+
addListener(event: 'error', listener: (err: Error) => void): this;
|
327 |
+
addListener(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
|
328 |
+
addListener(event: 'ready', listener: () => void): this;
|
329 |
+
addListener(event: 'timeout', listener: () => void): this;
|
330 |
+
emit(event: string | symbol, ...args: any[]): boolean;
|
331 |
+
emit(event: 'close', hadError: boolean): boolean;
|
332 |
+
emit(event: 'connect'): boolean;
|
333 |
+
emit(event: 'data', data: Buffer): boolean;
|
334 |
+
emit(event: 'drain'): boolean;
|
335 |
+
emit(event: 'end'): boolean;
|
336 |
+
emit(event: 'error', err: Error): boolean;
|
337 |
+
emit(event: 'lookup', err: Error, address: string, family: string | number, host: string): boolean;
|
338 |
+
emit(event: 'ready'): boolean;
|
339 |
+
emit(event: 'timeout'): boolean;
|
340 |
+
on(event: string, listener: (...args: any[]) => void): this;
|
341 |
+
on(event: 'close', listener: (hadError: boolean) => void): this;
|
342 |
+
on(event: 'connect', listener: () => void): this;
|
343 |
+
on(event: 'data', listener: (data: Buffer) => void): this;
|
344 |
+
on(event: 'drain', listener: () => void): this;
|
345 |
+
on(event: 'end', listener: () => void): this;
|
346 |
+
on(event: 'error', listener: (err: Error) => void): this;
|
347 |
+
on(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
|
348 |
+
on(event: 'ready', listener: () => void): this;
|
349 |
+
on(event: 'timeout', listener: () => void): this;
|
350 |
+
once(event: string, listener: (...args: any[]) => void): this;
|
351 |
+
once(event: 'close', listener: (hadError: boolean) => void): this;
|
352 |
+
once(event: 'connect', listener: () => void): this;
|
353 |
+
once(event: 'data', listener: (data: Buffer) => void): this;
|
354 |
+
once(event: 'drain', listener: () => void): this;
|
355 |
+
once(event: 'end', listener: () => void): this;
|
356 |
+
once(event: 'error', listener: (err: Error) => void): this;
|
357 |
+
once(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
|
358 |
+
once(event: 'ready', listener: () => void): this;
|
359 |
+
once(event: 'timeout', listener: () => void): this;
|
360 |
+
prependListener(event: string, listener: (...args: any[]) => void): this;
|
361 |
+
prependListener(event: 'close', listener: (hadError: boolean) => void): this;
|
362 |
+
prependListener(event: 'connect', listener: () => void): this;
|
363 |
+
prependListener(event: 'data', listener: (data: Buffer) => void): this;
|
364 |
+
prependListener(event: 'drain', listener: () => void): this;
|
365 |
+
prependListener(event: 'end', listener: () => void): this;
|
366 |
+
prependListener(event: 'error', listener: (err: Error) => void): this;
|
367 |
+
prependListener(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
|
368 |
+
prependListener(event: 'ready', listener: () => void): this;
|
369 |
+
prependListener(event: 'timeout', listener: () => void): this;
|
370 |
+
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
371 |
+
prependOnceListener(event: 'close', listener: (hadError: boolean) => void): this;
|
372 |
+
prependOnceListener(event: 'connect', listener: () => void): this;
|
373 |
+
prependOnceListener(event: 'data', listener: (data: Buffer) => void): this;
|
374 |
+
prependOnceListener(event: 'drain', listener: () => void): this;
|
375 |
+
prependOnceListener(event: 'end', listener: () => void): this;
|
376 |
+
prependOnceListener(event: 'error', listener: (err: Error) => void): this;
|
377 |
+
prependOnceListener(event: 'lookup', listener: (err: Error, address: string, family: string | number, host: string) => void): this;
|
378 |
+
prependOnceListener(event: 'ready', listener: () => void): this;
|
379 |
+
prependOnceListener(event: 'timeout', listener: () => void): this;
|
380 |
+
}
|
381 |
+
interface ListenOptions extends Abortable {
|
382 |
+
port?: number | undefined;
|
383 |
+
host?: string | undefined;
|
384 |
+
backlog?: number | undefined;
|
385 |
+
path?: string | undefined;
|
386 |
+
exclusive?: boolean | undefined;
|
387 |
+
readableAll?: boolean | undefined;
|
388 |
+
writableAll?: boolean | undefined;
|
389 |
+
/**
|
390 |
+
* @default false
|
391 |
+
*/
|
392 |
+
ipv6Only?: boolean | undefined;
|
393 |
+
}
|
394 |
+
interface ServerOpts {
|
395 |
+
/**
|
396 |
+
* Indicates whether half-opened TCP connections are allowed.
|
397 |
+
* @default false
|
398 |
+
*/
|
399 |
+
allowHalfOpen?: boolean | undefined;
|
400 |
+
/**
|
401 |
+
* Indicates whether the socket should be paused on incoming connections.
|
402 |
+
* @default false
|
403 |
+
*/
|
404 |
+
pauseOnConnect?: boolean | undefined;
|
405 |
+
/**
|
406 |
+
* If set to `true`, it disables the use of Nagle's algorithm immediately after a new incoming connection is received.
|
407 |
+
* @default false
|
408 |
+
* @since v16.5.0
|
409 |
+
*/
|
410 |
+
noDelay?: boolean | undefined;
|
411 |
+
/**
|
412 |
+
* If set to `true`, it enables keep-alive functionality on the socket immediately after a new incoming connection is received,
|
413 |
+
* similarly on what is done in `socket.setKeepAlive([enable][, initialDelay])`.
|
414 |
+
* @default false
|
415 |
+
* @since v16.5.0
|
416 |
+
*/
|
417 |
+
keepAlive?: boolean | undefined;
|
418 |
+
/**
|
419 |
+
* If set to a positive number, it sets the initial delay before the first keepalive probe is sent on an idle socket.
|
420 |
+
* @default 0
|
421 |
+
* @since v16.5.0
|
422 |
+
*/
|
423 |
+
keepAliveInitialDelay?: number | undefined;
|
424 |
+
}
|
425 |
+
/**
|
426 |
+
* This class is used to create a TCP or `IPC` server.
|
427 |
+
* @since v0.1.90
|
428 |
+
*/
|
429 |
+
class Server extends EventEmitter {
|
430 |
+
constructor(connectionListener?: (socket: Socket) => void);
|
431 |
+
constructor(options?: ServerOpts, connectionListener?: (socket: Socket) => void);
|
432 |
+
/**
|
433 |
+
* Start a server listening for connections. A `net.Server` can be a TCP or
|
434 |
+
* an `IPC` server depending on what it listens to.
|
435 |
+
*
|
436 |
+
* Possible signatures:
|
437 |
+
*
|
438 |
+
* * `server.listen(handle[, backlog][, callback])`
|
439 |
+
* * `server.listen(options[, callback])`
|
440 |
+
* * `server.listen(path[, backlog][, callback])` for `IPC` servers
|
441 |
+
* * `server.listen([port[, host[, backlog]]][, callback])` for TCP servers
|
442 |
+
*
|
443 |
+
* This function is asynchronous. When the server starts listening, the `'listening'` event will be emitted. The last parameter `callback`will be added as a listener for the `'listening'`
|
444 |
+
* event.
|
445 |
+
*
|
446 |
+
* All `listen()` methods can take a `backlog` parameter to specify the maximum
|
447 |
+
* length of the queue of pending connections. The actual length will be determined
|
448 |
+
* by the OS through sysctl settings such as `tcp_max_syn_backlog` and `somaxconn`on Linux. The default value of this parameter is 511 (not 512).
|
449 |
+
*
|
450 |
+
* All {@link Socket} are set to `SO_REUSEADDR` (see [`socket(7)`](https://man7.org/linux/man-pages/man7/socket.7.html) for
|
451 |
+
* details).
|
452 |
+
*
|
453 |
+
* The `server.listen()` method can be called again if and only if there was an
|
454 |
+
* error during the first `server.listen()` call or `server.close()` has been
|
455 |
+
* called. Otherwise, an `ERR_SERVER_ALREADY_LISTEN` error will be thrown.
|
456 |
+
*
|
457 |
+
* One of the most common errors raised when listening is `EADDRINUSE`.
|
458 |
+
* This happens when another server is already listening on the requested`port`/`path`/`handle`. One way to handle this would be to retry
|
459 |
+
* after a certain amount of time:
|
460 |
+
*
|
461 |
+
* ```js
|
462 |
+
* server.on('error', (e) => {
|
463 |
+
* if (e.code === 'EADDRINUSE') {
|
464 |
+
* console.log('Address in use, retrying...');
|
465 |
+
* setTimeout(() => {
|
466 |
+
* server.close();
|
467 |
+
* server.listen(PORT, HOST);
|
468 |
+
* }, 1000);
|
469 |
+
* }
|
470 |
+
* });
|
471 |
+
* ```
|
472 |
+
*/
|
473 |
+
listen(port?: number, hostname?: string, backlog?: number, listeningListener?: () => void): this;
|
474 |
+
listen(port?: number, hostname?: string, listeningListener?: () => void): this;
|
475 |
+
listen(port?: number, backlog?: number, listeningListener?: () => void): this;
|
476 |
+
listen(port?: number, listeningListener?: () => void): this;
|
477 |
+
listen(path: string, backlog?: number, listeningListener?: () => void): this;
|
478 |
+
listen(path: string, listeningListener?: () => void): this;
|
479 |
+
listen(options: ListenOptions, listeningListener?: () => void): this;
|
480 |
+
listen(handle: any, backlog?: number, listeningListener?: () => void): this;
|
481 |
+
listen(handle: any, listeningListener?: () => void): this;
|
482 |
+
/**
|
483 |
+
* Stops the server from accepting new connections and keeps existing
|
484 |
+
* connections. This function is asynchronous, the server is finally closed
|
485 |
+
* when all connections are ended and the server emits a `'close'` event.
|
486 |
+
* The optional `callback` will be called once the `'close'` event occurs. Unlike
|
487 |
+
* that event, it will be called with an `Error` as its only argument if the server
|
488 |
+
* was not open when it was closed.
|
489 |
+
* @since v0.1.90
|
490 |
+
* @param callback Called when the server is closed.
|
491 |
+
*/
|
492 |
+
close(callback?: (err?: Error) => void): this;
|
493 |
+
/**
|
494 |
+
* Returns the bound `address`, the address `family` name, and `port` of the server
|
495 |
+
* as reported by the operating system if listening on an IP socket
|
496 |
+
* (useful to find which port was assigned when getting an OS-assigned address):`{ port: 12346, family: 'IPv4', address: '127.0.0.1' }`.
|
497 |
+
*
|
498 |
+
* For a server listening on a pipe or Unix domain socket, the name is returned
|
499 |
+
* as a string.
|
500 |
+
*
|
501 |
+
* ```js
|
502 |
+
* const server = net.createServer((socket) => {
|
503 |
+
* socket.end('goodbye\n');
|
504 |
+
* }).on('error', (err) => {
|
505 |
+
* // Handle errors here.
|
506 |
+
* throw err;
|
507 |
+
* });
|
508 |
+
*
|
509 |
+
* // Grab an arbitrary unused port.
|
510 |
+
* server.listen(() => {
|
511 |
+
* console.log('opened server on', server.address());
|
512 |
+
* });
|
513 |
+
* ```
|
514 |
+
*
|
515 |
+
* `server.address()` returns `null` before the `'listening'` event has been
|
516 |
+
* emitted or after calling `server.close()`.
|
517 |
+
* @since v0.1.90
|
518 |
+
*/
|
519 |
+
address(): AddressInfo | string | null;
|
520 |
+
/**
|
521 |
+
* Asynchronously get the number of concurrent connections on the server. Works
|
522 |
+
* when sockets were sent to forks.
|
523 |
+
*
|
524 |
+
* Callback should take two arguments `err` and `count`.
|
525 |
+
* @since v0.9.7
|
526 |
+
*/
|
527 |
+
getConnections(cb: (error: Error | null, count: number) => void): void;
|
528 |
+
/**
|
529 |
+
* Opposite of `unref()`, calling `ref()` on a previously `unref`ed server will _not_ let the program exit if it's the only server left (the default behavior).
|
530 |
+
* If the server is `ref`ed calling `ref()` again will have no effect.
|
531 |
+
* @since v0.9.1
|
532 |
+
*/
|
533 |
+
ref(): this;
|
534 |
+
/**
|
535 |
+
* Calling `unref()` on a server will allow the program to exit if this is the only
|
536 |
+
* active server in the event system. If the server is already `unref`ed calling`unref()` again will have no effect.
|
537 |
+
* @since v0.9.1
|
538 |
+
*/
|
539 |
+
unref(): this;
|
540 |
+
/**
|
541 |
+
* Set this property to reject connections when the server's connection count gets
|
542 |
+
* high.
|
543 |
+
*
|
544 |
+
* It is not recommended to use this option once a socket has been sent to a child
|
545 |
+
* with `child_process.fork()`.
|
546 |
+
* @since v0.2.0
|
547 |
+
*/
|
548 |
+
maxConnections: number;
|
549 |
+
connections: number;
|
550 |
+
/**
|
551 |
+
* Indicates whether or not the server is listening for connections.
|
552 |
+
* @since v5.7.0
|
553 |
+
*/
|
554 |
+
listening: boolean;
|
555 |
+
/**
|
556 |
+
* events.EventEmitter
|
557 |
+
* 1. close
|
558 |
+
* 2. connection
|
559 |
+
* 3. error
|
560 |
+
* 4. listening
|
561 |
+
*/
|
562 |
+
addListener(event: string, listener: (...args: any[]) => void): this;
|
563 |
+
addListener(event: 'close', listener: () => void): this;
|
564 |
+
addListener(event: 'connection', listener: (socket: Socket) => void): this;
|
565 |
+
addListener(event: 'error', listener: (err: Error) => void): this;
|
566 |
+
addListener(event: 'listening', listener: () => void): this;
|
567 |
+
emit(event: string | symbol, ...args: any[]): boolean;
|
568 |
+
emit(event: 'close'): boolean;
|
569 |
+
emit(event: 'connection', socket: Socket): boolean;
|
570 |
+
emit(event: 'error', err: Error): boolean;
|
571 |
+
emit(event: 'listening'): boolean;
|
572 |
+
on(event: string, listener: (...args: any[]) => void): this;
|
573 |
+
on(event: 'close', listener: () => void): this;
|
574 |
+
on(event: 'connection', listener: (socket: Socket) => void): this;
|
575 |
+
on(event: 'error', listener: (err: Error) => void): this;
|
576 |
+
on(event: 'listening', listener: () => void): this;
|
577 |
+
once(event: string, listener: (...args: any[]) => void): this;
|
578 |
+
once(event: 'close', listener: () => void): this;
|
579 |
+
once(event: 'connection', listener: (socket: Socket) => void): this;
|
580 |
+
once(event: 'error', listener: (err: Error) => void): this;
|
581 |
+
once(event: 'listening', listener: () => void): this;
|
582 |
+
prependListener(event: string, listener: (...args: any[]) => void): this;
|
583 |
+
prependListener(event: 'close', listener: () => void): this;
|
584 |
+
prependListener(event: 'connection', listener: (socket: Socket) => void): this;
|
585 |
+
prependListener(event: 'error', listener: (err: Error) => void): this;
|
586 |
+
prependListener(event: 'listening', listener: () => void): this;
|
587 |
+
prependOnceListener(event: string, listener: (...args: any[]) => void): this;
|
588 |
+
prependOnceListener(event: 'close', listener: () => void): this;
|
589 |
+
prependOnceListener(event: 'connection', listener: (socket: Socket) => void): this;
|
590 |
+
prependOnceListener(event: 'error', listener: (err: Error) => void): this;
|
591 |
+
prependOnceListener(event: 'listening', listener: () => void): this;
|
592 |
+
}
|
593 |
+
type IPVersion = 'ipv4' | 'ipv6';
|
594 |
+
/**
|
595 |
+
* The `BlockList` object can be used with some network APIs to specify rules for
|
596 |
+
* disabling inbound or outbound access to specific IP addresses, IP ranges, or
|
597 |
+
* IP subnets.
|
598 |
+
* @since v15.0.0, v14.18.0
|
599 |
+
*/
|
600 |
+
class BlockList {
|
601 |
+
/**
|
602 |
+
* Adds a rule to block the given IP address.
|
603 |
+
* @since v15.0.0, v14.18.0
|
604 |
+
* @param address An IPv4 or IPv6 address.
|
605 |
+
* @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
|
606 |
+
*/
|
607 |
+
addAddress(address: string, type?: IPVersion): void;
|
608 |
+
addAddress(address: SocketAddress): void;
|
609 |
+
/**
|
610 |
+
* Adds a rule to block a range of IP addresses from `start` (inclusive) to`end` (inclusive).
|
611 |
+
* @since v15.0.0, v14.18.0
|
612 |
+
* @param start The starting IPv4 or IPv6 address in the range.
|
613 |
+
* @param end The ending IPv4 or IPv6 address in the range.
|
614 |
+
* @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
|
615 |
+
*/
|
616 |
+
addRange(start: string, end: string, type?: IPVersion): void;
|
617 |
+
addRange(start: SocketAddress, end: SocketAddress): void;
|
618 |
+
/**
|
619 |
+
* Adds a rule to block a range of IP addresses specified as a subnet mask.
|
620 |
+
* @since v15.0.0, v14.18.0
|
621 |
+
* @param net The network IPv4 or IPv6 address.
|
622 |
+
* @param prefix The number of CIDR prefix bits. For IPv4, this must be a value between `0` and `32`. For IPv6, this must be between `0` and `128`.
|
623 |
+
* @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
|
624 |
+
*/
|
625 |
+
addSubnet(net: SocketAddress, prefix: number): void;
|
626 |
+
addSubnet(net: string, prefix: number, type?: IPVersion): void;
|
627 |
+
/**
|
628 |
+
* Returns `true` if the given IP address matches any of the rules added to the`BlockList`.
|
629 |
+
*
|
630 |
+
* ```js
|
631 |
+
* const blockList = new net.BlockList();
|
632 |
+
* blockList.addAddress('123.123.123.123');
|
633 |
+
* blockList.addRange('10.0.0.1', '10.0.0.10');
|
634 |
+
* blockList.addSubnet('8592:757c:efae:4e45::', 64, 'ipv6');
|
635 |
+
*
|
636 |
+
* console.log(blockList.check('123.123.123.123')); // Prints: true
|
637 |
+
* console.log(blockList.check('10.0.0.3')); // Prints: true
|
638 |
+
* console.log(blockList.check('222.111.111.222')); // Prints: false
|
639 |
+
*
|
640 |
+
* // IPv6 notation for IPv4 addresses works:
|
641 |
+
* console.log(blockList.check('::ffff:7b7b:7b7b', 'ipv6')); // Prints: true
|
642 |
+
* console.log(blockList.check('::ffff:123.123.123.123', 'ipv6')); // Prints: true
|
643 |
+
* ```
|
644 |
+
* @since v15.0.0, v14.18.0
|
645 |
+
* @param address The IP address to check
|
646 |
+
* @param [type='ipv4'] Either `'ipv4'` or `'ipv6'`.
|
647 |
+
*/
|
648 |
+
check(address: SocketAddress): boolean;
|
649 |
+
check(address: string, type?: IPVersion): boolean;
|
650 |
+
}
|
651 |
+
interface TcpNetConnectOpts extends TcpSocketConnectOpts, SocketConstructorOpts {
|
652 |
+
timeout?: number | undefined;
|
653 |
+
}
|
654 |
+
interface IpcNetConnectOpts extends IpcSocketConnectOpts, SocketConstructorOpts {
|
655 |
+
timeout?: number | undefined;
|
656 |
+
}
|
657 |
+
type NetConnectOpts = TcpNetConnectOpts | IpcNetConnectOpts;
|
658 |
+
/**
|
659 |
+
* Creates a new TCP or `IPC` server.
|
660 |
+
*
|
661 |
+
* If `allowHalfOpen` is set to `true`, when the other end of the socket
|
662 |
+
* signals the end of transmission, the server will only send back the end of
|
663 |
+
* transmission when `socket.end()` is explicitly called. For example, in the
|
664 |
+
* context of TCP, when a FIN packed is received, a FIN packed is sent
|
665 |
+
* back only when `socket.end()` is explicitly called. Until then the
|
666 |
+
* connection is half-closed (non-readable but still writable). See `'end'` event and [RFC 1122](https://tools.ietf.org/html/rfc1122) (section 4.2.2.13) for more information.
|
667 |
+
*
|
668 |
+
* If `pauseOnConnect` is set to `true`, then the socket associated with each
|
669 |
+
* incoming connection will be paused, and no data will be read from its handle.
|
670 |
+
* This allows connections to be passed between processes without any data being
|
671 |
+
* read by the original process. To begin reading data from a paused socket, call `socket.resume()`.
|
672 |
+
*
|
673 |
+
* The server can be a TCP server or an `IPC` server, depending on what it `listen()` to.
|
674 |
+
*
|
675 |
+
* Here is an example of a TCP echo server which listens for connections
|
676 |
+
* on port 8124:
|
677 |
+
*
|
678 |
+
* ```js
|
679 |
+
* const net = require('net');
|
680 |
+
* const server = net.createServer((c) => {
|
681 |
+
* // 'connection' listener.
|
682 |
+
* console.log('client connected');
|
683 |
+
* c.on('end', () => {
|
684 |
+
* console.log('client disconnected');
|
685 |
+
* });
|
686 |
+
* c.write('hello\r\n');
|
687 |
+
* c.pipe(c);
|
688 |
+
* });
|
689 |
+
* server.on('error', (err) => {
|
690 |
+
* throw err;
|
691 |
+
* });
|
692 |
+
* server.listen(8124, () => {
|
693 |
+
* console.log('server bound');
|
694 |
+
* });
|
695 |
+
* ```
|
696 |
+
*
|
697 |
+
* Test this by using `telnet`:
|
698 |
+
*
|
699 |
+
* ```console
|
700 |
+
* $ telnet localhost 8124
|
701 |
+
* ```
|
702 |
+
*
|
703 |
+
* To listen on the socket `/tmp/echo.sock`:
|
704 |
+
*
|
705 |
+
* ```js
|
706 |
+
* server.listen('/tmp/echo.sock', () => {
|
707 |
+
* console.log('server bound');
|
708 |
+
* });
|
709 |
+
* ```
|
710 |
+
*
|
711 |
+
* Use `nc` to connect to a Unix domain socket server:
|
712 |
+
*
|
713 |
+
* ```console
|
714 |
+
* $ nc -U /tmp/echo.sock
|
715 |
+
* ```
|
716 |
+
* @since v0.5.0
|
717 |
+
* @param connectionListener Automatically set as a listener for the {@link 'connection'} event.
|
718 |
+
*/
|
719 |
+
function createServer(connectionListener?: (socket: Socket) => void): Server;
|
720 |
+
function createServer(options?: ServerOpts, connectionListener?: (socket: Socket) => void): Server;
|
721 |
+
/**
|
722 |
+
* Aliases to {@link createConnection}.
|
723 |
+
*
|
724 |
+
* Possible signatures:
|
725 |
+
*
|
726 |
+
* * {@link connect}
|
727 |
+
* * {@link connect} for `IPC` connections.
|
728 |
+
* * {@link connect} for TCP connections.
|
729 |
+
*/
|
730 |
+
function connect(options: NetConnectOpts, connectionListener?: () => void): Socket;
|
731 |
+
function connect(port: number, host?: string, connectionListener?: () => void): Socket;
|
732 |
+
function connect(path: string, connectionListener?: () => void): Socket;
|
733 |
+
/**
|
734 |
+
* A factory function, which creates a new {@link Socket},
|
735 |
+
* immediately initiates connection with `socket.connect()`,
|
736 |
+
* then returns the `net.Socket` that starts the connection.
|
737 |
+
*
|
738 |
+
* When the connection is established, a `'connect'` event will be emitted
|
739 |
+
* on the returned socket. The last parameter `connectListener`, if supplied,
|
740 |
+
* will be added as a listener for the `'connect'` event **once**.
|
741 |
+
*
|
742 |
+
* Possible signatures:
|
743 |
+
*
|
744 |
+
* * {@link createConnection}
|
745 |
+
* * {@link createConnection} for `IPC` connections.
|
746 |
+
* * {@link createConnection} for TCP connections.
|
747 |
+
*
|
748 |
+
* The {@link connect} function is an alias to this function.
|
749 |
+
*/
|
750 |
+
function createConnection(options: NetConnectOpts, connectionListener?: () => void): Socket;
|
751 |
+
function createConnection(port: number, host?: string, connectionListener?: () => void): Socket;
|
752 |
+
function createConnection(path: string, connectionListener?: () => void): Socket;
|
753 |
+
/**
|
754 |
+
* Returns `6` if `input` is an IPv6 address. Returns `4` if `input` is an IPv4
|
755 |
+
* address in [dot-decimal notation](https://en.wikipedia.org/wiki/Dot-decimal_notation) with no leading zeroes. Otherwise, returns`0`.
|
756 |
+
*
|
757 |
+
* ```js
|
758 |
+
* net.isIP('::1'); // returns 6
|
759 |
+
* net.isIP('127.0.0.1'); // returns 4
|
760 |
+
* net.isIP('127.000.000.001'); // returns 0
|
761 |
+
* net.isIP('127.0.0.1/24'); // returns 0
|
762 |
+
* net.isIP('fhqwhgads'); // returns 0
|
763 |
+
* ```
|
764 |
+
* @since v0.3.0
|
765 |
+
*/
|
766 |
+
function isIP(input: string): number;
|
767 |
+
/**
|
768 |
+
* Returns `true` if `input` is an IPv4 address in [dot-decimal notation](https://en.wikipedia.org/wiki/Dot-decimal_notation) with no
|
769 |
+
* leading zeroes. Otherwise, returns `false`.
|
770 |
+
*
|
771 |
+
* ```js
|
772 |
+
* net.isIPv4('127.0.0.1'); // returns true
|
773 |
+
* net.isIPv4('127.000.000.001'); // returns false
|
774 |
+
* net.isIPv4('127.0.0.1/24'); // returns false
|
775 |
+
* net.isIPv4('fhqwhgads'); // returns false
|
776 |
+
* ```
|
777 |
+
* @since v0.3.0
|
778 |
+
*/
|
779 |
+
function isIPv4(input: string): boolean;
|
780 |
+
/**
|
781 |
+
* Returns `true` if `input` is an IPv6 address. Otherwise, returns `false`.
|
782 |
+
*
|
783 |
+
* ```js
|
784 |
+
* net.isIPv6('::1'); // returns true
|
785 |
+
* net.isIPv6('fhqwhgads'); // returns false
|
786 |
+
* ```
|
787 |
+
* @since v0.3.0
|
788 |
+
*/
|
789 |
+
function isIPv6(input: string): boolean;
|
790 |
+
interface SocketAddressInitOptions {
|
791 |
+
/**
|
792 |
+
* The network address as either an IPv4 or IPv6 string.
|
793 |
+
* @default 127.0.0.1
|
794 |
+
*/
|
795 |
+
address?: string | undefined;
|
796 |
+
/**
|
797 |
+
* @default `'ipv4'`
|
798 |
+
*/
|
799 |
+
family?: IPVersion | undefined;
|
800 |
+
/**
|
801 |
+
* An IPv6 flow-label used only if `family` is `'ipv6'`.
|
802 |
+
* @default 0
|
803 |
+
*/
|
804 |
+
flowlabel?: number | undefined;
|
805 |
+
/**
|
806 |
+
* An IP port.
|
807 |
+
* @default 0
|
808 |
+
*/
|
809 |
+
port?: number | undefined;
|
810 |
+
}
|
811 |
+
/**
|
812 |
+
* @since v15.14.0, v14.18.0
|
813 |
+
*/
|
814 |
+
class SocketAddress {
|
815 |
+
constructor(options: SocketAddressInitOptions);
|
816 |
+
/**
|
817 |
+
* Either \`'ipv4'\` or \`'ipv6'\`.
|
818 |
+
* @since v15.14.0, v14.18.0
|
819 |
+
*/
|
820 |
+
readonly address: string;
|
821 |
+
/**
|
822 |
+
* Either \`'ipv4'\` or \`'ipv6'\`.
|
823 |
+
* @since v15.14.0, v14.18.0
|
824 |
+
*/
|
825 |
+
readonly family: IPVersion;
|
826 |
+
/**
|
827 |
+
* @since v15.14.0, v14.18.0
|
828 |
+
*/
|
829 |
+
readonly port: number;
|
830 |
+
/**
|
831 |
+
* @since v15.14.0, v14.18.0
|
832 |
+
*/
|
833 |
+
readonly flowlabel: number;
|
834 |
+
}
|
835 |
+
}
|
836 |
+
declare module 'node:net' {
|
837 |
+
export * from 'net';
|
838 |
+
}
|
igv_component/node_modules/@types/node/os.d.ts
ADDED
@@ -0,0 +1,466 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* The `os` module provides operating system-related utility methods and
|
3 |
+
* properties. It can be accessed using:
|
4 |
+
*
|
5 |
+
* ```js
|
6 |
+
* const os = require('os');
|
7 |
+
* ```
|
8 |
+
* @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/os.js)
|
9 |
+
*/
|
10 |
+
declare module 'os' {
|
11 |
+
interface CpuInfo {
|
12 |
+
model: string;
|
13 |
+
speed: number;
|
14 |
+
times: {
|
15 |
+
user: number;
|
16 |
+
nice: number;
|
17 |
+
sys: number;
|
18 |
+
idle: number;
|
19 |
+
irq: number;
|
20 |
+
};
|
21 |
+
}
|
22 |
+
interface NetworkInterfaceBase {
|
23 |
+
address: string;
|
24 |
+
netmask: string;
|
25 |
+
mac: string;
|
26 |
+
internal: boolean;
|
27 |
+
cidr: string | null;
|
28 |
+
}
|
29 |
+
interface NetworkInterfaceInfoIPv4 extends NetworkInterfaceBase {
|
30 |
+
family: 'IPv4';
|
31 |
+
scopeid?: undefined;
|
32 |
+
}
|
33 |
+
interface NetworkInterfaceInfoIPv6 extends NetworkInterfaceBase {
|
34 |
+
family: 'IPv6';
|
35 |
+
scopeid: number;
|
36 |
+
}
|
37 |
+
interface UserInfo<T> {
|
38 |
+
username: T;
|
39 |
+
uid: number;
|
40 |
+
gid: number;
|
41 |
+
shell: T;
|
42 |
+
homedir: T;
|
43 |
+
}
|
44 |
+
type NetworkInterfaceInfo = NetworkInterfaceInfoIPv4 | NetworkInterfaceInfoIPv6;
|
45 |
+
/**
|
46 |
+
* Returns the host name of the operating system as a string.
|
47 |
+
* @since v0.3.3
|
48 |
+
*/
|
49 |
+
function hostname(): string;
|
50 |
+
/**
|
51 |
+
* Returns an array containing the 1, 5, and 15 minute load averages.
|
52 |
+
*
|
53 |
+
* The load average is a measure of system activity calculated by the operating
|
54 |
+
* system and expressed as a fractional number.
|
55 |
+
*
|
56 |
+
* The load average is a Unix-specific concept. On Windows, the return value is
|
57 |
+
* always `[0, 0, 0]`.
|
58 |
+
* @since v0.3.3
|
59 |
+
*/
|
60 |
+
function loadavg(): number[];
|
61 |
+
/**
|
62 |
+
* Returns the system uptime in number of seconds.
|
63 |
+
* @since v0.3.3
|
64 |
+
*/
|
65 |
+
function uptime(): number;
|
66 |
+
/**
|
67 |
+
* Returns the amount of free system memory in bytes as an integer.
|
68 |
+
* @since v0.3.3
|
69 |
+
*/
|
70 |
+
function freemem(): number;
|
71 |
+
/**
|
72 |
+
* Returns the total amount of system memory in bytes as an integer.
|
73 |
+
* @since v0.3.3
|
74 |
+
*/
|
75 |
+
function totalmem(): number;
|
76 |
+
/**
|
77 |
+
* Returns an array of objects containing information about each logical CPU core.
|
78 |
+
*
|
79 |
+
* The properties included on each object include:
|
80 |
+
*
|
81 |
+
* ```js
|
82 |
+
* [
|
83 |
+
* {
|
84 |
+
* model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
|
85 |
+
* speed: 2926,
|
86 |
+
* times: {
|
87 |
+
* user: 252020,
|
88 |
+
* nice: 0,
|
89 |
+
* sys: 30340,
|
90 |
+
* idle: 1070356870,
|
91 |
+
* irq: 0
|
92 |
+
* }
|
93 |
+
* },
|
94 |
+
* {
|
95 |
+
* model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
|
96 |
+
* speed: 2926,
|
97 |
+
* times: {
|
98 |
+
* user: 306960,
|
99 |
+
* nice: 0,
|
100 |
+
* sys: 26980,
|
101 |
+
* idle: 1071569080,
|
102 |
+
* irq: 0
|
103 |
+
* }
|
104 |
+
* },
|
105 |
+
* {
|
106 |
+
* model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
|
107 |
+
* speed: 2926,
|
108 |
+
* times: {
|
109 |
+
* user: 248450,
|
110 |
+
* nice: 0,
|
111 |
+
* sys: 21750,
|
112 |
+
* idle: 1070919370,
|
113 |
+
* irq: 0
|
114 |
+
* }
|
115 |
+
* },
|
116 |
+
* {
|
117 |
+
* model: 'Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz',
|
118 |
+
* speed: 2926,
|
119 |
+
* times: {
|
120 |
+
* user: 256880,
|
121 |
+
* nice: 0,
|
122 |
+
* sys: 19430,
|
123 |
+
* idle: 1070905480,
|
124 |
+
* irq: 20
|
125 |
+
* }
|
126 |
+
* },
|
127 |
+
* ]
|
128 |
+
* ```
|
129 |
+
*
|
130 |
+
* `nice` values are POSIX-only. On Windows, the `nice` values of all processors
|
131 |
+
* are always 0.
|
132 |
+
* @since v0.3.3
|
133 |
+
*/
|
134 |
+
function cpus(): CpuInfo[];
|
135 |
+
/**
|
136 |
+
* Returns the operating system name as returned by [`uname(3)`](https://linux.die.net/man/3/uname). For example, it
|
137 |
+
* returns `'Linux'` on Linux, `'Darwin'` on macOS, and `'Windows_NT'` on Windows.
|
138 |
+
*
|
139 |
+
* See [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for additional information
|
140 |
+
* about the output of running [`uname(3)`](https://linux.die.net/man/3/uname) on various operating systems.
|
141 |
+
* @since v0.3.3
|
142 |
+
*/
|
143 |
+
function type(): string;
|
144 |
+
/**
|
145 |
+
* Returns the operating system as a string.
|
146 |
+
*
|
147 |
+
* On POSIX systems, the operating system release is determined by calling [`uname(3)`](https://linux.die.net/man/3/uname). On Windows, `GetVersionExW()` is used. See
|
148 |
+
* [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for more information.
|
149 |
+
* @since v0.3.3
|
150 |
+
*/
|
151 |
+
function release(): string;
|
152 |
+
/**
|
153 |
+
* Returns an object containing network interfaces that have been assigned a
|
154 |
+
* network address.
|
155 |
+
*
|
156 |
+
* Each key on the returned object identifies a network interface. The associated
|
157 |
+
* value is an array of objects that each describe an assigned network address.
|
158 |
+
*
|
159 |
+
* The properties available on the assigned network address object include:
|
160 |
+
*
|
161 |
+
* ```js
|
162 |
+
* {
|
163 |
+
* lo: [
|
164 |
+
* {
|
165 |
+
* address: '127.0.0.1',
|
166 |
+
* netmask: '255.0.0.0',
|
167 |
+
* family: 'IPv4',
|
168 |
+
* mac: '00:00:00:00:00:00',
|
169 |
+
* internal: true,
|
170 |
+
* cidr: '127.0.0.1/8'
|
171 |
+
* },
|
172 |
+
* {
|
173 |
+
* address: '::1',
|
174 |
+
* netmask: 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff',
|
175 |
+
* family: 'IPv6',
|
176 |
+
* mac: '00:00:00:00:00:00',
|
177 |
+
* scopeid: 0,
|
178 |
+
* internal: true,
|
179 |
+
* cidr: '::1/128'
|
180 |
+
* }
|
181 |
+
* ],
|
182 |
+
* eth0: [
|
183 |
+
* {
|
184 |
+
* address: '192.168.1.108',
|
185 |
+
* netmask: '255.255.255.0',
|
186 |
+
* family: 'IPv4',
|
187 |
+
* mac: '01:02:03:0a:0b:0c',
|
188 |
+
* internal: false,
|
189 |
+
* cidr: '192.168.1.108/24'
|
190 |
+
* },
|
191 |
+
* {
|
192 |
+
* address: 'fe80::a00:27ff:fe4e:66a1',
|
193 |
+
* netmask: 'ffff:ffff:ffff:ffff::',
|
194 |
+
* family: 'IPv6',
|
195 |
+
* mac: '01:02:03:0a:0b:0c',
|
196 |
+
* scopeid: 1,
|
197 |
+
* internal: false,
|
198 |
+
* cidr: 'fe80::a00:27ff:fe4e:66a1/64'
|
199 |
+
* }
|
200 |
+
* ]
|
201 |
+
* }
|
202 |
+
* ```
|
203 |
+
* @since v0.6.0
|
204 |
+
*/
|
205 |
+
function networkInterfaces(): NodeJS.Dict<NetworkInterfaceInfo[]>;
|
206 |
+
/**
|
207 |
+
* Returns the string path of the current user's home directory.
|
208 |
+
*
|
209 |
+
* On POSIX, it uses the `$HOME` environment variable if defined. Otherwise it
|
210 |
+
* uses the [effective UID](https://en.wikipedia.org/wiki/User_identifier#Effective_user_ID) to look up the user's home directory.
|
211 |
+
*
|
212 |
+
* On Windows, it uses the `USERPROFILE` environment variable if defined.
|
213 |
+
* Otherwise it uses the path to the profile directory of the current user.
|
214 |
+
* @since v2.3.0
|
215 |
+
*/
|
216 |
+
function homedir(): string;
|
217 |
+
/**
|
218 |
+
* Returns information about the currently effective user. On POSIX platforms,
|
219 |
+
* this is typically a subset of the password file. The returned object includes
|
220 |
+
* the `username`, `uid`, `gid`, `shell`, and `homedir`. On Windows, the `uid` and`gid` fields are `-1`, and `shell` is `null`.
|
221 |
+
*
|
222 |
+
* The value of `homedir` returned by `os.userInfo()` is provided by the operating
|
223 |
+
* system. This differs from the result of `os.homedir()`, which queries
|
224 |
+
* environment variables for the home directory before falling back to the
|
225 |
+
* operating system response.
|
226 |
+
*
|
227 |
+
* Throws a `SystemError` if a user has no `username` or `homedir`.
|
228 |
+
* @since v6.0.0
|
229 |
+
*/
|
230 |
+
function userInfo(options: { encoding: 'buffer' }): UserInfo<Buffer>;
|
231 |
+
function userInfo(options?: { encoding: BufferEncoding }): UserInfo<string>;
|
232 |
+
type SignalConstants = {
|
233 |
+
[key in NodeJS.Signals]: number;
|
234 |
+
};
|
235 |
+
namespace constants {
|
236 |
+
const UV_UDP_REUSEADDR: number;
|
237 |
+
namespace signals {}
|
238 |
+
const signals: SignalConstants;
|
239 |
+
namespace errno {
|
240 |
+
const E2BIG: number;
|
241 |
+
const EACCES: number;
|
242 |
+
const EADDRINUSE: number;
|
243 |
+
const EADDRNOTAVAIL: number;
|
244 |
+
const EAFNOSUPPORT: number;
|
245 |
+
const EAGAIN: number;
|
246 |
+
const EALREADY: number;
|
247 |
+
const EBADF: number;
|
248 |
+
const EBADMSG: number;
|
249 |
+
const EBUSY: number;
|
250 |
+
const ECANCELED: number;
|
251 |
+
const ECHILD: number;
|
252 |
+
const ECONNABORTED: number;
|
253 |
+
const ECONNREFUSED: number;
|
254 |
+
const ECONNRESET: number;
|
255 |
+
const EDEADLK: number;
|
256 |
+
const EDESTADDRREQ: number;
|
257 |
+
const EDOM: number;
|
258 |
+
const EDQUOT: number;
|
259 |
+
const EEXIST: number;
|
260 |
+
const EFAULT: number;
|
261 |
+
const EFBIG: number;
|
262 |
+
const EHOSTUNREACH: number;
|
263 |
+
const EIDRM: number;
|
264 |
+
const EILSEQ: number;
|
265 |
+
const EINPROGRESS: number;
|
266 |
+
const EINTR: number;
|
267 |
+
const EINVAL: number;
|
268 |
+
const EIO: number;
|
269 |
+
const EISCONN: number;
|
270 |
+
const EISDIR: number;
|
271 |
+
const ELOOP: number;
|
272 |
+
const EMFILE: number;
|
273 |
+
const EMLINK: number;
|
274 |
+
const EMSGSIZE: number;
|
275 |
+
const EMULTIHOP: number;
|
276 |
+
const ENAMETOOLONG: number;
|
277 |
+
const ENETDOWN: number;
|
278 |
+
const ENETRESET: number;
|
279 |
+
const ENETUNREACH: number;
|
280 |
+
const ENFILE: number;
|
281 |
+
const ENOBUFS: number;
|
282 |
+
const ENODATA: number;
|
283 |
+
const ENODEV: number;
|
284 |
+
const ENOENT: number;
|
285 |
+
const ENOEXEC: number;
|
286 |
+
const ENOLCK: number;
|
287 |
+
const ENOLINK: number;
|
288 |
+
const ENOMEM: number;
|
289 |
+
const ENOMSG: number;
|
290 |
+
const ENOPROTOOPT: number;
|
291 |
+
const ENOSPC: number;
|
292 |
+
const ENOSR: number;
|
293 |
+
const ENOSTR: number;
|
294 |
+
const ENOSYS: number;
|
295 |
+
const ENOTCONN: number;
|
296 |
+
const ENOTDIR: number;
|
297 |
+
const ENOTEMPTY: number;
|
298 |
+
const ENOTSOCK: number;
|
299 |
+
const ENOTSUP: number;
|
300 |
+
const ENOTTY: number;
|
301 |
+
const ENXIO: number;
|
302 |
+
const EOPNOTSUPP: number;
|
303 |
+
const EOVERFLOW: number;
|
304 |
+
const EPERM: number;
|
305 |
+
const EPIPE: number;
|
306 |
+
const EPROTO: number;
|
307 |
+
const EPROTONOSUPPORT: number;
|
308 |
+
const EPROTOTYPE: number;
|
309 |
+
const ERANGE: number;
|
310 |
+
const EROFS: number;
|
311 |
+
const ESPIPE: number;
|
312 |
+
const ESRCH: number;
|
313 |
+
const ESTALE: number;
|
314 |
+
const ETIME: number;
|
315 |
+
const ETIMEDOUT: number;
|
316 |
+
const ETXTBSY: number;
|
317 |
+
const EWOULDBLOCK: number;
|
318 |
+
const EXDEV: number;
|
319 |
+
const WSAEINTR: number;
|
320 |
+
const WSAEBADF: number;
|
321 |
+
const WSAEACCES: number;
|
322 |
+
const WSAEFAULT: number;
|
323 |
+
const WSAEINVAL: number;
|
324 |
+
const WSAEMFILE: number;
|
325 |
+
const WSAEWOULDBLOCK: number;
|
326 |
+
const WSAEINPROGRESS: number;
|
327 |
+
const WSAEALREADY: number;
|
328 |
+
const WSAENOTSOCK: number;
|
329 |
+
const WSAEDESTADDRREQ: number;
|
330 |
+
const WSAEMSGSIZE: number;
|
331 |
+
const WSAEPROTOTYPE: number;
|
332 |
+
const WSAENOPROTOOPT: number;
|
333 |
+
const WSAEPROTONOSUPPORT: number;
|
334 |
+
const WSAESOCKTNOSUPPORT: number;
|
335 |
+
const WSAEOPNOTSUPP: number;
|
336 |
+
const WSAEPFNOSUPPORT: number;
|
337 |
+
const WSAEAFNOSUPPORT: number;
|
338 |
+
const WSAEADDRINUSE: number;
|
339 |
+
const WSAEADDRNOTAVAIL: number;
|
340 |
+
const WSAENETDOWN: number;
|
341 |
+
const WSAENETUNREACH: number;
|
342 |
+
const WSAENETRESET: number;
|
343 |
+
const WSAECONNABORTED: number;
|
344 |
+
const WSAECONNRESET: number;
|
345 |
+
const WSAENOBUFS: number;
|
346 |
+
const WSAEISCONN: number;
|
347 |
+
const WSAENOTCONN: number;
|
348 |
+
const WSAESHUTDOWN: number;
|
349 |
+
const WSAETOOMANYREFS: number;
|
350 |
+
const WSAETIMEDOUT: number;
|
351 |
+
const WSAECONNREFUSED: number;
|
352 |
+
const WSAELOOP: number;
|
353 |
+
const WSAENAMETOOLONG: number;
|
354 |
+
const WSAEHOSTDOWN: number;
|
355 |
+
const WSAEHOSTUNREACH: number;
|
356 |
+
const WSAENOTEMPTY: number;
|
357 |
+
const WSAEPROCLIM: number;
|
358 |
+
const WSAEUSERS: number;
|
359 |
+
const WSAEDQUOT: number;
|
360 |
+
const WSAESTALE: number;
|
361 |
+
const WSAEREMOTE: number;
|
362 |
+
const WSASYSNOTREADY: number;
|
363 |
+
const WSAVERNOTSUPPORTED: number;
|
364 |
+
const WSANOTINITIALISED: number;
|
365 |
+
const WSAEDISCON: number;
|
366 |
+
const WSAENOMORE: number;
|
367 |
+
const WSAECANCELLED: number;
|
368 |
+
const WSAEINVALIDPROCTABLE: number;
|
369 |
+
const WSAEINVALIDPROVIDER: number;
|
370 |
+
const WSAEPROVIDERFAILEDINIT: number;
|
371 |
+
const WSASYSCALLFAILURE: number;
|
372 |
+
const WSASERVICE_NOT_FOUND: number;
|
373 |
+
const WSATYPE_NOT_FOUND: number;
|
374 |
+
const WSA_E_NO_MORE: number;
|
375 |
+
const WSA_E_CANCELLED: number;
|
376 |
+
const WSAEREFUSED: number;
|
377 |
+
}
|
378 |
+
namespace priority {
|
379 |
+
const PRIORITY_LOW: number;
|
380 |
+
const PRIORITY_BELOW_NORMAL: number;
|
381 |
+
const PRIORITY_NORMAL: number;
|
382 |
+
const PRIORITY_ABOVE_NORMAL: number;
|
383 |
+
const PRIORITY_HIGH: number;
|
384 |
+
const PRIORITY_HIGHEST: number;
|
385 |
+
}
|
386 |
+
}
|
387 |
+
const devNull: string;
|
388 |
+
const EOL: string;
|
389 |
+
/**
|
390 |
+
* Returns the operating system CPU architecture for which the Node.js binary was
|
391 |
+
* compiled. Possible values are `'arm'`, `'arm64'`, `'ia32'`, `'mips'`,`'mipsel'`, `'ppc'`, `'ppc64'`, `'s390'`, `'s390x'`, and `'x64'`.
|
392 |
+
*
|
393 |
+
* The return value is equivalent to `process.arch`.
|
394 |
+
* @since v0.5.0
|
395 |
+
*/
|
396 |
+
function arch(): string;
|
397 |
+
/**
|
398 |
+
* Returns a string identifying the kernel version.
|
399 |
+
*
|
400 |
+
* On POSIX systems, the operating system release is determined by calling [`uname(3)`](https://linux.die.net/man/3/uname). On Windows, `RtlGetVersion()` is used, and if it is not
|
401 |
+
* available, `GetVersionExW()` will be used. See [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for more information.
|
402 |
+
* @since v13.11.0, v12.17.0
|
403 |
+
*/
|
404 |
+
function version(): string;
|
405 |
+
/**
|
406 |
+
* Returns a string identifying the operating system platform for which
|
407 |
+
* the Node.js binary was compiled. The value is set at compile time.
|
408 |
+
* Possible values are `'aix'`, `'darwin'`, `'freebsd'`,`'linux'`,`'openbsd'`, `'sunos'`, and `'win32'`.
|
409 |
+
*
|
410 |
+
* The return value is equivalent to `process.platform`.
|
411 |
+
*
|
412 |
+
* The value `'android'` may also be returned if Node.js is built on the Android
|
413 |
+
* operating system. [Android support is experimental](https://github.com/nodejs/node/blob/HEAD/BUILDING.md#androidandroid-based-devices-eg-firefox-os).
|
414 |
+
* @since v0.5.0
|
415 |
+
*/
|
416 |
+
function platform(): NodeJS.Platform;
|
417 |
+
/**
|
418 |
+
* Returns the machine type as a string, such as arm, aarch64, mips, mips64, ppc64, ppc64le, s390, s390x, i386, i686, x86_64.
|
419 |
+
*
|
420 |
+
* On POSIX systems, the machine type is determined by calling [`uname(3)`](https://linux.die.net/man/3/uname).
|
421 |
+
* On Windows, `RtlGetVersion()` is used, and if it is not available, `GetVersionExW()` will be used.
|
422 |
+
* See [https://en.wikipedia.org/wiki/Uname#Examples](https://en.wikipedia.org/wiki/Uname#Examples) for more information.
|
423 |
+
* @since v18.9.0
|
424 |
+
*/
|
425 |
+
function machine(): string;
|
426 |
+
/**
|
427 |
+
* Returns the operating system's default directory for temporary files as a
|
428 |
+
* string.
|
429 |
+
* @since v0.9.9
|
430 |
+
*/
|
431 |
+
function tmpdir(): string;
|
432 |
+
/**
|
433 |
+
* Returns a string identifying the endianness of the CPU for which the Node.js
|
434 |
+
* binary was compiled.
|
435 |
+
*
|
436 |
+
* Possible values are `'BE'` for big endian and `'LE'` for little endian.
|
437 |
+
* @since v0.9.4
|
438 |
+
*/
|
439 |
+
function endianness(): 'BE' | 'LE';
|
440 |
+
/**
|
441 |
+
* Returns the scheduling priority for the process specified by `pid`. If `pid` is
|
442 |
+
* not provided or is `0`, the priority of the current process is returned.
|
443 |
+
* @since v10.10.0
|
444 |
+
* @param [pid=0] The process ID to retrieve scheduling priority for.
|
445 |
+
*/
|
446 |
+
function getPriority(pid?: number): number;
|
447 |
+
/**
|
448 |
+
* Attempts to set the scheduling priority for the process specified by `pid`. If`pid` is not provided or is `0`, the process ID of the current process is used.
|
449 |
+
*
|
450 |
+
* The `priority` input must be an integer between `-20` (high priority) and `19`(low priority). Due to differences between Unix priority levels and Windows
|
451 |
+
* priority classes, `priority` is mapped to one of six priority constants in`os.constants.priority`. When retrieving a process priority level, this range
|
452 |
+
* mapping may cause the return value to be slightly different on Windows. To avoid
|
453 |
+
* confusion, set `priority` to one of the priority constants.
|
454 |
+
*
|
455 |
+
* On Windows, setting priority to `PRIORITY_HIGHEST` requires elevated user
|
456 |
+
* privileges. Otherwise the set priority will be silently reduced to`PRIORITY_HIGH`.
|
457 |
+
* @since v10.10.0
|
458 |
+
* @param [pid=0] The process ID to set scheduling priority for.
|
459 |
+
* @param priority The scheduling priority to assign to the process.
|
460 |
+
*/
|
461 |
+
function setPriority(priority: number): void;
|
462 |
+
function setPriority(pid: number, priority: number): void;
|
463 |
+
}
|
464 |
+
declare module 'node:os' {
|
465 |
+
export * from 'os';
|
466 |
+
}
|