Skip to content

Commit 5fbae28

Browse files
committed
Add minimal retry package
1 parent b6f8cd6 commit 5fbae28

File tree

6 files changed

+53
-0
lines changed

6 files changed

+53
-0
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ jobs:
126126
*)
127127
esac
128128
for X in fixtures/*; do
129+
if [[ "$X" = fixtures/retry ]]; then
130+
continue
131+
fi
129132
pushd "$X"
130133
yarn
131134
wget --quiet https://github.com/trail-of-forks/sbpf-coverage/releases/download/$AGAVE_TAG/patched-agave-tools-$AGAVE_TAG-$EXT.tar.gz

fixtures/retry/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export declare function retry<T>(f: () => Promise<T>): Promise<T>;

fixtures/retry/index.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"use strict";
2+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4+
return new (P || (P = Promise))(function (resolve, reject) {
5+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8+
step((generator = generator.apply(thisArg, _arguments || [])).next());
9+
});
10+
};
11+
Object.defineProperty(exports, "__esModule", { value: true });
12+
exports.retry = retry;
13+
function retry(f) {
14+
return __awaiter(this, void 0, void 0, function* () {
15+
while (true) {
16+
try {
17+
return yield f();
18+
}
19+
catch (error) {
20+
console.error(error);
21+
yield new Promise(resolve => setTimeout(resolve, 1000));
22+
}
23+
}
24+
});
25+
}

fixtures/retry/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export async function retry<T>(f: () => Promise<T>): Promise<T> {
2+
while (true) {
3+
try {
4+
return await f();
5+
} catch (error) {
6+
console.error(error);
7+
await new Promise(resolve => setTimeout(resolve, 1000));
8+
}
9+
}
10+
}

fixtures/retry/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "retry",
3+
"version": "0.0.0",
4+
"main": "index.js",
5+
"types": "index.d.ts"
6+
}

fixtures/retry/tsconfig.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es2016",
4+
"module": "commonjs",
5+
"declaration": true,
6+
"strict": true,
7+
}
8+
}

0 commit comments

Comments
 (0)