-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathfunction.js
39 lines (32 loc) · 867 Bytes
/
function.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*jslint node: true, indent: 2 */
'use strict';
var doBody = require('./helper/body');
var args = require('./helper/arguments');
var identifier = require('./helper/identifier');
// name, params, isRef, returnType, body
module.exports = function (node, indent) {
var codegen, str;
codegen = this.process.bind(this);
str = 'function ';
if (node.byref) {
str += '&';
}
str += node.name;
str += args(node.arguments, indent, this);
// php7 / return type
if (node.type) {
str += this.ws + ':' + this.ws;
if (node.nullable) {
str += '?';
}
str += identifier(node.type);
}
if (this.options.bracketsNewLine) {
str += this.nl + indent + '{' + this.nl;
} else {
str += this.ws + '{' + this.nl;
}
str += doBody.call(this, codegen, indent, node.body.children);
str += indent + '}' + this.nl;
return str;
};