Skip to content

Commit beb472c

Browse files
authored
🤖 Merge PR DefinitelyTyped#74573 add throttle and retry types for hafas-client by @tsanona
1 parent c83706e commit beb472c

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { Profile } from ".";
2+
3+
/**
4+
* Retry options.
5+
*
6+
* Further opts could be used. Check {@link https://github.com/sindresorhus/p-retry | p-retry} for more info.
7+
*/
8+
export interface RetryOpts {
9+
/**
10+
* The maximum amount of times to retry the operation.
11+
* @default 3
12+
*/
13+
retries?: number;
14+
/**
15+
* The exponential factor to use.
16+
* @default 3
17+
*/
18+
factor?: number;
19+
/**
20+
* The number of milliseconds before starting the first retry.
21+
* @default 5000
22+
*/
23+
minTimeout?: number;
24+
}
25+
26+
/**
27+
* Use {@link Profile} opt-in for retrying failed requests to the endpoint.
28+
* @param profile - The base {@link Profile}
29+
* @param retryOpts - The {@link RetryOpts}
30+
*/
31+
export function withRetrying(profile: Profile, retryOpts?: RetryOpts): Profile;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Profile } from ".";
2+
3+
/**
4+
* Use {@link Profile} opt-in for throttling requests to the endpoint.
5+
* @param profile - The base {@link Profile}
6+
* @param [limit=5] - The maximum number of calls within an {@link interval}.
7+
* @param [interval=1000] - The timespan for {@link limit} in milliseconds.
8+
*/
9+
export function withThrottling(profile: Profile, limit?: number, interval?: number): Profile;

‎types/hafas-client/tsconfig.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
},
1616
"files": [
1717
"index.d.ts",
18+
"throttle.d.ts",
19+
"retry.d.ts",
1820
"hafas-client-tests.ts"
1921
]
2022
}

0 commit comments

Comments
 (0)