JSON TransformArray
pop
Remove elements from the end of an array
pop
Removes the last n elements from an array.
Options
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
n | integer | No | 1 | Number of elements to remove from the end. |
Example
Input
["a", "b", "c", "d"]Operation
{ "type": "pop", "options": { "n": 2 } }Output
["a", "b"]In a Circuit Step
{
"name": "drop_last_two",
"description": "Discard the last two events from the log",
"function": "circuit.core.transform.json",
"input": {
"source": "${{ event_log }}",
"operations": [
{ "type": "pop", "options": { "n": 2 } }
]
},
"outputs": [
{
"name": "trimmed_log",
"description": "Event log with the last two entries removed",
"value": "${{ drop_last_two.output.transformed_result }}"
}
]
}Notes & gotchas
- Errors with
pop: expected arrayif the input is not an array. nis clamped to the array length:popon["a"]withn: 5simply returns[].- Returns a new array; the original is not mutated.
- Returns the remaining elements, not the removed ones (this is the JS-style "remove" semantic, not the "take and return removed" semantic).