All files / src/generator merge-block.js

100% Statements 5/5
100% Branches 2/2
100% Functions 1/1
100% Lines 5/5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19      22x           2662x 2229x   433x   2662x        
// @flow
import type { IntermediateOpcodeType } from './flow/types';
 
const mergeBlock = (
  block: IntermediateOpcodeType[],
  v: IntermediateOpcodeType | IntermediateOpcodeType[]
): IntermediateOpcodeType[] => {
  // some node types are a sequence of opcodes:
  // nested expressions for example
  if (Array.isArray(v)) {
    block = [...block, ...v];
  } else {
    block.push(v);
  }
  return block;
};
 
export default mergeBlock;