with-banner.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // @ts-check
  2. /**
  3. * @param {string} title
  4. * @param {string[]} description
  5. * @param {Date} date
  6. * @param {string[]} content
  7. * @returns {string}
  8. */
  9. // const withBanner = (title, description, date, content) => {
  10. // return `########################################
  11. // # ${title}
  12. // # Last Updated: ${date.toISOString()}
  13. // # Size: ${content.length}
  14. // ${description.map(line => (line ? `# ${line}` : '#')).join('\n')}
  15. // ########################################\n${content.join('\n')}\n################# END ###################\n`;
  16. // };
  17. // module.exports.withBanner = withBanner;
  18. /**
  19. * @param {string} title
  20. * @param {string[]} description
  21. * @param {Date} date
  22. * @param {string[]} content
  23. * @returns {string[]}
  24. */
  25. const withBannerArray = (title, description, date, content) => {
  26. return [
  27. '########################################',
  28. `# ${title}`,
  29. `# Last Updated: ${date.toISOString()}`,
  30. `# Size: ${content.length}`,
  31. ...description.map(line => (line ? `# ${line}` : '#')),
  32. '########################################',
  33. ...content,
  34. '################# END ###################',
  35. ''
  36. ];
  37. };
  38. module.exports.withBannerArray = withBannerArray;