@mongosh/async-rewriter2
Advanced tools
Comparing version 0.12.1 to 0.13.1
@@ -28,2 +28,3 @@ "use strict"; | ||
const wrap_as_iife_1 = __importDefault(require("./stages/wrap-as-iife")); | ||
const uncatchable_exceptions_1 = __importDefault(require("./stages/uncatchable-exceptions")); | ||
const transform_maybe_await_1 = __importDefault(require("./stages/transform-maybe-await")); | ||
@@ -50,2 +51,3 @@ const error_codes_1 = require("./error-codes"); | ||
code = this.step(code, [wrap_as_iife_1.default]); | ||
code = this.step(code, [uncatchable_exceptions_1.default]); | ||
code = this.step(code, [ | ||
@@ -52,0 +54,0 @@ [ |
@@ -31,7 +31,4 @@ "use strict"; | ||
const identifierGroupKey = '@@mongosh.identifierGroup'; | ||
const symbolConstructor = babel.template.expression(` | ||
Object.getOwnPropertySymbols(Array.prototype)[0].constructor | ||
`)(); | ||
const syntheticPromiseSymbolTemplate = babel.template.statement(` | ||
const SP_IDENTIFIER = SYMBOL_CONSTRUCTOR.for("@@mongosh.syntheticPromise"); | ||
const SP_IDENTIFIER = Symbol.for("@@mongosh.syntheticPromise"); | ||
`); | ||
@@ -163,4 +160,3 @@ const markSyntheticPromiseTemplate = babel.template.statement(` | ||
Object.assign(syntheticPromiseSymbolTemplate({ | ||
SP_IDENTIFIER: syntheticPromiseSymbol, | ||
SYMBOL_CONSTRUCTOR: symbolConstructor | ||
SP_IDENTIFIER: syntheticPromiseSymbol | ||
}), { [isGeneratedHelper]: true }), | ||
@@ -167,0 +163,0 @@ Object.assign(expressionHolderVariableTemplate({ |
{ | ||
"name": "@mongosh/async-rewriter2", | ||
"version": "0.12.1", | ||
"version": "0.13.1", | ||
"description": "MongoDB Shell Async Rewriter Package", | ||
@@ -40,3 +40,3 @@ "main": "./lib/index.js", | ||
}, | ||
"gitHead": "9205f20ae5e28f281e040bbcd781f0719ad5846e" | ||
"gitHead": "fbb222324b90d79db02aac0a7d3b90c49e4dab3c" | ||
} |
@@ -36,3 +36,3 @@ # next-gen async-rewriter | ||
The transformation takes place in two main steps. | ||
The transformation takes place in three main steps. | ||
@@ -67,4 +67,61 @@ ### Step one: IIFE wrapping | ||
### Step two: Async function wrapping | ||
### Step two: Making certain exceptions uncatchable | ||
In order to support Ctrl+C properly, we add a type of exception that is not | ||
catchable by userland code. | ||
For example, | ||
```js | ||
try { | ||
foo3(); | ||
} catch { | ||
bar3(); | ||
} | ||
``` | ||
is transformed into | ||
```js | ||
try { | ||
foo3(); | ||
} catch (_err) { | ||
if (!err || !_err[Symbol.for('@@mongosh.uncatchable')]) { | ||
bar3(); | ||
} else { | ||
throw _err; | ||
} | ||
} | ||
``` | ||
and | ||
```js | ||
try { | ||
foo1(); | ||
} catch (err) { | ||
bar1(err); | ||
} finally { | ||
baz(); | ||
} | ||
``` | ||
into | ||
```js | ||
let _isCatchable; | ||
try { | ||
foo1(); | ||
} catch (err) { | ||
_isCatchable = !err || !err[Symbol.for('@@mongosh.uncatchable')]; | ||
if (_isCatchable) bar1(err); else throw err; | ||
} finally { | ||
if (_isCatchable) baz(); | ||
} | ||
``` | ||
### Step three: Async function wrapping | ||
We perform three operations: | ||
@@ -71,0 +128,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
93214
28
980
232