All files / src/emitter/section functions.js

100% Statements 10/10
100% Branches 0/0
100% Functions 3/3
100% Lines 8/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17    21x 21x   21x 158x 69x 69x   158x   69x        
// @flow
// Emits function section. For function code emitter look into code.js
import { varuint32 } from '../numbers';
import OutputStream from '../../utils/output-stream';
 
const emit = (functions: any[]) => {
  functions = functions.filter(func => func !== null);
  const stream = new OutputStream();
  stream.push(varuint32, functions.length, 'count');
 
  functions.forEach(index => stream.push(varuint32, index, 'type index'));
 
  return stream;
};
 
export default emit;