fs: loosen validation to allow objects with an own toString function
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
This is a loosening of #31030 (which is only in v14 atm). It allows an object that has an own toString
function, which does not conflict with the OP of #31030 which is primarily concerned with accidental stringification.
This unbreaks uglify-js v2, which is the last version that retains IE 8 support, which a few of my packages need. I'm hoping this strikes the right balance to avoid footguns while allowing idiomatic JS behavior.