addTwoNumbers Documentation
Overview
The node is a lightweight utility designed to sum two numerical inputs. It is ideal for applications where simple arithmetic operations are needed. This function ensures that the inputs are valid numbers and returns their sum, making it easy to integrate basic calculations into larger workflows or data processing pipelines.
Purpose
The primary purpose of the node is to provide a straightforward solution for adding two numbers. This can be useful in various scenarios, including data processing, analytics applications, or any context where numerical sums are required.
Settings
The node offers the following settings:
1. Input Configuration
Setting Name: input1
- Input Type: Numeric (can be a number or a string that represents a number)
- Description: This setting is used to provide the first number to be added. If this value is not provided, the function will look for a default value in the
configobject or will default to0. - Default Value:
0
Setting Name: input2
- Input Type: Numeric (can be a number or a string that represents a number)
- Description: This setting serves as the second number for the addition. Like
input1, if not specified in the input, it will default to a value from theconfigobject or will default to0. - Default Value:
0
Behavior: Both input1 and input2 can accept values in various forms (as numbers or strings). The function will attempt to convert these inputs into numbers using the node. If either of the inputs is non-numeric, the function will throw an error.
Output
Setting Name: output1
- Output Type: Numeric
- Description: Provides the result of the addition operation, which is the sum of
input1andinput2. - Default Value: Computed at runtime based on the inputs.
How It Works
The node begins by destructuring inputs and config objects to retrieve the values for input1 and input2. If the values are not found, it defaults to 0. It then converts the inputs to numbers and checks their validity:
- Converts
input1andinput2to numerical values. - Validates that both values are numbers. If either input is invalid (e.g., non-numeric), it throws an error.
- Computes the sum of
input1andinput2. - Returns the computed sum as an object with a property named
output1.
Expected Data
The node expects the following data format:
- Inputs: An object containing
input1andinput2, which can either be directly passed or defined in theconfig. The expected types for these inputs are numeric or string representations of numbers. - Output: An object that contains
output1, which will hold the sum of the two inputs.
Use Cases & Examples
Use Cases
- Data Transformation in ETL Processes: Useful in Extract, Transform, Load (ETL) processes where constant summation of various numerical fields is required, like aggregating sales revenue.
- Real-Time Calculations: Can be employed in dashboards to calculate and display real-time statistics involving user input, such as total expenses or revenue.
- Integration in APIs: Can be used as part of a backend service that provides additional functionality for applications requiring simple arithmetic operations.
Example Configuration
Use Case: Summing two numerical inputs for an expense tracker application where users input their daily expenditures.
Configuration Example
{
"inputs": {
"input1": "150",
"input2": "250"
},
"config": {}
}Expected Output:
{
"output1": 400
}In this example, the user inputs values for input1 as 150 and input2 as 250. When passed to the node, it computes the sum, resulting in an output of 400.
AI Integrations and Billing Impacts
- AI Integrations: While
addTwoNumbersdoes not directly integrate with AI components, it could be part of more complex workflows that leverage AI for data processing or analysis. - Billing Impacts: Since this function is lightweight in terms of processing power, its usage will not significantly affect billing. However, if incorporated into a larger, resource-intensive application, the cumulative costs may increase depending on the scale of usage.