UNPKG

@stryke/helpers

Version:

A package containing miscellaneous helper functions that are used across many different Storm Software projects.

2 lines (1 loc) 359 B
import{isPlainObject as a}from"@stryke/type-checks/is-plain-object";export function flattenObject(t){return T(t)}function T(t,s=""){const c={},b=Object.keys(t);for(const n of b){const e=t[n],y=s?`${s}.${n}`:n;if(a(e)&&Object.keys(e).length>0)Object.assign(c,T(e,y));else if(Array.isArray(e))for(const[j,O]of e.entries())c[`${y}.${j}`]=O;else c[y]=e}return c}