ServerJS/IO/A: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
mNo edit summary |
||
Line 11: | Line 11: | ||
==== Stream ==== | ==== Stream ==== | ||
The Stream class implements a stream | The Stream class implements a stream for reading and writing raw bytes. | ||
;Constructor | ;Constructor |
Revision as of 09:48, 7 September 2009
Work in progress.
This document describes an interface for reading and writing stream of raw bytes, and classes built on top of it to provide buffered and string based reading and writing.
Specification
Platforms implementing this specification must provide a top level io module. The io module defines an interface for raw, byte based I/O, and classes for buffered and text based I/O layered upon the raw I/O.
Raw I/O
Stream
The Stream class implements a stream for reading and writing raw bytes.
- Constructor
- Whether the Stream class provides a public constructor, and what the arguments of the constructor are, is not part of this specification. The process of creating actual Stream objects is implementation specific.
- Various built-in modules such as the file module will know how to build native Stream objects in a platform specific way. Application classes should be able to extend the Stream class through JavaScript prototype chaining. However, duck typing should also work for Stream objects, meaning that any object implementing the Stream interface should work for code expecting an io.Stream object.
Instance Methods
- read(n Number) ByteString
- readAll() ByteString
- readInto(buffer ByteArray, [begin Number], [end Number]) Number
- skip(n Number) Number
- write(b Binary, [begin Number], [end Number]) Number
- tell() Number
- seek(position Number, whence Number)
- truncate([length Number=0])
- rewind()
- readable() Boolean
- writable() Boolean
- seekable() Boolean