function prepareNetwork(component, options) {
  // If we were given a graph instance, then just create a network
  if (typeof component === 'object') {
    // This is a graph object
    const network = new Network(component, {
      ...options,
      componentLoader: options.loader,
    });
    // Wire the network up
    return network.connect();
  }

  if (!options.loader) {
    return Promise.reject(new Error('No component loader provided'));
  }

  // Start by loading the component
  return options.loader.load(component, {})
    .then((instance) => {
      // Prepare a graph wrapping the component
      const graph = new Graph(options.name);
      const nodeName = options.name || 'AsCallback';
      graph.addNode(nodeName, component);
      // Expose ports
      const inPorts = instance.inPorts.ports;
      const outPorts = instance.outPorts.ports;
      Object.keys(inPorts).forEach((port) => {
        graph.addInport(port, nodeName, port);
      });
      Object.keys(outPorts).forEach((port) => {
        graph.addOutport(port, nodeName, port);
      });
      // Prepare network
      const network = new Network(graph, {
        ...options,
        componentLoader: options.loader,
      });
      // Wire the network up and start execution
      return network.connect();
    });
}
@param {AsCallbackComponent} component
@param {AsCallbackOptions} options
@returns {Promise<Network>}