@ -303,3 +303,17 @@ export const injectCustomHeadCode = (customHeadCode: string) => {
|
||||
document.head.append(noScriptElement)
|
||||
})
|
||||
}
|
||||
|
||||
export const getAtPath = <T>(obj: T, path: string): unknown => {
|
||||
if (isNotDefined(obj)) return undefined
|
||||
const pathParts = path.split('.')
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let current: any = obj
|
||||
for (const part of pathParts) {
|
||||
if (current === undefined) {
|
||||
return undefined
|
||||
}
|
||||
current = current[part]
|
||||
}
|
||||
return current
|
||||
}
|
||||
|
Reference in New Issue
Block a user