@win2win/shared 1.0.142 → 1.0.143
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.
|
@@ -10,3 +10,6 @@ export declare function deserializeWithContextAndRun(stringFn?: string, context?
|
|
|
10
10
|
export declare function toCurrency(value: number, symbol?: string, options?: {
|
|
11
11
|
decimals: number;
|
|
12
12
|
}): string;
|
|
13
|
+
export declare function mergeObjects(target: Record<string, any>, source: Record<string, any>, options?: {
|
|
14
|
+
emptyValues?: any[];
|
|
15
|
+
}): Record<string, any>;
|
|
@@ -5,6 +5,7 @@ exports.deserializeAndRun = deserializeAndRun;
|
|
|
5
5
|
exports.deserializeWithContext = deserializeWithContext;
|
|
6
6
|
exports.deserializeWithContextAndRun = deserializeWithContextAndRun;
|
|
7
7
|
exports.toCurrency = toCurrency;
|
|
8
|
+
exports.mergeObjects = mergeObjects;
|
|
8
9
|
const lodash_1 = require("lodash");
|
|
9
10
|
// TODO: refactorizar para usar siempre invisible context, si se pasa
|
|
10
11
|
function deserialize(stringFn, options) {
|
|
@@ -56,11 +57,11 @@ function toCurrency(value, symbol = "EUR", options) {
|
|
|
56
57
|
}).format(value);
|
|
57
58
|
return formatted;
|
|
58
59
|
}
|
|
59
|
-
function
|
|
60
|
+
function mergeObjects(target, source, options) {
|
|
61
|
+
const emptyValues = [undefined, ...(options?.emptyValues || [])];
|
|
60
62
|
return (0, lodash_1.mergeWith)(target, source, (objValue, srcValue) => {
|
|
61
|
-
if ((
|
|
63
|
+
if (emptyValues.some((v) => srcValue === v))
|
|
62
64
|
return objValue;
|
|
63
|
-
}
|
|
64
65
|
return srcValue;
|
|
65
66
|
});
|
|
66
67
|
}
|
package/package.json
CHANGED