cafe-utility 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +15 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -652,6 +652,19 @@ const camelToTitle = string => capitalize(string.replace(/([A-Z])/g, ' $1'))
|
|
|
652
652
|
|
|
653
653
|
const slugToTitle = string => string.split('-').map(capitalize).join(' ')
|
|
654
654
|
|
|
655
|
+
const joinHumanly = (parts, separator = ', ', lastSeparator = ' and ') => {
|
|
656
|
+
if (!parts || !parts.length) {
|
|
657
|
+
return null
|
|
658
|
+
}
|
|
659
|
+
if (parts.length === 1) {
|
|
660
|
+
return parts[0]
|
|
661
|
+
}
|
|
662
|
+
if (parts.length === 2) {
|
|
663
|
+
return `${parts[0]}${lastSeparator}${parts[1]}`
|
|
664
|
+
}
|
|
665
|
+
return `${parts.slice(0, parts.length - 1).join(separator)}${lastSeparator}${parts[parts.length - 1]}`
|
|
666
|
+
}
|
|
667
|
+
|
|
655
668
|
const surroundInOut = (string, filler) => filler + string.split('').join(filler) + filler
|
|
656
669
|
|
|
657
670
|
const enumify = string => slugify(string).replace(/-/g, '_').toUpperCase()
|
|
@@ -1589,7 +1602,8 @@ module.exports = {
|
|
|
1589
1602
|
normalizeFilename,
|
|
1590
1603
|
parseFilename,
|
|
1591
1604
|
camelToTitle,
|
|
1592
|
-
slugToTitle
|
|
1605
|
+
slugToTitle,
|
|
1606
|
+
joinHumanly
|
|
1593
1607
|
},
|
|
1594
1608
|
Assertions: {
|
|
1595
1609
|
asEqual,
|