All files / src/generator return-statement.js

100% Statements 7/7
100% Branches 0/0
100% Functions 1/1
100% Lines 7/7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19  22x 22x 22x     22x   164x       163x   163x        
// @flow
import mapSyntax from './map-syntax';
import mergeBlock from './merge-block';
import opcode from '../emitter/opcode';
import type { GeneratorType } from './flow/types';
 
const generateReturn: GeneratorType = node => {
  // Postfix in return statement should be a no-op UNLESS it's editing globals
  const block = node.params
    .filter(Boolean)
    .map(mapSyntax(null))
    .reduce(mergeBlock, []);
  block.push({ kind: opcode.Return, params: [] });
 
  return block;
};
 
export default generateReturn;