@8ms/helpers 1.3.31 → 1.3.33
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/string/getProperCase.d.ts +7 -3
- package/string/getProperCase.js +14 -3
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
type GetProperCase = {
|
|
2
|
+
input: any;
|
|
3
|
+
hyphen?: boolean;
|
|
4
|
+
pipe?: boolean;
|
|
5
|
+
underscore?: boolean;
|
|
6
|
+
};
|
|
1
7
|
/**
|
|
2
8
|
* Return a string "With Proper Casing".
|
|
3
9
|
*/
|
|
4
|
-
declare const getProperCase: (
|
|
5
|
-
input: any;
|
|
6
|
-
}) => string;
|
|
10
|
+
declare const getProperCase: (props: GetProperCase) => string;
|
|
7
11
|
export default getProperCase;
|
package/string/getProperCase.js
CHANGED
|
@@ -7,9 +7,20 @@ const getString_1 = __importDefault(require("./getString"));
|
|
|
7
7
|
/**
|
|
8
8
|
* Return a string "With Proper Casing".
|
|
9
9
|
*/
|
|
10
|
-
const getProperCase = (
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const getProperCase = (props) => {
|
|
11
|
+
let string = (0, getString_1.default)({
|
|
12
|
+
input: props.input,
|
|
13
|
+
});
|
|
14
|
+
if (props?.hyphen) {
|
|
15
|
+
string = string.split(/-/g).join(' ');
|
|
16
|
+
}
|
|
17
|
+
if (props?.pipe) {
|
|
18
|
+
string = string.split(/\|/g).join(' ');
|
|
19
|
+
}
|
|
20
|
+
if (props?.underscore) {
|
|
21
|
+
string = string.split(/_/g).join(' ');
|
|
22
|
+
}
|
|
23
|
+
return string.replace(/\w\S*/g, word => word.charAt(0)
|
|
13
24
|
.toUpperCase() + word.substr(1)
|
|
14
25
|
.toLowerCase());
|
|
15
26
|
};
|