Socket
Socket
Sign inDemoInstall

@mongosh/async-rewriter2

Package Overview
Dependencies
Maintainers
13
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 1.10.6 to 2.0.0

3

benchmark/index.ts

@@ -6,3 +6,4 @@ import AsyncWriter from '../src/index';

const start = process.hrtime.bigint();
for (let i = 0; i < RUNS; i++) new AsyncWriter().runtimeSupportCode();
for (let i = 0; i < RUNS; i++)
new AsyncWriter().unprocessedRuntimeSupportCode();
const stop = process.hrtime.bigint();

@@ -9,0 +10,0 @@

@@ -21,2 +21,5 @@ "use strict";

for (const decl of path.node.declarations) {
if (decl.id.name ===
this.completionRecordId.name)
return;
this.variables.push(decl.id.name);

@@ -57,2 +60,11 @@ if (decl.init) {

}
if (path.isExpressionWrapper() &&
!path.getFunctionParent() &&
!((path.isExpressionStatement() &&
path.node.expression.type === 'AssignmentExpression' &&
path.node.expression.left.type === 'Identifier' &&
path.node.expression.left.name === this.completionRecordId.name))) {
path.replaceWith(t.expressionStatement(t.assignmentExpression('=', this.completionRecordId, path.node.expression)));
return;
}
if (path.parentPath.isProgram()) {

@@ -64,2 +76,5 @@ this.movedStatements.push(path.node);

enter(path) {
if (this.hasFinishedMoving)
return;
this.completionRecordId = path.scope.generateUidIdentifier('cr');
if (path.node.directives.length === 1 &&

@@ -80,6 +95,2 @@ path.node.directives[0].value.type === 'DirectiveLiteral' &&

this.hasFinishedMoving = true;
this.completionRecordId = path.scope.generateUidIdentifier('cr');
this.movedStatements.unshift(t.variableDeclaration('var', [
t.variableDeclarator(this.completionRecordId),
]));
path.replaceWith(t.program([

@@ -90,29 +101,12 @@ ...this.variables.map((v) => t.variableDeclaration('var', [

...this.functionDeclarations,
t.expressionStatement(t.callExpression(t.arrowFunctionExpression([], t.blockStatement(this.movedStatements)), [])),
t.expressionStatement(t.callExpression(t.arrowFunctionExpression([], t.blockStatement([
t.variableDeclaration('var', [
t.variableDeclarator(this.completionRecordId),
]),
...this.movedStatements,
t.returnStatement(this.completionRecordId),
])), [])),
], path.node.directives));
},
},
BlockStatement: {
exit(path) {
if (!this.hasFinishedMoving)
return;
if (!path.parentPath.isArrowFunctionExpression())
return;
if (path.parentPath.getFunctionParent())
return;
if (this.addedCompletionRecords)
return;
this.addedCompletionRecords = true;
const records = path.getCompletionRecords();
for (const record of records) {
if (record.isExpressionWrapper()) {
record.replaceWith(t.expressionStatement(t.assignmentExpression('=', this.completionRecordId, record.node.expression)));
}
}
path.replaceWith(t.blockStatement([
...path.node.body,
t.returnStatement(this.completionRecordId),
]));
},
},
},

@@ -119,0 +113,0 @@ };

{
"name": "@mongosh/async-rewriter2",
"version": "1.10.6",
"version": "2.0.0",
"description": "MongoDB Shell Async Rewriter Package",

@@ -11,2 +11,4 @@ "main": "./lib/index.js",

"test-ci": "node ../../scripts/run-if-package-requested.js npm test",
"test-coverage": "nyc --no-clean --cwd ../.. --reporter=none npm run test",
"test-ci-coverage": "nyc --no-clean --cwd ../.. --reporter=none npm run test-ci",
"eslint": "eslint",

@@ -50,5 +52,5 @@ "lint": "npm run eslint . && npm run prettier -- --check .",

"devDependencies": {
"@mongodb-js/eslint-config-mongosh": "1.10.6",
"@mongodb-js/eslint-config-mongosh": "^1.0.0",
"@mongodb-js/prettier-config-devtools": "^1.0.1",
"@mongodb-js/tsconfig-mongosh": "1.10.6",
"@mongodb-js/tsconfig-mongosh": "^1.0.0",
"depcheck": "^1.4.3",

@@ -58,3 +60,3 @@ "eslint": "^7.25.0",

},
"gitHead": "6bcde16381f6258d9be713998c67c48a99cfd691"
"gitHead": "60053aa2f37dc6c3e4fe059e806565ec51ece9e8"
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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