-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
43 lines (35 loc) · 1.11 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// CAPITALIZE
module.exports.capAll = function (string) {
return string.toUpperCase();
}
module.exports.capFirstWord = function (string) {
return string.charAt(0).toUpperCase() + string.substring(1);
}
module.exports.capWords = function (string) {
return string.replace(/(^|[^a-zA-Z\u00C0-\u017F'])([a-zA-Z\u00C0-\u017F])/g, function (m) {
return m.toUpperCase();
});
}
module.exports.capCamelize = function (string) {
var camelize = string.replace(/\W+(.)/g, function(m, chr) {
return chr.toUpperCase();
});
return camelize.charAt(0).toUpperCase() + camelize.substring(1);
}
// TO LOWER CASE
module.exports.lowAll = function (string) {
return string.toLowerCase();
}
module.exports.lowFirstWord = function (string) {
return string.charAt(0).toLowerCase() + string.substring(1);
}
module.exports.lowWords = function (string) {
return string.replace(/(^|[^a-zA-Z\u00C0-\u017F'])([a-zA-Z\u00C0-\u017F])/g, function (m) {
return m.toLowerCase();
});
}
module.exports.lowCamelize = function (string) {
return string.replace(/\W+(.)/g, function(m, chr) {
return chr.toUpperCase();
});
}