0c10d32af6ea0480adfae6d7a60ca08ce2cdd615f21d02d36ee05e3a87e9e4c1fae67999047ee92b77349811b550128ffc8cf6ad28d3af3e59206a2589113f 523 B

123456789101112131415161718
  1. 'use strict';
  2. /**
  3. * Applies formatters to all AnnotatedErrors.
  4. *
  5. * A formatter has the following signature: FormattedError => Array<String>.
  6. * It takes a formatted error produced by a transformer and returns a list
  7. * of log statements to print.
  8. *
  9. */
  10. function formatErrors(errors, formatters, errorType) {
  11. const format = (formatter) => formatter(errors, errorType) || [];
  12. const flatten = (accum, curr) => accum.concat(curr);
  13. return formatters.map(format).reduce(flatten, [])
  14. }
  15. module.exports = formatErrors;