Socket
Socket
Sign inDemoInstall

@mongosh/async-rewriter2

Package Overview
Dependencies
Maintainers
11
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mongosh/async-rewriter2 - npm Package Compare versions

Comparing version 0.12.1 to 0.13.1

lib/stages/uncatchable-exceptions.d.ts

2

lib/async-writer-babel.js

@@ -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 @@ [

8

lib/stages/transform-maybe-await.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc