diff options
author | Caleb Maclennan <caleb@alerque.com> | 2023-11-10 09:12:04 +0300 |
---|---|---|
committer | Caleb Maclennan <caleb@alerque.com> | 2023-11-10 09:12:04 +0300 |
commit | 5c4fc93d5f4137bf4c22ddf1a048c907a4a26727 (patch) | |
tree | a9a68e1f6a9c3bfe2b64fa1c3a4098865b7d3b5d /src/ltn12.lua | |
parent | ccef3bc4e2aa6ee5b997a80aabb58f4ff0b0e98f (diff) | |
parent | 43a97b7f0053313b43906371dbdc226271e6c8ab (diff) | |
download | luasocket-hjelmeland-patch-1.tar.gz luasocket-hjelmeland-patch-1.tar.bz2 luasocket-hjelmeland-patch-1.zip |
Merge branch 'master' into hjelmeland-patch-1hjelmeland-patch-1
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) |