Creates a proxy that intercepts function calls and applies retries.
(target: T)
| 69 | |
| 70 | /** Creates a proxy that intercepts function calls and applies retries. */ |
| 71 | function createRetryProxy<T extends object>(target: T): T { |
| 72 | return new Proxy(target, { |
| 73 | get(targetObj, prop, receiver) { |
| 74 | const value = Reflect.get(targetObj, prop, receiver); |
| 75 | if (typeof value === 'function') { |
| 76 | return new Proxy(value, { |
| 77 | apply(targetFn, thisArg, argArray) { |
| 78 | return invokeWithRetry(() => (targetFn as Function).apply(targetObj, argArray)); |
| 79 | }, |
| 80 | }); |
| 81 | } |
| 82 | if (typeof value === 'object' && value !== null) { |
| 83 | return createRetryProxy(value); |
| 84 | } |
| 85 | return value; |
| 86 | }, |
| 87 | apply(targetFn, thisArg, argArray) { |
| 88 | return invokeWithRetry(() => (targetFn as Function).apply(thisArg, argArray)); |
| 89 | }, |
| 90 | }); |
| 91 | } |
| 92 | |
| 93 | /** A Github client for interacting with the Github APIs. */ |
| 94 | export class GithubClient { |
no outgoing calls
no test coverage detected