Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-transform-flow-to-gen

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-flow-to-gen - npm Package Compare versions

Comparing version 0.0.14-0 to 0.0.14-1

63

lib/plugin.js

@@ -18,13 +18,14 @@ 'use strict';

var walkToScope = function walkToScope(path) {
while (!t.SCOPABLE_TYPES.includes(path.parentPath.type)) {
path = path.parentPath;
}
return path;
return path.findParent(function (p) {
return p.parentPath.isScopable();
});
};
var nameCount = 0;
var nextName = function nextName() {
nameCount += 1;
return _GEN_ID2.default + '_EXP_' + nameCount + '__';
// TODO figure out which what helper function is supposed to create this node...
var namedExport = function namedExport(input, output) {
return {
type: 'ExportNamedDeclaration',
specifiers: [t.exportSpecifier(input, output)],
exportKind: 'value'
};
};

@@ -46,17 +47,15 @@

if (node.exportKind === 'type') {
var declaration = node.declaration;
if (node.exportKind === 'value') {
return;
}
var declaration = node.declaration;
node.exportKind = 'value';
if (declaration) {
var namedExport = {
type: 'ExportNamedDeclaration',
specifiers: [t.exportSpecifier(declaration.id, declaration.id)],
exportKind: 'value'
};
node.exportKind = 'value';
path.replaceWithMultiple([declaration, namedExport]);
}
if (declaration) {
var id = declaration.id;
path.replaceWithMultiple([declaration, namedExport(id, id)]);
}

@@ -80,7 +79,10 @@ },

var nodes = [root.node].concat(fn);
root.replaceWithMultiple(nodes);
},
FunctionExpression: function FunctionExpression(path) {
var node = path.node;
var node = path.node,
parentPath = path.parentPath;
if (!allParamsAreTyped(node)) {

@@ -90,4 +92,4 @@ return;

if (t.isVariableDeclarator(path.parentPath)) {
var name = path.parentPath.node.id.name;
if (t.isVariableDeclarator(parentPath)) {
var name = parentPath.node.id.name;

@@ -100,10 +102,9 @@ var fn = (0, _transformFunction2.default)(name, node.params, node.typeParameters);

if (t.isReturnStatement(path.parentPath)) {
node.id = node.id || t.identifier(nextName());
if (t.isReturnStatement(parentPath)) {
node.id = path.scope.generateUidIdentifierBasedOnNode(node);
var _name = node.id.name;
var _fn = (0, _transformFunction2.default)(_name, node.params, node.typeParameters);
var _root = path.parentPath;
var _nodes = [node].concat(_fn).concat(t.returnStatement(t.identifier(_name)));
_root.replaceWithMultiple(_nodes);
parentPath.replaceWithMultiple(_nodes);
}

@@ -117,3 +118,3 @@ },

var id = t.identifier(nextName());
var id = path.scope.generateUidIdentifier(node);
var params = node.params;

@@ -129,3 +130,3 @@ var body = node.body;

path.replaceWith(exp);
path.replaceWithMultiple([exp]);
}

@@ -136,6 +137,2 @@ }

var _GEN_ID = require('./GEN_ID');
var _GEN_ID2 = _interopRequireDefault(_GEN_ID);
var _transformType = require('./transformType');

@@ -142,0 +139,0 @@

{
"name": "babel-plugin-transform-flow-to-gen",
"version": "0.0.14-0",
"version": "0.0.14-1",
"description": "Turn flow definitions into generator functions",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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