fs: validate the input data to be of expected types
The input was not validated so far and that caused unwanted side
effects. E.g., undefined
became the string 'undefined'
. It was
expected to fail or to end up as empty string.
Now all input is validated to be either some type of array buffer
view or a string. That way it's always clear what the user intents.
Fixes: https://github.com/nodejs/node/issues/31025
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