Skip to content

Commit

Permalink
keep "async" keyword for async oncreate functions
Browse files Browse the repository at this point in the history
  • Loading branch information
m59peacemaker committed Oct 25, 2017
1 parent 0997107 commit 5275892
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/generators/Generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,30 +509,34 @@ export default class Generator {
});

const addArrowFunctionExpression = (name: string, node: Node) => {
const { body, params } = node;
const { body, params, async } = node;
const fnKeyword = async ? 'async function' : 'function';

const paramString = params.length ?
`[✂${params[0].start}-${params[params.length - 1].end}✂]` :
``;

if (body.type === 'BlockStatement') {
componentDefinition.addBlock(deindent`
function ${name}(${paramString}) [✂${body.start}-${body.end}✂]
${fnKeyword} ${name}(${paramString}) [✂${body.start}-${body.end}✂]
`);
} else {
componentDefinition.addBlock(deindent`
function ${name}(${paramString}) {
${fnKeyword} ${name}(${paramString}) {
return [✂${body.start}-${body.end}✂];
}
`);
}
};

const addFunctionExpression = (name: string, node: Node) => {
const { async } = node;
const fnKeyword = async ? 'async function' : 'function';

let c = node.start;
while (this.source[c] !== '(') c += 1;
componentDefinition.addBlock(deindent`
function ${name}[✂${c}-${node.end}✂];
${fnKeyword} ${name}[✂${c}-${node.end}✂];
`);
};

Expand Down

0 comments on commit 5275892

Please sign in to comment.