Some checks failed
CI / lint-and-test (push) Has been cancelled
Move content to correct locations: - AGENTS.md → .agents/AGENTS.md (with orchestrator reference update) - third_party/docs/ (8 reference docs) → wiki/concepts/ - manuals/ (12 Node-RED docs) → wiki/manuals/ Delete 23 unreferenced one-off scripts from scripts/ (keeping 5 active). Delete stale Dockerfile.e2e, docker-compose.e2e.yml, test/e2e/. Remove empty third_party/ directory. Root is now: README, CLAUDE.md, LICENSE, package.json, Makefile, Dockerfile, docker-compose.yml, docker/, scripts/ (5), nodes/, wiki/, plus dotfiles (.agents, .claude, .gitea). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
30 lines
1006 B
Markdown
30 lines
1006 B
Markdown
# Node-RED Function Node Patterns (EVOLV Summary)
|
|
|
|
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.
|