Socket
Socket
Sign inDemoInstall

babel-helper-remap-async-to-generator

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-helper-remap-async-to-generator - npm Package Compare versions

Comparing version 6.0.14 to 6.0.15

.npmignore

65

lib/index.js

@@ -15,2 +15,6 @@ /* @flow */

var _babelTemplate = require("babel-template");
var _babelTemplate2 = _interopRequireDefault(_babelTemplate);
var _babelTypes = require("babel-types");

@@ -22,2 +26,4 @@

var buildWrapper = _babelTemplate2["default"]("\n (function () {\n var ref = FUNCTION;\n return function (PARAMS) {\n return ref.apply(this, arguments);\n };\n })\n");
var awaitVisitor = {

@@ -35,16 +41,15 @@ Function: function Function(path) {

exports["default"] = function (path /*: NodePath*/, callId /*: Object*/) {
function classMethod(path /*: NodePath*/, callId /*: Object*/) {
var node = path.node;
if (node.generator) return;
var body = node.body;
if (path.isClassMethod()) {
node.async = false;
node.async = false;
var body = node.body;
var container = t.functionExpression(null, [], t.blockStatement(body.body), true);
container.shadow = true;
body.body = [t.returnStatement(t.callExpression(t.callExpression(callId, [container]), []))];
}
var _container = t.functionExpression(null, [], t.blockStatement(body.body), true);
_container.shadow = true;
body.body = [t.returnStatement(t.callExpression(t.callExpression(callId, [_container]), []))];
return;
}
function plainFunction(path /*: NodePath*/, callId /*: Object*/) {
var node = path.node;

@@ -56,11 +61,18 @@ node.async = false;

var container = t.functionExpression(null, [], t.blockStatement([t.returnStatement(t.callExpression(t.callExpression(callId, [node]), []))]));
node.shadow = container;
var built = t.callExpression(callId, [node]);
var container = buildWrapper({
FUNCTION: built,
PARAMS: node.params.map(function () {
return path.scope.generateUidIdentifier("x");
})
}).expression;
var retFunction = container.body.body[1].argument;
if (path.isFunctionDeclaration()) {
var declar = t.variableDeclaration("let", [t.variableDeclarator(t.identifier(node.id.name), container)]);
var declar = t.variableDeclaration("let", [t.variableDeclarator(t.identifier(node.id.name), t.callExpression(container, []))]);
declar._blockHoist = true;
_babelHelperFunctionName2["default"]({
node: container,
node: retFunction,
parent: declar.declarations[0],

@@ -72,6 +84,29 @@ scope: path.scope

} else {
path.replaceWith(container);
_babelHelperFunctionName2["default"]({
node: retFunction,
parent: path.parent,
scope: path.scope
});
if (retFunction.id || node.params.length) {
// we have an inferred function id or params so we need this wrapper
path.replaceWith(t.callExpression(container, []));
} else {
// we can omit this wrapper as the conditions it protects for do not apply
path.replaceWith(built);
}
}
}
exports["default"] = function (path /*: NodePath*/, callId /*: Object*/) {
var node = path.node;
if (node.generator) return;
if (path.isClassMethod()) {
return classMethod(path, callId);
} else {
return plainFunction(path, callId);
}
};
module.exports = exports["default"];
{
"name": "babel-helper-remap-async-to-generator",
"version": "6.0.14",
"version": "6.0.15",
"description": "",

@@ -10,6 +10,7 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-remap-async-to-generator",

"babel-runtime": "^5.0.0",
"babel-types": "^6.0.14",
"babel-template": "^6.0.15",
"babel-types": "^6.0.15",
"babel-traverse": "^6.0.14",
"babel-helper-function-name": "^6.0.14"
"babel-helper-function-name": "^6.0.15"
}
}
}
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