babel/lib/6to5/transformation/transformers/spec-block-hoist-functions.js
Sebastian McKenzie 615425c808 fix linting errors
2014-12-12 12:14:02 +11:00

19 lines
442 B
JavaScript

var t = require("../../types");
exports.BlockStatement = function (node, parent) {
if (t.isFunction(parent)) return;
node.body = node.body.map(function (node) {
if (t.isFunction(node)) {
node.type = "FunctionExpression";
var declar = t.variableDeclaration("let", [
t.variableDeclarator(node.id, node)
]);
declar._blockHoist = true;
return declar;
} else {
return node;
}
});
};