mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-21 05:50:55 +08:00
- Preserve unbound class methods, call-time receivers, and bound callback arguments. - Keep native factory results, fallback functions, and mutable JavaScript renderer state intact. - Support live Error.cause assignment, deletion, and property descriptors across aliases.
14 lines
659 B
JavaScript
14 lines
659 B
JavaScript
const runtime = globalThis[Symbol.for("scriptc.test.runtime")];
|
|
beforeInitialization();
|
|
export var sleep = runtime?.sleep ?? standardSleep;
|
|
export var format = runtime?.format || standardFormat;
|
|
export var selected = runtime ? standardFormat : alternateFormat;
|
|
function beforeInitialization() {
|
|
console.log(typeof sleep);
|
|
try { sleep(0); } catch (error) { console.log(error.name); }
|
|
}
|
|
function standardSleep(value) { return Promise.resolve(value); }
|
|
function standardFormat(value) { return `standard:${value}`; }
|
|
function alternateFormat(value) { return `alternate:${value}`; }
|
|
export function replace() { sleep = (value) => Promise.resolve(value + 1); }
|