Add node modules and compiled JavaScript from main (#54)
Co-authored-by: Oliver King <oking3@uncc.edu>
This commit is contained in:
committed by
GitHub
parent
4a983766a0
commit
52d71d28bd
5
node_modules/got/dist/source/core/calculate-retry-delay.d.ts
generated
vendored
Normal file
5
node_modules/got/dist/source/core/calculate-retry-delay.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { RetryFunction } from '.';
|
||||
declare type Returns<T extends (...args: any) => unknown, V> = (...args: Parameters<T>) => V;
|
||||
export declare const retryAfterStatusCodes: ReadonlySet<number>;
|
||||
declare const calculateRetryDelay: Returns<RetryFunction, number>;
|
||||
export default calculateRetryDelay;
|
29
node_modules/got/dist/source/core/calculate-retry-delay.js
generated
vendored
Normal file
29
node_modules/got/dist/source/core/calculate-retry-delay.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.retryAfterStatusCodes = void 0;
|
||||
exports.retryAfterStatusCodes = new Set([413, 429, 503]);
|
||||
const calculateRetryDelay = ({ attemptCount, retryOptions, error, retryAfter }) => {
|
||||
if (attemptCount > retryOptions.limit) {
|
||||
return 0;
|
||||
}
|
||||
const hasMethod = retryOptions.methods.includes(error.options.method);
|
||||
const hasErrorCode = retryOptions.errorCodes.includes(error.code);
|
||||
const hasStatusCode = error.response && retryOptions.statusCodes.includes(error.response.statusCode);
|
||||
if (!hasMethod || (!hasErrorCode && !hasStatusCode)) {
|
||||
return 0;
|
||||
}
|
||||
if (error.response) {
|
||||
if (retryAfter) {
|
||||
if (retryOptions.maxRetryAfter === undefined || retryAfter > retryOptions.maxRetryAfter) {
|
||||
return 0;
|
||||
}
|
||||
return retryAfter;
|
||||
}
|
||||
if (error.response.statusCode === 413) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
const noise = Math.random() * 100;
|
||||
return ((2 ** (attemptCount - 1)) * 1000) + noise;
|
||||
};
|
||||
exports.default = calculateRetryDelay;
|
1124
node_modules/got/dist/source/core/index.d.ts
generated
vendored
Normal file
1124
node_modules/got/dist/source/core/index.d.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1505
node_modules/got/dist/source/core/index.js
generated
vendored
Normal file
1505
node_modules/got/dist/source/core/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
5
node_modules/got/dist/source/core/utils/dns-ip-version.d.ts
generated
vendored
Normal file
5
node_modules/got/dist/source/core/utils/dns-ip-version.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
export declare type DnsLookupIpVersion = 'auto' | 'ipv4' | 'ipv6';
|
||||
declare type DnsIpFamily = 0 | 4 | 6;
|
||||
export declare const isDnsLookupIpVersion: (value: any) => boolean;
|
||||
export declare const dnsLookupIpVersionToFamily: (dnsLookupIpVersion: DnsLookupIpVersion) => DnsIpFamily;
|
||||
export {};
|
17
node_modules/got/dist/source/core/utils/dns-ip-version.js
generated
vendored
Normal file
17
node_modules/got/dist/source/core/utils/dns-ip-version.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.dnsLookupIpVersionToFamily = exports.isDnsLookupIpVersion = void 0;
|
||||
const conversionTable = {
|
||||
auto: 0,
|
||||
ipv4: 4,
|
||||
ipv6: 6
|
||||
};
|
||||
exports.isDnsLookupIpVersion = (value) => {
|
||||
return value in conversionTable;
|
||||
};
|
||||
exports.dnsLookupIpVersionToFamily = (dnsLookupIpVersion) => {
|
||||
if (exports.isDnsLookupIpVersion(dnsLookupIpVersion)) {
|
||||
return conversionTable[dnsLookupIpVersion];
|
||||
}
|
||||
throw new Error('Invalid DNS lookup IP version');
|
||||
};
|
3
node_modules/got/dist/source/core/utils/get-body-size.d.ts
generated
vendored
Normal file
3
node_modules/got/dist/source/core/utils/get-body-size.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { ClientRequestArgs } from 'http';
|
||||
declare const _default: (body: unknown, headers: ClientRequestArgs['headers']) => Promise<number | undefined>;
|
||||
export default _default;
|
32
node_modules/got/dist/source/core/utils/get-body-size.js
generated
vendored
Normal file
32
node_modules/got/dist/source/core/utils/get-body-size.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fs_1 = require("fs");
|
||||
const util_1 = require("util");
|
||||
const is_1 = require("@sindresorhus/is");
|
||||
const is_form_data_1 = require("./is-form-data");
|
||||
const statAsync = util_1.promisify(fs_1.stat);
|
||||
exports.default = async (body, headers) => {
|
||||
if (headers && 'content-length' in headers) {
|
||||
return Number(headers['content-length']);
|
||||
}
|
||||
if (!body) {
|
||||
return 0;
|
||||
}
|
||||
if (is_1.default.string(body)) {
|
||||
return Buffer.byteLength(body);
|
||||
}
|
||||
if (is_1.default.buffer(body)) {
|
||||
return body.length;
|
||||
}
|
||||
if (is_form_data_1.default(body)) {
|
||||
return util_1.promisify(body.getLength.bind(body))();
|
||||
}
|
||||
if (body instanceof fs_1.ReadStream) {
|
||||
const { size } = await statAsync(body.path);
|
||||
if (size === 0) {
|
||||
return undefined;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
return undefined;
|
||||
};
|
4
node_modules/got/dist/source/core/utils/get-buffer.d.ts
generated
vendored
Normal file
4
node_modules/got/dist/source/core/utils/get-buffer.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
/// <reference types="node" />
|
||||
import { Readable } from 'stream';
|
||||
declare const getBuffer: (stream: Readable) => Promise<Buffer>;
|
||||
export default getBuffer;
|
16
node_modules/got/dist/source/core/utils/get-buffer.js
generated
vendored
Normal file
16
node_modules/got/dist/source/core/utils/get-buffer.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// TODO: Update https://github.com/sindresorhus/get-stream
|
||||
const getBuffer = async (stream) => {
|
||||
const chunks = [];
|
||||
let length = 0;
|
||||
for await (const chunk of stream) {
|
||||
chunks.push(chunk);
|
||||
length += Buffer.byteLength(chunk);
|
||||
}
|
||||
if (Buffer.isBuffer(chunks[0])) {
|
||||
return Buffer.concat(chunks, length);
|
||||
}
|
||||
return Buffer.from(chunks.join(''));
|
||||
};
|
||||
exports.default = getBuffer;
|
8
node_modules/got/dist/source/core/utils/is-form-data.d.ts
generated
vendored
Normal file
8
node_modules/got/dist/source/core/utils/is-form-data.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/// <reference types="node" />
|
||||
import { Readable } from 'stream';
|
||||
interface FormData extends Readable {
|
||||
getBoundary: () => string;
|
||||
getLength: (callback: (error: Error | null, length: number) => void) => void;
|
||||
}
|
||||
declare const _default: (body: unknown) => body is FormData;
|
||||
export default _default;
|
4
node_modules/got/dist/source/core/utils/is-form-data.js
generated
vendored
Normal file
4
node_modules/got/dist/source/core/utils/is-form-data.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const is_1 = require("@sindresorhus/is");
|
||||
exports.default = (body) => is_1.default.nodeStream(body) && is_1.default.function_(body.getBoundary);
|
2
node_modules/got/dist/source/core/utils/is-response-ok.d.ts
generated
vendored
Normal file
2
node_modules/got/dist/source/core/utils/is-response-ok.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import { Response } from '..';
|
||||
export declare const isResponseOk: (response: Response) => boolean;
|
8
node_modules/got/dist/source/core/utils/is-response-ok.js
generated
vendored
Normal file
8
node_modules/got/dist/source/core/utils/is-response-ok.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.isResponseOk = void 0;
|
||||
exports.isResponseOk = (response) => {
|
||||
const { statusCode } = response;
|
||||
const limitStatusCode = response.request.options.followRedirect ? 299 : 399;
|
||||
return (statusCode >= 200 && statusCode <= limitStatusCode) || statusCode === 304;
|
||||
};
|
14
node_modules/got/dist/source/core/utils/options-to-url.d.ts
generated
vendored
Normal file
14
node_modules/got/dist/source/core/utils/options-to-url.d.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import { URL } from 'url';
|
||||
export interface URLOptions {
|
||||
href?: string;
|
||||
protocol?: string;
|
||||
host?: string;
|
||||
hostname?: string;
|
||||
port?: string | number;
|
||||
pathname?: string;
|
||||
search?: string;
|
||||
searchParams?: unknown;
|
||||
path?: string;
|
||||
}
|
||||
declare const _default: (origin: string, options: URLOptions) => URL;
|
||||
export default _default;
|
53
node_modules/got/dist/source/core/utils/options-to-url.js
generated
vendored
Normal file
53
node_modules/got/dist/source/core/utils/options-to-url.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
/* istanbul ignore file: deprecated */
|
||||
const url_1 = require("url");
|
||||
const keys = [
|
||||
'protocol',
|
||||
'host',
|
||||
'hostname',
|
||||
'port',
|
||||
'pathname',
|
||||
'search'
|
||||
];
|
||||
exports.default = (origin, options) => {
|
||||
var _a, _b;
|
||||
if (options.path) {
|
||||
if (options.pathname) {
|
||||
throw new TypeError('Parameters `path` and `pathname` are mutually exclusive.');
|
||||
}
|
||||
if (options.search) {
|
||||
throw new TypeError('Parameters `path` and `search` are mutually exclusive.');
|
||||
}
|
||||
if (options.searchParams) {
|
||||
throw new TypeError('Parameters `path` and `searchParams` are mutually exclusive.');
|
||||
}
|
||||
}
|
||||
if (options.search && options.searchParams) {
|
||||
throw new TypeError('Parameters `search` and `searchParams` are mutually exclusive.');
|
||||
}
|
||||
if (!origin) {
|
||||
if (!options.protocol) {
|
||||
throw new TypeError('No URL protocol specified');
|
||||
}
|
||||
origin = `${options.protocol}//${(_b = (_a = options.hostname) !== null && _a !== void 0 ? _a : options.host) !== null && _b !== void 0 ? _b : ''}`;
|
||||
}
|
||||
const url = new url_1.URL(origin);
|
||||
if (options.path) {
|
||||
const searchIndex = options.path.indexOf('?');
|
||||
if (searchIndex === -1) {
|
||||
options.pathname = options.path;
|
||||
}
|
||||
else {
|
||||
options.pathname = options.path.slice(0, searchIndex);
|
||||
options.search = options.path.slice(searchIndex + 1);
|
||||
}
|
||||
delete options.path;
|
||||
}
|
||||
for (const key of keys) {
|
||||
if (options[key]) {
|
||||
url[key] = options[key].toString();
|
||||
}
|
||||
}
|
||||
return url;
|
||||
};
|
3
node_modules/got/dist/source/core/utils/proxy-events.d.ts
generated
vendored
Normal file
3
node_modules/got/dist/source/core/utils/proxy-events.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
/// <reference types="node" />
|
||||
import { EventEmitter } from 'events';
|
||||
export default function (from: EventEmitter, to: EventEmitter, events: string[]): () => void;
|
17
node_modules/got/dist/source/core/utils/proxy-events.js
generated
vendored
Normal file
17
node_modules/got/dist/source/core/utils/proxy-events.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function default_1(from, to, events) {
|
||||
const fns = {};
|
||||
for (const event of events) {
|
||||
fns[event] = (...args) => {
|
||||
to.emit(event, ...args);
|
||||
};
|
||||
from.on(event, fns[event]);
|
||||
}
|
||||
return () => {
|
||||
for (const event of events) {
|
||||
from.off(event, fns[event]);
|
||||
}
|
||||
};
|
||||
}
|
||||
exports.default = default_1;
|
29
node_modules/got/dist/source/core/utils/timed-out.d.ts
generated
vendored
Normal file
29
node_modules/got/dist/source/core/utils/timed-out.d.ts
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
import { ClientRequest } from 'http';
|
||||
declare const reentry: unique symbol;
|
||||
interface TimedOutOptions {
|
||||
host?: string;
|
||||
hostname?: string;
|
||||
protocol?: string;
|
||||
}
|
||||
export interface Delays {
|
||||
lookup?: number;
|
||||
connect?: number;
|
||||
secureConnect?: number;
|
||||
socket?: number;
|
||||
response?: number;
|
||||
send?: number;
|
||||
request?: number;
|
||||
}
|
||||
export declare type ErrorCode = 'ETIMEDOUT' | 'ECONNRESET' | 'EADDRINUSE' | 'ECONNREFUSED' | 'EPIPE' | 'ENOTFOUND' | 'ENETUNREACH' | 'EAI_AGAIN';
|
||||
export declare class TimeoutError extends Error {
|
||||
event: string;
|
||||
code: ErrorCode;
|
||||
constructor(threshold: number, event: string);
|
||||
}
|
||||
declare const _default: (request: ClientRequest, delays: Delays, options: TimedOutOptions) => () => void;
|
||||
export default _default;
|
||||
declare module 'http' {
|
||||
interface ClientRequest {
|
||||
[reentry]: boolean;
|
||||
}
|
||||
}
|
121
node_modules/got/dist/source/core/utils/timed-out.js
generated
vendored
Normal file
121
node_modules/got/dist/source/core/utils/timed-out.js
generated
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TimeoutError = void 0;
|
||||
const net = require("net");
|
||||
const unhandle_1 = require("./unhandle");
|
||||
const reentry = Symbol('reentry');
|
||||
const noop = () => { };
|
||||
class TimeoutError extends Error {
|
||||
constructor(threshold, event) {
|
||||
super(`Timeout awaiting '${event}' for ${threshold}ms`);
|
||||
this.event = event;
|
||||
this.name = 'TimeoutError';
|
||||
this.code = 'ETIMEDOUT';
|
||||
}
|
||||
}
|
||||
exports.TimeoutError = TimeoutError;
|
||||
exports.default = (request, delays, options) => {
|
||||
if (reentry in request) {
|
||||
return noop;
|
||||
}
|
||||
request[reentry] = true;
|
||||
const cancelers = [];
|
||||
const { once, unhandleAll } = unhandle_1.default();
|
||||
const addTimeout = (delay, callback, event) => {
|
||||
var _a;
|
||||
const timeout = setTimeout(callback, delay, delay, event);
|
||||
(_a = timeout.unref) === null || _a === void 0 ? void 0 : _a.call(timeout);
|
||||
const cancel = () => {
|
||||
clearTimeout(timeout);
|
||||
};
|
||||
cancelers.push(cancel);
|
||||
return cancel;
|
||||
};
|
||||
const { host, hostname } = options;
|
||||
const timeoutHandler = (delay, event) => {
|
||||
request.destroy(new TimeoutError(delay, event));
|
||||
};
|
||||
const cancelTimeouts = () => {
|
||||
for (const cancel of cancelers) {
|
||||
cancel();
|
||||
}
|
||||
unhandleAll();
|
||||
};
|
||||
request.once('error', error => {
|
||||
cancelTimeouts();
|
||||
// Save original behavior
|
||||
/* istanbul ignore next */
|
||||
if (request.listenerCount('error') === 0) {
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
request.once('close', cancelTimeouts);
|
||||
once(request, 'response', (response) => {
|
||||
once(response, 'end', cancelTimeouts);
|
||||
});
|
||||
if (typeof delays.request !== 'undefined') {
|
||||
addTimeout(delays.request, timeoutHandler, 'request');
|
||||
}
|
||||
if (typeof delays.socket !== 'undefined') {
|
||||
const socketTimeoutHandler = () => {
|
||||
timeoutHandler(delays.socket, 'socket');
|
||||
};
|
||||
request.setTimeout(delays.socket, socketTimeoutHandler);
|
||||
// `request.setTimeout(0)` causes a memory leak.
|
||||
// We can just remove the listener and forget about the timer - it's unreffed.
|
||||
// See https://github.com/sindresorhus/got/issues/690
|
||||
cancelers.push(() => {
|
||||
request.removeListener('timeout', socketTimeoutHandler);
|
||||
});
|
||||
}
|
||||
once(request, 'socket', (socket) => {
|
||||
var _a;
|
||||
const { socketPath } = request;
|
||||
/* istanbul ignore next: hard to test */
|
||||
if (socket.connecting) {
|
||||
const hasPath = Boolean(socketPath !== null && socketPath !== void 0 ? socketPath : net.isIP((_a = hostname !== null && hostname !== void 0 ? hostname : host) !== null && _a !== void 0 ? _a : '') !== 0);
|
||||
if (typeof delays.lookup !== 'undefined' && !hasPath && typeof socket.address().address === 'undefined') {
|
||||
const cancelTimeout = addTimeout(delays.lookup, timeoutHandler, 'lookup');
|
||||
once(socket, 'lookup', cancelTimeout);
|
||||
}
|
||||
if (typeof delays.connect !== 'undefined') {
|
||||
const timeConnect = () => addTimeout(delays.connect, timeoutHandler, 'connect');
|
||||
if (hasPath) {
|
||||
once(socket, 'connect', timeConnect());
|
||||
}
|
||||
else {
|
||||
once(socket, 'lookup', (error) => {
|
||||
if (error === null) {
|
||||
once(socket, 'connect', timeConnect());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if (typeof delays.secureConnect !== 'undefined' && options.protocol === 'https:') {
|
||||
once(socket, 'connect', () => {
|
||||
const cancelTimeout = addTimeout(delays.secureConnect, timeoutHandler, 'secureConnect');
|
||||
once(socket, 'secureConnect', cancelTimeout);
|
||||
});
|
||||
}
|
||||
}
|
||||
if (typeof delays.send !== 'undefined') {
|
||||
const timeRequest = () => addTimeout(delays.send, timeoutHandler, 'send');
|
||||
/* istanbul ignore next: hard to test */
|
||||
if (socket.connecting) {
|
||||
once(socket, 'connect', () => {
|
||||
once(request, 'upload-complete', timeRequest());
|
||||
});
|
||||
}
|
||||
else {
|
||||
once(request, 'upload-complete', timeRequest());
|
||||
}
|
||||
}
|
||||
});
|
||||
if (typeof delays.response !== 'undefined') {
|
||||
once(request, 'upload-complete', () => {
|
||||
const cancelTimeout = addTimeout(delays.response, timeoutHandler, 'response');
|
||||
once(request, 'response', cancelTimeout);
|
||||
});
|
||||
}
|
||||
return cancelTimeouts;
|
||||
};
|
11
node_modules/got/dist/source/core/utils/unhandle.d.ts
generated
vendored
Normal file
11
node_modules/got/dist/source/core/utils/unhandle.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
/// <reference types="node" />
|
||||
import { EventEmitter } from 'events';
|
||||
declare type Origin = EventEmitter;
|
||||
declare type Event = string | symbol;
|
||||
declare type Fn = (...args: any[]) => void;
|
||||
interface Unhandler {
|
||||
once: (origin: Origin, event: Event, fn: Fn) => void;
|
||||
unhandleAll: () => void;
|
||||
}
|
||||
declare const _default: () => Unhandler;
|
||||
export default _default;
|
22
node_modules/got/dist/source/core/utils/unhandle.js
generated
vendored
Normal file
22
node_modules/got/dist/source/core/utils/unhandle.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// When attaching listeners, it's very easy to forget about them.
|
||||
// Especially if you do error handling and set timeouts.
|
||||
// So instead of checking if it's proper to throw an error on every timeout ever,
|
||||
// use this simple tool which will remove all listeners you have attached.
|
||||
exports.default = () => {
|
||||
const handlers = [];
|
||||
return {
|
||||
once(origin, event, fn) {
|
||||
origin.once(event, fn);
|
||||
handlers.push({ origin, event, fn });
|
||||
},
|
||||
unhandleAll() {
|
||||
for (const handler of handlers) {
|
||||
const { origin, event, fn } = handler;
|
||||
origin.removeListener(event, fn);
|
||||
}
|
||||
handlers.length = 0;
|
||||
}
|
||||
};
|
||||
};
|
15
node_modules/got/dist/source/core/utils/url-to-options.d.ts
generated
vendored
Normal file
15
node_modules/got/dist/source/core/utils/url-to-options.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import { URL, UrlWithStringQuery } from 'url';
|
||||
export interface LegacyUrlOptions {
|
||||
protocol: string;
|
||||
hostname: string;
|
||||
host: string;
|
||||
hash: string | null;
|
||||
search: string | null;
|
||||
pathname: string;
|
||||
href: string;
|
||||
path: string;
|
||||
port?: number;
|
||||
auth?: string;
|
||||
}
|
||||
declare const _default: (url: URL | UrlWithStringQuery) => LegacyUrlOptions;
|
||||
export default _default;
|
24
node_modules/got/dist/source/core/utils/url-to-options.js
generated
vendored
Normal file
24
node_modules/got/dist/source/core/utils/url-to-options.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const is_1 = require("@sindresorhus/is");
|
||||
exports.default = (url) => {
|
||||
// Cast to URL
|
||||
url = url;
|
||||
const options = {
|
||||
protocol: url.protocol,
|
||||
hostname: is_1.default.string(url.hostname) && url.hostname.startsWith('[') ? url.hostname.slice(1, -1) : url.hostname,
|
||||
host: url.host,
|
||||
hash: url.hash,
|
||||
search: url.search,
|
||||
pathname: url.pathname,
|
||||
href: url.href,
|
||||
path: `${url.pathname || ''}${url.search || ''}`
|
||||
};
|
||||
if (is_1.default.string(url.port) && url.port.length > 0) {
|
||||
options.port = Number(url.port);
|
||||
}
|
||||
if (url.username || url.password) {
|
||||
options.auth = `${url.username || ''}:${url.password || ''}`;
|
||||
}
|
||||
return options;
|
||||
};
|
8
node_modules/got/dist/source/core/utils/weakable-map.d.ts
generated
vendored
Normal file
8
node_modules/got/dist/source/core/utils/weakable-map.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
export default class WeakableMap<K, V> {
|
||||
weakMap: WeakMap<Record<string, unknown>, V>;
|
||||
map: Map<K, V>;
|
||||
constructor();
|
||||
set(key: K, value: V): void;
|
||||
get(key: K): V | undefined;
|
||||
has(key: K): boolean;
|
||||
}
|
29
node_modules/got/dist/source/core/utils/weakable-map.js
generated
vendored
Normal file
29
node_modules/got/dist/source/core/utils/weakable-map.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
class WeakableMap {
|
||||
constructor() {
|
||||
this.weakMap = new WeakMap();
|
||||
this.map = new Map();
|
||||
}
|
||||
set(key, value) {
|
||||
if (typeof key === 'object') {
|
||||
this.weakMap.set(key, value);
|
||||
}
|
||||
else {
|
||||
this.map.set(key, value);
|
||||
}
|
||||
}
|
||||
get(key) {
|
||||
if (typeof key === 'object') {
|
||||
return this.weakMap.get(key);
|
||||
}
|
||||
return this.map.get(key);
|
||||
}
|
||||
has(key) {
|
||||
if (typeof key === 'object') {
|
||||
return this.weakMap.has(key);
|
||||
}
|
||||
return this.map.has(key);
|
||||
}
|
||||
}
|
||||
exports.default = WeakableMap;
|
Reference in New Issue
Block a user