generator-begcode
Version:
Spring Boot + Angular/React/Vue in one handy generator
18 lines (17 loc) • 535 B
JavaScript
export { formatComment };
export default function formatComment(comment) {
if (!comment) {
return undefined;
}
const parts = comment.trim().split('\n');
if (parts.length === 1 && parts[0].indexOf('*') !== 0) {
return parts[0];
}
return parts.reduce((previousValue, currentValue) => {
let delimiter = '';
if (previousValue !== '') {
delimiter = '\\n';
}
return previousValue.concat(delimiter, currentValue.trim().replace(/[*]*\s*/, ''));
}, '');
}