ServerJS/IO/A: Difference between revisions

Jump to navigation Jump to search
1,585 bytes added ,  8 September 2009
→‎Specification: add text stream stuff from filesystem spec
(→‎Specification: add text stream stuff from filesystem spec)
Line 68: Line 68:
== Text I/O ==
== Text I/O ==


todo
=== TextStream ===
 
The TextStream class wraps a raw stream and exposes a similar interface as the Stream class, but its write() method takes a string as first arguments and its read() method returns a string. Additionally, it defines the properties and methods listed below.
 
===== Constructor =====
 
;[new] TextStream(raw Stream, [options Object]) TextStream
:Build a TextStream around a raw byte stream. The options argument may contain the following properties:
* charset: a string containing the name of the encoding to use
* newline: a string containing the newline character sequence to use
* delimiter: a string containing the delimiter to use in print()
 
===== Instance Properties =====
 
;raw
:A readonly property containing the raw byte stream wrapped by this text stream.
 
===== Instance Methods =====
 
; readLine() String
: Reads a line from the reader.  If the end of the stream is reached before any data is gathered, returns an empty string. Otherwise, returns the line including the newline.
 
; readLines() Array*String
: Returns an Array of Strings accumulated by calling readLine until an empty string turns up. Does not include the final empty string, and does include newline at the end of every line.
 
; next() String throws StopIteration
: Returns the next line of input without the newline. Throws StopIteration if the end of stream is reached.
 
; iterator() Iterator
: Returns the reader itself
 
; writeLine(line String)
: Writes line followed by a newline.
 
; print(...)
: writes a delimiter delimited array of Strings terminated with a newline.


== Memory based I/O ==
== Memory based I/O ==
Line 133: Line 168:


== Errors ==
== Errors ==
=== IOError ===


todo
todo
55

edits

Navigation menu