| /** | |
| * 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 | |
| }; | |