mirror of
https://github.com/nodejs/node.git
synced 2025-05-16 02:01:52 +00:00

PR-URL: https://github.com/nodejs/node/pull/35474 Reviewed-By: Ruy Adorno <ruyadorno@github.com> Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org> Reviewed-By: Ben Coe <bencoe@gmail.com> Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Shelley Vohr <codebytere@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
34 lines
843 B
JavaScript
34 lines
843 B
JavaScript
'use strict'
|
|
|
|
const initializeCache = require('./initialize-cache')
|
|
|
|
module.exports = function configureOptions (_opts) {
|
|
const opts = Object.assign({}, _opts || {})
|
|
opts.method = (opts.method || 'GET').toUpperCase()
|
|
|
|
if (!opts.retry) {
|
|
// opts.retry was falsy; set default
|
|
opts.retry = { retries: 0 }
|
|
} else {
|
|
if (typeof opts.retry !== 'object') {
|
|
// Shorthand
|
|
if (typeof opts.retry === 'number') {
|
|
opts.retry = { retries: opts.retry }
|
|
}
|
|
if (typeof opts.retry === 'string') {
|
|
const value = parseInt(opts.retry, 10)
|
|
opts.retry = (value) ? { retries: value } : { retries: 0 }
|
|
}
|
|
} else {
|
|
// Set default retries
|
|
opts.retry = Object.assign({}, { retries: 0 }, opts.retry)
|
|
}
|
|
}
|
|
|
|
if (opts.cacheManager) {
|
|
initializeCache(opts)
|
|
}
|
|
|
|
return opts
|
|
}
|