function mergeTokenGroups(results) {
  const tokens = [];
  const groups = [results.tokens, ...Object.values(results.groups)];
  // eslint-disable-next-line no-constant-condition
  while (true) {
    let firstGroupIndex = -1;
    let firstStartOffset = Infinity;
    for (let i = 0; i < groups.length; i++) {
      const token = groups[i][0];
      if (token && token.startOffset < firstStartOffset) {
        firstStartOffset = token.startOffset;
        firstGroupIndex = i;
      }
    }
    if (firstGroupIndex >= 0) {
      tokens.push(groups[firstGroupIndex].shift());
    } else {
      break;
    }
  }
  return { ...results, tokens, groups: {} };
}
// merges all token groups (e.x. whitespace, comments) into a single array of tokens
merges all token groups (e.x. whitespace, comments) into a single array of tokens
merges all token groups ( e . x . whitespace comments ) into a single array of tokens
function mergeTokenGroups(results) {
  const tokens = [];
  const groups = [results.tokens, ...Object.values(results.groups)];
  while (true) {
    let firstGroupIndex = -1;
    let firstStartOffset = Infinity;
    for (let i = 0; i < groups.length; i++) {
      const token = groups[i][0];
      if (token && token.startOffset < firstStartOffset) {
        firstStartOffset = token.startOffset;
        firstGroupIndex = i;
      }
    }
    if (firstGroupIndex >= 0) {
      tokens.push(groups[firstGroupIndex].shift());
    } else {
      break;
    }
  }
  return { ...results, tokens, groups: {} };
}
function mergeTokenGroups ( results ) { const tokens = [ ] ; const groups = [ results . tokens , ... Object . values ( results . groups ) ] ; while ( true ) { let firstGroupIndex = - 1 ; let firstStartOffset = Infinity ; for ( let i = 0 ; i < groups . length ; i ++ ) { const token = groups [ i ] [ 0 ] ; if ( token && token . startOffset < firstStartOffset ) { firstStartOffset = token . startOffset ; firstGroupIndex = i ; } } if ( firstGroupIndex >= 0 ) { tokens . push ( groups [ firstGroupIndex ] . shift ( ) ) ; } else { break ; } } return { ... results , tokens , groups : { } } ; }
merges all token groups (e.x.
merges all token groups ( e . x .
// eslint-disable-next-line no-constant-condition