ReadableStream

public protocol ReadableStream: class, TextOutputStreamable, CommandRunning

A stream of text. Does as much as possible lazily.

  • Undocumented

    Declaration

    Swift

    public protocol ReadableStream: class, TextOutputStreamable, CommandRunning
  • Undocumented

    Declaration

    Swift

    public protocol ReadableStream: class, TextOutputStreamable, CommandRunning
  • readSome() Default implementation

    All the text the stream contains so far. If the source is a file this will read everything at once. - Returns: more text from the stream, or nil if we have reached the end.

    Default Implementation

    Reads everything at once.

    Declaration

    Swift

    func readSome() -> String?

    Return Value

    more text from the stream, or nil if we have reached the end.

  • read() Default implementation

    Reads everything at once.

    Default Implementation

    Reads everything at once.

    Declaration

    Swift

    func read() -> String
  • lines() Extension method

    Splits stream lazily into lines.

    Declaration

    Swift

    public func lines() -> LazySequence<AnySequence<String>>
  • write(to:) Extension method

    Writes the text in this file to the given TextOutputStream.

    Declaration

    Swift

    public func write<Target: TextOutputStream>(to target: inout Target)
  • context Extension method

    Undocumented

    Declaration

    Swift

    public protocol ReadableStream: class, TextOutputStreamable, CommandRunning
  • onOutput(handler:) Extension method

    handler will be called whenever there is new output available. Pass nil to remove any preexisting handlers. - Note: if the stream is read from outside of the handler, or more than once inside the handler, it may be called once when stream is closed and empty.

    Declaration

    Swift

    public func onOutput ( handler: ((ReadableStream) -> ())? )
  • onStringOutput(handler:) Extension method

    handler will be called whenever there is new text output available. Pass nil to remove any preexisting handlers. - Note: if the stream is read from outside of the handler, or more than once inside the handler, it may be called once when stream is closed and empty.

    Declaration

    Swift

    public func onStringOutput ( handler: ((String) -> ())? )