diff options
Diffstat (limited to 'doc/ltn12.html')
-rw-r--r-- | doc/ltn12.html | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/doc/ltn12.html b/doc/ltn12.html index 363ce43..7b379c2 100644 --- a/doc/ltn12.html +++ b/doc/ltn12.html | |||
@@ -35,13 +35,21 @@ | |||
35 | 35 | ||
36 | <h2 id=ltn12>LTN12</h2> | 36 | <h2 id=ltn12>LTN12</h2> |
37 | 37 | ||
38 | <p> The LTN12 module implements the ideas described in | 38 | <p> The <tt>ltn12</tt> namespace implements the ideas described in |
39 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks"> | 39 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks"> |
40 | LTN012, Filters sources and sinks</a>. This manual simply describe the | 40 | LTN012, Filters sources and sinks</a>. This manual simply describes the |
41 | functions. Please refer to the LTN for a deeper explanation of the | 41 | functions. Please refer to the LTN for a deeper explanation of the |
42 | functionality provided by this module. | 42 | functionality provided by this module. |
43 | </p> | 43 | </p> |
44 | 44 | ||
45 | <p class=description> To obtain the <tt>ltn12</tt> namespace, run: | ||
46 | </p> | ||
47 | |||
48 | <pre class=example> | ||
49 | -- loads the LTN21 module | ||
50 | local ltn12 = require("ltn12") | ||
51 | </pre> | ||
52 | |||
45 | <!-- filters ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 53 | <!-- filters ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
46 | 54 | ||
47 | <h3 id="filter">Filters</h3> | 55 | <h3 id="filter">Filters</h3> |
@@ -68,15 +76,15 @@ The function returns the chained filter. | |||
68 | </p> | 76 | </p> |
69 | 77 | ||
70 | <p class=note> | 78 | <p class=note> |
71 | The nesting of filters can be arbritrary. For instance, the useless filter | 79 | The nesting of filters can be arbitrary. For instance, the useless filter |
72 | below doesn't do anything but return the data that was passed to it, | 80 | below doesn't do anything but return the data that was passed to it, |
73 | unaltered. | 81 | unaltered. |
74 | </p> | 82 | </p> |
75 | 83 | ||
76 | <pre class=example> | 84 | <pre class=example> |
77 | -- load required modules | 85 | -- load required modules |
78 | ltn12 = require("ltn12") | 86 | local ltn12 = require("ltn12") |
79 | mime = require("mime") | 87 | local mime = require("mime") |
80 | 88 | ||
81 | -- create a silly identity filter | 89 | -- create a silly identity filter |
82 | id = ltn12.filter.chain( | 90 | id = ltn12.filter.chain( |
@@ -165,12 +173,7 @@ ltn12.sink.<b>chain(</b>filter, sink<b>)</b> | |||
165 | </p> | 173 | </p> |
166 | 174 | ||
167 | <p class=description> | 175 | <p class=description> |
168 | Creates a new sink that passes data through a <tt>filter</tt> before sending | 176 | Creates and returns a new sink that passes data through a <tt>filter</tt> before sending it to a given <tt>sink</tt>. |
169 | it to a given <tt>sink</tt>. | ||
170 | </p> | ||
171 | |||
172 | <p class=return> | ||
173 | The function returns the new sink. | ||
174 | </p> | 177 | </p> |
175 | 178 | ||
176 | <!-- error ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 179 | <!-- error ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
@@ -180,7 +183,7 @@ ltn12.sink.<b>error(</b>message<b>)</b> | |||
180 | </p> | 183 | </p> |
181 | 184 | ||
182 | <p class=description> | 185 | <p class=description> |
183 | Creates and returns a sink that aborts transmission with an error | 186 | Creates and returns a sink that aborts transmission with the error |
184 | <tt>message</tt>. | 187 | <tt>message</tt>. |
185 | </p> | 188 | </p> |
186 | 189 | ||
@@ -202,7 +205,7 @@ Creates a sink that sends data to a file. | |||
202 | <p class=return> | 205 | <p class=return> |
203 | The function returns a sink that sends all data to the given <tt>handle</tt> | 206 | The function returns a sink that sends all data to the given <tt>handle</tt> |
204 | and closes the file when done, or a sink that aborts the transmission with | 207 | and closes the file when done, or a sink that aborts the transmission with |
205 | an error <tt>message</tt> | 208 | the error <tt>message</tt> |
206 | </p> | 209 | </p> |
207 | 210 | ||
208 | <p class=note> | 211 | <p class=note> |
@@ -258,7 +261,7 @@ efficiently concatenated into a single string. | |||
258 | </p> | 261 | </p> |
259 | 262 | ||
260 | <p class=return> | 263 | <p class=return> |
261 | The function returns the sink and the table. | 264 | The function returns the sink and the table used to store the chunks. |
262 | </p> | 265 | </p> |
263 | 266 | ||
264 | <pre class=example> | 267 | <pre class=example> |
@@ -266,14 +269,14 @@ The function returns the sink and the table. | |||
266 | local http = require("http") | 269 | local http = require("http") |
267 | local ltn12 = require("ltn12") | 270 | local ltn12 = require("ltn12") |
268 | 271 | ||
269 | -- the http.get function | 272 | -- a simplified http.get function |
270 | function get(u) | 273 | function http.get(u) |
271 | local t = {} | 274 | local t = {} |
272 | local respt = request{ | 275 | local respt = request{ |
273 | url = u, | 276 | url = u, |
274 | sink = ltn12.sink.table(t) | 277 | sink = ltn12.sink.table(t) |
275 | } | 278 | } |
276 | return table.concat(t), respt.headers, respt.code, respt.error | 279 | return table.concat(t), respt.headers, respt.code |
277 | end | 280 | end |
278 | </pre> | 281 | </pre> |
279 | 282 | ||
@@ -334,7 +337,7 @@ ltn12.source.<b>error(</b>message<b>)</b> | |||
334 | </p> | 337 | </p> |
335 | 338 | ||
336 | <p class=description> | 339 | <p class=description> |
337 | Creates and returns a source that aborts transmission with an error | 340 | Creates and returns a source that aborts transmission with the error |
338 | <tt>message</tt>. | 341 | <tt>message</tt>. |
339 | </p> | 342 | </p> |
340 | 343 | ||
@@ -357,7 +360,7 @@ Creates a source that produces the contents of a file. | |||
357 | The function returns a source that reads chunks of data from | 360 | The function returns a source that reads chunks of data from |
358 | given <tt>handle</tt> and returns it to the user, | 361 | given <tt>handle</tt> and returns it to the user, |
359 | closing the file when done, or a source that aborts the transmission with | 362 | closing the file when done, or a source that aborts the transmission with |
360 | an error <tt>message</tt> | 363 | the error <tt>message</tt> |
361 | </p> | 364 | </p> |
362 | 365 | ||
363 | <p class=note> | 366 | <p class=note> |