summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/make-fetch-happen/utils/configure-options.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/make-fetch-happen/utils/configure-options.js')
-rw-r--r--deps/npm/node_modules/make-fetch-happen/utils/configure-options.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/deps/npm/node_modules/make-fetch-happen/utils/configure-options.js b/deps/npm/node_modules/make-fetch-happen/utils/configure-options.js
new file mode 100644
index 0000000000..d55fec4397
--- /dev/null
+++ b/deps/npm/node_modules/make-fetch-happen/utils/configure-options.js
@@ -0,0 +1,33 @@
+'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
+}