2022-04-18 23:07:00 +02:00
|
|
|
export const reach = (path, data) => {
|
2024-07-30 11:37:11 +02:00
|
|
|
if (!data) return;
|
|
|
|
|
2022-04-18 23:07:00 +02:00
|
|
|
const parts = path.split('.');
|
|
|
|
let part;
|
|
|
|
while (part = parts.shift()) {
|
|
|
|
data = data instanceof Set || data instanceof Map ? data.get(part) : data[part];
|
|
|
|
if (parts.length > 0 && (typeof data !== 'object' || data === null)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|