Added variable length Buffer.read* methods#93
Conversation
- added `readIntBE`, `readIntLE`, `readUIntBE`, and `readUIntLE`. - also refactored out some common methods to create errors
dop251
left a comment
There was a problem hiding this comment.
Thanks for submitting! I've added a couple of minor comments.
| } | ||
|
|
||
| func (b *Buffer) newArgumentOutOfRangeError(name string, v int64) *goja.Object { | ||
| return errors.NewError(b.r, nil, errors.ErrCodedOutOfRange, "The value of \"%s\" %d is out of range", name, v) |
There was a problem hiding this comment.
This should have RangeError as a prototype. You can either add errors.NewRangeError or just fetch the prototype here and pass it to NewError.
| proto.Set("readUInt32BE", b.readUInt32BE) | ||
| proto.Set("readUInt32LE", b.readUInt32LE) | ||
| proto.Set("readUIntBE", b.readUIntBE) | ||
| proto.Set("readUIntLE", b.readUIntLE) |
There was a problem hiding this comment.
It looks like, all ReadUInt* methods have ReadUint* aliases.
… -> `ErrCodeOutOfRange` (extra `d`)
|
@dop251, also wanted to ask you your thoughts about the best way to add the |
|
What's the issue with the write* methods? |
|
|
|
|
|
OK, I'll give that a try, thanks! |
* Added variable length `Buffer.read*` methods - added `readIntBE`, `readIntLE`, `readUIntBE`, and `readUIntLE`. - also refactored out some common methods to create errors * added errors.NewRangeError. Also fixed mispelled `ErrCodedOutOfRange` -> `ErrCodeOutOfRange` (extra `d`) * added the `readUint*` (small `i`) aliases --------- Co-authored-by: dave sinclair <david_sinclair@cable.comcast.com>
Added variable length
Buffer.read*methodsreadIntBE,readIntLE,readUIntBE, andreadUIntLE.