src/debug.js
/**
 * Colorize log arguments if enabled.
 *
 */
Colorize log arguments if enabled.
Colorize log arguments if enabled .
function formatBrowserArgs(args, config) {
  args[0] = (config.useColors ? '%c' : '') + config.namespace;
  if (!config.useColors) {
    return;
  }
  const c = 'color: ' + config.color;
  let index = 0;
  let lastC = 0;
  args[0].replace(/%[a-zA-Z%]/g, match => {
    if (match === '%%') {
      return;
    }
    index++;
    if (match === '%c') {
      lastC = index;
    }
  });
  args.splice(lastC, 0, c);
}
function formatBrowserArgs ( args , config ) { args [ 0 ] = ( config . useColors ? '%c' : '' ) + config . namespace ; if ( ! config . useColors ) { return ; } const c = 'color: ' + config . color ; let index = 0 ; let lastC = 0 ; args [ 0 ] . replace ( / %[a-zA-Z%] / g , match => { if ( match === '%%' ) { return ; } index ++ ; if ( match === '%c' ) { lastC = index ; } } ) ; args . splice ( lastC , 0 , c ) ; }
Colorize log arguments if enabled.
Colorize log arguments if enabled .
// The final "%c" is somewhat tricky, because there could be other // arguments passed either before or after the %c, so we need to // figure out the correct index to insert the CSS into // We only are interested in the *last* %c // (the user may have provided their own)