( options: ThrottleStrategyOptions, )
| 46 | * ``` |
| 47 | */ |
| 48 | export function throttleStrategy( |
| 49 | options: ThrottleStrategyOptions, |
| 50 | ): ThrottleStrategy { |
| 51 | const throttler = new LiteThrottler( |
| 52 | (callback: () => Transaction) => callback(), |
| 53 | options, |
| 54 | ) |
| 55 | |
| 56 | return { |
| 57 | _type: `throttle`, |
| 58 | options, |
| 59 | execute: <T extends object = Record<string, unknown>>( |
| 60 | fn: () => Transaction<T>, |
| 61 | ) => { |
| 62 | throttler.maybeExecute(fn as () => Transaction) |
| 63 | }, |
| 64 | cleanup: () => { |
| 65 | throttler.cancel() |
| 66 | }, |
| 67 | } |
| 68 | } |
no test coverage detected