@sammachin/node-red-lookup 1.0.0

Node-RED node that maps the value of one message field to another using a lookup table, with a configurable default for no match

npm install @sammachin/node-red-lookup

@sammachin/node-red-lookup

A single Node-RED node that maps the value of one message field to another using a lookup table.

You choose a source field to read and a target field to write (they can be the same field), give it a list of from → to pairs, and decide what happens when a value isn't in the table.

Example

Source msg.payload.from, target msg.payload.to, with pairs:

123 → 456
+441234 → +445678

An incoming msg.payload.from = "123" produces msg.payload.to = "456".

Configuration

Field Description
Source The field to read. A msg property (default payload), or flow / global context.
Target The field to write on a match. Same choices as source; set it equal to the source to rewrite in place.
Pairs The lookup table. The left side (from) is matched by value; the right side (to) is a typed input, so it can be a string, number, boolean, JSON, a message / context property, or a JSONata expression.
No match What to do when the source value isn't in the table (see below).

Matching

Matching is by value as a string, so the number 123 and the string "123" both match a pair keyed 123. A missing source field (undefined) never matches. If two rows share the same from value, the first one wins.

No match

  • Pass through unchanged — the target is left alone and the message is sent on.
  • Set a default value — the target is set to a fixed value, then sent on.
  • Send to 2nd output — the node grows a second output; matched messages leave the first output, unmatched ones leave the second, so you can handle them separately.

Develop

npm install
npm test

The node lives in src/nodes/lookup.js (runtime) and src/nodes/lookup.html (editor). Tests use node-red-node-test-helper.

Licence

MIT

Node Info

Version: 1.0.0
Updated 2 hours ago
License: MIT
Rating: not yet rated

Categories

Actions

Rate:

Downloads

0 in the last week

Nodes

  • lookup

Keywords

  • node-red
  • lookup
  • translate
  • map
  • recode
  • table

Maintainers