mirror of
https://github.com/encounter/phantomjs.git
synced 2026-03-30 11:35:11 -07:00
836719f72e
The [IO/A spec][1] for `read` is as follows: > Read up to n bytes from the stream, or until the end of the stream > has been reached. [If] n is null, reads up to the block size of the > underlying device, or up to 1024 bytes if the block size is not > discernible. If n is not specified, this method always reads the > full stream until its end is reached. ... Since discovering the block size of the underlying device is non-trivial, we will just default to 1024. **NOTE** The initial implementation of `File::read()` saves the current (original) position, seeks to the beginning of the stream, `readAll`s to the end, and then resets to the original position. I think that this behavior is unexpected and should be changed--it should read from the current position to the end of the stream and stay there. The user should explicitly `seek` to the beginning of the stream when necessary. With the current implementation, the user should note that the position *will not change* after calling `read()` with no arguments. [1]: http://wiki.commonjs.org/wiki/IO/A#Instance_Methods http://code.google.com/p/phantomjs/issues/detail?id=938