Establish a connection to the MIDI driver

@return {Promise} A connection promise
348373
function connect() {
    return new Promise(function (resolve, reject) {
        navigator.requestMIDIAccess().then(function (access) {
            resolve(new Driver(access));
        }).catch(function () {
            reject(new Error('MIDI access denied'));
        });
    });
}
112661
function() {
        var self = this;

        return new Promise(function(resolve, reject) {
            var config = {};

            for (var i = 0; i < self._modules.length; i++) {
                var module = self._modules[i];

                var storedModule = config[module.name] = {
                    dependencies: module.dependencies
                };

                if (module.condition) {
                    storedModule.condition = module.condition;
                }

                if (!self._options.ignorePath) {
                    if (module.fullPath) {
                        storedModule.fullPath = upath.toUnix(module.fullPath);
                    } else {
                        var dirname = path.dirname(module.name);

                        var modulePath = module.path || (dirname !== '.' ? dirname + '/' + module.file : module.file);

                        storedModule.path = upath.toUnix(modulePath);
                    }
                }
            }

            resolve(config);
        });
    }
549847
function getConnection(options) {
  debug('getConnection','start',options);

  let key = null;
  let promise = null;
  try {
    //clone options
    options = clone(options);

    //serialize the options as a key for pools
    key = stringify(options || {});

    //if there's already a promise for the given connection, return it
    if (promises[key]) return promises[key];

    //create a new promise for the given connection options
    promise = promises[key] = createConnectionPromise(key, options);

    debug('getConnection','success')
    return promise;
  } catch(err) {
    debug('getConnection','error',err);
    return Promise.reject(err);
  }
}
700648
function () {
    require('ts-node').register({
      project: 'e2e/tsconfig.e2e.json'
    });
    console.log("Connecting local");
    return new Promise(function (resolve, reject) {
      exports.bs_local = new browserstack.Local();
      exports.bs_local.start({'key': exports.config.capabilities['browserstack.key']}, function (error) {
        if (error) return reject(error);
        console.log('Connected. Now testing...');

        resolve();
      });
    });
  }
58809
function() {
      return Promise.retry(function() {
        log.debug(format('Connecting to redis on %s:%s', REDIS_IP, REDIS_PORT));
        return redis.createClient(REDIS_PORT, REDIS_IP);
      });
    }
1371121
async function getConnection(url, opts = {}) {

    const dbName = opts.databaseName;
    if (!dbName || dbName === '')
        throw boom.badImplementation('jollof-data-arangodb: databaseName config is required', { url, opts })

    const key = url + dbName;

    //Get connection
    let connection;
    if (connPool[key]) {
        connection = connPool[key];
    } else {
        connection = new Database(url)
        connPool[key] = connection;
    }

    //Now ensure database exists
    const dbNames = await connection.listDatabases();
    if (dbNames.indexOf(dbName) > -1) {
        //our db exists. use it.
        connection.useDatabase(dbName)
    } else {
        //our db does not exist. Attempting to create it
        await connection.createDatabase(dbName, [{ username: opts.username, passw: opts.password }])
        connection.useDatabase(dbName)
    }

    return connection;
}
455615
function connectApp(token) {
  const CONNECTION = new Connection();

  return new Promise((resolve, reject) => {
    CONNECTION.connect(token)
      .then(() => resolve(new ConnectionHandler(CONNECTION)))
      .catch((error) => reject(error));
  });
}
624770
function() {
    var me = this;
    var connectionOptions = me._connectionOptions;

    return promised(function(cb) {
      if (me.isConnected || me.status === 'connecting') {
        return cb(new Error('Broker client already connected or connecting.'));
      }

      if (!me.mqttClient) {
        var mqttClient = new PahoMQTT.Client(
          connectionOptions.host,
          connectionOptions.port,
          connectionOptions.path,
          connectionOptions.clientId
        );

        _registerPahoClientEventListeners(me, mqttClient);
        me.mqttClient = mqttClient;
      }

      me.status = 'connecting';
      me.emit('connecting');

      me.mqttClient.connect(
        merge(_getPahoCallbacks(cb), {
          cleanSession: connectionOptions.clean,
          keepAliveInterval: connectionOptions.keepAliveInterval,
          reconnect: connectionOptions.reconnect,
          useSSL: connectionOptions.useSSL
        })
      );
    }).then(function(connectResponse) {
      if (me.enableSubscriptionSyncEvents) {
        me.initSubscriptionSyncEvents();
      }

      return connectResponse;
    });
  }
306327
function initialize() {
  var scene = ds = exports.ds = {
    "time": 0,
    "song": null,
    "graph": null,
    "shaders": {},
    "textures": {},
    "texturesToLoad": 0,
    "audio": { "loaded": false, "playing": false },
    "isLoaded": function() {
      return this.graph !== null && this.texturesToLoad === 0 && this.audio.loaded === true;
    },
    "next": null
  };
  scene.gl = initializeWebGL();
  initAudio(scene.audio);
  initUI(scene);

  scene.shaders.sprite = createGlslProgram(scene.gl, "vertexShaderSprite", "fragmentShaderSprite");
  scene.shaders.particle = createGlslProgram(scene.gl, "vertexShaderParticle", "fragmentShaderParticle");

  window.requestAnimationFrame(animationFrame.bind(null, scene));
}
414657
function () {
            var ret = new Promise(), conn;
            if (this.count > this.__maxObjects) {
                this.__deferredQueue.enqueue(ret);
            } else {
                //todo override getObject to make async so creating a connetion can execute setup sql
                conn = this.getObject();
                if (!conn) {
                    //we need to deffer it
                    this.__deferredQueue.enqueue(ret);
                } else {
                    ret.callback(conn);
                }
            }
            if (this.count > this.__maxObjects && !conn) {
                ret.errback(new Error("Unexpected ConnectionPool error"));
            }
            return ret.promise();
        }
757758
async function getConnection(){
    // already connected ?
    if (_nodeMcuConnector.isConnected()){
        return;
    }

    // create new connector
    try{
        const msg = await _nodeMcuConnector.connect(_options.device, _options.baudrate, true, _options.connectionDelay);

        // status message
        _logger.log('Connected');
        _mculogger.log(msg);

    }catch(e){
        _logger.error('Unable to establish connection');
        throw e;
    }
}
565210
function() {
        try {
          var server = {
            "host": params.host,
            "port": params.port,
            "timeout": params.timeout || 20000,
            "connectHeaders": {
              "host": "/",
              "login": params.username,
              "passcode": params.password,
              "heart-beat": "5000, 5000"
            }
          };

          var servers = [server];

          var reconnectOptions = {
            'maxReconnects': 20
          };

          var manager = new Stompit.ConnectFailover(servers, reconnectOptions);

          manager.connect(function(error, stompClient, reconnect) {
            if (error) {
              fireEvent("error", {
                errorCode: error.code,
                errorMessage: error.message,
                errorEvent: error
              });

              return;
            }

            client = stompClient;

            client.on('error', function(error) {
              fireEvent("error", {
                errorCode: 999,
                errorMessage: "ActiveMQ client has had an error",
                errorEvent: error
              });
              reconnect();
            });

            fireEvent("init");
          });

        } catch (error) {
          console.error(error);
        }
      }
177845
function addTrackToNewPlaylist(options) {
    return new Promise(function (resolve, reject) {
        var form = new FormData();
        form.append('format', 'json');

        if (!options.tracks) {
            return reject('Error while addTrackToNewPlaylist options.tracks is null');
        } else {
            _.each(options.tracks, function (track) {
                form.append('playlist[tracks][][id]', track.id);
            });
        }
        if (!options.title) {
            return reject('Error while addTrackToNewPlaylist options.title is null');
        } else {
            form.append('playlist[title]', options.title);
        }
        if (!options.sharing) {
            return reject('Error while addTrackToNewPlaylist options.sharing is null');
        } else {
            form.append('playlist[sharing]', options.sharing);
        }
        if (!options.oauth_token) {
            return reject('Error while addTrackToNewPlaylist options.oauth_token is null');
        } else {
            form.append('oauth_token', options.oauth_token);
        }

        form.getLength(function (err, length) {

            fetch(`https://api.soundcloud.com/playlists?oauth_token=${options.oauth_token}`, {
                method: 'POST',
                body: form,
                headers: {'content-length': length}
            }).then(function (res) {

                if (res.status === 201) {
                    if (DEBUG_MODE_ON) {
                        console.log(`INFO: addTrackToNewPlaylist, OK -> ${res.statusCode}.`);
                    }
                    return res.json();
                } else {
                    return null;
                }
            }).then(function (json) {
                if (!json) {
                    reject();
                } else {
                    if (DEBUG_MODE_ON) {
                        console.log('INFO: addTrack successful');
                    }
                    resolve(json);
                }
            }).catch(function (e) {
                reject(e);
            });

        });
    });
}
678475
function(pool) {
    const conn = new Connection(options.connOptions);
    return conn
      .connect()
      .then(() => {
        if (pool.closed) {
          conn
            .end()
            .then(() => {})
            .catch(() => {});
          return Promise.reject(
            Errors.createError(
              'Cannot create new connection to pool, pool closed',
              true,
              null,
              '08S01',
              Errors.ER_ADD_CONNECTION_CLOSED_POOL,
              null
            )
          );
        }

        conn.releaseWithoutError = () => {
          conn.release().catch(() => {});
        };

        conn.forceEnd = conn.end;

        conn.release = () => {
          if (pool.closed) {
            pool._discardConnection(conn);
            return Promise.resolve();
          }
          if (options.noControlAfterUse) {
            pool._releaseConnection(conn);
            return Promise.resolve();
          }
          //if server permit it, reset the connection, or rollback only if not
          let revertFunction = conn.rollback;
          if (
            options.resetAfterUse &&
            ((conn.info.isMariaDB() && conn.info.hasMinVersion(10, 2, 4)) ||
              (!conn.info.isMariaDB() && conn.info.hasMinVersion(5, 7, 3)))
          ) {
            revertFunction = conn.reset;
          }

          return revertFunction()
            .then(() => {
              pool._releaseConnection(conn);
              return Promise.resolve();
            })
            .catch(err => {
              //uncertain connection state.
              // discard it
              pool._discardConnection(conn);
              return Promise.resolve();
            });
        };
        conn.end = conn.release;
        return Promise.resolve(conn);
      })
      .catch(err => {
        return Promise.reject(err);
      });
  }
188512
function OpenConnection(connection) {
    let base = new pg.Client({
        host: connection.Hostname || 'localhost',
        port: parseInt(connection.Port) || 5432,
        user: connection.Username,
        password: connection.Password,
        database: connection.Database
    });
    base.connect();
    return new PostgreSQL(base);
}
1154625
function provide() {
    if (console) console.warn('@provide is now deprecated. Use @connect instead');
    return composeWithContext(Array.prototype.slice.call(arguments))
}
334952
function connect()
    {
        if(scope._conn)
        {
            if(scope._conn.readyState === 1)
            {
                return;
            }
            scope._conn.close();
        }
        var url = (scope._redirectURL.length>0) ? scope._redirectURL : scope._url;

        scope._conn            = new WebSocket(url);
        scope._conn.binaryType = "arraybuffer";
        scope._conn.open       = onOpen;
        scope._conn.onerror    = onerror;
        scope._conn.onclose    = onClose;
        scope._conn.onmessage  = onMessage;
    }