Flusspferd API and module docs

mixin io.Stream

Description

Base stream beahviour that is shared between files, sockets and other stream-like objects

Instance properties

  • autoFlush #

    io.Stream#autoFlush -> Bool

    Should io.Stream#flush be called every every write. Default false.

  • fieldSeparator #

    io.Stream#fieldSeparator -> String

    Written between each argument passed to io.Stream#print. Default " ".

  • recordSeparator #

    io.Stream#recordSeparator -> String

    Written once after each call to print. Default "\n" (new line). Set to null or undefined to disable.

Instance methods

  • flush #

    io.Stream#flush() ⇒ undefined

    Tell the underlying OS to flush the file cache to disk.

  • io.Stream#print(args...) ⇒ undefined
    • args (String | Array) – What to print

    Print args to the stream, seperated by io.Stream#fieldSeparator and terminated with a io.Stream#recordSeparator.

    If any of the arguments is an Array, it is expaneded out. That is to say, the following two lines would print the same thing:

    stream.print(1, [2, 3], 4)
    stream.print(1, 2, 3, 4)
  • read #

    io.Stream#read([size = 4096]) ⇒ String
    • size (Integer) – number of bytes to read

    Read a chunk of text. The size param is the number of bytes to read currently, and not number of characters as it should be.

  • readBinary #

    io.Stream#readBinary(size, read_into) ⇒ binary
    • size (Integer): number of bytes to read
    • read_into (binary.ByteArray): append data into this blob

    Read a chunk of data. Behaves similarly to #readWholebinary, just reads only the next size bytes, not everything.

  • readLine #

    io.Stream#readLine([sep]) ⇒ String
    • sep (String) – line seperator.

    Read a line of text. A line is defined as everything up until EOF or until sep is sene. Currently the separator must be a single character and must be in the range [0,127].

  • readWhole #

    io.Stream#readWhole() ⇒ String

    Read the rest of the stream as a text

  • readWholeBinary #

    io.Stream#readWholeBinary() ⇒ binary.ByteString
    io.Stream#readWholeBinary(read_into) ⇒ read_into
    • read_into (binary.ByteArray): Append file contents into this blob

    Read the rest of the stream as binary data.

    If read_into is passed, the read data will be appended to it, and the same ByteArray will be returned. Otherwise a new ByteString is returned.

  • write #

    io.Stream#write(data) ⇒ undefined
    • data (Any): What to print