Utils / Controller / splitBooleanOutputs
Function: splitBooleanOutputs()
ts
function splitBooleanOutputs(conditionTerm, msg): unknown[];Splits a message into two outputs based on a boolean condition.
Parameters
| Parameter | Type | Description |
|---|---|---|
|
| The condition to evaluate. Expected to be a boolean ( |
|
| The message object to route based on the condition. |
Returns
unknown[]
An array of two elements:
- The first element contains the message if
conditionTermistrue, otherwisenull. - The second element contains the message if
conditionTermisfalse, otherwisenull.
Example
ts
const msg = { payload: 'Hello, world!' };
const result = splitBooleanOutputs(true, msg);
console.log(result); // Output: [{ payload: 'Hello, world!' }, null]