manga / utils.js
haaaaus's picture
Upload 17 files
0acf70a verified
raw
history blame contribute delete
571 Bytes
/**
* Format story name from ID
* @param {string} name
* @returns {string}
*/
function formatStoryName(name) {
if (!name) return '';
return name
.replace(/[-_]/g, ' ')
.replace(/\b\w/g, c => c.toUpperCase());
}
/**
* Natural sort comparator for strings containing numbers
* @param {string} a
* @param {string} b
* @returns {number}
*/
function naturalSort(a, b) {
return a.localeCompare(b, undefined, { numeric: true, sensitivity: 'base' });
}
module.exports = {
formatStoryName,
naturalSort
};