Core nodes collection for Node-RED runtime providing fundamental building blocks for visual programming flows
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
Sequence nodes provide message flow control and manipulation capabilities for handling arrays, message streams, and batch processing. These nodes enable complex data aggregation, splitting, and ordering operations within Node-RED flows.
Split messages into sequences based on arrays, objects, or string delimiters. Creates a sequence of individual messages from composite data.
/**
* Split node for breaking messages into sequences
* Registers as node type: "split"
*/
function SplitNode(config) {
RED.nodes.createNode(this, config);
// Configuration properties:
// config.splt - Split character/delimiter (for strings)
// config.spltType - Split type: "str", "len", "stream"
// config.arraySplt - Array split mode
// config.arraySpltType - Array split type
// config.stream - Stream mode for large objects
// config.addname - Add property name for object splits
}Usage Examples:
// Split array into individual messages
// Input: { payload: [1, 2, 3, 4, 5] }
// Output: { payload: 1, parts: {index: 0, count: 5, id: "abc"} }
// { payload: 2, parts: {index: 1, count: 5, id: "abc"} }
// ... etc
// Split string by delimiter
{
"splt": ",",
"spltType": "str"
}
// Input: { payload: "red,green,blue" }
// Output: { payload: "red", parts: {index: 0, count: 3, id: "def"} }
// { payload: "green", parts: {index: 1, count: 3, id: "def"} }
// { payload: "blue", parts: {index: 2, count: 3, id: "def"} }
// Split object into key-value pairs
{
"arraySplt": true,
"addname": true
}
// Input: { payload: {name: "John", age: 30, city: "NYC"} }
// Output: { payload: "John", topic: "name", parts: {...} }
// { payload: 30, topic: "age", parts: {...} }
// { payload: "NYC", topic: "city", parts: {...} }Combine message sequences back into arrays, objects, or concatenated strings. Supports automatic and manual join modes.
/**
* Join node for combining message sequences
* Registers as node type: "join"
*/
function JoinNode(config) {
RED.nodes.createNode(this, config);
// Configuration properties:
// config.mode - Join mode: "auto", "custom", "reduce"
// config.build - Build type: "array", "object", "string", "merged"
// config.property - Property to join (default: "payload")
// config.propertyType - Property type: "msg", "full"
// config.key - Key property for object building
// config.joiner - String joiner character
// config.joinerType - Joiner type
// config.accumulate - Accumulate results
// config.timeout - Join timeout in seconds
// config.count - Expected message count (manual mode)
}Usage Examples:
// Auto-join split array back together
{
"mode": "auto",
"build": "array"
}
// Input: Sequence of messages with parts.index/count/id
// Output: { payload: [1, 2, 3, 4, 5] }
// Join messages into object using topic as key
{
"mode": "custom",
"build": "object",
"key": "topic",
"count": "3"
}
// Input: { payload: "John", topic: "name" }
// { payload: 30, topic: "age" }
// { payload: "NYC", topic: "city" }
// Output: { payload: {name: "John", age: 30, city: "NYC"} }
// Join messages into string
{
"mode": "custom",
"build": "string",
"joiner": ", ",
"count": "3"
}
// Input: { payload: "red" }, { payload: "green" }, { payload: "blue" }
// Output: { payload: "red, green, blue" }
// Reduce mode for calculations
{
"mode": "reduce",
"build": "merged",
"reduceRight": false,
"reduceExp": "$A + payload",
"reduceInit": "0",
"reduceInitType": "num"
}Sort message sequences by specified properties with configurable sort order.
/**
* Sort node for ordering message sequences
* Registers as node type: "sort"
*/
function SortNode(config) {
RED.nodes.createNode(this, config);
// Configuration properties:
// config.target - Property to sort by (default: "payload")
// config.targetType - Target type: "msg", "seq"
// config.msgKey - Message key for sorting
// config.msgKeyType - Key type: "elem", "jsonata"
// config.seqKey - Sequence key for sorting
// config.seqKeyType - Sequence key type
// config.order - Sort order: "ascending", "descending"
}Usage Examples:
// Sort by payload value (ascending)
{
"target": "payload",
"order": "ascending"
}
// Input: { payload: 3, parts: {...} }
// { payload: 1, parts: {...} }
// { payload: 2, parts: {...} }
// Output: { payload: 1, parts: {...} }
// { payload: 2, parts: {...} }
// { payload: 3, parts: {...} }
// Sort objects by property (descending)
{
"target": "payload",
"msgKey": "age",
"msgKeyType": "elem",
"order": "descending"
}
// Input: { payload: {name: "John", age: 30} }
// { payload: {name: "Jane", age: 25} }
// { payload: {name: "Bob", age: 35} }
// Output: { payload: {name: "Bob", age: 35} }
// { payload: {name: "John", age: 30} }
// { payload: {name: "Jane", age: 25} }
// Sort using JSONata expression
{
"msgKey": "payload.timestamp",
"msgKeyType": "jsonata",
"order": "ascending"
}Group messages into batches based on count, time intervals, or other criteria.
/**
* Batch node for grouping messages
* Registers as node type: "batch"
*/
function BatchNode(config) {
RED.nodes.createNode(this, config);
// Configuration properties:
// config.mode - Batch mode: "count", "interval"
// config.count - Messages per batch (count mode)
// config.overlap - Overlap count for sliding window
// config.interval - Time interval in seconds (interval mode)
// config.allowEmptySequence - Allow empty batches
// config.topics - Topic grouping
}Usage Examples:
// Batch by message count
{
"mode": "count",
"count": "3",
"overlap": "0"
}
// Input: 6 individual messages
// Output: 2 batches of 3 messages each
// Sliding window batch
{
"mode": "count",
"count": "3",
"overlap": "1"
}
// Creates overlapping batches: [1,2,3], [2,3,4], [3,4,5], etc.
// Time-based batching
{
"mode": "interval",
"interval": "5"
}
// Collects messages for 5 seconds, then outputs batch
// Topic-based grouping
{
"mode": "count",
"count": "2",
"topics": true
}
// Groups messages by topic, batching within each topicSequence nodes use a standard parts property to track message sequences:
// Message parts structure for sequence tracking
interface MessageParts {
id: string; // Unique sequence identifier
index: number; // Position in sequence (0-based)
count: number; // Total messages in sequence
type?: string; // Sequence type: "array", "object", "string"
ch?: string; // Character used for string splits
key?: string; // Object key (for object sequences)
len?: number; // Length information
}
// Example message with parts
interface SequenceMessage {
payload: any;
parts: MessageParts;
topic?: string; // May contain key for object sequences
[key: string]: any;
}Sequence nodes implement consistent patterns for handling message flows:
// Standard sequence processing pattern
this.on("input", function(msg, send, done) {
try {
if (msg.hasOwnProperty("parts")) {
// Handle sequenced message
processSequencedMessage(msg);
} else {
// Handle standalone message
processStandaloneMessage(msg);
}
// Check if sequence is complete
if (isSequenceComplete()) {
var result = buildResult();
send(result);
}
done();
} catch (error) {
done(error);
}
});
// Sequence completion detection
function isSequenceComplete() {
// Check if all expected messages received
return receivedCount >= expectedCount;
}Join node supports reduce operations for calculations across sequences:
// Reduce configuration for calculations
{
"mode": "reduce",
"build": "merged",
"reduceRight": false,
"reduceExp": "$A + payload.value", // JSONata expression
"reduceInit": "0", // Initial accumulator value
"reduceInitType": "num"
}
// Example reduce operations:
// Sum: "$A + payload"
// Product: "$A * payload"
// Max: "payload > $A ? payload : $A"
// Concatenate: "$A & payload"
// Count: "$A + 1"Join node supports timeouts for incomplete sequences:
// Timeout configuration
{
"timeout": "30", // 30 second timeout
"build": "array",
"mode": "custom"
}
// Behavior on timeout:
// - Sends partial results if any messages received
// - Clears internal sequence state
// - Continues processing new sequencesBatch node can group messages by topic for parallel processing:
// Topic grouping configuration
{
"mode": "count",
"count": "5",
"topics": true
}
// Creates separate batches per topic:
// Topic "sensor1": [msg1, msg2, msg3, msg4, msg5]
// Topic "sensor2": [msg1, msg2, msg3, msg4, msg5]
// Each topic maintains independent batch stateSequence nodes handle various error conditions:
// Common error scenarios:
// Missing parts property (join/sort nodes)
// Recovery: Treat as single-message sequence
// Sequence timeout (join node)
// Recovery: Send partial results, clear state
// Invalid sort key (sort node)
// Recovery: Skip sorting, pass messages through
// Memory limits (large sequences)
// Recovery: Implement backpressure, limit sequence size