Skip to main content

Lua Extensions

table.contains#

-- @param t table
-- @param element
function table.contains(t, element)
end

Checks if table contains specified element.

Example#

local t = {1,3,4,5}
local result = table.contains(t, 4)
enapter.log('Table '..inspect(t)..' contains value `4`: '..tostring(result))

inspect#

Build verbose string representation of the passed variable using inspect.lua.

-- @param v string,table,number
-- @param options table
function inspect(v, options)
end

Example#

enapter.log(inspect({1,2,3}))
-- { 1, 2, 3 }
enapter.log(inspect({value = 1}))
-- {
-- value = 1
-- }
enapter.log(inspect({_value = 1, f = function() return nil end}))
-- {
-- _value = 1,
-- f = <function 1>
-- }
Hardware diversity is welcome. Integrate any device into a unified energy network.
© 2022 Enapter
Developer toolkit
DocumentationReference
Community
GithubTindie