Skip to content

Commit

Permalink
Add isInTable() util to Gremlin
Browse files Browse the repository at this point in the history
  • Loading branch information
danhunsaker committed Apr 3, 2024
1 parent 5156881 commit a2a0322
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/gremlin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,15 @@ Gremlin = {

return _outZones
end,
isInTable = function(_tbl, _needle)
for _, _straw in pairs(_tbl) do
if _straw == _needle then
return true
end
end

return false
end,
parseFuncArgs = function(_args, _objs)
local _out = {}
for _, _arg in pairs(_args) do
Expand Down
12 changes: 12 additions & 0 deletions test/gremlin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,18 @@ TestGremlinUtils = {
-- SIDE EFFECTS
-- N/A?
end,
testIsInTable = function()
-- INIT
-- N/A?

-- TEST
lu.assertEquals(Gremlin.utils.isInTable({}, 'test'), false)
lu.assertEquals(Gremlin.utils.isInTable({ 'test' }, 'test'), true)
lu.assertEquals(Gremlin.utils.isInTable({ test = 'test' }, 'test'), true)

-- SIDE EFFECTS
-- N/A?
end,
testParseFuncArgs = function()
-- INIT
-- N/A?
Expand Down

0 comments on commit a2a0322

Please sign in to comment.