mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-23 06:10:02 +08:00
- Add shared ArrayBuffer storage and native Unicode grapheme segmentation. - Preserve builtin modules, globals, and byte views across JavaScript bindings. - Compile package initialization expressions and optional native callables.
12 lines
504 B
JavaScript
12 lines
504 B
JavaScript
const bun = globalThis.Bun;
|
|
const width = bun?.stringWidth ?? ((text) => text.length);
|
|
const sleep = bun?.sleep ?? (() => "portable");
|
|
console.log(typeof bun, width("hello"), sleep());
|
|
console.log(globalThis?.Bun === undefined, globalThis.Deno === undefined);
|
|
const scope = globalThis;
|
|
console.log(scope.Bun === undefined, global.Bun === undefined);
|
|
function shadowed(globalThis) {
|
|
return globalThis.Bun.stringWidth("abc");
|
|
}
|
|
console.log(shadowed({ Bun: { stringWidth: (text) => text.length + 4 } }));
|