Limite
Limits the number of elements transmitted to the next block. Keeps the first N elements of an array.
Parameters
| Parameter | Type | Required | Variable | Description |
|---|---|---|---|---|
inputArray | dynamic value | No | Yes | Input array to limit. Can reference a previous block output. |
limit | dynamic value | Yes | Yes | Maximum number of items to keep. (min 1) |
offset | dynamic value | No | Yes | Number of items to skip from the start (default: 0). |
fromEnd | boolean | No | No | Take items from the end instead of the start. (Default: false) |
outputVariable | text | No | No | Output variable name containing the limited array. |
Parameters marked Variable = Yes accept the
{{blockName.field}}syntax.
Output
Output variable : limitedData
{
"results": [],
"count": 0
}
Example
Keep only the first 5 results.
Input :
{"items": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]}
Output :
{"results": [1, 2, 3, 4, 5], "count": 5}
Tip
{{limitedData.results}} contains the truncated array. Combine with a Sort block to keep the top N results.