Skip to content

Guarantee that BufferReader#buf is a Buffer #668

@seishun

Description

@seishun

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 properties buf and pos. 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's decode. The latter accepts BufferReader, but the documentation for BufferReader says its buf is a Uint8Array, not Buffer, so it would be technically incompatible with my decode. 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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions