( debouncer: number | 'blur' | Debouncer<TValue, TPathKind>, )
| 38 | } |
| 39 | |
| 40 | function normalizeDebouncer<TValue, TPathKind extends PathKind>( |
| 41 | debouncer: number | 'blur' | Debouncer<TValue, TPathKind>, |
| 42 | ) { |
| 43 | // If it's already a debounce function, return it as-is. |
| 44 | if (typeof debouncer === 'function') { |
| 45 | return debouncer; |
| 46 | } |
| 47 | // If it's 'blur', return a debouncer that never resolves. The field will still be updated when |
| 48 | // the control is blurred. |
| 49 | if (debouncer === 'blur') { |
| 50 | return debounceUntilBlur(); |
| 51 | } |
| 52 | // If it's a non-zero number, return a timer-based debouncer. |
| 53 | if (debouncer > 0) { |
| 54 | return debounceForDuration(debouncer); |
| 55 | } |
| 56 | // Otherwise it's 0, so we return a function that will synchronize the model without delay. |
| 57 | return immediate; |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Creates a debouncer that will wait for the given duration before resolving. |
no test coverage detected
searching dependent graphs…