rangenode

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 6 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Range node

Type: range
Category: Flow Control

Maps a numeric property from an input range to an output range.

Behavior

This node is registered as range and runs as part of a workflow. Its exact runtime behavior is implemented in node.go; this document summarizes the editor-facing purpose and configuration contract.

Configuration

Field Type Default Description
action string scale Action — scale: extrapolate freely; drop: discard out-of-range messages; clamp: clamp to the input range; roll: wrap into the input range
maxin number 100 Input Max — Upper bound of the input range
maxout number 1 Output Max — Upper bound of the output range
minin number 0 Input Min — Lower bound of the input range
minout number 0 Output Min — Lower bound of the output range
property string payload Property — Field to map; "payload" (default) or a dotted path inside the payload
round boolean false Round Result — Round the scaled value to the nearest integer

Implementation

  • node.go contains the executor, validation, schema, and registration.
  • editor.html contains the editor integration.
  • node_test.go, when present, contains behavioral tests.

Documentation

Overview

Package rangenode contains the range node implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RangeConfig

type RangeConfig struct {
	// Action is "scale" (default, extrapolate freely), "drop"
	// (discard out-of-range messages), "clamp" (clamp to the input
	// range) or "roll" (wrap into the input range)
	Action string `json:"action"`
	// Property is the dotted path into the payload; "payload" (the
	// default) targets the whole payload
	Property string  `json:"property"`
	MinIn    float64 `json:"minin"`
	MaxIn    float64 `json:"maxin"`
	MinOut   float64 `json:"minout"`
	MaxOut   float64 `json:"maxout"`
	// Round rounds the scaled result to the nearest integer
	Round bool `json:"round"`
}

RangeConfig holds configuration for the range node — the Node-RED range equivalent. MinIn/MaxIn define the input range, MinOut/MaxOut the output range the value is linearly mapped to.

type RangeNode

type RangeNode struct {
	*nodebase.BaseNode
	// contains filtered or unexported fields
}

RangeNode linearly maps a numeric payload property from an input range to an output range, with an optional out-of-range action applied to the input range before scaling.

func NewRangeNode

func NewRangeNode(node nodestore.NodeInterface, config *RangeConfig) *RangeNode

NewRangeNode creates a new range node

func (*RangeNode) Execute

Execute reads the configured property, applies the out-of-range action, scales the value and writes it back. A non-numeric value or a value dropped by the "drop" action ends the message here (nil output); a missing property passes the message through unchanged.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL