mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 02:48:50 +00:00
* port 'initial support for using declarations' 1:1 port of this commit:56a3e01244* port 'initial support for await using declarations' 1:1 port of this commit:1634a0b5ad* fix cmake config for local jsc * add global defines for symbols * begin porting lowering implementation based off of https://github.com/evanw/esbuild/pull/3192 * [autofix.ci] apply automated fixes * add some fun webkit scripts * fix the minification bug * refactor runtime_js, etc * rename test file * finished yapping * silly silyl * Update src/bundler.zig * ok * a * Fix crash --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Jarred Sumner <jarred@jarredsumner.com> Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
export * from "./runtime";
|
|
|
|
// TODO: these are duplicated from bundle_v2.js, can we ... not do that?
|
|
export var __using = (stack, value, async) => {
|
|
if (value != null) {
|
|
if (typeof value !== "object" && typeof value !== "function")
|
|
throw TypeError('Object expected to be assigned to "using" declaration');
|
|
let dispose;
|
|
if (async) dispose = value[Symbol.asyncDispose];
|
|
if (dispose === void 0) dispose = value[Symbol.dispose];
|
|
if (typeof dispose !== "function") throw TypeError("Object not disposable");
|
|
stack.push([async, dispose, value]);
|
|
} else if (async) {
|
|
stack.push([async]);
|
|
}
|
|
return value;
|
|
};
|
|
|
|
export var __callDispose = (stack, error, hasError) => {
|
|
let fail = e =>
|
|
(error = hasError
|
|
? new SuppressedError(e, error, "An error was suppressed during disposal")
|
|
: ((hasError = true), e)),
|
|
next = it => {
|
|
while ((it = stack.pop())) {
|
|
try {
|
|
var result = it[1] && it[1].call(it[2]);
|
|
if (it[0]) return Promise.resolve(result).then(next, e => (fail(e), next()));
|
|
} catch (e) {
|
|
fail(e);
|
|
}
|
|
}
|
|
if (hasError) throw error;
|
|
};
|
|
return next();
|
|
};
|