UNPKG

softkave-js-utils

Version:

JavaScript & Typescript utility functions, types, and classes

21 lines 741 B
export function flattenObjDeep(obj) { const stack = [['', obj]]; const result = {}; for (let next = stack.pop(); next; next = stack.pop()) { const [parentKey, currentObj] = next; for (const instanceKey in currentObj) { const instanceValue = currentObj[instanceKey]; const completeInstanceKey = parentKey ? parentKey + '.' + instanceKey : instanceKey; if (typeof instanceValue === 'object') { stack.push([completeInstanceKey, instanceValue]); } else { result[completeInstanceKey] = instanceValue; } } } return result; } //# sourceMappingURL=flattenObjDeep.js.map