The Collection component is a generic component that allows users to manipulate collection-type data.
It can carry out the following tasks:
#Release Stage
Alpha
#Configuration
The component definition and tasks are defined in the definition.json and tasks.json files respectively.
#Supported Tasks
#Assign
Assign the data.
Input | ID | Type | Description |
---|
Task ID (required) | task | string | TASK_ASSIGN |
Data (required) | data | any | Specify the data you want to assign. |
Output | ID | Type | Description |
---|
Data | data | any | The data you assign. |
#Append
Add data to the end of an array.
Input | ID | Type | Description |
---|
Task ID (required) | task | string | TASK_APPEND |
Array (required) | array | array | Specify the array you want to append to. |
Data (required) | element | any | Specify the data you want to append. |
Output | ID | Type | Description |
---|
Array | array | array | A updated array with the specified data appended to the end of it. |
#Union
Find the union of the sets
Input | ID | Type | Description |
---|
Task ID (required) | task | string | TASK_UNION |
Array (required) | sets | array | Specify the sets you want to union. |
Output | ID | Type | Description |
---|
Array | set | array | The union set. |
#Intersection
Find the intersection of the sets
Input | ID | Type | Description |
---|
Task ID (required) | task | string | TASK_INTERSECTION |
Array (required) | sets | array | Specify the sets you want to intersect. |
Output | ID | Type | Description |
---|
Array | set | array | The intersection set. |
#Difference
Find the difference between the two sets, i.e. set-a
\ set-b
, identifying the elements that are in set-a
but not in set-b
.
Input | ID | Type | Description |
---|
Task ID (required) | task | string | TASK_DIFFERENCE |
Array (required) | set-a | array | Specify the set-a. |
Array (required) | set-b | array | Specify the set-b. |
Output | ID | Type | Description |
---|
Array | set | array | The difference set. |
#Concat
Concatenate the arrays. i.e. [1, 2] + [3, 4] = [1, 2, 3, 4]
Input | ID | Type | Description |
---|
Task ID (required) | task | string | TASK_CONCAT |
Arrays (required) | arrays | array | The arrays to be concatenated. |
Output | ID | Type | Description |
---|
Array | array | array | The concatenated arrays. |
#Split
Split the array into an array of arrays with group size. i.e. [1, 2, 3, 4, 5, 6]
with group size 2 = [[1, 2], [3, 4], [5, 6]]
. If the array length is not divisible by the group size, the last group will have fewer elements.
Input | ID | Type | Description |
---|
Task ID (required) | task | string | TASK_SPLIT |
Array (required) | array | array | The array to be split. |
Group Size (required) | group-size | integer | The size of each group. |
Output | ID | Type | Description |
---|
Arrays | arrays | array | The array of arrays with group size. |
#Example Recipes
#Combine 2 arrays using TASK_UNION
and TASK_CONCAT
# This component combines two arrays of strings in a union, ensuring that no duplicates are included.
# ["foo", "bar"], ["foo", "bat"] -> ["foo", "bar", "bat"]
# This component concatenates two arrays of strings.
# ["foo", "bar"], ["zot", "bat"] -> ["foo", "bar", "zot", "bat"]
value: ${union.output.set}
value: ${concat.output.array}
#Use TASK_ASSIGN
to create an object with type
and text
keys
value: ${text-object.output.data}
#Use TASK_SPLIT
to split an array of strings into groups of a specified size
# This pipeline splits an array of elements into groups of a specified size.
# ["foo", "bar", "bat", "zot"], 2 -> [["foo", "bar"], ["bat", "zot"]]
# ["foo", "bar", "bat", "zot"], 3 -> [["foo", "bar", "bat"], ["zot"]]
group-size: ${variable.group-size}