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
ParamType
leftL
The left value to merge into. required
rightR
The right value to merge in. required
leftImmutableArray<L>
Immutable array: an array that cannot be changed. required
rightImmutableArray<R>
Immutable array: an array that cannot be changed. required
leftunknown
required
rightR
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 }