Socket
Socket
Sign inDemoInstall

@http-ext/plugin-retry

Package Overview
Dependencies
1
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.0 to 2.0.0

6

bundles/http-ext-plugin-retry.umd.js

@@ -263,3 +263,3 @@ (function (global, factory) {

/**
* @param condition
* @param shouldHandleRequest
* @param initialInterval defaults to 200ms

@@ -271,7 +271,7 @@ * @param maxInterval defaults to 1min

function createRetryPlugin(_a) {
var _b = _a === void 0 ? {} : _a, _c = _b.condition, condition = _c === void 0 ? function () { return true; } : _c, _d = _b.initialInterval, initialInterval = _d === void 0 ? 200 : _d, _e = _b.maxInterval, maxInterval = _e === void 0 ? 60000 : _e, // 1 min
var _b = _a === void 0 ? {} : _a, _c = _b.shouldHandleRequest, shouldHandleRequest = _c === void 0 ? function () { return true; } : _c, _d = _b.initialInterval, initialInterval = _d === void 0 ? 200 : _d, _e = _b.maxInterval, maxInterval = _e === void 0 ? 60000 : _e, // 1 min
_f = _b.maxRetries, // 1 min
maxRetries = _f === void 0 ? 10 : _f, _g = _b.shouldRetry, shouldRetry = _g === void 0 ? isServerOrUnknownError : _g;
return {
condition: condition,
shouldHandleRequest: shouldHandleRequest,
handler: new RetryHandler({

@@ -278,0 +278,0 @@ initialInterval: initialInterval,

@@ -15,3 +15,3 @@ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("backoff-rxjs")):"function"==typeof define&&define.amd?define("@http-ext/plugin-retry",["exports","backoff-rxjs"],e):e(((t=t||self)["http-ext"]=t["http-ext"]||{},t["http-ext"]["plugin-retry"]={}),t["backoff-rxjs"])}(this,(function(t,e){"use strict";

and limitations under the License.
***************************************************************************** */function r(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a}function n(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(r(arguments[e]));return t}var i=function(t){return t.status>=500},o=function(t){return 0===t.status},a=function(t){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return t.some((function(t){return t.apply(void 0,n(e))}))}}(i,o)(t)},u=function(){function t(t){var e=t.initialInterval,r=t.maxInterval,n=t.maxRetries,i=t.shouldRetry;this._initialInterval=e,this._maxInterval=r,this._maxRetries=n,this._shouldRetry=i}return t.prototype.handle=function(t){var r=t.request;return(0,t.next)({request:r}).pipe(e.retryBackoff({initialInterval:this._initialInterval,maxInterval:this._maxInterval,maxRetries:this._maxRetries,shouldRetry:this._shouldRetry}))},t}();t.createRetryPlugin=function(t){var e=void 0===t?{}:t,r=e.condition,n=void 0===r?function(){return!0}:r,i=e.initialInterval,o=void 0===i?200:i,l=e.maxInterval,f=void 0===l?6e4:l,s=e.maxRetries,c=void 0===s?10:s,v=e.shouldRetry;return{condition:n,handler:new u({initialInterval:o,maxInterval:f,maxRetries:c,shouldRetry:void 0===v?a:v})}},t.ɵa=u,Object.defineProperty(t,"__esModule",{value:!0})}));
***************************************************************************** */function r(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a}function n(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(r(arguments[e]));return t}var i=function(t){return t.status>=500},o=function(t){return 0===t.status},a=function(t){return function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return t.some((function(t){return t.apply(void 0,n(e))}))}}(i,o)(t)},u=function(){function t(t){var e=t.initialInterval,r=t.maxInterval,n=t.maxRetries,i=t.shouldRetry;this._initialInterval=e,this._maxInterval=r,this._maxRetries=n,this._shouldRetry=i}return t.prototype.handle=function(t){var r=t.request;return(0,t.next)({request:r}).pipe(e.retryBackoff({initialInterval:this._initialInterval,maxInterval:this._maxInterval,maxRetries:this._maxRetries,shouldRetry:this._shouldRetry}))},t}();t.createRetryPlugin=function(t){var e=void 0===t?{}:t,r=e.shouldHandleRequest,n=void 0===r?function(){return!0}:r,i=e.initialInterval,o=void 0===i?200:i,l=e.maxInterval,f=void 0===l?6e4:l,s=e.maxRetries,c=void 0===s?10:s,d=e.shouldRetry;return{shouldHandleRequest:n,handler:new u({initialInterval:o,maxInterval:f,maxRetries:c,shouldRetry:void 0===d?a:d})}},t.ɵa=u,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=http-ext-plugin-retry.umd.min.js.map

@@ -6,2 +6,20 @@ # Change Log

# [2.0.0](https://github.com/jscutlery/http-ext/compare/v1.0.0...v2.0.0) (2020-04-01)
### Features
* ✅ rename `condition` to `shouldHandleRequest` ([9e93b5d](https://github.com/jscutlery/http-ext/commit/9e93b5d20e4c3cb0ef94b5b6a1440565b685b6c7))
### BREAKING CHANGES
* rename `condition` to `shouldHandleRequest`
Co-authored-by: Edouard Bozon <bozonedouard@gmail.com>
# [1.2.0](https://github.com/jscutlery/http-ext/compare/v1.1.0...v1.2.0) (2020-03-31)

@@ -8,0 +26,0 @@

import { isServerOrUnknownError } from './predicates/is-server-or-unknown-error';
import { RetryHandler } from './retry-handler';
/**
* @param condition
* @param shouldHandleRequest
* @param initialInterval defaults to 200ms

@@ -10,6 +10,6 @@ * @param maxInterval defaults to 1min

*/
export function createRetryPlugin({ condition = () => true, initialInterval = 200, maxInterval = 60000, // 1 min
export function createRetryPlugin({ shouldHandleRequest = () => true, initialInterval = 200, maxInterval = 60000, // 1 min
maxRetries = 10, shouldRetry = isServerOrUnknownError } = {}) {
return {
condition,
shouldHandleRequest,
handler: new RetryHandler({

@@ -23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ogQHBhcmFtIHNob3VsZEhhbmRsZVJlcXVlc3RcbiAqIEBwYXJhbSBpbml0aWFsSW50ZXJ2YWwgZGVmYXVsdHMgdG8gMjAwbXNcbiAqIEBwYXJhbSBtYXhJbnRlcnZhbCBkZWZhdWx0cyB0byAxbWluXG4gKiBAcGFyYW0gbWF4UmV0cmllcyBkZWZhdWx0cyB0byAxMFxuICogQHBhcmFtIHNob3VsZFJldHJ5IGRlZmF1bHRzIHRvIHNlcnZlciBlcnJvcjogNXh4XG4gKi9cbmV4cG9ydCBmdW5jdGlvbiBjcmVhdGVSZXRyeVBsdWdpbih7XG4gIHNob3VsZEhhbmRsZVJlcXVlc3QgPSAoKSA9PiB0cnVlLFxuICBpbml0aWFsSW50ZXJ2YWwgPSAyMDAsXG4gIG1heEludGVydmFsID0gNjAwMDAsIC8vIDEgbWluXG4gIG1heFJldHJpZXMgPSAxMCxcbiAgc2hvdWxkUmV0cnkgPSBpc1NlcnZlck9yVW5rbm93bkVycm9yXG59OiBQYXJ0aWFsPFJldHJ5UGx1Z2luT3B0aW9ucz4gPSB7fSkge1xuICByZXR1cm4ge1xuICAgIHNob3VsZEhhbmRsZVJlcXVlc3QsXG4gICAgaGFuZGxlcjogbmV3IFJldHJ5SGFuZGxlcih7XG4gICAgICBpbml0aWFsSW50ZXJ2YWwsXG4gICAgICBtYXhJbnRlcnZhbCxcbiAgICAgIG1heFJldHJpZXMsXG4gICAgICBzaG91bGRSZXRyeVxuICAgIH0pXG4gIH07XG59XG4iXX0=
import { isServerOrUnknownError } from './predicates/is-server-or-unknown-error';
import { RetryHandler } from './retry-handler';
/**
* @param condition
* @param shouldHandleRequest
* @param initialInterval defaults to 200ms

@@ -11,7 +11,7 @@ * @param maxInterval defaults to 1min

export function createRetryPlugin(_a) {
var _b = _a === void 0 ? {} : _a, _c = _b.condition, condition = _c === void 0 ? function () { return true; } : _c, _d = _b.initialInterval, initialInterval = _d === void 0 ? 200 : _d, _e = _b.maxInterval, maxInterval = _e === void 0 ? 60000 : _e, // 1 min
var _b = _a === void 0 ? {} : _a, _c = _b.shouldHandleRequest, shouldHandleRequest = _c === void 0 ? function () { return true; } : _c, _d = _b.initialInterval, initialInterval = _d === void 0 ? 200 : _d, _e = _b.maxInterval, maxInterval = _e === void 0 ? 60000 : _e, // 1 min
_f = _b.maxRetries, // 1 min
maxRetries = _f === void 0 ? 10 : _f, _g = _b.shouldRetry, shouldRetry = _g === void 0 ? isServerOrUnknownError : _g;
return {
condition: condition,
shouldHandleRequest: shouldHandleRequest,
handler: new RetryHandler({

@@ -25,2 +25,2 @@ initialInterval: initialInterval,

}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3JlYXRlLXJldHJ5LXBsdWdpbi5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0BodHRwLWV4dC9wbHVnaW4tcmV0cnkvIiwic291cmNlcyI6WyJsaWIvY3JlYXRlLXJldHJ5LXBsdWdpbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEVBQUUsc0JBQXNCLEVBQUUsTUFBTSx5Q0FBeUMsQ0FBQztBQUNqRixPQUFPLEVBQWtCLFlBQVksRUFBRSxNQUFNLGlCQUFpQixDQUFDO0FBTS9EOzs7Ozs7R0FNRztBQUNILE1BQU0sVUFBVSxpQkFBaUIsQ0FBQyxFQU1DO1FBTkQsNEJBTUMsRUFMakMsaUJBQXNCLEVBQXRCLDZEQUFzQixFQUN0Qix1QkFBcUIsRUFBckIsMENBQXFCLEVBQ3JCLG1CQUFtQixFQUFuQix3Q0FBbUIsRUFBRSxRQUFRO0lBQzdCLGtCQUFlLEVBRE0sUUFBUTtJQUM3QixvQ0FBZSxFQUNmLG1CQUFvQyxFQUFwQyx5REFBb0M7SUFFcEMsT0FBTztRQUNMLFNBQVMsV0FBQTtRQUNULE9BQU8sRUFBRSxJQUFJLFlBQVksQ0FBQztZQUN4QixlQUFlLGlCQUFBO1lBQ2YsV0FBVyx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YW5kbGVyOiBuZXcgUmV0cnlIYW5kbGVyKHtcbiAgICAgIGluaXRpYWxJbnRlcnZhbCxcbiAgICAgIG1heEludGVydmFsLFxuICAgICAgbWF4UmV0cmllcyxcbiAgICAgIHNob3VsZFJldHJ5XG4gICAgfSlcbiAgfTtcbn1cbiJdfQ==

@@ -32,3 +32,3 @@ import { retryBackoff } from 'backoff-rxjs';

/**
* @param condition
* @param shouldHandleRequest
* @param initialInterval defaults to 200ms

@@ -39,6 +39,6 @@ * @param maxInterval defaults to 1min

*/
function createRetryPlugin({ condition = () => true, initialInterval = 200, maxInterval = 60000, // 1 min
function createRetryPlugin({ shouldHandleRequest = () => true, initialInterval = 200, maxInterval = 60000, // 1 min
maxRetries = 10, shouldRetry = isServerOrUnknownError } = {}) {
return {
condition,
shouldHandleRequest,
handler: new RetryHandler({

@@ -45,0 +45,0 @@ initialInterval,

@@ -46,3 +46,3 @@ import { __spread } from 'tslib';

/**
* @param condition
* @param shouldHandleRequest
* @param initialInterval defaults to 200ms

@@ -54,7 +54,7 @@ * @param maxInterval defaults to 1min

function createRetryPlugin(_a) {
var _b = _a === void 0 ? {} : _a, _c = _b.condition, condition = _c === void 0 ? function () { return true; } : _c, _d = _b.initialInterval, initialInterval = _d === void 0 ? 200 : _d, _e = _b.maxInterval, maxInterval = _e === void 0 ? 60000 : _e, // 1 min
var _b = _a === void 0 ? {} : _a, _c = _b.shouldHandleRequest, shouldHandleRequest = _c === void 0 ? function () { return true; } : _c, _d = _b.initialInterval, initialInterval = _d === void 0 ? 200 : _d, _e = _b.maxInterval, maxInterval = _e === void 0 ? 60000 : _e, // 1 min
_f = _b.maxRetries, // 1 min
maxRetries = _f === void 0 ? 10 : _f, _g = _b.shouldRetry, shouldRetry = _g === void 0 ? isServerOrUnknownError : _g;
return {
condition: condition,
shouldHandleRequest: shouldHandleRequest,
handler: new RetryHandler({

@@ -61,0 +61,0 @@ initialInterval: initialInterval,

@@ -1,1 +0,1 @@

{"__symbolic":"module","version":4,"metadata":{"RetryPluginOptions":{"__symbolic":"interface"},"createRetryPlugin":{"__symbolic":"function","parameters":["condition","initialInterval","maxInterval","maxRetries","shouldRetry"],"defaults":[{}],"value":{"condition":{"__symbolic":"reference","name":"condition"},"handler":{"__symbolic":"new","expression":{"__symbolic":"reference","name":"ɵa"},"arguments":[{"initialInterval":{"__symbolic":"reference","name":"initialInterval"},"maxInterval":{"__symbolic":"reference","name":"maxInterval"},"maxRetries":{"__symbolic":"reference","name":"maxRetries"},"shouldRetry":{"__symbolic":"reference","name":"shouldRetry"}}]}}},"RetryPredicate":{"__symbolic":"interface"},"ɵa":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"any"}]}],"handle":[{"__symbolic":"method"}]}}},"origins":{"RetryPluginOptions":"./lib/create-retry-plugin","createRetryPlugin":"./lib/create-retry-plugin","RetryPredicate":"./lib/predicates/retry-predicate","ɵa":"./lib/retry-handler"},"importAs":"@http-ext/plugin-retry"}
{"__symbolic":"module","version":4,"metadata":{"RetryPluginOptions":{"__symbolic":"interface"},"createRetryPlugin":{"__symbolic":"function","parameters":["shouldHandleRequest","initialInterval","maxInterval","maxRetries","shouldRetry"],"defaults":[{}],"value":{"shouldHandleRequest":{"__symbolic":"reference","name":"shouldHandleRequest"},"handler":{"__symbolic":"new","expression":{"__symbolic":"reference","name":"ɵa"},"arguments":[{"initialInterval":{"__symbolic":"reference","name":"initialInterval"},"maxInterval":{"__symbolic":"reference","name":"maxInterval"},"maxRetries":{"__symbolic":"reference","name":"maxRetries"},"shouldRetry":{"__symbolic":"reference","name":"shouldRetry"}}]}}},"RetryPredicate":{"__symbolic":"interface"},"ɵa":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"any"}]}],"handle":[{"__symbolic":"method"}]}}},"origins":{"RetryPluginOptions":"./lib/create-retry-plugin","createRetryPlugin":"./lib/create-retry-plugin","RetryPredicate":"./lib/predicates/retry-predicate","ɵa":"./lib/retry-handler"},"importAs":"@http-ext/plugin-retry"}
import { RequestCondition } from '@http-ext/core';
import { HandlerOptions, RetryHandler } from './retry-handler';
export interface RetryPluginOptions extends HandlerOptions {
condition: RequestCondition;
shouldHandleRequest: RequestCondition;
}
/**
* @param condition
* @param shouldHandleRequest
* @param initialInterval defaults to 200ms

@@ -13,6 +13,6 @@ * @param maxInterval defaults to 1min

*/
export declare function createRetryPlugin({ condition, initialInterval, maxInterval, // 1 min
export declare function createRetryPlugin({ shouldHandleRequest, initialInterval, maxInterval, // 1 min
maxRetries, shouldRetry }?: Partial<RetryPluginOptions>): {
condition: RequestCondition;
shouldHandleRequest: RequestCondition;
handler: RetryHandler;
};
{
"name": "@http-ext/plugin-retry",
"version": "1.2.0",
"version": "2.0.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "private": false,

@@ -49,9 +49,9 @@ # @http-ext/plugin-retry

| Property | Type | Default value | Description |
| ------------------- | ------------------ | --------------- | ------------------------------------------------------------------ |
| `initialIntervalMs` | `number` | `200` | Duration before the first retry. |
| `maxIntervalMs` | `number` | `60000` | Maximum time span before retrying. |
| `maxRetries` | `number` | `10` | Maximum number of retries. |
| `shouldRetry` | `RetryPredicate` | `isServerError` | Predicate function to know which failed request should be retried. |
| `condition` | `RequestCondition` | `() => true` | Predicate function to know which request the plugin should handle. |
| Property | Type | Default value | Description |
| -------------------- | ------------------ | --------------- | ------------------------------------------------------------------ |
| `initialIntervalMs` | `number` | `200` | Duration before the first retry. |
| `maxIntervalMs` | `number` | `60000` | Maximum time span before retrying. |
| `maxRetries` | `number` | `10` | Maximum number of retries. |
| `shouldRetry` | `RetryPredicate` | `isServerError` | Predicate function to know which failed request should be retried. |
| `shouldHandleRequest`| `RequestCondition` | `() => true` | Predicate function to know which request the plugin should handle. |

@@ -72,3 +72,3 @@ Here is an example passing a configuration object.

shouldRetry: response => response.status !== 404,
condition: ({ request }) => request.url.includes('api.github.com')
shouldHandleRequest: ({ request }) => request.url.includes('api.github.com')
})

@@ -75,0 +75,0 @@ ]

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

Sorry, the diff of this file is not supported yet

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