This package provides three essential Node-RED nodes designed to facilitate flow looping within the Node-RED environment: `counter-loop`, `array-loop`, and `while-loop`. The `counter-loop` node enables `for-loop`-like behavior using a configurable counter, defining initial, terminal, and increment values. The `array-loop` node iterates over elements within a standard JavaScript array, akin to `forEach` or `for-of`, exposing the current key and value. The `while-loop` node executes based on a dynamic conditional expression. Currently at version 0.5.1, the package is actively maintained with a steady cadence of minor updates, frequently addressing bug fixes and introducing new features such as loop time limitations for `while-loop` and explicit variable resetting for iterative nodes. It significantly enhances Node-RED's capabilities by providing structured control flow mechanisms for repetitive tasks, which are not inherently available through basic core nodes.
npm install node-red-contrib-loop-processingNo compatibility data collected yet for this library.
This quickstart JSON demonstrates how to install the package and configure a basic `counter-loop` node in Node-RED, iterating a counter from 0 to 5 and logging each step, while also showing the loop completion.
After a loop completes, use a `change` node or a `function` node to explicitly set the relevant loop variable property (e.g., `msg.payload.counter`) to `null`, `undefined`, or an empty string before initiating another loop that relies on the same variable.
Review the `while-loop` node's configuration in the Node-RED editor to understand the default time limit. If longer durations are required, adjust this setting cautiously while ensuring that your loop condition is guaranteed to eventually become false to prevent system resource exhaustion.
Ensure that the input property for the `array-loop` node is a standard JavaScript array (`[]`). If you need to iterate over properties of an object, use a preceding `function` node to convert the object's keys or values into an array, or consider alternative Node-RED patterns for object processing.
Open your terminal, navigate to your Node-RED user directory (typically `~/.node-red`), and execute `npm install node-red-contrib-loop-processing`. After successful installation, restart your Node-RED instance.
Carefully verify the condition expression configured in your `while-loop` node to ensure it will eventually resolve to `false`. If a time limit is being hit, adjust the `while-loop` node's timeout settings if your design truly requires a longer loop, or refactor your flow logic to process data in smaller, discrete steps to avoid long-running iterations.