@win2win/shared 1.0.162 → 1.0.163
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.
|
@@ -21,3 +21,13 @@ export declare function toCurrency(value: number, symbol?: string, options?: {
|
|
|
21
21
|
* @returns
|
|
22
22
|
*/
|
|
23
23
|
export declare function mergeObjects<T = Record<string, any>>(...args: (Record<string, any> | undefined | null | "")[]): T;
|
|
24
|
+
export declare function capitalize(text: string, allWords?: boolean): string;
|
|
25
|
+
export declare function formatContactName(contact?: {
|
|
26
|
+
NOMBRE?: string | null;
|
|
27
|
+
APELLIDO?: string | null;
|
|
28
|
+
APELLIDO2?: string | null;
|
|
29
|
+
} | {
|
|
30
|
+
nombre?: string | null;
|
|
31
|
+
apellido: string | null;
|
|
32
|
+
apellido2: string | null;
|
|
33
|
+
} | null): string;
|
|
@@ -8,6 +8,8 @@ exports.tryToDeserialize = tryToDeserialize;
|
|
|
8
8
|
exports.tryToDeserializeAndRun = tryToDeserializeAndRun;
|
|
9
9
|
exports.toCurrency = toCurrency;
|
|
10
10
|
exports.mergeObjects = mergeObjects;
|
|
11
|
+
exports.capitalize = capitalize;
|
|
12
|
+
exports.formatContactName = formatContactName;
|
|
11
13
|
const lodash_1 = require("lodash");
|
|
12
14
|
const validators_1 = require("./validators");
|
|
13
15
|
// TODO: refactorizar para usar siempre invisible context, si se pasa
|
|
@@ -100,3 +102,21 @@ function mergeObjects(...args) {
|
|
|
100
102
|
});
|
|
101
103
|
}, {});
|
|
102
104
|
}
|
|
105
|
+
const formatOneWord = (word) => word.charAt(0).toUpperCase() + word.slice(1);
|
|
106
|
+
function capitalize(text, allWords = false) {
|
|
107
|
+
if (typeof text !== "string")
|
|
108
|
+
return text;
|
|
109
|
+
text = text.toLowerCase().replaceAll("_", " ").trim();
|
|
110
|
+
return allWords
|
|
111
|
+
? text.split(" ").map(formatOneWord).join(" ")
|
|
112
|
+
: formatOneWord(text);
|
|
113
|
+
}
|
|
114
|
+
function formatContactName(contact) {
|
|
115
|
+
if (!contact)
|
|
116
|
+
return "";
|
|
117
|
+
const { nombre, apellido, apellido2 } = (0, lodash_1.mapKeys)(contact, (v, k) => k.toLowerCase());
|
|
118
|
+
return capitalize([nombre, apellido, apellido2]
|
|
119
|
+
.map((v) => (v || "").trim())
|
|
120
|
+
.filter(Boolean)
|
|
121
|
+
.join(" "), true).trim();
|
|
122
|
+
}
|
package/package.json
CHANGED