Splice List
Uncontrolled node
Overview
Remove items and optionally insert one value into a copy of a list.
Create an edited copy of a list by removing items and optionally inserting one new value at the same position. The source list is not changed.
This node is evaluated when another node needs its output. It has no run or done event.
Inputs
| Input | Type | Description |
|---|---|---|
| list | List | The list to edit. An empty list is valid. |
| start | Number | Zero-based position to begin editing. Defaults to 0; negative values count back from the end. |
| deleteCount | Number | Number of items to remove. Defaults to 0, which inserts without deleting. |
| newItem | Data | Optional single value to insert. Leave unconnected to delete only. A list is inserted as one nested item, not spread into separate items. |
Outputs
| Output | Type | Description |
|---|---|---|
| output | Data | The edited list, or { "error": "Input is not a list" } for a non-list input. |
| deleted | List | Items removed from a valid input list, in their original order. Empty when nothing is removed. Not supplied on invalid input. |
Editing behaviour
Use whole-number positions and counts; fractions are rounded down. A position beyond the end appends the new item. A negative delete count removes nothing, and a count beyond the remaining length removes only the available items.
Supplying null, false, 0 or empty text as newItem inserts that value. To avoid inserting anything, leave newItem unset.
Examples
For list: ["a", "b", "c"]:
| Start | Delete count | New item | Output | Deleted |
|---|---|---|---|---|
1 | 1 | "x" | ["a", "x", "c"] | ["b"] |
1 | 0 | "x" | ["a", "x", "b", "c"] | [] |
1 | 2 | Unset | ["a"] | ["b", "c"] |
3 | 0 | ["x", "y"] | ["a", "b", "c", ["x", "y"]] | [] |