utils.js
/**
 * 
 * @param {SFE_Connection} connection 
 * @param {boolean} isTest
 *   Indicates if the connection is just to be tested and then immediately
 *   closed.
 * @param {function(Error, jsforce.UserInfo)} callback
 */
@param {SFE_Connection} connection
@param {boolean} isTest
Indicates if the connection is just to be tested and then immediately
closed.
@param { SFE_Connection } connection @param { boolean } isTest Indicates if the connection is just to be tested and then immediately closed .
function login(connection, isTest, callback) {
  const {username, password, token, loginUrl, uuid} = connection;
  const {jsforceConnsByUUID} = globalThis;
  if (uuid in jsforceConnsByUUID) {
    logout(connection, (err, res) => {
      login(connection, isTest, callback);
    });
  }
  else {
    const jsforceConn = new jsforce.Connection({ loginUrl });
    jsforceConn.login(
      username,
      password + [token],
      (err, res) => {
        if (!err && !isTest) {
          globalThis.jsforceConnsByUUID[uuid] = jsforceConn;
        }
        callback(err, res);
      }
    );
  }
}
function login ( connection , isTest , callback ) { const { username , password , token , loginUrl , uuid } = connection ; const { jsforceConnsByUUID } = globalThis ; if ( uuid in jsforceConnsByUUID ) { logout ( connection , ( err , res ) => { login ( connection , isTest , callback ) ; } ) ; } else { const jsforceConn = new jsforce . Connection ( { loginUrl } ) ; jsforceConn . login ( username , password + [ token ] , ( err , res ) => { if ( ! err && ! isTest ) { globalThis . jsforceConnsByUUID [ uuid ] = jsforceConn ; } callback ( err , res ) ; } ) ; } }
@param {SFE_Connection} connection
 @param {boolean} isTest
   Indicates if the connection is just to be tested and then immediately
   closed.
@param { SFE_Connection } connection @param { boolean } isTest Indicates if the connection is just to be tested and then immediately closed .
// Concatenated string with an array to force token to be a string even if // is null:  'Hello' + [null] === 'Hello'