Comparing version 12.0.0-beta.2 to 12.0.0-beta.3
@@ -237,2 +237,65 @@ "use strict"; | ||
}; | ||
const cloneRaw = (raw) => { | ||
const { hooks, retry } = raw; | ||
const result = { ...raw }; | ||
if (raw.context) { | ||
result.context = { ...raw.context }; | ||
} | ||
if (raw.cacheOptions) { | ||
result.cacheOptions = { ...raw.cacheOptions }; | ||
} | ||
if (raw.https) { | ||
result.https = { ...raw.https }; | ||
} | ||
if (raw.cacheOptions) { | ||
result.cacheOptions = { ...result.cacheOptions }; | ||
} | ||
if (raw.agent) { | ||
result.agent = { ...raw.agent }; | ||
} | ||
if (raw.headers) { | ||
result.headers = { ...raw.headers }; | ||
} | ||
if (retry) { | ||
result.retry = { ...retry }; | ||
if (retry.errorCodes) { | ||
result.retry.errorCodes = [...retry.errorCodes]; | ||
} | ||
if (retry.methods) { | ||
result.retry.methods = [...retry.methods]; | ||
} | ||
if (retry.statusCodes) { | ||
result.retry.statusCodes = [...retry.statusCodes]; | ||
} | ||
} | ||
if (raw.timeout) { | ||
result.timeout = { ...raw.timeout }; | ||
} | ||
if (hooks) { | ||
result.hooks = {}; | ||
if (hooks.init) { | ||
result.hooks.init = [...hooks.init]; | ||
} | ||
if (hooks.beforeRequest) { | ||
result.hooks.beforeRequest = [...hooks.beforeRequest]; | ||
} | ||
if (hooks.beforeError) { | ||
result.hooks.beforeError = [...hooks.beforeError]; | ||
} | ||
if (hooks.beforeRedirect) { | ||
result.hooks.beforeRedirect = [...hooks.beforeRedirect]; | ||
} | ||
if (hooks.beforeRetry) { | ||
result.hooks.beforeRetry = [...hooks.beforeRetry]; | ||
} | ||
if (hooks.afterResponse) { | ||
result.hooks.afterResponse = [...hooks.afterResponse]; | ||
} | ||
} | ||
// TODO: raw.searchParams | ||
if (raw.pagination) { | ||
result.pagination = { ...raw.pagination }; | ||
} | ||
return result; | ||
}; | ||
const getHttp2TimeoutOption = (internals) => { | ||
@@ -345,15 +408,5 @@ const delays = [internals.timeout.socket, internals.timeout.connect, internals.timeout.lookup, internals.timeout.request, internals.timeout.secureConnect].filter(delay => typeof delay === 'number'); | ||
} | ||
options = cloneRaw(options); | ||
init(this, options, this); | ||
init(options, options, this); | ||
// This is way much faster than cloning ^_^ | ||
Object.freeze(options); | ||
Object.freeze(options.hooks); | ||
Object.freeze(options.https); | ||
Object.freeze(options.cacheOptions); | ||
Object.freeze(options.agent); | ||
Object.freeze(options.headers); | ||
Object.freeze(options.timeout); | ||
Object.freeze(options.retry); | ||
Object.freeze(options.hooks); | ||
Object.freeze(options.context); | ||
this._merging = true; | ||
@@ -1562,2 +1615,8 @@ // Always merge `isStream` first | ||
Object.freeze(options.hooks); | ||
Object.freeze(options.hooks.afterResponse); | ||
Object.freeze(options.hooks.beforeError); | ||
Object.freeze(options.hooks.beforeRedirect); | ||
Object.freeze(options.hooks.beforeRequest); | ||
Object.freeze(options.hooks.beforeRetry); | ||
Object.freeze(options.hooks.init); | ||
Object.freeze(options.https); | ||
@@ -1569,3 +1628,5 @@ Object.freeze(options.cacheOptions); | ||
Object.freeze(options.retry); | ||
Object.freeze(options.hooks); | ||
Object.freeze(options.retry.errorCodes); | ||
Object.freeze(options.retry.methods); | ||
Object.freeze(options.retry.statusCodes); | ||
Object.freeze(options.context); | ||
@@ -1572,0 +1633,0 @@ } |
{ | ||
"name": "got-cjs", | ||
"version": "12.0.0-beta.2", | ||
"version": "12.0.0-beta.3", | ||
"description": "Human-friendly and powerful HTTP request library for Node.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
249276
5427