fcs
2025-04-10 0163870d662dc5b7d69ceff977490ede594f7d82
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'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
}