| 35 | const missingResetValue = Symbol('missingResetValue') |
| 36 | |
| 37 | function valueAtResetAddress( |
| 38 | value: unknown, |
| 39 | address: Array<string | number> |
| 40 | ): unknown | typeof missingResetValue { |
| 41 | let current = value |
| 42 | for (const segment of address) { |
| 43 | if ( |
| 44 | current === null || |
| 45 | typeof current !== 'object' || |
| 46 | !(segment in current) |
| 47 | ) { |
| 48 | return missingResetValue |
| 49 | } |
| 50 | current = (current as Record<string | number, unknown>)[segment] |
| 51 | } |
| 52 | return current |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Resets an input to its "initial" value. If the input is a group or list it |