stream: convert string to Buffer when calling `unshift(<string>)`
readable.unshift
can take a string as an argument, but that
string wasn't being converted to a Buffer, which caused a
TypeError: Argument must be a buffer
in some cases.
A second optional argument encoding
was added to unshift
to
prevent all strings being coerced to utf8.
Fixes: #27192 (closed)
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
documentation is changed or added -
commit message follows commit guidelines
A documentation change will be needed, for the encoding
argument, but wanted to submit the PR first to see if it will get approved. I will also make a few tests for this if everything is okay.