mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-23 06:10:02 +08:00
- Support stored builtin helpers, typed rest callbacks, and shared FileHandle values. - Preserve async results, specialized function bodies, and checked class receivers. - Compile live export dictionaries and keep native property names distinct.
17 lines
566 B
TypeScript
17 lines
566 B
TypeScript
import { open, unlink } from "node:fs/promises";
|
|
import type { FileHandle } from "node:fs/promises";
|
|
const path = `/tmp/scriptc-file-handle-values-${process.pid}.txt`;
|
|
const handle = await open(path, "w+", 0o600);
|
|
try {
|
|
const stored: unknown = handle;
|
|
const alias: FileHandle = stored as FileHandle;
|
|
console.log(handle === alias, alias.fd === handle.fd);
|
|
await alias.writeFile("native", "utf8");
|
|
console.log((await handle.stat()).size);
|
|
await alias.close();
|
|
console.log(handle.fd, alias.fd);
|
|
await handle.close();
|
|
} finally {
|
|
await unlink(path);
|
|
}
|