(
f: (...args: Array<{}>) => T, waitMs: number,
nowFunc?: Function)
| 485 | * @param waitMs The time between two consecutive calls to `f` in ms. |
| 486 | */ |
| 487 | export function debounce<T>( |
| 488 | f: (...args: Array<{}>) => T, waitMs: number, |
| 489 | nowFunc?: Function): (...args: Array<{}>) => T { |
| 490 | let lastTime = nowFunc != null ? nowFunc() : util.now(); |
| 491 | let lastResult: T; |
| 492 | const f2 = (...args: Array<{}>) => { |
| 493 | const now = nowFunc != null ? nowFunc() : util.now(); |
| 494 | if (now - lastTime < waitMs) { |
| 495 | return lastResult; |
| 496 | } |
| 497 | lastTime = now; |
| 498 | lastResult = f(...args); |
| 499 | return lastResult; |
| 500 | }; |
| 501 | return f2; |
| 502 | } |
| 503 | |
| 504 | /** |
| 505 | * Returns the fusable activation given a layers identifier. |
nothing calls this directly
no test coverage detected
searching dependent graphs…