STREAM Library
The STREAM library provides functions for working with data streams in Lua, including streams from strings, files, pipes, and sockets, and supports filters, and writing streams to files or external processes. The streaming functions can be used to deal with large files that need to be processed a little bit at a time.
How to use it
Import the library into your component using the New+ dropdown in Translator. This will also automatically add the require statement to the top of your main.lua:
require "STREAM.STREAMdata"
The library functions will automatically be added to the STREAMdata.* function table and will be listed in the auto-completion.
How it works
Use the Translator's built in help to review more details on how to use each function:
-
STREAMdata.fromString() creates a stream from a string.
-
STREAMdata.toString() writes a stream to a string, from another stream.
-
STREAMdata.fromFile() creates a stream from a file.
-
STREAMdata.toFile() writes a stream to a file, from another stream.
-
STREAMdata.fromPipe() creates a stream from an external process (pipe).
-
STREAMdata.toPipe() writes a stream to an external process (pipe), from another stream.
-
STREAMdata.fromSocket() creates a stream from a TCP/IP connection (socket).
-
STREAMdata.toSocket() writes a stream to a TCP/IP connection (socket), from another stream.
-
STREAMdata.filter() creates a stream by filtering another stream.
-
STREAMdata.setBufferSize() sets a custom buffer size. By default, buffer size is set to 64*1024.
-
STREAMdata.getBufferSize() gets the current buffer size.