src/js/extensions/chart/chart.js
function detectDelimiter(code) {
  code = trimKeepingTabs(code);

  // chunk first max 10 lines to detect
  const chunk = code.split(REGEX_LINE_ENDING).slice(0, 10).join('\n');

  // calc delta for each delimiters
  // then pick a delimiter having the minimum value delta
  return DSV_DELIMITERS.map(delimiter => ({
    delimiter,
    delta: calcDSVDelta(chunk, delimiter)
  })).sort((a, b) => (
    a.delta - b.delta
  ))[0].delimiter;
}
function detectDelimiter(code) {
  code = trimKeepingTabs(code);

  // chunk first max 10 lines to detect
  const chunk = code.split(REGEX_LINE_ENDING).slice(0, 10).join('\n');

  // calc delta for each delimiters
  // then pick a delimiter having the minimum value delta
  return DSV_DELIMITERS.map(delimiter => ({
    delimiter,
    delta: calcDSVDelta(chunk, delimiter)
  })).sort((a, b) => (
    a.delta - b.delta
  ))[0].delimiter;
}
function detectDelimiter ( code ) { code = trimKeepingTabs ( code ) ; // chunk first max 10 lines to detect const chunk = code . split ( REGEX_LINE_ENDING ) . slice ( 0 , 10 ) . join ( '\n' ) ; // calc delta for each delimiters // then pick a delimiter having the minimum value delta return DSV_DELIMITERS . map ( delimiter => ( { delimiter , delta : calcDSVDelta ( chunk , delimiter ) } ) ) . sort ( ( a , b ) => ( a . delta - b . delta ) ) [ 0 ] . delimiter ; }
detect delimiter the comma, tab, regex
@param {string} code - code to detect delimiter
@returns {string|RegExp} - detected delimiter
@ignore
detect delimiter the comma tab regex