mergeDataDeep function
dynamic
mergeDataDeep(
- dynamic a,
- dynamic b, [
- dynamic elseFilter(
- dynamic
Merges two data structures deeply.
Implementation
dynamic mergeDataDeep(
dynamic a,
dynamic b, [
dynamic Function(dynamic)? elseFilter,
]) {
if (a is Map && b is Map) {
return mergeMaps(
a,
b,
value: (a, b) {
if (a is Map && b is Map) {
return mergeDataDeep(a.nonNulls, b.nonNulls, elseFilter);
}
if (a is List || a is Set || a is Queue) {
return mergeListsSetsOrQueues(a as Iterable, b as Iterable);
}
if (a is Iterable) {
return mergeIterables(a, b);
}
return elseFilter?.call(b) ?? b;
},
);
}
if (a is List || a is Set || a is Queue) {
return mergeListsSetsOrQueues(a as Iterable, b as Iterable);
}
if (a is Iterable) {
return mergeIterables(a, b);
}
return elseFilter?.call(b) ?? b;
}