hd-utils
Version:
A handy utils for modern JS developers
9 lines (8 loc) • 469 B
TypeScript
/**
* @description will return a new object that combines all of the passed objects as new copy (not reference as Object.assign).
* @example joinObjects({a:1},{b:2}) => {a:1, b:2}
* @example joinObjects([1,2]) => {}
* @example joinObjects(({ a: 1 }, { b: 2 })) => { a: 1, b: 2 }
* @example joinObjects(({ a: 1 }, null || undefined || !object)) => { a: 1 }
*/
export default function joinObjects<T extends object | null | undefined | {}>(...args: (T | any)[]): T;