@win2win/shared 1.0.143 → 1.0.145

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,6 +10,11 @@ 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>;
13
+ /**
14
+ *
15
+ * Merges multiple objects into one, ignoring properties with values that match the specified empty values.
16
+ * @param args - Objects to merge. The last argument can be an options object.
17
+ * @param options.emptyValues - Array of values that should be ignored when merging objects (default: `undefined`)
18
+ * @returns
19
+ */
20
+ export declare function mergeObjects(...args: Record<string, any>[]): Record<string, any>;
@@ -57,11 +57,27 @@ function toCurrency(value, symbol = "EUR", options) {
57
57
  }).format(value);
58
58
  return formatted;
59
59
  }
60
- function mergeObjects(target, source, options) {
60
+ /**
61
+ *
62
+ * Merges multiple objects into one, ignoring properties with values that match the specified empty values.
63
+ * @param args - Objects to merge. The last argument can be an options object.
64
+ * @param options.emptyValues - Array of values that should be ignored when merging objects (default: `undefined`)
65
+ * @returns
66
+ */
67
+ function mergeObjects(...args) {
68
+ const lastArg = args[args.length - 1];
69
+ const options = lastArg &&
70
+ !Array.isArray(lastArg) &&
71
+ typeof lastArg === "object" &&
72
+ "emptyValues" in lastArg
73
+ ? args.pop()
74
+ : undefined;
61
75
  const emptyValues = [undefined, ...(options?.emptyValues || [])];
62
- return (0, lodash_1.mergeWith)(target, source, (objValue, srcValue) => {
63
- if (emptyValues.some((v) => srcValue === v))
64
- return objValue;
65
- return srcValue;
66
- });
76
+ return args.reduce((acc, obj) => {
77
+ return (0, lodash_1.mergeWith)(acc, obj, (objValue, srcValue) => {
78
+ if (emptyValues.some((v) => srcValue === v))
79
+ return objValue;
80
+ return srcValue;
81
+ });
82
+ }, {});
67
83
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@win2win/shared",
3
- "version": "1.0.143",
3
+ "version": "1.0.145",
4
4
  "description": "Tipos, interfaces, funciones, constantes, clases y enums compartidos por todos los proyectos de Win2Win",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",