@symbo.ls/utils 0.0.9 → 0.0.10
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/package.json +1 -1
- package/src/index.js +7 -4
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -28,9 +28,11 @@ export const toCamelCase = str => {
|
|
|
28
28
|
}).replace(/\s+/g, '')
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
export const toTitleCase = str =>
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
export const toTitleCase = str => str.replace(
|
|
32
|
+
/\w\S*/g, txt => {
|
|
33
|
+
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase()
|
|
34
|
+
}
|
|
35
|
+
)
|
|
34
36
|
|
|
35
37
|
export const toDashCase = val => val
|
|
36
38
|
.replace(/[A-Z]/g, (match, offset) => (offset > 0 ? '-' : '') + match.toLowerCase())
|
|
@@ -38,5 +40,6 @@ export const toDashCase = val => val
|
|
|
38
40
|
|
|
39
41
|
|
|
40
42
|
export const toDescriptionCase = str => {
|
|
41
|
-
|
|
43
|
+
const result = str.replace(/([A-Z])/g, " $1")
|
|
44
|
+
return result.charAt(0).toUpperCase() + result.slice(1)
|
|
42
45
|
}
|