lib/compiler/tokens.js
function splitArgs(str) {
  const out = [];

  let inString = false;
  let currentArg = '';

  for (let index = 0; index < str.length; index += 1) {
    const c = str[index];
    if (c === ',' && !inString) {
      out.push(currentArg.trim());
      currentArg = '';
    } else if (currentArg.length === 0 && c === '"' && !inString) {
      currentArg += c;
      inString = true;
    } else if (inString && c === '"' && str[index - 1] !== '\\') {
      currentArg += c;
      inString = false;
    } else if (!(c === ' ' && currentArg.length === 0)) {
      currentArg += c;
    }
  }
  out.push(currentArg.trim());

  return out;
}
function splitArgs(str) {
  const out = [];

  let inString = false;
  let currentArg = '';

  for (let index = 0; index < str.length; index += 1) {
    const c = str[index];
    if (c === ',' && !inString) {
      out.push(currentArg.trim());
      currentArg = '';
    } else if (currentArg.length === 0 && c === '"' && !inString) {
      currentArg += c;
      inString = true;
    } else if (inString && c === '"' && str[index - 1] !== '\\') {
      currentArg += c;
      inString = false;
    } else if (!(c === ' ' && currentArg.length === 0)) {
      currentArg += c;
    }
  }
  out.push(currentArg.trim());

  return out;
}
function splitArgs ( str ) { const out = [ ] ; let inString = false ; let currentArg = '' ; for ( let index = 0 ; index < str . length ; index += 1 ) { const c = str [ index ] ; if ( c === ',' && ! inString ) { out . push ( currentArg . trim ( ) ) ; currentArg = '' ; } else if ( currentArg . length === 0 && c === '"' && ! inString ) { currentArg += c ; inString = true ; } else if ( inString && c === '"' && str [ index - 1 ] !== '\\' ) { currentArg += c ; inString = false ; } else if ( ! ( c === ' ' && currentArg . length === 0 ) ) { currentArg += c ; } } out . push ( currentArg . trim ( ) ) ; return out ; }
Split on commas, but ignore commas inside strings
@param {string} str
Split on commas but ignore commas inside strings