function processSVGData(config, info, data, output, input) {
  const startTime = Date.now();
  const prevFileSize = Buffer.byteLength(data, 'utf8');

  let result;
  try {
    result = optimize(data, { ...config, ...info });
  } catch (error) {
    if (error instanceof SvgoParserError) {
      console.error(colors.red(error.toString()));
      process.exit(1);
    } else {
      throw error;
    }
  }
  if (config.datauri) {
    result.data = encodeSVGDatauri(result.data, config.datauri);
  }
  const resultFileSize = Buffer.byteLength(result.data, 'utf8');
  const processingTime = Date.now() - startTime;

  return writeOutput(input, output, result.data).then(
    function () {
      if (!config.quiet && output != '-') {
        if (input) {
          console.log(`\n${path.basename(input)}:`);
        }
        printTimeInfo(processingTime);
        printProfitInfo(prevFileSize, resultFileSize);
      }
    },
    (error) =>
      Promise.reject(
        new Error(
          error.code === 'ENOTDIR'
            ? `Error: output '${output}' is not a directory.`
            : error,
        ),
      ),
  );
}
Optimize SVG data.

@param {any} config options
@param {?{ path: string }} info
@param {string} data SVG content to optimize
@param {string} output where to write optimized file
@param {any=} input input file name (being used if output is a directory)
@return {Promise<any>}