diff options
Diffstat (limited to '')
-rw-r--r-- | src/ltn12.lua | 15 |
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 | ----------------------------------------------------------------------------- |
10 | local string = require("string") | 10 | local string = require("string") |
11 | local table = require("table") | 11 | local table = require("table") |
12 | local unpack = unpack or table.unpack | ||
12 | local base = _G | 13 | local base = _G |
14 | local select = select | ||
15 | |||
13 | local _M = {} | 16 | local _M = {} |
14 | if module then -- heuristic for exporting a global package table | 17 | if module then -- heuristic for exporting a global package table |
15 | ltn12 = _M | 18 | ltn12 = _M -- luacheck: ignore |
16 | end | 19 | end |
17 | local filter,source,sink,pump = {},{},{},{} | 20 | local 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 |
125 | end | 128 | end |
126 | 129 | ||
130 | -- creates table source | ||
131 | function 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 | ||
138 | end | ||
139 | |||
127 | -- creates rewindable source | 140 | -- creates rewindable source |
128 | function source.rewind(src) | 141 | function source.rewind(src) |
129 | base.assert(src) | 142 | base.assert(src) |