UNPKG

599 BJavaScriptView Raw
1var transform = require('../')
2
3var result = transform(`
4var multiply = (a, b) => {
5 return a * b
6}
7var add = (a, b) => a + b
8`, function (node) {
9 if (node.type === 'ArrowFunctionExpression') {
10 var params = node.params.map(function (param) { return param.getSource() })
11 if (node.body.type !== 'BlockStatement') {
12 node.body.edit.update(`{ return ${node.body.getSource()} }`)
13 }
14 node.edit.update(`function (${params.join(', ')}) ${node.body.getSource()}`)
15 }
16})
17
18console.log(
19 result.toString() +
20 '\n//# sourceMappingURL=' +
21 result.generateMap({ hires: true }).toUrl()
22)