Files
scriptc/tests/corpus/native-buffer-coercion.js
Chris Tate 5a495dc02c feat(compiler): own frontend services in native clients
- Share native parsing, declaration projection, and npm capability analysis through explicit frontend services.
- Scope module analysis caches and parser connections to their owning program lifecycle.
- Preserve global fetch reads in destructuring defaults across embedded npm modules.
2026-09-28 13:48:53 -05:00

31 lines
872 B
JavaScript

// Stream callbacks deliver Buffer-flavored checked values. Their implicit
// conversions use UTF-8 even though no encoding argument reaches the runtime.
import { Readable } from "node:stream";
function wrap(fn) {
return function () { return fn.apply(this, arguments); };
}
function show(value) {
console.log(JSON.stringify(String(value)));
console.log(JSON.stringify("prefix:" + value));
console.log(Number(value));
console.log(JSON.stringify(value.toString("hex")));
const nested = JSON.parse("[null]");
nested.push(value);
console.log(JSON.stringify(String(nested)));
}
let sent = false;
const stream = new Readable({
read() {
if (sent) return;
sent = true;
this.push(Buffer.from("42"));
this.push(Buffer.from("héllo\0world"));
this.push(Buffer.from([0xc3, 0x28]));
this.push(null);
},
});
stream.on("data", wrap(show));