Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export const flattenObject = (object: any): any => {
- return Object.keys(object).reduce((prev, element) => {
- return object[element] && typeof object[element] === 'object' && !(object[element] instanceof Array)
- ? { ...prev, ...flatten(object[element]) }
- ? { ...prev, ...flattenObject(object[element]) }
- : { ...prev, ...{ [`${element}`]: object[element] } };
- }, {});
- };
Add Comment
Please, Sign In to add comment