(obj: any, path: (string | number)[], value: any)
| 1979 | |
| 1980 | // Helper function to set a value at a nested path |
| 1981 | const setValueAtPath = (obj: any, path: (string | number)[], value: any): void => { |
| 1982 | let current = obj |
| 1983 | for (let i = 0; i < path.length - 1; i++) { |
| 1984 | const key = path[i] |
| 1985 | if (current && typeof current === 'object' && key in current) { |
| 1986 | current = current[key] |
| 1987 | } else { |
| 1988 | return // Path doesn't exist |
| 1989 | } |
| 1990 | } |
| 1991 | if (current !== undefined && current !== null) { |
| 1992 | const finalKey = path[path.length - 1] |
| 1993 | current[finalKey] = value |
| 1994 | } |
| 1995 | } |
| 1996 | |
| 1997 | // Helper function to get a value at a nested path |
| 1998 | const getValueAtPath = (obj: any, path: (string | number)[]): any => { |
no outgoing calls
no test coverage detected