ServerJS/IO/A: Difference between revisions

Line 34: Line 34:


;read(n Number) ByteString
;read(n Number) ByteString
:Read up to n bytes from the stream, or until the end of the stream has been reached. null is returned when the end of the stream has been reached.
:Read up to n bytes from the stream, or until the end of the stream has been reached. An empty ByteString is returned when the end of the stream has been reached.


;readAll() ByteString
;readAll() ByteString
:Read all the bytes from the stream until its end has been reached.
:Read all the bytes from the stream until its end has been reached. An empty ByteString is returned when the end of the stream has been reached.


;readInto(buffer ByteArray, [begin Number], [end Number]) Number  
;readInto(buffer ByteArray, [begin Number], [end Number]) Number  
:Read bytes from the stream into the ByteArray buffer.  
:Read bytes from the stream into the ByteArray buffer. This method does not increase the length of the ByteArray buffer. Returns the number of bytes read, or -1 if the end of the stream has been reached. '''''Note''': Can we safely return 0 on EOF?''


;skip(n Number) Number
;skip(n Number) Number
:Skip over n bytes in the stream.
:Try to skip over n bytes in the stream.


;write(b Binary, [begin Number], [end Number]) Number
;write(b Binary, [begin Number], [end Number]) Number
:Write bytes from b to the stream. If begin and end are specified, only the range starting at begin and ending before end are written.
:Write bytes from b to the stream. If begin and end are specified, only the range starting at begin and ending before end are written. Returns the number of bytes actually written.


;readable() Boolean
;readable() Boolean
55

edits