1 | var transform = require('../')
|
2 |
|
3 | var result = transform(`
|
4 | var multiply = (a, b) => {
|
5 | return a * b
|
6 | }
|
7 | var 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 |
|
18 | console.log(
|
19 | result.toString() +
|
20 | '\n//# sourceMappingURL=' +
|
21 | result.generateMap({ hires: true }).toUrl()
|
22 | )
|