Socket
Socket
Sign inDemoInstall

got

Package Overview
Dependencies
29
Maintainers
2
Versions
175
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 12.0.0-beta.2 to 12.0.0-beta.3

85

dist/source/core/options.js

@@ -213,2 +213,65 @@ import { promisify, inspect } from 'util';

};
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) => {

@@ -319,15 +382,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;

@@ -1535,2 +1588,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);

@@ -1542,5 +1601,7 @@ 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);
}
}

2

package.json
{
"name": "got",
"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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc