UNPKG

apphouse

Version:

Component library for React that uses observable state management and theme-able components.

20 lines (16 loc) 498 B
export function getMappedKeys(obj: object, prefix = ''): string[] { let keys: string[] = []; for (const key in obj) { // eslint-disable-next-line no-prototype-builtins if (obj.hasOwnProperty(key)) { const value = obj[key]; if (typeof value === 'object' && value !== null) { const nestedKeys = getMappedKeys(value, `${prefix}${key}.`); keys = keys.concat(nestedKeys); } else { keys.push(`${prefix}${key}`); } } } return keys; }