UNPKG

qsu

Version:

qsu is a utility library that contains useful and frequently used functions. Start with your preferred language and the modern development environment.

1 lines 391 B
import{isObject as e}from"../verify/isObject.js";export function objTo1d(t,r="."){if(!r||r.length<1)throw new Error("`separator` must have value at least 1 character.");const o=(t,n="")=>{let s={};const c=Object.keys(t).length,a=n.length<1;for(let l=0;l<c;l+=1){const c=Object.keys(t)[l],h=t[c],i=`${n}${a?"":r}${c}`;e(h)?(s=Object.assign(s,o(h,i)),delete s[c]):s[i]=h}return s};return o(t)}