mergeConcatArray增加了对空数组的容错
This commit is contained in:
parent
8380982fc4
commit
2d514cd138
|
|
@ -29,5 +29,5 @@ import pullAll from 'lodash/pullAll';
|
|||
* @returns
|
||||
*/
|
||||
declare function mergeConcatArray(object: any, source: any): any;
|
||||
declare function mergeConcatMany<T>(array: Array<T>): T;
|
||||
declare function mergeConcatMany<T>(array: Array<T>): T | undefined;
|
||||
export { unset, pull, uniq, uniqBy, get, set, intersection, intersectionBy, omit, merge, mergeWith, mergeConcatArray, mergeConcatMany, cloneDeep, pick, isEqual, union, difference, differenceBy, groupBy, unionBy, pullAll, };
|
||||
|
|
|
|||
|
|
@ -67,6 +67,9 @@ function mergeConcatArray(object, source) {
|
|||
}
|
||||
exports.mergeConcatArray = mergeConcatArray;
|
||||
function mergeConcatMany(array) {
|
||||
if (array.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
return array.reduce((prev, current) => mergeConcatArray(prev, current));
|
||||
}
|
||||
exports.mergeConcatMany = mergeConcatMany;
|
||||
|
|
|
|||
|
|
@ -44,6 +44,9 @@ function mergeConcatArray(object: any, source: any) {
|
|||
}
|
||||
|
||||
function mergeConcatMany<T>(array: Array<T>) {
|
||||
if (array.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
return array.reduce(
|
||||
(prev, current) => mergeConcatArray(prev, current)
|
||||
) as T;
|
||||
|
|
|
|||
Loading…
Reference in New Issue