summaryrefslogtreecommitdiff
path: root/meta/3rd/OpenResty/library/table.nkeys.lua
blob: 41a42d6a45418ee504737ba8eb2406b37cf3dff8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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