Function: merge

merge<T>(...objs): Record<string, T[]>

深度合并多个对象

Type parameters

Name Description
T 对象值的类型

Parameters

Name Type Description
...objs Record<string, T>[] 要合并的对象数组

Returns

Record<string, T[]>

合并后的新对象

Description

将多个对象的属性深度合并,数组属性会被展开合并,非数组属性会被转换为数组

Throws

当输入参数不是对象时抛出

Example

merge(
  { a: 1, b: [2] },
  { a: 2, b: [3], c: 'foo' }
);
// => { a: [1, 2], b: [2, 3], c: ['foo'] }