[fixed] sequence regressions

This commit is contained in:
Max Cahill 2020-06-02 15:01:21 +10:00
parent 00ac480ed9
commit 11483c52ad

View File

@ -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
@ -76,4 +82,4 @@ function sequence:zip(other, f)
return sequence(functional.zip(self, other, f)) return sequence(functional.zip(self, other, f))
end end
return sequence return sequence