JSON TransformArray
shift
Remove elements from the beginning of an array
shift
Removes the first n elements from an array.
Options
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
n | integer | No | 1 | Number of elements to remove from the beginning. |
Example
Input
["a", "b", "c", "d"]Operation
{ "type": "shift", "options": { "n": 2 } }Output
["c", "d"]In a Circuit Step
{
"name": "drop_first_two",
"description": "Discard the first two events from the log",
"function": "circuit.core.transform.json",
"input": {
"source": "${{ event_log }}",
"operations": [
{ "type": "shift", "options": { "n": 2 } }
]
},
"outputs": [
{
"name": "remaining_log",
"description": "Event log with leading entries removed",
"value": "${{ drop_first_two.output.transformed_result }}"
}
]
}Notes & gotchas
- Errors with
shift: expected arrayif the input is not an array. nis clamped to the array length, soshifton["a"]withn: 5returns[].- Returns the remaining elements, not the removed ones.
- Use
unshiftto add elements at the beginning.