Data processing
The data processing utility class provides a collection of functions for common data manipulation, transformation, and logical operations. Use these functions to work with arrays and objects, handle JSON payloads, map numerical value ranges, and delay data flows. All functions in this class are static, meaning you do not need to create an instance before using them. The code class name is Tools.
echo
Returns the exact input value it receives.
Parameters
value
Any input argument to return.
any
Output
Returns the unchanged input value.
combine
Combines two or more arguments into a single array. Undefined values beyond the first two arguments are ignored.
Parameters
arg1, arg2, ...
An arbitrary number of arguments to combine into an array.
any
Example
# arg1
123
# arg2
"hello"
# arg3
{ "key": "value" }Output
Returns the combined array:
mergeObjects
Merges two or more objects into a single new object. If the same key exists in multiple objects, the value from the last object in the argument list overwrites the previous values. The function ignores any arguments that are not plain objects (including arrays).
Parameters
arg1, arg2, ...
Two or more objects to merge together.
object
Example
Output
Returns the merged object:
arrayPush
Pushes one or more items to the end of an array. If an item is itself an array, the function unpacks its elements and adds them individually to the base array. If the first input is not an array, the function wraps it in one; null or an empty input starts a new array.
Parameters
array
The destination input array.
array
items
Any number of items to push to the end of the array.
any
Example
Output
Returns the updated array:
mapRange
Maps a numerical value from an original range to a new range. The function rounds the final result to the nearest integer.
Parameters
value
The numerical value to map.
number
options
origMin
The minimum value of the original range.
number
origMax
The maximum value of the original range.
number
newMin
The minimum value of the new range.
number
newMax
The maximum value of the new range.
number
Example
Map a sensor value (0 to 1023) to a percentage scale (0 to 100):
Output
Returns the mapped integer value: 50
delay
Returns the provided value after a configurable time delay. This function executes asynchronously.
Parameters
value
The value to return after the delay.
any
options
timeout
The delay duration in milliseconds. Default 1000.
integer
Output
Returns the unchanged input value after the specified time delay.
areAllParamsTrue
Applies a logical AND operation. This function checks if the exact number of specified arguments are all truthy (not false, 0, "", null, or undefined).
Parameters
nParams
The exact number of arguments that must be provided and evaluate to truthy.
integer
args
The arguments to evaluate.
any
Examples
Scenario 1: All elements match and evaluate to truthy
Output: true (3 arguments were provided and all evaluate to truthy)
Scenario 2: Insufficient truthy parameters provided
Output: false (only 2 truthy arguments were provided instead of 3)
Output
Returns true if all arguments match nParams and evaluate to truthy; otherwise, returns false.
isOneOrMoreParamTrue
Applies a logical OR operation. This function checks if at least one of the provided arguments evaluates to truthy.
Parameters
args
Any number of input parameters to check.
any
Example
Output
Returns true if at least one argument evaluates to truthy (because "hello" is truthy); otherwise, returns false.
jsonStringify
Converts a JavaScript runtime value (such as an object or array) into a standard JSON string.
Parameters
value
The JavaScript object or array to convert.
any
Example
Output
Returns the generated JSON string:
'{"name":"John","is_active":true,"roles":["admin","editor"]}'
jsonParse
Converts a valid JSON string back into its corresponding JavaScript object or value representation.
Parameters
text
A valid JSON string to parse.
string
Example
Output
Returns the parsed JavaScript entity. Throws an error if the string is not valid JSON.
flatten
Takes a nested JavaScript object and flattens it into a single-level object structure by generating dot-delimited keys.
Parameters
target
The nested target object to flatten.
object
options
delimiter
A custom delimiter string to separate keys instead of the default dot ..
string
safe
If true, preserves arrays and their contents intact instead of flattening their indexes. Default false.
boolean
maxDepth
The maximum number of nested levels to flatten.
integer
Example
Output
Returns the flattened object:
unflatten
The inverse operation of flatten. Takes a flat object containing delimited keys and converts it back into a deeply nested object structure.
Parameters
target
The flat target object to unflatten.
object
options
delimiter
A custom delimiter string to identify nested breaks instead of a dot.
string
safe
If true, preserves arrays and their nested contents intact. Default false.
boolean
object
If true, prevents the automatic instantiation of arrays when unflattening. Default false.
boolean
override
If true, overwrites existing keys if they cannot accommodate a newly encountered nested object value. Default false.
boolean
Example
Output
Returns the unflattened nested object structure:
mergeArrays
Merges multiple arrays by combining the objects located at corresponding indexes. The function truncates the final output array to match the length of the shortest provided input array. Non-object elements are included with a key of an underscore _ followed by the source array index.
Parameters
args
Multiple arrays of objects to merge together.
array
Example
Output
Returns the merged index array:
combineArrays
Combines multiple arrays similarly to mergeArrays, but appends an underscore _ followed by the source array index to each object key. This prevents key collisions when the arrays contain objects with identical keys.
Parameters
args
Multiple arrays to combine.
array
Example
Output
Returns the indexed combination array:
groupArrays
Groups and merges objects compiled from multiple separate arrays based on a shared property key or an array of designated keys. This utility provides an efficient way to execute client-side joins across distinct data streams.
Parameters
keys
The property key string or array of key strings to group target data items by.
string or array
args
Multiple arrays composed of data objects to group and merge.
array
Example
Grouping distinct collections using a shared id key:
Output
Returns the grouped and structurally merged array:
renameObjectKeys
Generates a new object with renamed keys based on a specified mapping configuration. Keys not present in the mapping remain unchanged.
Parameters
object
The target object whose keys require renaming.
object
keyMapping
A dictionary object where each key represents the original property string and its corresponding value defines the new key string identifier.
object
Example
Output
Returns the object with updated keys:
base64Decode
Decodes a base64-encoded string back into its original text representation.
Parameters
base64String
The base64 encoded source string.
string
encoding
The character encoding of the returned string. Default utf8.
string
Example
Output
Returns the decoded text string: Hello World
base64Encode
Encodes a plain text string or binary byte collection into a base64 string representation.
Parameters
bytes
The input text string or raw bytes to encode.
any
Example
Output
Returns the generated base64-encoded string: SGVsbG8gV29ybGQ=
memory
Passes its input value directly to its output immediately upon any input update. This function has input and output slots but no visible trigger; it behaves as if its trigger were permanently set to on input update.

Parameters
value
Any input argument to pass through.
any
Output
Returns the unchanged input value.
trigger
A function without inputs. Use it to start flows manually or on a schedule via its trigger.
Parameters
None.
Output
Returns the current Unix timestamp in milliseconds.
Last updated
Was this helpful?