Filter

The filter acts as a conditional gate for your flow, allowing you to branch logic based on specific conditions. It is the primary method for implementing if/else scenarios within Heisenware.

Filters are part of the function extensions. To add a filter to your function:

  1. Click the + icon on the right side of any function output, modifier, or existing filter.

  2. Select filter from the list.

  3. A new filter box will appear where you can write your JavaScript logic.

When to use

A filter evaluates a JavaScript expression that must return a boolean value (true or false). The input value from the preceding output is available as the reserved variable x.

Logical gate

If the result is true, the data is passed on to the next modifier following that filter; if false, the data flow is halted at this point.

Branching logic

The true and false states of the filter can be used to trigger separate logic paths. For example, you can use the true state to trigger another function.

circle-exclamation

JS filter examples

Unlike modifiers, filters strictly require an expression that evaluates to a boolean state (true or false).

Example 1: Threshold monitoring

Checks if a sensor value exceeds a critical limit.

Data:

Filter content:

Return of the filter: true

Example 2: Industrial error detection

Inspects a status message for specific keywords like "Error".

Data:

Filter content:

Return of the filter: true

Example 3: Validating array data

Ensures that an array contains data before attempting to process it.

Data:

Filter content:

Return of the filter: false

Using AI for filters

You can use AI chatbots like ChatGPT, Claude, or Gemini to generate complex filter logic. Since filters use standard JavaScript, you can provide the AI with the context of your data structure to get an immediate result.

To optimize results, copy this article as context for the AI. Use the Copy button at the top of the page or the direct Open in ChatGPT or Open in Claude buttons located in the top navigation bar.

Copy and paste this prompt into your AI to ensure it understands the Heisenware environment and specific variable references.

Last updated

Was this helpful?