mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-06 08:23:19 +08:00
Node answers a Buffer from fs.readFileSync (path and fd), fs.promises.readFile and FileHandle#readFile, so Buffer.isBuffer, .constructor, inspect output and Buffer's numeric search semantics apply to the bytes. scr_lib.c returned unbranded bytes and diverged. Branding inside the shared unit would change the executable of every typed program that links it, so the brand lives in a SCR_FS_BUFFER_BRAND build of scr_lib.c, selected per program the way SCR_FS_WATCH_FILE is: a runtime feature (moduleUsesFsBufferBrand) selects it only when the module reads file bytes through a typed read and can observe their Buffer-ness (Buffer.isBuffer, inspect of a Uint8Array-typed bytes value, boxing to a dynamic value, or one of the numeric searches). The default object stays byte-identical. tests/corpus/fs-buffer-brand.ts covers the sync, fd, promise and callback reads, unknown boxing, inspect and the searches; it matches Node byte for byte plain and sanitized. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>