-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Guarantee that BufferReader#buf is a Buffer #668
Comments
The Would it be enough if documentation would cover this textually, without changing the actual type to |
I'm not sure how that would look like, but sure, as long as the documentation makes it clear that it's a Buffer I'd be okay with that. Could you clarify why overriding all the functions would be necessary though? |
Sorry, not all functions, just the ones referencing |
So just |
That and
(thought it would be more) Currently looking into this. |
Seems reasonable to me, although I'm not sure what you mean by I think it would be particularly useful to note that BufferWriter#finish returns a Buffer since that seems to be its primary difference from Writer. Also BufferWriter#bytes doesn't need any doc change since it does actually accept Uint8Array, not only Buffer. And BufferWriter#buf doesn't exist. |
Yes, thanks for the quick response! |
I'm in the process of updating my encoder/decoder generator to match the API of protobuf.js 6.x (currently it mimics protobuf.js 4.x, you can see it here). The generated
decode
methods will take an object with propertiesbuf
andpos
.buf
will have to be a Buffer since the decoder will take advantage of Buffer's methods.I also want to be able to pass the same data type to both my own
decode
and protobuf.js'sdecode
. The latter accepts BufferReader, but the documentation for BufferReader says itsbuf
is a Uint8Array, not Buffer, so it would be technically incompatible with mydecode
. But it's clear from the source code that it's actually a Buffer.Can you update the documentation to state that BufferReader#buf is a Buffer and not just Uint8Array?
The text was updated successfully, but these errors were encountered: