Skip to content

Commit

Permalink
Fix helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Jun 29, 2023
1 parent b771a14 commit 1ad03e6
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 25 deletions.
14 changes: 5 additions & 9 deletions packages/swc-helpers/esm/_dispose.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,12 @@ function dispose_SuppressedError(suppressed, error) {
this.error = error;
this.stack = new Error().stack;
};
dispose_SuppressedError.prototype = Object.create(Error.prototype, {
constructor: {
value: dispose_SuppressedError,
writable: true,
configurable: true,
},
});
dispose_SuppressedError.prototype = Object.create(Error.prototype, { constructor: { value: dispose_SuppressedError, writable: true, configurable: true } });
}
return new dispose_SuppressedError(suppressed, error);
}

export default function _dispose(stack, error, hasError) {
export function _dispose(stack, error, hasError) {
function next() {
while (stack.length > 0) {
try {
Expand All @@ -42,4 +36,6 @@ export default function _dispose(stack, error, hasError) {
}

return next();
}
}

export { _dispose as _ };
13 changes: 6 additions & 7 deletions packages/swc-helpers/esm/_using.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
/* @minVersion 7.22.0 */

export default function _using(stack, value, isAwait) {
export function _using(stack, value, isAwait) {
if (value === null || value === void 0) return value;
if (typeof value !== "object") {
throw new TypeError(
"using declarations can only be used with objects, null, or undefined."
);
throw new TypeError("using declarations can only be used with objects, null, or undefined.");
}
// core-js-pure uses Symbol.for for polyfilling well-known symbols
if (isAwait) {
var dispose =
value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
var dispose = value[Symbol.asyncDispose || Symbol.for("Symbol.asyncDispose")];
}
if (dispose === null || dispose === void 0) {
dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")];
Expand All @@ -20,4 +17,6 @@ export default function _using(stack, value, isAwait) {
}
stack.push({ v: value, d: dispose, a: isAwait });
return value;
}
}

export { _using as _ };
4 changes: 3 additions & 1 deletion packages/swc-helpers/esm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
export { _apply_decorated_descriptor } from "./_apply_decorated_descriptor.js";
export { _apply_decs_2203_r } from "./_apply_decs_2203_r.js";
export { _array_like_to_array } from "./_array_like_to_array.js";
export { _array_without_holes } from "./_array_without_holes.js";
export { _array_with_holes } from "./_array_with_holes.js";
export { _array_without_holes } from "./_array_without_holes.js";
export { _assert_this_initialized } from "./_assert_this_initialized.js";
export { _async_generator } from "./_async_generator.js";
export { _async_generator_delegate } from "./_async_generator_delegate.js";
Expand Down Expand Up @@ -46,6 +46,7 @@ export { _decorate } from "./_decorate.js";
export { _defaults } from "./_defaults.js";
export { _define_enumerable_properties } from "./_define_enumerable_properties.js";
export { _define_property } from "./_define_property.js";
export { _dispose } from "./_dispose.js";
export { _export_star } from "./_export_star.js";
export { _extends } from "./_extends.js";
export { _get } from "./_get.js";
Expand Down Expand Up @@ -94,6 +95,7 @@ export { _ts_values } from "./_ts_values.js";
export { _type_of } from "./_type_of.js";
export { _unsupported_iterable_to_array } from "./_unsupported_iterable_to_array.js";
export { _update } from "./_update.js";
export { _using } from "./_using.js";
export { _wrap_async_generator } from "./_wrap_async_generator.js";
export { _wrap_native_super } from "./_wrap_native_super.js";
export { _write_only_error } from "./_write_only_error.js";
24 changes: 16 additions & 8 deletions packages/swc-helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@
"import": "./esm/index.js",
"default": "./cjs/index.cjs"
},
"./_/index": {
"import": "./esm/index.js",
"default": "./cjs/index.cjs"
},
"./_/_apply_decorated_descriptor": {
"import": "./esm/_apply_decorated_descriptor.js",
"default": "./cjs/_apply_decorated_descriptor.cjs"
Expand All @@ -66,14 +62,14 @@
"import": "./esm/_array_like_to_array.js",
"default": "./cjs/_array_like_to_array.cjs"
},
"./_/_array_without_holes": {
"import": "./esm/_array_without_holes.js",
"default": "./cjs/_array_without_holes.cjs"
},
"./_/_array_with_holes": {
"import": "./esm/_array_with_holes.js",
"default": "./cjs/_array_with_holes.cjs"
},
"./_/_array_without_holes": {
"import": "./esm/_array_without_holes.js",
"default": "./cjs/_array_without_holes.cjs"
},
"./_/_assert_this_initialized": {
"import": "./esm/_assert_this_initialized.js",
"default": "./cjs/_assert_this_initialized.cjs"
Expand Down Expand Up @@ -234,6 +230,10 @@
"import": "./esm/_define_property.js",
"default": "./cjs/_define_property.cjs"
},
"./_/_dispose": {
"import": "./esm/_dispose.js",
"default": "./cjs/_dispose.cjs"
},
"./_/_export_star": {
"import": "./esm/_export_star.js",
"default": "./cjs/_export_star.cjs"
Expand Down Expand Up @@ -426,6 +426,10 @@
"import": "./esm/_update.js",
"default": "./cjs/_update.cjs"
},
"./_/_using": {
"import": "./esm/_using.js",
"default": "./cjs/_using.cjs"
},
"./_/_wrap_async_generator": {
"import": "./esm/_wrap_async_generator.js",
"default": "./cjs/_wrap_async_generator.cjs"
Expand All @@ -437,6 +441,10 @@
"./_/_write_only_error": {
"import": "./esm/_write_only_error.js",
"default": "./cjs/_write_only_error.cjs"
},
"./_/index": {
"import": "./esm/index.js",
"default": "./cjs/index.cjs"
}
}
}

0 comments on commit 1ad03e6

Please sign in to comment.