The Stream API is a non-object, which is implemented in various parts of the API including in File, Socket, Pipe (std[in/out])and String Stream IO.
Methods
1 // Read
2 // All read methods return false if there is nothing left in the stream.
3 io.read(); // Read the entire stream into a string or blob and return it.
4 io.read(length); // Read ''length'' bytes the stream into a string and return it.
5 io.readTo(str, [length]); // Read from the stream till ''str'' is hit. ''length'' can limit how much is read.
6 io.readLine(); // Read one system independant line from the stream. (Differences between system line endings are ignored /\r\n|\n\r|[\n\r]/ is considered to be a single line ending.
7 io.seek(length); // Skip ''length'' bytes in the stream. Return number of bytes actually skipped. Return false if there was nothing left.
8 // Write
9 io.write(string, [length]); // Write the entire string into the stream. If ''length'' is specified then only that many bytes from string ''will'' be written.
10 io.writeLine(string, [length]); // Write a single line into the stream. Line ending is automatically handled to match the system line ending.
11 io.truncate(); // Clear out the entire stream. Not always supported.
12
Properties
1 io.position; // Position in the stream. Can be set to seek to another position. (io.position += 1024); is basically the same as (io.seek(1024));
2 io.available; // Number of bytes left available in the stream. (io.read()); is basically the same as (io.read(io.available));
3 io.length; // Entire length of the stream
4 io.isReadable; // Can the stream be read from? (Note: File IO repurposes this as "Is the file readable for me?")
5 io.isWritable; // Can the stream be written to? (Note: File IO repurposes this as "Is the file writeable for me?")
6