Skip to content

Commit

Permalink
fix(docs): add 2 missing methods of Map.lua (#477)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaurens authored Jun 4, 2024
1 parent 767e9ba commit e2ea9b7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lua/pl/Map.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,22 @@ local function makelist(t)
return setmetatable(t, require('pl.List'))
end

--- list of keys.
--- return a List of all keys.
-- @class function
-- @name Map:keys
Map.keys = tablex.keys

--- list of values.
--- return a List of all values.
-- @class function
-- @name Map:values
Map.values = tablex.values

--- return an iterator over all key-value pairs.
function Map:iter ()
return pairs(self)
end

--- return a List of all key-value pairs, sorted by the keys.
--- return a List of all key-value pairs, sorted by the keys in ascending order.
function Map:items()
local ls = makelist(tablex.pairmap (function (k,v) return makelist {k,v} end, self))
ls:sort(function(t1,t2) return t1[1] < t2[1] end)
Expand Down

0 comments on commit e2ea9b7

Please sign in to comment.