lib/pool-base.js
function(pool) {
    let toRemove = Math.max(1, pool.idleConnections() - opts.minimumIdle);
    while (toRemove > 0) {
      const conn = idleConnections.peek();
      --toRemove;
      if (conn && conn.lastUse + opts.idleTimeout * 1000 < Date.now()) {
        idleConnections.shift();
        conn.forceEnd().catch(err => {});
        conn.releaseWithoutError();
        continue;
      }
      break;
    }
    ensurePoolSize(pool);
  }
function(pool) {
    let toRemove = Math.max(1, pool.idleConnections() - opts.minimumIdle);
    while (toRemove > 0) {
      const conn = idleConnections.peek();
      --toRemove;
      if (conn && conn.lastUse + opts.idleTimeout * 1000 < Date.now()) {
        idleConnections.shift();
        conn.forceEnd().catch(err => {});
        conn.releaseWithoutError();
        continue;
      }
      break;
    }
    ensurePoolSize(pool);
  }
function ( pool ) { let toRemove = Math . max ( 1 , pool . idleConnections ( ) - opts . minimumIdle ) ; while ( toRemove > 0 ) { const conn = idleConnections . peek ( ) ; -- toRemove ; if ( conn && conn . lastUse + opts . idleTimeout * 1000 < Date . now ( ) ) { idleConnections . shift ( ) ; conn . forceEnd ( ) . catch ( err => { } ) ; conn . releaseWithoutError ( ) ; continue ; } break ; } ensurePoolSize ( pool ) ; }
Permit to remove idle connection if unused for some time.
@param pool  current pool
Permit to remove idle connection if unused for some time .