export function getArray(obj: any, path: string): any { if (path === '' || path === '.') { return obj; } switch (typeof obj) { case 'object': { if (obj === null) { return obj; } const steps = path.split('.'); const subPath = steps.slice(1).join('.'); if (steps[0] === '*') { if (Array.isArray(obj)) { return obj.map((el) => getArray(el, subPath)); } else { return undefined; } } else { if (Array.isArray(obj)) { const index = Number(steps[0]); if (isNaN(index)) { return undefined; } return getArray(obj[index], subPath); } else { return getArray(obj[steps[0]], subPath); } } } default: { return undefined; } } }