Files
scriptc/tests/corpus/global-runtime-probes.js
Chris Tate f668fc4bfd Support native runtime values used by OpenTUI
- 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.
2026-09-28 19:01:50 -05:00

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 } }));