# 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
    21x
    21x

    125x
    125x

    125x
    9x

    116x

     // @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,
      };
    }