1 | var traverse = require('../traverse');
|
2 | var helpers = require('../helpers');
|
3 | var Identifier = require('./Identifier');
|
4 | var VariableDeclaration = require('./VariableDeclaration');
|
5 | var VariableDeclarator = require('./VariableDeclarator');
|
6 |
|
7 | var FunctionExpression = module.exports = function(id, params, body) {
|
8 | this.type = 'FunctionExpression';
|
9 | this.id = id;
|
10 | this.params = params;
|
11 | this.body = body;
|
12 | };
|
13 |
|
14 | FunctionExpression.prototype.normalize = function (place) {
|
15 | this.body.normalize();
|
16 | var dec = helpers.extractVariableDeclarations(this.body);
|
17 | if (dec.declarations.length > 0) {
|
18 | this.body.body.unshift(dec);
|
19 | }
|
20 | };
|
21 |
|
22 | FunctionExpression.prototype.transform = function (place) {
|
23 | this.body.transform(place);
|
24 | if (this.body.async) {
|
25 | this.async = true;
|
26 | }
|
27 | return place;
|
28 | };
|