mirror of
https://github.com/1bardesign/batteries.git
synced 2024-11-26 15:44:35 +00:00
[fixed] sequence regressions
This commit is contained in:
parent
00ac480ed9
commit
11483c52ad
30
sequence.lua
30
sequence.lua
@ -9,6 +9,7 @@ local path = (...):gsub("sequence", "")
|
|||||||
local class = require(path .. "class")
|
local class = require(path .. "class")
|
||||||
local table = require(path .. "tablex") --shadow global table module
|
local table = require(path .. "tablex") --shadow global table module
|
||||||
local functional = require(path .. "functional")
|
local functional = require(path .. "functional")
|
||||||
|
local stable_sort = require(path .. "sort").stable_sort
|
||||||
|
|
||||||
local sequence = class(table) --proxy missing table fns to tablex api
|
local sequence = class(table) --proxy missing table fns to tablex api
|
||||||
|
|
||||||
@ -17,29 +18,34 @@ function sequence:new(t)
|
|||||||
return self:init(t or {})
|
return self:init(t or {})
|
||||||
end
|
end
|
||||||
|
|
||||||
--alias
|
--sorting default to stable
|
||||||
sequence.join = table.concat
|
sequence.sort = stable_sort
|
||||||
|
|
||||||
--sorting default to stable if present
|
|
||||||
sequence.sort = table.stable_sort or table.sort
|
|
||||||
|
|
||||||
--patch various interfaces in a type-preserving way, for method chaining
|
--patch various interfaces in a type-preserving way, for method chaining
|
||||||
|
|
||||||
--import copying tablex
|
--import copying tablex
|
||||||
function sequence:keys()
|
function sequence:keys()
|
||||||
return sequence(self:keys())
|
return sequence(table.keys(self))
|
||||||
end
|
end
|
||||||
|
|
||||||
function sequence:values()
|
function sequence:values()
|
||||||
return sequence(self:values())
|
return sequence(table.values(self))
|
||||||
end
|
|
||||||
|
|
||||||
function sequence:append(other)
|
|
||||||
return sequence(self:append(other))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function sequence:dedupe()
|
function sequence:dedupe()
|
||||||
return sequence(self:dedupe())
|
return sequence(table.dedupe(self))
|
||||||
|
end
|
||||||
|
|
||||||
|
function sequence:append(...)
|
||||||
|
return sequence(table.append(self, ...))
|
||||||
|
end
|
||||||
|
|
||||||
|
function sequence:overlay(...)
|
||||||
|
return sequence(table.overlay(self, ...))
|
||||||
|
end
|
||||||
|
|
||||||
|
function sequence:copy(...)
|
||||||
|
return sequence(table.copy(self, ...))
|
||||||
end
|
end
|
||||||
|
|
||||||
--import functional interface
|
--import functional interface
|
||||||
|
Loading…
Reference in New Issue
Block a user