baldrick-broth
Version:
Build automation tool and task runner
20 lines (19 loc) • 606 B
JavaScript
const keepAlphaNumeric = (title) => {
const azText = title.replace(/[^\dA-Za-z-]/g, ' ');
const singleSpace = azText.replace(/\s+/g, ' ').trim();
return singleSpace;
};
export const dasherizeTitle = (title) => {
const azText = keepAlphaNumeric(title);
return azText === ''
? 'empty-title'
: azText
.split(' ')
.map((t) => t.toLowerCase())
.join('-');
};
export const isStringArray = (value) => typeof value === 'object' &&
value !== null &&
Array.isArray(value) &&
value.length > 0 &&
typeof value.at(0) === 'string';