Return waypoints of given connection; throw if non exists (should not happen!!).

@param {Connection} connection

@return {Array<Point>}
170076
function safeGetWaypoints(connection) {

  var waypoints = connection.waypoints;

  if (!waypoints.length) {
    throw new Error('connection#' + connection.id + ': no waypoints');
  }

  return waypoints;
}
1082626
function(point) {
                if (!this.contains(point)) { return null; }
                var P = point.elements || point;
                var A = this.anchor.elements, D = this.direction.elements;
                return (P[0] - A[0]) * D[0] + (P[1] - A[1]) * D[1] + ((P[2] || 0) - A[2]) * D[2];
              }
794877
public void returnConnection(DataConnection connection) {
        if (connection.isUsable()) {
            connection.setLastUsage(new Date());
            availableConnections.add(connection);
        }
        else {
            connection.close();
        }

        usedConnections.remove(connection);
    }
701724
function(connection) {
      var t = this;
      log.info('removeConnection', 'Conn_' + connection.id);
      connection.disconnect('connection_removed');
      t.connections.remove(connection);
      t.trigger('connection:remove', connection);
    }
803794
function parseWaypoint(qualifiedWaypoint) {
		var parts;
		if (!parsedWaypoints[qualifiedWaypoint]) {
			parts = qualifiedWaypoint.split('.');
			if (parts.length === 1) {
				parts.unshift('globals');
			}
			parsedWaypoints[qualifiedWaypoint] = {
				namespace : parts.shift(),
				waypoint : parts.join('.')
			};
		}
		return parsedWaypoints[qualifiedWaypoint];
	}
887997
function (conn, cb) {

      // TODO: disconnect here
      if (typeof conn == 'function') {
        cb = conn;
        conn = null;
      }
      if (!conn) {
        connections = {};
        return cb();
      }
      if(!connections[conn]) return cb();
      delete connections[conn];
      cb();
    }
5226
def get_connection_state(self, connection: str) -> Dict[str, Any]:
        
        if connection not in self.connections:
            raise ConnectionNotOpen(connection)

        return self.connections[connection].state
537899
async function searchPrevRoutes(target) {
    const connNames = await listConnectionNames();
    const ret = [];
    for (const connName of connNames) {
        const cmd = [
            'nmcli', '-f', 'IP4.ROUTE', 'connection', 'show', connName,
        ];
        const output = await executeCommand(cmd);
        for (const line of output.split('\n')) {
            const exs = `dst\\s*=\\s*${target},\\snh\\s*=\\s*([\\d\.]+)`;
            const re = line.match(new RegExp(exs));
            if (!re) {
                continue;
            }
            ret.push({
                connName: connName,
                target: target,
                gatewayIP: re[1],
            });
        }
    }
    return ret;
}
249391
function Endpoint() {
  var self = this;
  const subscriptions = {};
  const ps = new Pubsub();
  this._publish = ps.publish;
  this._subscribe = ps.subscribe;
  this.active = false;
  this.connections = [];

  /**
   * Publishes a new connection.
   * @function _newConnection
   * @private
   * @param {string} sID socket ID
   * @returns this
   */
  this._newConnection = sId => {
    self.connections.push(sId || 'unknown');
    self.active = true;
    self._publish('change', {count: self.connections.length});
    return this;
  };

  /**
   * Records a lost connection.
   * @function _lostConnection
   * @private
   * @param {string} sID socket ID
   * @returns this
   */
  this._lostConnection = sId => {
    const index = this.connections.indexOf(sId);
    this.connections.splice(index, 1);
    if (this.connections.length === 0) {
      this.active = false;
    }

    self._publish('change', {count: self.connections.length});

    return this;
  };

  /**
   * Subscribe an action to perform when a message is received.
   * @function onmessage
   * @param {string} type
   * @param {messageResponse}
   * @param {boolean} [historical=false] Whether or not to call the listener if this message has been received before this listener was set.
   * @returns {subscription}
   */
  this.onmessage = (type, cb, historical = false) => {
    return self._subscribe(type, cb, historical);
  };

  /**
   * Subscribe an action to perform when the connection changes.
   * @function onchange
   * @param {changeCallback}
   * @returns {subscription}
   */
  this.onchange = cb => {
    return self._subscribe('change', cb);
  };

  /**
   * Remove all subscriptions to connection events.
   * @function clear
   */
  this.clear = ps.clear;
}
198740
function( connection ) {
    this._users = []; // Collect high-level information about users
    this._channels = {}; // Collect high-level information about channels
    this.sessions = {}; // Sessions to user map

    // TODO: We are storing the users twice to avoid some looping. Is this the
    // best approach?

    /**
     * @summary Defines whether the connection has been succesffully handshaken.
     *
     * @description
     * The connection is considered `ready` when the server handshake has been
     * processed and the initial ping has been received.
     *
     * @name MumbleClient#ready
     * @type Boolean
     */
    this.ready = false;

    /**
     * @summary The internal {@link MumbleConnection} object.
     *
     * @description
     * The connection object is used for the low level access to the Mumble
     * protocol. Most developers should find a higher level APIs for the
     * functionality on the {@link MumbleClient} class instead.
     *
     * @name MumbleClient#connection
     * @type MumbleConnection
     */
    this.connection = connection;

    /**
     * @summary The server root channel.
     *
     * @name MumbleClient#rootChannel
     * @type Channel
     */
    this.rootChannel = undefined;

    /**
     * @summary The current user.
     *
     * @name MumbleClient#user
     * @type User
     */
    this.user = undefined;

    this._gotServerSync = false;
    this._gotInitialPing = false;

    // Generate list of free whisper target IDs.
    this.freeTargets = [];
    for( var i = 1; i <= 30; i++ ) {
        this.freeTargets.push( i );
    }

    /*
     * Forward all events from the connection
     */
    this.on( 'newListener', function( event, listener ) {
        connection.on( event, listener );
    } );

    connection.once( 'ping', this._initialPing.bind( this ) );
    connection.on( 'channelRemove', this._channelRemove.bind( this ) );
    connection.on( 'userRemove', this._userRemove.bind( this ) );
    connection.on( 'serverSync', this._serverSync.bind( this ) );
    connection.on( 'userState', this._userState.bind( this ) );
    connection.on( 'channelState', this._channelState.bind( this ) );
    connection.on( 'permissionQuery', this._permissionQuery.bind( this ) );
    connection.on( 'textMessage', this._textMessage.bind( this ) );
}
373579
function(latLngs, pattern) {
        if (latLngs.length < 2) {
            return [];
        }
        const pathAsPoints = latLngs.map(latLng => this._map.project(latLng));
        return projectPatternOnPointPath(pathAsPoints, pattern)
            .map(point => ({
                latLng: this._map.unproject(L.point(point.pt)),
                heading: point.heading,
            }));
    }
1238759
public static List<String> getGeometryFields(Connection connection,TableLocation location) throws SQLException {
        return getGeometryFields(connection, location.getCatalog(), location.getSchema(), location.getTable());
    }
386297
function (connection) {
            var headerStr = connection.getAllResponseHeaders(), headers = {};

            if (headerStr) {
                var headerLines = headerStr.split("\n");
                for (var i = 0; i < headerLines.length; i++) {
                    var delimitPos = headerLines[i].indexOf(":");
                    if (delimitPos != -1) {
                        // Trime headers
                        headers[headerLines[i].substring(0, delimitPos)] = headerLines[i].substring(delimitPos + 2).replace(/^\s+|\s+$/g, "");
                    }
                }
            }

            var response = {
                statusText : (connection.status == 1223) ? "No Content" : connection.statusText,
                getResponseHeader : headers,
                getAllResponseHeaders : headerLines,
                responseText : connection.responseText,
                responseXML : connection.responseXML
            };

            return response;
        }
1211522
public final static List<ConnectionNotation> getAllEdgeConnections(List<ConnectionNotation> connections) {
    List<ConnectionNotation> listEdgeConnection = new ArrayList<ConnectionNotation>();
    for (ConnectionNotation connection : connections) {
      if (!(connection.getrGroupSource().equals("pair"))) {
        listEdgeConnection.add(connection);
      }
    }
    return listEdgeConnection;
  }
825945
function find(connector) {
  var connectors = [];
  if (connector && connector.id) {
    // this is an object
    return [rtcConnectors[connector.id]];
  }
  if (connector && rtcConnectors.hasOwnProperty(connector)) {
    return rtcConnectors[connector];
  } 
  // Deep find if it is actually a key.
  if (typeof connector === 'string') { 
    // It is probably a key if we are here, we will try to find it.
    for (var id in rtcConnectors) {
      // return them all in an array.
      if (rtcConnectors[id].key === connector ) {
        connectors.push(rtcConnectors[id]);
      }
    }
  }
  return connectors;
}
1298428
function eachEndpoint(iterator) {
	for (var namespace in endpoints) {
		var methods = endpoints[namespace];

		for (var name in methods) {
			var method = methods[name];

			iterator(namespace, name, method);
		}
	}

	return endpoints;
}
775122
function buildURL(connection) {
  var scheme;
  var url;

  switch (connection.adapter) {
    case 'sails-mysql':
      scheme = 'mysql';
      break;
    case 'sails-postgresql':
      scheme = 'postgres';
      break;
    case 'sails-mongo':
      scheme = 'mongodb'
      break;
    default:
      throw new Error('migrations not supported for ' + connection.adapter);
  }

  // return the connection url if one is configured
  if (connection.url) {
    return connection.url;
  }

  url = scheme + '://';
  if (connection.user) {
    url += connection.user;
    if (connection.password) {
      url += ':' + encodeURIComponent(connection.password)
    }
    url += '@';
  }
  url += connection.host || 'localhost';
  if (connection.port) {
    url += ':' + connection.port;
  }
  if (connection.database) {
    url += '/' + encodeURIComponent(connection.database);
  }

  var params = [];
  if (connection.multipleStatements) {
    params.push('multipleStatements=true');
  }

  if (params.length > 0) {
    url += '?' + params.join('&');
  }

  return url;
}