Description
Can we extend the decoding methods to write to an existing buffer?
The simplest thing I can imagine is a into
option, which takes a buffer and writes into it, and returns that buffer instead of a new one. You can make a view if you want an offset. And it could throw (before doing any writes) if the data doesn't fit (or not).
Unfortunately you're probably also going to want the number of bytes written, and figuring that out in the case of padding in base64 is annoying. In the streaming case we could return a written
count, at least, but there's no obvious place to put a count in the non-streaming case. Maybe the option should only be for the streaming case?
Alternatively we could have new methods for writing to an existing buffer, at the cost of having new methods.
I'm not sure either is worth it. cc @syg