shallowMerge()function
shallowMerge(left: L, right: R): L & R
shallowMerge(left: ImmutableArray<L>, right: ImmutableArray<R>): ImmutableArray<L | R>
shallowMerge(left: unknown, right: R): R
| Param | Type | |
|---|---|---|
left | L | The left value to merge into. required |
right | R | The right value to merge in. required |
left | ImmutableArray<L> | Immutable array: an array that cannot be changed. required |
right | ImmutableArray<R> | Immutable array: an array that cannot be changed. required |
left | unknown | required |
right | R | required |
| Return | |
|---|---|
L & R | Merged value. - Will be left instance if no properties/items changed.- Will be merged instance otherwise. |
ImmutableArray<L | R> | Immutable array: an array that cannot be changed. |
R |
Shallow merge two unknown values.
- Two objects: props are merged together (shallowly).
- Two arrays: unique items are merged together (shallowly).
- Any other value: right value is returned.
Examples
shallowMerge({ a: 1 }, { b: 2 }) // { a: 1, b: 2 }