Source-tree mirror of EVOLV.wiki.git refactor (27a42ee on wiki.git): - 7 master pages rewritten with clean design (Home, Architecture, Topology-Patterns, Topic-Conventions, Telemetry, Getting-Started, Glossary). Tables and Mermaid for visuals, gitea alert callouts for warnings, shields badges for metadata only. No emoji as decoration. - Archive.md becomes a removal-changelog pointing readers to git history and to the successor pages. - _Sidebar.md updated to navigate the new flat-name layout. - Concept / finding / manual pages: uniform mini-header (badges + "reference page" callout) added without rewriting domain content. - Every internal link now uses the flat naming that resolves on the live gitea wiki (Concept-ASM-Models, Finding-BEP-..., etc.). On wiki.git: 29 Archive-* pages hard-deleted (the git history preserves them; Archive.md documents the removal). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
36 lines
1.2 KiB
Markdown
36 lines
1.2 KiB
Markdown
# Node-RED Function Node Patterns (EVOLV Summary)
|
|
|
|
 -orange)
|
|
|
|
> [!NOTE]
|
|
> Reference page. Maintained for context; not regenerated by code. See [Home](Home) for current top-level navigation.
|
|
|
|
|
|
Based on: https://nodered.org/docs/user-guide/writing-functions
|
|
|
|
## Return Semantics
|
|
|
|
- `return msg;` sends to output 1.
|
|
- `return [msg1, msg2, ...];` sends one message per output position.
|
|
- Use `null` for outputs that should not emit.
|
|
|
|
Examples:
|
|
|
|
- `return [msg, null, null];` -> output 1 only
|
|
- `return [null, msg, null];` -> output 2 only
|
|
|
|
## Message Mutation Pattern
|
|
|
|
- Start with the incoming `msg`, set fields (`msg.topic`, `msg.payload`), then return/send.
|
|
- This preserves message context unless there is a deliberate reason to create a new object.
|
|
|
|
## Async Function Pattern
|
|
|
|
- For asynchronous work, call `node.send(...)` and then `node.done()`.
|
|
- Avoid returning a message when output is sent asynchronously.
|
|
|
|
## EVOLV Practical Rule
|
|
|
|
- In example flows (including parsers), always align return-array position with downstream wiring.
|
|
- For dashboard parser functions, keep one stable output mapping per metric to avoid wire-level regressions.
|