Socket
Socket
Sign inDemoInstall

gaxios

Package Overview
Dependencies
4
Maintainers
1
Versions
77
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.0.2 to 5.1.0-debug

12

build/src/common.d.ts

@@ -14,3 +14,3 @@ /// <reference types="node" />

}
export declare type GaxiosPromise<T = any> = Promise<GaxiosResponse<T>>;
export type GaxiosPromise<T = any> = Promise<GaxiosResponse<T>>;
export interface GaxiosXMLHttpRequest {

@@ -115,5 +115,11 @@ responseURL: string;

noResponseRetries?: number;
/**
* Function to invoke which returns a promise. After the promise resolves,
* the retry will be triggered. If provided, this will be used in-place of
* the `retryDelay`
*/
retryBackoff?: (err: GaxiosError, defaultBackoffMs: number) => Promise<void>;
}
export declare type FetchImplementation = (input: FetchRequestInfo, init?: FetchRequestInit) => Promise<FetchResponse>;
export declare type FetchRequestInfo = any;
export type FetchImplementation = (input: FetchRequestInfo, init?: FetchRequestInit) => Promise<FetchResponse>;
export type FetchRequestInfo = any;
export interface FetchResponse {

@@ -120,0 +126,0 @@ readonly status: number;

@@ -22,2 +22,3 @@ "use strict";

this.config = options;
this.response.data = translateData(options.responseType, response.data);
this.code = response.status.toString();

@@ -27,2 +28,16 @@ }

exports.GaxiosError = GaxiosError;
function translateData(responseType, data) {
switch (responseType) {
case 'stream':
return data;
case 'json':
return JSON.parse(JSON.stringify(data));
case 'arraybuffer':
return JSON.parse(Buffer.from(data).toString('utf8'));
case 'blob':
return JSON.parse(data.text());
default:
return data;
}
}
//# sourceMappingURL=common.js.map

@@ -130,2 +130,12 @@ "use strict";

if (!opts.validateStatus(translatedResponse.status)) {
if (opts.responseType === 'stream') {
let response = '';
await new Promise(resolve => {
translatedResponse.data.on('data', chunk => {
response += chunk;
});
translatedResponse.data.on('end', resolve);
});
translatedResponse.data = response;
}
throw new common_1.GaxiosError(`Request failed with status code ${translatedResponse.status}`, opts, translatedResponse);

@@ -132,0 +142,0 @@ }

@@ -67,5 +67,7 @@ "use strict";

// Create a promise that invokes the retry after the backOffDelay
const backoff = new Promise(resolve => {
setTimeout(resolve, delay);
});
const backoff = config.retryBackoff
? config.retryBackoff(err, delay)
: new Promise(resolve => {
setTimeout(resolve, delay);
});
// Notify the user if they added an `onRetryAttempt` handler

@@ -72,0 +74,0 @@ if (config.onRetryAttempt) {

# Changelog
## [5.1.0](https://github.com/googleapis/gaxios/compare/v5.0.2...v5.1.0) (2023-03-06)
### Features
* Add support for custom backoff ([#498](https://github.com/googleapis/gaxios/issues/498)) ([4a34467](https://github.com/googleapis/gaxios/commit/4a344678110864d97818a8272ebcc5e1c4921b52))
## [5.0.2](https://github.com/googleapis/gaxios/compare/v5.0.1...v5.0.2) (2022-09-09)

@@ -4,0 +11,0 @@

{
"name": "gaxios",
"version": "5.0.2",
"version": "5.1.0-debug",
"description": "A simple common HTTP client specifically for Google APIs and services.",

@@ -40,5 +40,5 @@ "main": "build/src/index.js",

"devDependencies": {
"@babel/plugin-proposal-private-methods": "^7.18.6",
"@compodoc/compodoc": "^1.1.9",
"@types/cors": "^2.8.6",
"@types/execa": "^0.9.0",
"@types/express": "^4.16.1",

@@ -50,11 +50,11 @@ "@types/extend": "^3.0.1",

"@types/ncp": "^2.0.1",
"@types/node": "^17.0.23",
"@types/node": "^18.0.0",
"@types/node-fetch": "^2.5.7",
"@types/sinon": "^10.0.0",
"@types/tmp": "0.2.3",
"@types/uuid": "^8.0.0",
"@types/uuid": "^9.0.0",
"abort-controller": "^3.0.0",
"assert": "^2.0.0",
"browserify": "^17.0.0",
"c8": "^7.0.0",
"c8": "^8.0.0",
"cors": "^2.8.5",

@@ -72,3 +72,3 @@ "execa": "^5.0.0",

"karma-remap-coverage": "^0.1.5",
"karma-sourcemap-loader": "^0.3.7",
"karma-sourcemap-loader": "^0.4.0",
"karma-webpack": "^5.0.0",

@@ -82,4 +82,4 @@ "linkinator": "^4.0.0",

"null-loader": "^4.0.0",
"puppeteer": "^17.0.0",
"sinon": "^14.0.0",
"puppeteer": "^20.0.0",
"sinon": "^15.0.0",
"stream-browserify": "^3.0.0",

@@ -97,4 +97,4 @@ "tmp": "0.2.1",

"is-stream": "^2.0.0",
"node-fetch": "^2.6.7"
"node-fetch": "^2.6.9"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc