Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
options.retry.limit = retry;
}
if (options.retry.maxRetryAfter === undefined) {
options.retry.maxRetryAfter = Math.min(
...[options.timeout.request, options.timeout.connect].filter((n): n is number => !is.nullOrUndefined(n))
);
}
options.retry.methods = [...new Set(options.retry.methods!.map(method => method.toUpperCase() as Method))];
options.retry.statusCodes = [...new Set(options.retry.statusCodes)];
options.retry.errorCodes = [...new Set(options.retry.errorCodes)];
// `options.dnsCache`
if (options.dnsCache && !(options.dnsCache instanceof CacheableLookup)) {
options.dnsCache = new CacheableLookup({cacheAdapter: options.dnsCache as Keyv});
}
// `options.method`
if (is.string(options.method)) {
options.method = options.method.toUpperCase() as Method;
} else {
options.method = defaults?.method ?? 'GET';
}
// Better memory management, so we don't have to generate a new object every time
if (options.cache) {
(options as NormalizedOptions).cacheableRequest = new CacheableRequest(
// @ts-ignore Cannot properly type a function with multiple definitions yet
(requestOptions, handler) => requestOptions.request(requestOptions, handler),
options.cache
);