Lua code
Lua runs as Lua 5.4 compiled to WebAssembly. It is the lightest of the seven languages: ideal for a short transformation.
The API
Section titled “The API”| Symbol | Role |
|---|---|
input | The value received on the input port |
vars | A table of the run variables |
print(...) | Writes to the execution log (arguments joined by tabs) |
return | The value returned leaves on the result port |
Example
Section titled “Example”local commandes = input.commandeslocal total, nombre = 0, 0
for _, commande in ipairs(commandes) do if commande.statut == "payee" then total = total + commande.montant nombre = nombre + 1 endend
print(string.format("%d commandes payées, total %.2f €", nombre, total))
return { nombre = nombre, total = total }Things worth knowing
Section titled “Things worth knowing”- Lua tables are indexed from 1:
input[1]is the first element of a list you receive. - A table with consecutive numeric keys comes back out as a JSON array; a table with textual keys comes out as an object.
- The standard library is available:
string,table,math,os.
External packages
Section titled “External packages”The packages field accepts pure-Lua source LuaRocks modules. They are
resolved on the first run then injected offline afterwards.