-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathFunctionNode.js
More file actions
23 lines (20 loc) · 849 Bytes
/
Copy pathFunctionNode.js
File metadata and controls
23 lines (20 loc) · 849 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'use strict'
const SymbolNode = require('mr-parser').nodeTypes.SymbolNode
const functionProxy = function (node) {
return '$$mathCodegen.functionProxy(' + this.next(new SymbolNode(node.name)) + ', ' + JSON.stringify(node.name) + ')'
}
module.exports = function (node) {
const self = this
// wrap in a helper function to detect the type of symbol it must be a function
// NOTE: if successful the wrapper returns the function itself
// NOTE: node.name should be a symbol so that it's correctly represented as a string in SymbolNode
const method = functionProxy.call(this, node)
let args = []
this.rawify(this.options.rawCallExpressionElements, function () {
args = node.args.map(function (arg) {
return self.next(arg)
})
})
return method + '(' + args.join(', ') + ')'
}
module.exports.functionProxy = functionProxy