mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-22 05:59:31 +08:00
- Preserve callable properties, descriptors, and shared module bindings across native JavaScript code. - Add stored process streams with input control, output callbacks, and write interception. - Preserve Error identity and classification through native rethrows and promise rejection.
20 lines
713 B
JavaScript
20 lines
713 B
JavaScript
function unavailable(value) { throw value; }
|
|
function loadBackend(enabled) {
|
|
if (enabled) return { open(path, symbols) { return symbols; } };
|
|
return { open() { return unavailable(new Error('native backend')); } };
|
|
}
|
|
var backend = loadBackend(false);
|
|
var open = backend.open;
|
|
var other = backend['open'];
|
|
function getLibrary(value) { return open(value, { symbol: 'entry' }); }
|
|
class Library {
|
|
load(value) { return other(value, { symbol: 'entry' }); }
|
|
}
|
|
try { getLibrary('library'); }
|
|
catch (error) { console.log(error.message); }
|
|
try { new Library().load('library'); }
|
|
catch (error) { console.log(error.message); }
|
|
backend = loadBackend(true);
|
|
open = backend.open;
|
|
console.log(getLibrary('library').symbol);
|