getFormatterOptionsText.js 384 B

12345678910111213141516171819
  1. 'use strict';
  2. const formatters = require('../formatters');
  3. /**
  4. * @param {{ useOr?: boolean }} [options={}]
  5. * @returns {string}
  6. */
  7. module.exports = function getFormatterOptionsText(options = {}) {
  8. let output = Object.keys(formatters)
  9. .map((name) => `"${name}"`)
  10. .join(', ');
  11. if (options.useOr) {
  12. output = output.replace(/, ([a-z"]+)$/u, ' or $1');
  13. }
  14. return output;
  15. };