merge comprehension transformers
This commit is contained in:
@@ -7,7 +7,23 @@ var t = require("../../types");
|
||||
|
||||
exports.experimental = true;
|
||||
|
||||
var build = function (node, parent, scope, context, file) {
|
||||
exports.ComprehensionExpression = function (node) {
|
||||
if (!node.generator) return;
|
||||
|
||||
var body = [];
|
||||
var container = t.functionExpression(null, [], t.blockStatement(body), true);
|
||||
container._aliasFunction = true;
|
||||
|
||||
body.push(buildComprehension(node, function () {
|
||||
return t.expressionStatement(t.yieldExpression(node.body));
|
||||
}));
|
||||
|
||||
return t.callExpression(container, []);
|
||||
};
|
||||
|
||||
exports.ComprehensionExpression = function (node, parent, scope, context, file) {
|
||||
if (node.generator) return;
|
||||
|
||||
var uid = scope.generateUidBasedOnNode(parent, file);
|
||||
|
||||
var container = util.template("array-comprehension-container", {
|
||||
@@ -35,9 +51,3 @@ var build = function (node, parent, scope, context, file) {
|
||||
|
||||
return container;
|
||||
};
|
||||
|
||||
exports.ComprehensionExpression = function (node, parent, scope, context, file) {
|
||||
if (node.generator) return;
|
||||
|
||||
return build(node, parent, scope, context, file);
|
||||
};
|
||||
@@ -1,20 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
var buildComprehension = require("../helpers/build-comprehension");
|
||||
var t = require("../../types");
|
||||
|
||||
exports.experimental = true;
|
||||
|
||||
exports.ComprehensionExpression = function (node) {
|
||||
if (!node.generator) return;
|
||||
|
||||
var body = [];
|
||||
var container = t.functionExpression(null, [], t.blockStatement(body), true);
|
||||
container._aliasFunction = true;
|
||||
|
||||
body.push(buildComprehension(node, function () {
|
||||
return t.expressionStatement(t.yieldExpression(node.body));
|
||||
}));
|
||||
|
||||
return t.callExpression(container, []);
|
||||
};
|
||||
Reference in New Issue
Block a user