aboutsummaryrefslogtreecommitdiff
path: root/src/ltn12.lua
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/ltn12.lua15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/ltn12.lua b/src/ltn12.lua
index 1014de2..4cb17f5 100644
--- a/src/ltn12.lua
+++ b/src/ltn12.lua
@@ -9,10 +9,13 @@
9----------------------------------------------------------------------------- 9-----------------------------------------------------------------------------
10local string = require("string") 10local string = require("string")
11local table = require("table") 11local table = require("table")
12local unpack = unpack or table.unpack
12local base = _G 13local base = _G
14local select = select
15
13local _M = {} 16local _M = {}
14if module then -- heuristic for exporting a global package table 17if module then -- heuristic for exporting a global package table
15 ltn12 = _M 18 ltn12 = _M -- luacheck: ignore
16end 19end
17local filter,source,sink,pump = {},{},{},{} 20local filter,source,sink,pump = {},{},{},{}
18 21
@@ -124,6 +127,16 @@ function source.string(s)
124 else return source.empty() end 127 else return source.empty() end
125end 128end
126 129
130-- creates table source
131function source.table(t)
132 base.assert('table' == type(t))
133 local i = 0
134 return function()
135 i = i + 1
136 return t[i]
137 end
138end
139
127-- creates rewindable source 140-- creates rewindable source
128function source.rewind(src) 141function source.rewind(src)
129 base.assert(src) 142 base.assert(src)