Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

apollo-link-retry

Package Overview
Dependencies
Maintainers
3
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apollo-link-retry - npm Package Compare versions

Comparing version 0.6.1-beta.1 to 0.6.1-beta.3

lib/bundle.umd.js

76

package.json
{
"name": "apollo-link-retry",
"version": "0.6.1-beta.1",
"version": "0.6.1-beta.3",
"description": "Retry Apollo Link for GraphQL Network Stack",

@@ -13,6 +13,6 @@ "author": "Evans Hauser <evanshauser@gmail.com>",

"license": "MIT",
"main": "./dist/src/bundle.umd.js",
"module": "./dist/src/retryLink.js",
"jsnext:main": "./dist/src/retryLink.js",
"typings": "./dist/src/retryLink.d.ts",
"main": "./lib/bundle.umd.js",
"module": "./lib/retryLink.js",
"jsnext:main": "./lib/retryLink.js",
"typings": "./lib/retryLink.d.ts",
"repository": {

@@ -27,51 +27,43 @@ "type": "git",

"scripts": {
"pretest": "npm run build-test",
"test": "npm run test-only --",
"posttest": "npm run lint",
"test-only": "mocha --reporter spec --full-trace dist/tests/tests.js",
"test-watch":
"mocha --reporter spec --full-trace dist/tests/tests.js --watch",
"coverage":
"istanbul cover ./node_modules/mocha/bin/_mocha -- --reporter dot --full-trace dist/tests/tests.js",
"postcoverage":
"remap-istanbul --input coverage/coverage.json --type lcovonly --output coverage/lcov.info",
"build:browser":
"browserify ./lib/bundle.umd.js -o=./lib/bundle.js --i apollo-link && npm run minify:browser",
"build": "tsc -p .",
"bundle": "rollup -c",
"clean": "rimraf lib/* && rimraf coverage/*",
"filesize": "npm run build && npm run build:browser",
"lint":
"tslint --type-check -p tsconfig.test.json src/*.ts && tslint --type-check -p tsconfig.test.json tests/*.ts",
"prebuild": "npm run clean:dist",
"build": "tsc -p .",
"build-test": "tsc -p tsconfig.test.json",
"tslint --type-check -p tsconfig.json -c ../../tslint.json src/*.ts",
"minify:browser":
"uglifyjs -c -m -o ./lib/bundle.min.js -- ./lib/bundle.js",
"postbuild": "npm run bundle",
"postbuild-test": "npm run bundle",
"bundle": "rollup -c",
"watch": "tsc -w -p .",
"clean": "npm run clean:dist && npm run clean:coverage",
"clean:dist": "rimraf dist/*",
"clean:coverage": "rimraf coverage/*",
"prepublishOnly": "npm run clean && npm run build"
"prebuild": "npm run clean",
"prepublishOnly": "npm run clean && npm run build",
"test": "jest",
"watch": "tsc -w -p ."
},
"peerDependencies": {
"apollo-link": "^0.6.1-beta.1"
"apollo-link": "^0.6.1-beta.3"
},
"devDependencies": {
"@types/chai": "4.0.4",
"@types/chai-as-promised": "0.0.31",
"@types/mocha": "2.2.42",
"@types/sinon": "2.3.3",
"apollo-link": "^0.6.1-beta.1",
"chai": "4.1.1",
"chai-as-promised": "7.1.1",
"fetch-mock": "5.12.2",
"@types/graphql": "0.10.2",
"@types/jest": "^20.0.8",
"apollo-link": "^0.6.1-beta.3",
"browserify": "^14.4.0",
"graphql": "0.10.5",
"graphql-tag": "2.4.2",
"istanbul": "0.4.5",
"lodash": "4.17.4",
"mocha": "3.5.0",
"remap-istanbul": "0.9.5",
"jest": "^21.1.0",
"rimraf": "2.6.1",
"rollup": "^0.45.2",
"sinon": "3.2.0",
"source-map-support": "0.4.16",
"ts-jest": "^21.0.1",
"tslint": "5.7.0",
"typescript": "2.5.1"
"typescript": "2.5.1",
"uglify-js": "^3.1.1"
},
"jest": {
"transform": {
".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"moduleFileExtensions": ["ts", "tsx", "js", "json"]
}
}
export default {
entry: 'dist/src/retryLink.js',
dest: 'dist/src/bundle.umd.js',
entry: 'lib/retryLink.js',
dest: 'lib/bundle.umd.js',
format: 'umd',

@@ -8,10 +8,7 @@ sourceMap: true,

exports: 'named',
onwarn
onwarn,
};
function onwarn(message) {
const suppressed = [
'UNRESOLVED_IMPORT',
'THIS_IS_UNDEFINED'
];
const suppressed = ['UNRESOLVED_IMPORT', 'THIS_IS_UNDEFINED'];

@@ -18,0 +15,0 @@ if (!suppressed.find(code => message.code === code)) {

@@ -10,19 +10,26 @@ import {

const operationFnOrNumber = prop =>
typeof prop === 'number' ? () => prop : prop;
const defaultInterval = delay => delay;
export type ParamFnOrNumber = (operation: Operation) => number | number;
export default class RetryLink extends ApolloLink {
private count: number = 0;
private delay: number;
private max: number;
private delay: ParamFnOrNumber;
private max: ParamFnOrNumber;
private interval: (delay: number, count: number) => number;
private subscription: ZenObservable.Subscription;
private timer;
private subscriptions: { [key: string]: ZenObservable.Subscription } = {};
private timers = {};
private counts: { [key: string]: number } = {};
constructor(params?: {
max?: number;
delay?: number;
max?: ParamFnOrNumber;
delay?: ParamFnOrNumber;
interval?: (delay: number, count: number) => number;
}) {
super();
this.max = (params && params.max) || 10;
this.delay = (params && params.delay) || 300;
this.interval = (params && params.interval) || this.defaultInterval;
this.max = operationFnOrNumber((params && params.max) || 10);
this.delay = operationFnOrNumber((params && params.delay) || 300);
this.interval = (params && params.interval) || defaultInterval;
}

@@ -34,15 +41,17 @@

): Observable<FetchResult> {
const key = operation.toKey();
if (!this.counts[key]) this.counts[key] = 0;
return new Observable(observer => {
const subscriber = {
next: data => {
this.count = 0;
this.counts[key] = 0;
observer.next(data);
},
error: error => {
this.count++;
if (this.count < this.max) {
this.timer = setTimeout(() => {
this.counts[key]++;
if (this.counts[key] < this.max(operation)) {
this.timers[key] = setTimeout(() => {
const observable = forward(operation);
this.subscription = observable.subscribe(subscriber);
}, this.interval(this.delay, this.count));
this.subscriptions[key] = observable.subscribe(subscriber);
}, this.interval(this.delay(operation), this.counts[key]));
} else {

@@ -55,14 +64,10 @@ observer.error(error);

this.subscription = forward(operation).subscribe(subscriber);
this.subscriptions[key] = forward(operation).subscribe(subscriber);
return () => {
this.subscription.unsubscribe();
if (this.timer) {
clearTimeout(this.timer);
}
this.subscriptions[key].unsubscribe();
if (this.timers[key]) clearTimeout(this.timers[key]);
};
});
}
private defaultInterval = delay => delay;
}
{
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "dist",
"rootDir": "."
"rootDir": "./src",
"outDir": "lib"
},
"include": ["src/**/*.ts"]
"include": ["src/**/*.ts"],
"exclude": ["src/**/__tests__/*.ts"]
}
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc