Length
Uncontrolled node
Overview
The Length node calculates the size or count of various data types. It accepts lists (arrays), dictionaries (objects), or text strings as input and outputs the corresponding length:
- For lists: returns the number of elements
- For dictionaries: returns the number of keys
- For text: returns the character count (including spaces)
This is an uncontrolled node, meaning it automatically computes and outputs the length whenever the input data changes, without requiring an event trigger.
Inputs
| Input | Type | Description | Default |
|---|---|---|---|
| Object | Data | The item to measure. Can be a list, dictionary, or text string. | - |
Outputs
| Output | Type | Description |
|---|---|---|
| Length | Number | The calculated length based on input type: count of items in a list, count of keys in a dictionary, or character count in text. Returns 0 if the input type is not recognized. |
Runtime Behavior
The Length node evaluates the input data type at runtime:
- Arrays: Uses the array's
.lengthproperty - Strings: Uses
.lengthto count characters (including whitespace) - Objects: Uses
Object.keys(obj).lengthto count enumerable keys - Other types: Returns
0
No default values are required as the node simply measures whatever is passed to it.
Example
Scenario: Counting items in a shopping list
- Connect a List node containing
["Apples", "Bananas", "Oranges"]to the Object input - The Length output will return
3
Scenario: Measuring text input
- Connect a Text node containing
"Hello World"to the Object input - The Length output will return
11(including the space)
Scenario: Counting dictionary keys
- Connect a Dictionary node containing
{"name": "John", "age": 30}to the Object input - The Length output will return
2