@symbo.ls/utils 0.0.8 → 0.0.9
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 +14 -1
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -22,8 +22,21 @@ export const copyStringToClipboard = str => {
|
|
|
22
22
|
document.body.removeChild(el)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export const
|
|
25
|
+
export const toCamelCase = str => {
|
|
26
26
|
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
|
|
27
27
|
return index === 0 ? word.toLowerCase() : word.toUpperCase()
|
|
28
28
|
}).replace(/\s+/g, '')
|
|
29
29
|
}
|
|
30
|
+
|
|
31
|
+
export const toTitleCase = str => {
|
|
32
|
+
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, word => word.toUpperCase()).replace(/\s+/g, '')
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const toDashCase = val => val
|
|
36
|
+
.replace(/[A-Z]/g, (match, offset) => (offset > 0 ? '-' : '') + match.toLowerCase())
|
|
37
|
+
.replace('.', '-')
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
export const toDescriptionCase = str => {
|
|
41
|
+
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, word => word.toUpperCase()).replace(/\s+/g, ' ')
|
|
42
|
+
}
|