Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
52ce528
commit dad4497
Showing
9 changed files
with
103 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
/* @minVersion 7.0.0-beta.0 */ | ||
|
||
export default function _using(stack, value) { | ||
export default function _using(stack, value, isAwait) { | ||
if (value !== null && value !== void 0) { | ||
// core-js-pure uses Symbol.for("Symbol.dispose"). | ||
var dispose = value[Symbol.dispose || Symbol.for("Symbol.dispose")]; | ||
if (typeof dispose !== "function") { | ||
throw new TypeError(`Property [Symbol.dispose] is not a function.`); | ||
} | ||
stack.push({ v: value, d: dispose }); | ||
stack.push({ v: value, d: dispose, a: isAwait }); | ||
} | ||
return value; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...plugin-proposal-explicit-resource-management/test/fixtures/transform-await/mixed/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
using a = 1; | ||
await using b = 2; | ||
using c = 3; | ||
} |
11 changes: 11 additions & 0 deletions
11
...ugin-proposal-explicit-resource-management/test/fixtures/transform-await/mixed/output.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
try { | ||
var _stack = []; | ||
const a = babelHelpers.using(_stack, 1); | ||
const b = babelHelpers.using(_stack, 2, true); | ||
const c = babelHelpers.using(_stack, 3); | ||
} catch (_) { | ||
var _error = _; | ||
var _hasError = true; | ||
} finally { | ||
await babelHelpers.dispose(_stack, _error, _hasError, typeof SuppressedError !== undefined && SuppressedError); | ||
} |
6 changes: 6 additions & 0 deletions
6
...osal-explicit-resource-management/test/fixtures/transform-await/only-using-await/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
await using x = obj; | ||
stmt; | ||
await using y = obj, z = obj; | ||
doSomethingWith(x, y); | ||
} |
13 changes: 13 additions & 0 deletions
13
...al-explicit-resource-management/test/fixtures/transform-await/only-using-await/output.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
try { | ||
var _stack = []; | ||
const x = babelHelpers.using(_stack, obj, true); | ||
stmt; | ||
const y = babelHelpers.using(_stack, obj, true), | ||
z = babelHelpers.using(_stack, obj, true); | ||
doSomethingWith(x, y); | ||
} catch (_) { | ||
var _error = _; | ||
var _hasError = true; | ||
} finally { | ||
await babelHelpers.dispose(_stack, _error, _hasError, typeof SuppressedError !== undefined && SuppressedError); | ||
} |
4 changes: 4 additions & 0 deletions
4
...l-plugin-proposal-explicit-resource-management/test/fixtures/transform-await/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"sourceType": "module", | ||
"plugins": ["proposal-explicit-resource-management"] | ||
} |