{"ast":null,"code":"'use strict';\n\nvar _asyncToGenerator = require(\"D:\\\\Development\\\\Work\\\\CENOS\\\\cenos-ui\\\\node_modules\\\\@angular-devkit\\\\build-angular\\\\node_modules\\\\@babel\\\\runtime\\\\helpers\\\\asyncToGenerator.js\").default;\n\nconst {\n  URL\n} = require('url'); // TODO: Use the `URL` global when targeting Node.js 10\n\n\nconst util = require('util');\n\nconst EventEmitter = require('events');\n\nconst http = require('http');\n\nconst https = require('https');\n\nconst urlLib = require('url');\n\nconst CacheableRequest = require('cacheable-request');\n\nconst toReadableStream = require('to-readable-stream');\n\nconst is = require('@sindresorhus/is');\n\nconst timer = require('@szmarczak/http-timer');\n\nconst timedOut = require('./utils/timed-out');\n\nconst getBodySize = require('./utils/get-body-size');\n\nconst getResponse = require('./get-response');\n\nconst progress = require('./progress');\n\nconst {\n  CacheError,\n  UnsupportedProtocolError,\n  MaxRedirectsError,\n  RequestError,\n  TimeoutError\n} = require('./errors');\n\nconst urlToOptions = require('./utils/url-to-options');\n\nconst getMethodRedirectCodes = new Set([300, 301, 302, 303, 304, 305, 307, 308]);\nconst allMethodRedirectCodes = new Set([300, 303, 307, 308]);\n\nmodule.exports = (options, input) => {\n  const emitter = new EventEmitter();\n  const redirects = [];\n  let currentRequest;\n  let requestUrl;\n  let redirectString;\n  let uploadBodySize;\n  let retryCount = 0;\n  let shouldAbort = false;\n  const setCookie = options.cookieJar ? util.promisify(options.cookieJar.setCookie.bind(options.cookieJar)) : null;\n  const getCookieString = options.cookieJar ? util.promisify(options.cookieJar.getCookieString.bind(options.cookieJar)) : null;\n  const agents = is.object(options.agent) ? options.agent : null;\n\n  const emitError = /*#__PURE__*/function () {\n    var _ref = _asyncToGenerator(function* (error) {\n      try {\n        for (const hook of options.hooks.beforeError) {\n          // eslint-disable-next-line no-await-in-loop\n          error = yield hook(error);\n        }\n\n        emitter.emit('error', error);\n      } catch (error2) {\n        emitter.emit('error', error2);\n      }\n    });\n\n    return function emitError(_x) {\n      return _ref.apply(this, arguments);\n    };\n  }();\n\n  const get = /*#__PURE__*/function () {\n    var _ref2 = _asyncToGenerator(function* (options) {\n      const currentUrl = redirectString || requestUrl;\n\n      if (options.protocol !== 'http:' && options.protocol !== 'https:') {\n        throw new UnsupportedProtocolError(options);\n      }\n\n      decodeURI(currentUrl);\n      let fn;\n\n      if (is.function(options.request)) {\n        fn = {\n          request: options.request\n        };\n      } else {\n        fn = options.protocol === 'https:' ? https : http;\n      }\n\n      if (agents) {\n        const protocolName = options.protocol === 'https:' ? 'https' : 'http';\n        options.agent = agents[protocolName] || options.agent;\n      }\n      /* istanbul ignore next: electron.net is broken */\n\n\n      if (options.useElectronNet && process.versions.electron) {\n        const r = {\n          x: require\n        }['yx'.slice(1)]; // Trick webpack\n\n        const electron = r('electron');\n        fn = electron.net || electron.remote.net;\n      }\n\n      if (options.cookieJar) {\n        const cookieString = yield getCookieString(currentUrl, {});\n\n        if (is.nonEmptyString(cookieString)) {\n          options.headers.cookie = cookieString;\n        }\n      }\n\n      let timings;\n\n      const handleResponse = /*#__PURE__*/function () {\n        var _ref3 = _asyncToGenerator(function* (response) {\n          try {\n            /* istanbul ignore next: fixes https://github.com/electron/electron/blob/cbb460d47628a7a146adf4419ed48550a98b2923/lib/browser/api/net.js#L59-L65 */\n            if (options.useElectronNet) {\n              response = new Proxy(response, {\n                get: (target, name) => {\n                  if (name === 'trailers' || name === 'rawTrailers') {\n                    return [];\n                  }\n\n                  const value = target[name];\n                  return is.function(value) ? value.bind(target) : value;\n                }\n              });\n            }\n\n            const {\n              statusCode\n            } = response;\n            response.url = currentUrl;\n            response.requestUrl = requestUrl;\n            response.retryCount = retryCount;\n            response.timings = timings;\n            response.redirectUrls = redirects;\n            response.request = {\n              gotOptions: options\n            };\n            const rawCookies = response.headers['set-cookie'];\n\n            if (options.cookieJar && rawCookies) {\n              yield Promise.all(rawCookies.map(rawCookie => setCookie(rawCookie, response.url)));\n            }\n\n            if (options.followRedirect && 'location' in response.headers) {\n              if (allMethodRedirectCodes.has(statusCode) || getMethodRedirectCodes.has(statusCode) && (options.method === 'GET' || options.method === 'HEAD')) {\n                response.resume(); // We're being redirected, we don't care about the response.\n\n                if (statusCode === 303) {\n                  // Server responded with \"see other\", indicating that the resource exists at another location,\n                  // and the client should request it from that location via GET or HEAD.\n                  options.method = 'GET';\n                }\n\n                if (redirects.length >= 10) {\n                  throw new MaxRedirectsError(statusCode, redirects, options);\n                } // Handles invalid URLs. See https://github.com/sindresorhus/got/issues/604\n\n\n                const redirectBuffer = Buffer.from(response.headers.location, 'binary').toString();\n                const redirectURL = new URL(redirectBuffer, currentUrl);\n                redirectString = redirectURL.toString();\n                redirects.push(redirectString);\n                const redirectOptions = { ...options,\n                  ...urlToOptions(redirectURL)\n                };\n\n                for (const hook of options.hooks.beforeRedirect) {\n                  // eslint-disable-next-line no-await-in-loop\n                  yield hook(redirectOptions);\n                }\n\n                emitter.emit('redirect', response, redirectOptions);\n                yield get(redirectOptions);\n                return;\n              }\n            }\n\n            getResponse(response, options, emitter);\n          } catch (error) {\n            emitError(error);\n          }\n        });\n\n        return function handleResponse(_x3) {\n          return _ref3.apply(this, arguments);\n        };\n      }();\n\n      const handleRequest = request => {\n        if (shouldAbort) {\n          request.once('error', () => {});\n          request.abort();\n          return;\n        }\n\n        currentRequest = request;\n        request.once('error', error => {\n          if (request.aborted) {\n            return;\n          }\n\n          if (error instanceof timedOut.TimeoutError) {\n            error = new TimeoutError(error, options);\n          } else {\n            error = new RequestError(error, options);\n          }\n\n          if (emitter.retry(error) === false) {\n            emitError(error);\n          }\n        });\n        timings = timer(request);\n        progress.upload(request, emitter, uploadBodySize);\n\n        if (options.gotTimeout) {\n          timedOut(request, options.gotTimeout, options);\n        }\n\n        emitter.emit('request', request);\n\n        const uploadComplete = () => {\n          request.emit('upload-complete');\n        };\n\n        try {\n          if (is.nodeStream(options.body)) {\n            options.body.once('end', uploadComplete);\n            options.body.pipe(request);\n            options.body = undefined;\n          } else if (options.body) {\n            request.end(options.body, uploadComplete);\n          } else if (input && (options.method === 'POST' || options.method === 'PUT' || options.method === 'PATCH')) {\n            input.once('end', uploadComplete);\n            input.pipe(request);\n          } else {\n            request.end(uploadComplete);\n          }\n        } catch (error) {\n          emitError(new RequestError(error, options));\n        }\n      };\n\n      if (options.cache) {\n        const cacheableRequest = new CacheableRequest(fn.request, options.cache);\n        const cacheRequest = cacheableRequest(options, handleResponse);\n        cacheRequest.once('error', error => {\n          if (error instanceof CacheableRequest.RequestError) {\n            emitError(new RequestError(error, options));\n          } else {\n            emitError(new CacheError(error, options));\n          }\n        });\n        cacheRequest.once('request', handleRequest);\n      } else {\n        // Catches errors thrown by calling fn.request(...)\n        try {\n          handleRequest(fn.request(options, handleResponse));\n        } catch (error) {\n          emitError(new RequestError(error, options));\n        }\n      }\n    });\n\n    return function get(_x2) {\n      return _ref2.apply(this, arguments);\n    };\n  }();\n\n  emitter.retry = error => {\n    let backoff;\n\n    try {\n      backoff = options.retry.retries(++retryCount, error);\n    } catch (error2) {\n      emitError(error2);\n      return;\n    }\n\n    if (backoff) {\n      const retry = /*#__PURE__*/function () {\n        var _ref4 = _asyncToGenerator(function* (options) {\n          try {\n            for (const hook of options.hooks.beforeRetry) {\n              // eslint-disable-next-line no-await-in-loop\n              yield hook(options, error, retryCount);\n            }\n\n            yield get(options);\n          } catch (error) {\n            emitError(error);\n          }\n        });\n\n        return function retry(_x4) {\n          return _ref4.apply(this, arguments);\n        };\n      }();\n\n      setTimeout(retry, backoff, { ...options,\n        forceRefresh: true\n      });\n      return true;\n    }\n\n    return false;\n  };\n\n  emitter.abort = () => {\n    if (currentRequest) {\n      currentRequest.once('error', () => {});\n      currentRequest.abort();\n    } else {\n      shouldAbort = true;\n    }\n  };\n\n  setImmediate( /*#__PURE__*/_asyncToGenerator(function* () {\n    try {\n      // Convert buffer to stream to receive upload progress events (#322)\n      const {\n        body\n      } = options;\n\n      if (is.buffer(body)) {\n        options.body = toReadableStream(body);\n        uploadBodySize = body.length;\n      } else {\n        uploadBodySize = yield getBodySize(options);\n      }\n\n      if (is.undefined(options.headers['content-length']) && is.undefined(options.headers['transfer-encoding'])) {\n        if ((uploadBodySize > 0 || options.method === 'PUT') && !is.null(uploadBodySize)) {\n          options.headers['content-length'] = uploadBodySize;\n        }\n      }\n\n      for (const hook of options.hooks.beforeRequest) {\n        // eslint-disable-next-line no-await-in-loop\n        yield hook(options);\n      }\n\n      requestUrl = options.href || new URL(options.path, urlLib.format(options)).toString();\n      yield get(options);\n    } catch (error) {\n      emitError(error);\n    }\n  }));\n  return emitter;\n};","map":{"version":3,"sources":["D:/Development/Work/CENOS/cenos-ui/node_modules/got/source/request-as-event-emitter.js"],"names":["URL","require","util","EventEmitter","http","https","urlLib","CacheableRequest","toReadableStream","is","timer","timedOut","getBodySize","getResponse","progress","CacheError","UnsupportedProtocolError","MaxRedirectsError","RequestError","TimeoutError","urlToOptions","getMethodRedirectCodes","Set","allMethodRedirectCodes","module","exports","options","input","emitter","redirects","currentRequest","requestUrl","redirectString","uploadBodySize","retryCount","shouldAbort","setCookie","cookieJar","promisify","bind","getCookieString","agents","object","agent","emitError","error","hook","hooks","beforeError","emit","error2","get","currentUrl","protocol","decodeURI","fn","function","request","protocolName","useElectronNet","process","versions","electron","r","x","slice","net","remote","cookieString","nonEmptyString","headers","cookie","timings","handleResponse","response","Proxy","target","name","value","statusCode","url","redirectUrls","gotOptions","rawCookies","Promise","all","map","rawCookie","followRedirect","has","method","resume","length","redirectBuffer","Buffer","from","location","toString","redirectURL","push","redirectOptions","beforeRedirect","handleRequest","once","abort","aborted","retry","upload","gotTimeout","uploadComplete","nodeStream","body","pipe","undefined","end","cache","cacheableRequest","cacheRequest","backoff","retries","beforeRetry","setTimeout","forceRefresh","setImmediate","buffer","null","beforeRequest","href","path","format"],"mappings":"AAAA;;;;AACA,MAAM;AAACA,EAAAA;AAAD,IAAQC,OAAO,CAAC,KAAD,CAArB,C,CAA8B;;;AAC9B,MAAMC,IAAI,GAAGD,OAAO,CAAC,MAAD,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BAAhB,CAAb,CAAvD,EAA2G;AAC1G,YAAI,CAACrC,cAAc,GAAG,CAAjB,IAAsBP,OAAO,CAACgE,MAAR,KAAmB,KAA1C,KAAoD,CAACjF,EAAE,CAACoH,IAAH,CAAQ5F,cAAR,CAAzD,EAAkF;AACjFP,UAAAA,OAAO,CAAC4C,OAAR,CAAgB,gBAAhB,IAAoCrC,cAApC;AACA;AACD;;AAED,WAAK,MAAMa,IAAX,IAAmBpB,OAAO,CAACqB,KAAR,CAAc+E,aAAjC,EAAgD;AAC/C;AACA,cAAMhF,IAAI,CAACpB,OAAD,CAAV;AACA;;AAEDK,MAAAA,UAAU,GAAGL,OAAO,CAACqG,IAAR,IAAiB,IAAI/H,GAAJ,CAAQ0B,OAAO,CAACsG,IAAhB,EAAsB1H,MAAM,CAAC2H,MAAP,CAAcvG,OAAd,CAAtB,CAAD,CAAgDuE,QAAhD,EAA7B;AAEA,YAAM9C,GAAG,CAACzB,OAAD,CAAT;AACA,KAxBD,CAwBE,OAAOmB,KAAP,EAAc;AACfD,MAAAA,SAAS,CAACC,KAAD,CAAT;AACA;AACD,GA5BW,EAAZ;AA8BA,SAAOjB,OAAP;AACA,CAlSD","sourcesContent":["'use strict';\nconst {URL} = require('url'); // TODO: Use the `URL` global when targeting Node.js 10\nconst util = require('util');\nconst EventEmitter = require('events');\nconst http = require('http');\nconst https = require('https');\nconst urlLib = require('url');\nconst CacheableRequest = require('cacheable-request');\nconst toReadableStream = require('to-readable-stream');\nconst is = require('@sindresorhus/is');\nconst timer = require('@szmarczak/http-timer');\nconst timedOut = require('./utils/timed-out');\nconst getBodySize = require('./utils/get-body-size');\nconst getResponse = require('./get-response');\nconst progress = require('./progress');\nconst {CacheError, UnsupportedProtocolError, MaxRedirectsError, RequestError, TimeoutError} = require('./errors');\nconst urlToOptions = require('./utils/url-to-options');\n\nconst getMethodRedirectCodes = new Set([300, 301, 302, 303, 304, 305, 307, 308]);\nconst allMethodRedirectCodes = new Set([300, 303, 307, 308]);\n\nmodule.exports = (options, input) => {\n\tconst emitter = new EventEmitter();\n\tconst redirects = [];\n\tlet currentRequest;\n\tlet requestUrl;\n\tlet redirectString;\n\tlet uploadBodySize;\n\tlet retryCount = 0;\n\tlet shouldAbort = false;\n\n\tconst setCookie = options.cookieJar ? util.promisify(options.cookieJar.setCookie.bind(options.cookieJar)) : null;\n\tconst getCookieString = options.cookieJar ? util.promisify(options.cookieJar.getCookieString.bind(options.cookieJar)) : null;\n\tconst agents = is.object(options.agent) ? options.agent : null;\n\n\tconst emitError = async error => {\n\t\ttry {\n\t\t\tfor (const hook of options.hooks.beforeError) {\n\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\terror = await hook(error);\n\t\t\t}\n\n\t\t\temitter.emit('error', error);\n\t\t} catch (error2) {\n\t\t\temitter.emit('error', error2);\n\t\t}\n\t};\n\n\tconst get = async options => {\n\t\tconst currentUrl = redirectString || requestUrl;\n\n\t\tif (options.protocol !== 'http:' && options.protocol !== 'https:') {\n\t\t\tthrow new UnsupportedProtocolError(options);\n\t\t}\n\n\t\tdecodeURI(currentUrl);\n\n\t\tlet fn;\n\t\tif (is.function(options.request)) {\n\t\t\tfn = {request: options.request};\n\t\t} else {\n\t\t\tfn = options.protocol === 'https:' ? https : http;\n\t\t}\n\n\t\tif (agents) {\n\t\t\tconst protocolName = options.protocol === 'https:' ? 'https' : 'http';\n\t\t\toptions.agent = agents[protocolName] || options.agent;\n\t\t}\n\n\t\t/* istanbul ignore next: electron.net is broken */\n\t\tif (options.useElectronNet && process.versions.electron) {\n\t\t\tconst r = ({x: require})['yx'.slice(1)]; // Trick webpack\n\t\t\tconst electron = r('electron');\n\t\t\tfn = electron.net || electron.remote.net;\n\t\t}\n\n\t\tif (options.cookieJar) {\n\t\t\tconst cookieString = await getCookieString(currentUrl, {});\n\n\t\t\tif (is.nonEmptyString(cookieString)) {\n\t\t\t\toptions.headers.cookie = cookieString;\n\t\t\t}\n\t\t}\n\n\t\tlet timings;\n\t\tconst handleResponse = async response => {\n\t\t\ttry {\n\t\t\t\t/* istanbul ignore next: fixes https://github.com/electron/electron/blob/cbb460d47628a7a146adf4419ed48550a98b2923/lib/browser/api/net.js#L59-L65 */\n\t\t\t\tif (options.useElectronNet) {\n\t\t\t\t\tresponse = new Proxy(response, {\n\t\t\t\t\t\tget: (target, name) => {\n\t\t\t\t\t\t\tif (name === 'trailers' || name === 'rawTrailers') {\n\t\t\t\t\t\t\t\treturn [];\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst value = target[name];\n\t\t\t\t\t\t\treturn is.function(value) ? value.bind(target) : value;\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tconst {statusCode} = response;\n\t\t\t\tresponse.url = currentUrl;\n\t\t\t\tresponse.requestUrl = requestUrl;\n\t\t\t\tresponse.retryCount = retryCount;\n\t\t\t\tresponse.timings = timings;\n\t\t\t\tresponse.redirectUrls = redirects;\n\t\t\t\tresponse.request = {\n\t\t\t\t\tgotOptions: options\n\t\t\t\t};\n\n\t\t\t\tconst rawCookies = response.headers['set-cookie'];\n\t\t\t\tif (options.cookieJar && rawCookies) {\n\t\t\t\t\tawait Promise.all(rawCookies.map(rawCookie => setCookie(rawCookie, response.url)));\n\t\t\t\t}\n\n\t\t\t\tif (options.followRedirect && 'location' in response.headers) {\n\t\t\t\t\tif (allMethodRedirectCodes.has(statusCode) || (getMethodRedirectCodes.has(statusCode) && (options.method === 'GET' || options.method === 'HEAD'))) {\n\t\t\t\t\t\tresponse.resume(); // We're being redirected, we don't care about the response.\n\n\t\t\t\t\t\tif (statusCode === 303) {\n\t\t\t\t\t\t\t// Server responded with \"see other\", indicating that the resource exists at another location,\n\t\t\t\t\t\t\t// and the client should request it from that location via GET or HEAD.\n\t\t\t\t\t\t\toptions.method = 'GET';\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (redirects.length >= 10) {\n\t\t\t\t\t\t\tthrow new MaxRedirectsError(statusCode, redirects, options);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Handles invalid URLs. See https://github.com/sindresorhus/got/issues/604\n\t\t\t\t\t\tconst redirectBuffer = Buffer.from(response.headers.location, 'binary').toString();\n\t\t\t\t\t\tconst redirectURL = new URL(redirectBuffer, currentUrl);\n\t\t\t\t\t\tredirectString = redirectURL.toString();\n\n\t\t\t\t\t\tredirects.push(redirectString);\n\n\t\t\t\t\t\tconst redirectOptions = {\n\t\t\t\t\t\t\t...options,\n\t\t\t\t\t\t\t...urlToOptions(redirectURL)\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tfor (const hook of options.hooks.beforeRedirect) {\n\t\t\t\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\t\t\t\tawait hook(redirectOptions);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\temitter.emit('redirect', response, redirectOptions);\n\n\t\t\t\t\t\tawait get(redirectOptions);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tgetResponse(response, options, emitter);\n\t\t\t} catch (error) {\n\t\t\t\temitError(error);\n\t\t\t}\n\t\t};\n\n\t\tconst handleRequest = request => {\n\t\t\tif (shouldAbort) {\n\t\t\t\trequest.once('error', () => {});\n\t\t\t\trequest.abort();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcurrentRequest = request;\n\n\t\t\trequest.once('error', error => {\n\t\t\t\tif (request.aborted) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (error instanceof timedOut.TimeoutError) {\n\t\t\t\t\terror = new TimeoutError(error, options);\n\t\t\t\t} else {\n\t\t\t\t\terror = new RequestError(error, options);\n\t\t\t\t}\n\n\t\t\t\tif (emitter.retry(error) === false) {\n\t\t\t\t\temitError(error);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\ttimings = timer(request);\n\n\t\t\tprogress.upload(request, emitter, uploadBodySize);\n\n\t\t\tif (options.gotTimeout) {\n\t\t\t\ttimedOut(request, options.gotTimeout, options);\n\t\t\t}\n\n\t\t\temitter.emit('request', request);\n\n\t\t\tconst uploadComplete = () => {\n\t\t\t\trequest.emit('upload-complete');\n\t\t\t};\n\n\t\t\ttry {\n\t\t\t\tif (is.nodeStream(options.body)) {\n\t\t\t\t\toptions.body.once('end', uploadComplete);\n\t\t\t\t\toptions.body.pipe(request);\n\t\t\t\t\toptions.body = undefined;\n\t\t\t\t} else if (options.body) {\n\t\t\t\t\trequest.end(options.body, uploadComplete);\n\t\t\t\t} else if (input && (options.method === 'POST' || options.method === 'PUT' || options.method === 'PATCH')) {\n\t\t\t\t\tinput.once('end', uploadComplete);\n\t\t\t\t\tinput.pipe(request);\n\t\t\t\t} else {\n\t\t\t\t\trequest.end(uploadComplete);\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\temitError(new RequestError(error, options));\n\t\t\t}\n\t\t};\n\n\t\tif (options.cache) {\n\t\t\tconst cacheableRequest = new CacheableRequest(fn.request, options.cache);\n\t\t\tconst cacheRequest = cacheableRequest(options, handleResponse);\n\n\t\t\tcacheRequest.once('error', error => {\n\t\t\t\tif (error instanceof CacheableRequest.RequestError) {\n\t\t\t\t\temitError(new RequestError(error, options));\n\t\t\t\t} else {\n\t\t\t\t\temitError(new CacheError(error, options));\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tcacheRequest.once('request', handleRequest);\n\t\t} else {\n\t\t\t// Catches errors thrown by calling fn.request(...)\n\t\t\ttry {\n\t\t\t\thandleRequest(fn.request(options, handleResponse));\n\t\t\t} catch (error) {\n\t\t\t\temitError(new RequestError(error, options));\n\t\t\t}\n\t\t}\n\t};\n\n\temitter.retry = error => {\n\t\tlet backoff;\n\n\t\ttry {\n\t\t\tbackoff = options.retry.retries(++retryCount, error);\n\t\t} catch (error2) {\n\t\t\temitError(error2);\n\t\t\treturn;\n\t\t}\n\n\t\tif (backoff) {\n\t\t\tconst retry = async options => {\n\t\t\t\ttry {\n\t\t\t\t\tfor (const hook of options.hooks.beforeRetry) {\n\t\t\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\t\t\tawait hook(options, error, retryCount);\n\t\t\t\t\t}\n\n\t\t\t\t\tawait get(options);\n\t\t\t\t} catch (error) {\n\t\t\t\t\temitError(error);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tsetTimeout(retry, backoff, {...options, forceRefresh: true});\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t};\n\n\temitter.abort = () => {\n\t\tif (currentRequest) {\n\t\t\tcurrentRequest.once('error', () => {});\n\t\t\tcurrentRequest.abort();\n\t\t} else {\n\t\t\tshouldAbort = true;\n\t\t}\n\t};\n\n\tsetImmediate(async () => {\n\t\ttry {\n\t\t\t// Convert buffer to stream to receive upload progress events (#322)\n\t\t\tconst {body} = options;\n\t\t\tif (is.buffer(body)) {\n\t\t\t\toptions.body = toReadableStream(body);\n\t\t\t\tuploadBodySize = body.length;\n\t\t\t} else {\n\t\t\t\tuploadBodySize = await getBodySize(options);\n\t\t\t}\n\n\t\t\tif (is.undefined(options.headers['content-length']) && is.undefined(options.headers['transfer-encoding'])) {\n\t\t\t\tif ((uploadBodySize > 0 || options.method === 'PUT') && !is.null(uploadBodySize)) {\n\t\t\t\t\toptions.headers['content-length'] = uploadBodySize;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const hook of options.hooks.beforeRequest) {\n\t\t\t\t// eslint-disable-next-line no-await-in-loop\n\t\t\t\tawait hook(options);\n\t\t\t}\n\n\t\t\trequestUrl = options.href || (new URL(options.path, urlLib.format(options))).toString();\n\n\t\t\tawait get(options);\n\t\t} catch (error) {\n\t\t\temitError(error);\n\t\t}\n\t});\n\n\treturn emitter;\n};\n"]},"metadata":{},"sourceType":"script"}