Skip to content

Commit

Permalink
typings: add JSDoc typings for https
Browse files Browse the repository at this point in the history
Added JSDoc typings for the `https` lib module.

PR-URL: #38589
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
VoltrexKeyva authored and danielleadams committed May 31, 2021
1 parent 9ca5c0e commit 30c0020
Showing 1 changed file with 71 additions and 1 deletion.
72 changes: 71 additions & 1 deletion lib/https.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,17 @@ ObjectSetPrototypeOf(Server, tls.Server);

Server.prototype.setTimeout = HttpServer.prototype.setTimeout;

/**
* Creates a new `https.Server` instance.
* @param {{
* IncomingMessage?: IncomingMessage;
* ServerResponse?: ServerResponse;
* insecureHTTPParser?: boolean;
* maxHeaderSize?: number;
* }} [opts]
* @param {Function} [requestListener]
* @returns {Server}
*/
function createServer(opts, requestListener) {
return new Server(opts, requestListener);
}
Expand Down Expand Up @@ -151,7 +162,21 @@ function createConnection(port, host, options) {
return socket;
}


/**
* Creates a new `HttpAgent` instance.
* @param {{
* keepAlive?: boolean;
* keepAliveMsecs?: number;
* maxSockets?: number;
* maxTotalSockets?: number;
* maxFreeSockets?: number;
* scheduling?: string;
* timeout?: number;
* maxCachedSessions?: number;
* servername?: string;
* }} [options]
* @returns {Agent}
*/
function Agent(options) {
if (!(this instanceof Agent))
return new Agent(options);
Expand All @@ -172,6 +197,16 @@ ObjectSetPrototypeOf(Agent.prototype, HttpAgent.prototype);
ObjectSetPrototypeOf(Agent, HttpAgent);
Agent.prototype.createConnection = createConnection;

/**
* Gets a unique name for a set of options.
* @param {{
* host: string;
* port: number;
* localAddress: string;
* family: number;
* }} [options]
* @returns {string}
*/
Agent.prototype.getName = function getName(options) {
let name = FunctionPrototypeCall(HttpAgent.prototype.getName, this, options);

Expand Down Expand Up @@ -295,6 +330,11 @@ Agent.prototype._evictSession = function _evictSession(key) {

const globalAgent = new Agent();

/**
* Makes a request to a secure web server.
* @param {...any} args
* @returns {ClientRequest}
*/
function request(...args) {
let options = {};

Expand All @@ -317,6 +357,36 @@ function request(...args) {
return ReflectConstruct(ClientRequest, args);
}

/**
* Makes a GET request to a secure web server.
* @param {string | URL} input
* @param {{
* agent?: Agent | boolean;
* auth?: string;
* createConnection?: Function;
* defaultPort?: number;
* family?: number;
* headers?: Object;
* hints?: number;
* host?: string;
* hostname?: string;
* insecureHTTPParser?: boolean;
* localAddress?: string;
* localPort?: number;
* lookup?: Function;
* maxHeaderSize?: number;
* method?: string;
* path?: string;
* port?: number;
* protocol?: string;
* setHost?: boolean;
* socketPath?: string;
* timeout?: number;
* signal?: AbortSignal;
* } | string | URL} [options]
* @param {Function} [cb]
* @returns {ClientRequest}
*/
function get(input, options, cb) {
const req = request(input, options, cb);
req.end();
Expand Down

0 comments on commit 30c0020

Please sign in to comment.