Removed retainkeys argument from lume.set()

This commit is contained in:
rxi 2015-01-11 14:33:56 +00:00
parent 756d30416d
commit c773acdcf4
2 changed files with 4 additions and 6 deletions

View File

@ -135,10 +135,8 @@ an error is raised,
lume.reduce({1, 2, 3}, function(a, b) return a + b end) -- Returns 6
```
### lume.set(t [, retainkeys])
Returns a copy of the `t` table with all the duplicate values removed. If
`retainkeys` is true the table is not treated as an array and retains its
original keys.
### lume.set(t)
Returns a copy of the `t` array with all the duplicate values removed.
```lua
lume.set({2, 1, 2, "cat", "cat"}) -- Returns {1, 2, "cat"}
```

View File

@ -232,10 +232,10 @@ function lume.reduce(t, fn, first)
end
function lume.set(t, retainkeys)
function lume.set(t)
local rtn = {}
for k, v in pairs(lume.invert(t)) do
rtn[retainkeys and v or (#rtn + 1)] = k
rtn[#rtn + 1] = k
end
return rtn
end