{"size": 1722, "ext": "js", "max_stars_repo_path": "lidl-core/lib/graphInputs/addInterfaceToGraph.js", "max_stars_repo_name": "crubier/lidl", "max_stars_repo_stars_event_min_datetime": "2021-11-24T21:53:57.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-28T08:51:23.000Z", "max_issues_repo_path": "lidl-core/lib/graphInputs/addInterfaceToGraph.js", "max_issues_repo_name": "crubier/lidl", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lidl-core/lib/graphInputs/addInterfaceToGraph.js", "max_forks_repo_name": "crubier/lidl", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 22.0769230769, "max_line_length": 263, "alphanum_fraction": 0.5673635308}
"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default =




addInterfaceToGraph;var _lodash = require("lodash");var _lodash2 = _interopRequireDefault(_lodash);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}function addInterfaceToGraph(graph, interfac, prefix, definitionNode) {
  var rootNode;

  switch (interfac.type) {
    case "InterfaceAtomic":

      rootNode =
      graph.
      addNode({
        type: 'Interface',
        name: prefix,
        content: interfac });


      break;
    case "InterfaceComposite":
      rootNode =
      graph.
      addNode({
        type: 'Interface',
        name: prefix,
        content: interfac });


      var nodeOfElement =
      (0, _lodash2.default)(interfac.element).
      map(function (x) {return addInterfaceToGraph(graph, x.value, prefix + "." + x.key, definitionNode);}).
      value();

      (0, _lodash2.default)(nodeOfElement).
      forEach(function (x, index) {return (
          graph.
          addEdge({
            type: 'InterfaceElement',
            from: {
              node: rootNode,
              index: index + 1 },

            to: {
              node: x,
              index: 0 } }));}).


      commit();
      break;
    case "InterfaceNamed":
      rootNode =
      graph.
      addNode({
        type: 'Interface',
        name: prefix,
        content: interfac });

      break;
    default:
      throw new Error("Cannot transform into a graph the interface of type " + interfac.type);}





  graph.
  addEdge({
    type: 'DefinitionSubInterface',
    from: {
      node: definitionNode },

    to: {
      node: rootNode } });


  return rootNode;
}