# All files / src/emitter/section exports.js

100% Statements 12/12
100% Branches 0/0
100% Functions 2/2
100% Lines 12/12

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    21x
    21x
    21x
    21x

    21x
    64x
    64x

    64x
    125x

    125x
    125x

    64x

     // @flow
    import { u8 } from "wasm-types";
    import { varuint32 } from "../numbers";
    import { emitString } from "../string";
    import OutputStream from "../../utils/output-stream";

    const emit = (exports: any[]) => {
      const payload = new OutputStream();
      payload.push(varuint32, exports.length, "count");

      exports.forEach(({ field, kind, index }) => {
        emitString(payload, field, "field");

        payload.push(u8, kind, "Global");
        payload.push(varuint32, index, "index");
      });

      return payload;
    };

    export default emit;