buffer: support boxed strings and toPrimitive
Add support for Buffer.from(new String('...'))
and Buffer.from({[Symbol.toPrimitive]() { return '...'; }})
const buf1 = Buffer.from(new String('this is a test'));
class Foo {
[Symbol.toPrimitive]() {
return 'this is a test';
}
}
const buf2 = Buffer.from(new Foo());
/cc @bnoordhuis @addaleax
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
Affected core subsystem(s)
buffer