@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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +7 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/utils",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "",
5
5
  "source": "src/index.js",
6
6
  "main": "src/index.js",
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
- return str.replace(/(?:^\w|[A-Z]|\b\w)/g, word => word.toUpperCase()).replace(/\s+/g, '')
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
- return str.replace(/(?:^\w|[A-Z]|\b\w)/g, word => word.toUpperCase()).replace(/\s+/g, ' ')
43
+ const result = str.replace(/([A-Z])/g, " $1")
44
+ return result.charAt(0).toUpperCase() + result.slice(1)
42
45
  }