This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
api:buffer [2016/06/19 07:50] payonel [Instance Methods] |
api:buffer [2016/06/19 07:54] payonel [Interface Methods] |
||
---|---|---|---|
Line 134: | Line 134: | ||
- `read(n: number) ok, reason` | - `read(n: number) ok, reason` | ||
- | Return `n` unicode chars. The caller assumes there is more data to read until `nil` is returned. A empty string or a string shorter than `n` chars long is a valid return, but the caller may assume there is more data to request until `nil` is returned. | + | Return `n` bytes, and **not** `n` unicode-aware chars. Assume your data is binary data and let the buffer library manage the mode and the unicode string packaging (if applicable). Note that this is exactly how the [[api:filesystem|filesystem]] library operates.The caller assumes there is more data to read until `nil` is returned. A empty string or a string shorter than `n` chars long is a valid return, but the caller may assume there is more data to request until `nil` is returned. |
- `seek([whence: string], [offset: number]) [offset from start] or falsey, reason` | - `seek([whence: string], [offset: number]) [offset from start] or falsey, reason` |