Skip to content
v2.274.0

ArrayMergeStrategy Class ​

Strategies for merging arrays in L1 property mixins.

Array elements are never deep-merged.

Methods ​

append(): IArrayMergeStrategy@staticmethod def append() -> IArrayMergeStrategypublic static IArrayMergeStrategy append()public static IArrayMergeStrategy Append()func Append() IArrayMergeStrategystatic#
Append source elements after the existing target elements.
example
ts
// target: [1, 2], source: [3, 4] → [1, 2, 3, 4]
prepend(): IArrayMergeStrategy@staticmethod def prepend() -> IArrayMergeStrategypublic static IArrayMergeStrategy prepend()public static IArrayMergeStrategy Prepend()func Prepend() IArrayMergeStrategystatic#
Prepend source elements before the existing target elements.
example
ts
// target: [1, 2], source: [3, 4] → [3, 4, 1, 2]
replace(): IArrayMergeStrategy@staticmethod def replace() -> IArrayMergeStrategypublic static IArrayMergeStrategy replace()public static IArrayMergeStrategy Replace()func Replace() IArrayMergeStrategystatic#
Replace the target array entirely with the source array.
example
ts
// target: [1, 2, 3], source: [4, 5] → [4, 5]
replaceByIndex(): IArrayMergeStrategy@staticmethod def replace_by_index() -> IArrayMergeStrategypublic static IArrayMergeStrategy replaceByIndex()public static IArrayMergeStrategy ReplaceByIndex()func ReplaceByIndex() IArrayMergeStrategystatic#
Overwrite target elements positionally with source elements.

Target elements beyond the source length are preserved.

example
ts
// target: ['a', 'b', 'c', 'd'], source: ['x', 'y'] → ['x', 'y', 'c', 'd']
replaceByKey(key: string): IArrayMergeStrategy@staticmethod def replace_by_key(key: str) -> IArrayMergeStrategypublic static IArrayMergeStrategy replaceByKey(String key)public static IArrayMergeStrategy ReplaceByKey(string key)func ReplaceByKey(Key *string) IArrayMergeStrategystatic#
Match source and target elements by a shared key property.

Matching target elements are replaced (not deep-merged). Unmatched source elements are appended.

Supports Box-backed elements: when target array elements are Boxes, the match is deferred until the Boxes resolve.

1 parameter · example

Parameters

  • keykeykeykeyKey — - The property name to match elements on.
ts
// key: 'id'
// target: [{id: 1, v: 'old'}, {id: 2, v: 'keep'}]
// source: [{id: 1, v: 'new'}, {id: 3, v: 'added'}]
// result: [{id: 1, v: 'new'}, {id: 2, v: 'keep'}, {id: 3, v: 'added'}]