mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-22 05:59:31 +08:00
- Lowering rationale names the idiom; one user-facing hint reworded - Diagnostics snapshot re-pinned to the neutral hint text
13 lines
659 B
TypeScript
13 lines
659 B
TypeScript
// The module spelling of the Buffer global: `import { Buffer } from
|
|
// "node:buffer"` resolves through the import alias to the SAME stdlib
|
|
// symbol the bare-global lowerings answer for (the pattern's source graph
|
|
// carries third-party .d.ts files that import the name this way).
|
|
import { Buffer } from "node:buffer";
|
|
|
|
const b: Buffer = Buffer.from("héllo", "utf8");
|
|
console.log(b.toString("hex"));
|
|
console.log(b.length, b.readUInt8(0), b.subarray(1, 3).toString("utf8"));
|
|
const c = Buffer.alloc(4, 7);
|
|
console.log(c.readUInt32BE(0), Buffer.byteLength("héllo"), Buffer.isEncoding("utf8"));
|
|
console.log(Buffer.concat([b, c]).length, Buffer.compare(b, c));
|