combine

Combine two sets of values.

This method chains a combine operation to the patch, which combines two sets of values without duplicates.

Non-existent paths and null values are treated as an empty collection.

Signature

This method has the following signature:

patch.combine(path: string, value: JsonValue): Patch

The return is the Patch instance itself to allow operation chaining.

Example

Here is a basic example of how to use this method:

path.combine('interests', 'data science');

The following table shows how the operation behaves in different scenarios:

Current valueGiven valueResult
[][][]
[]['a', 'a']['a']
['a']null['a']
['a']'b'['a', 'b']
['a']['b', null]['a', 'b']
[null]['a']['a']
nullnull[]
null['a']['a']
null'a'['a']
'a''b'['a', 'b']
'a'['b']['a', 'b']
'a'['a']['a']

Parameters

The following list describes the supported parameters:

path
string

The path to the collection in dot notation, like interests.

value
JSON

The value to combine with the Current value, like data science.