# All files / src/generator export.js

100% Statements 7/7
100% Branches 2/2
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
    20
    21
    22
    23
    24
    23x
    23x

    126x
    126x

    126x
    1x

    125x

     // @flow
    import { GLOBAL_INDEX, FUNCTION_INDEX } from "../semantics/metadata";
    import { EXTERN_GLOBAL, EXTERN_FUNCTION } from "../emitter/external_kind";
    import type { NodeType, IntermediateExportType } from "./flow/types";

    export default function generateExport(node: NodeType): IntermediateExportType {
      const functionIndexMeta = node.meta[FUNCTION_INDEX];
      const globalIndexMeta = node.meta[GLOBAL_INDEX];

      if (globalIndexMeta != null) {
        return {
          index: globalIndexMeta,
          kind: EXTERN_GLOBAL,
          field: node.value,
        };
      }

      return {
        index: functionIndexMeta,
        kind: EXTERN_FUNCTION,
        field: node.value,
      };
    }