mirror of
https://github.com/appgurueu/modlib.git
synced 2024-12-23 05:42:28 +01:00
Add text.inputstream
This commit is contained in:
parent
b3703ab91d
commit
63050f3bad
13
text.lua
13
text.lua
@ -50,6 +50,19 @@ end
|
||||
|
||||
trim_right = trim_end
|
||||
|
||||
local inputstream_metatable = {
|
||||
__index = {read = function(self, count)
|
||||
local cursor = self.cursor + 1
|
||||
self.cursor = self.cursor + count
|
||||
local text = self.text:sub(cursor, self.cursor)
|
||||
return text ~= "" and text or nil
|
||||
end}
|
||||
}
|
||||
function inputstream(text)
|
||||
return setmetatable({text = text, cursor = 0}, inputstream_metatable)
|
||||
end
|
||||
|
||||
|
||||
function split(text, delimiter, limit, is_regex)
|
||||
limit = limit or math.huge
|
||||
local no_regex = not is_regex
|
||||
|
Loading…
Reference in New Issue
Block a user