mirror of
https://github.com/TangentFoxy/lume.git
synced 2024-11-19 07:04:24 +00:00
Changed lume.filter()'s implementation to mimic lume.reject()
This commit is contained in:
parent
48a4b43640
commit
b1c9e3ec2e
8
lume.lua
8
lume.lua
@ -280,8 +280,14 @@ function lume.filter(t, fn, retainkeys)
|
||||
fn = iteratee(fn)
|
||||
local iter = getiter(t)
|
||||
local rtn = {}
|
||||
if retainkeys then
|
||||
for k, v in iter(t) do
|
||||
if fn(v) then rtn[retainkeys and k or (#rtn + 1)] = v end
|
||||
if fn(v) then rtn[k] = v end
|
||||
end
|
||||
else
|
||||
for k, v in iter(t) do
|
||||
if fn(v) then rtn[#rtn + 1] = v end
|
||||
end
|
||||
end
|
||||
return rtn
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user