diff options
Diffstat (limited to 'meta/3rd/OpenResty/library/table.nkeys.lua')
-rw-r--r-- | meta/3rd/OpenResty/library/table.nkeys.lua | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/meta/3rd/OpenResty/library/table.nkeys.lua b/meta/3rd/OpenResty/library/table.nkeys.lua new file mode 100644 index 00000000..41a42d6a --- /dev/null +++ b/meta/3rd/OpenResty/library/table.nkeys.lua @@ -0,0 +1,23 @@ +---@meta + +--- Returns the total number of elements in a given Lua table (i.e. from both the +--- array and hash parts combined). +--- +--- This API can be JIT compiled. +--- +--- Usage: +--- +--- ```lua +--- local nkeys = require "table.nkeys" +--- +--- print(nkeys({})) -- 0 +--- print(nkeys({ "a", nil, "b" })) -- 2 +--- print(nkeys({ dog = 3, cat = 4, bird = nil })) -- 2 +--- print(nkeys({ "a", dog = 3, cat = 4 })) -- 3 +--- ``` +--- +---@param t table +---@return integer +local function nkeys(t) end + +return nkeys |