()
| 4 | const THROTTLE_OFFSET = 300 // ms |
| 5 | |
| 6 | export const throttle = (): Date | null => { |
| 7 | const now = new Date() |
| 8 | if (+now > +lastRun + THROTTLE_OFFSET) { |
| 9 | lastRun = now |
| 10 | return lastRun |
| 11 | } |
| 12 | return null |
| 13 | } |
| 14 | |
| 15 | // quick solution to prevent processing multiple results |
| 16 | // NOTE: may be possible to kill child process early if we migrate to tasks |