@win2win/shared 1.0.141 → 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 mergeData(target, source) {
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 ((0, lodash_1.isNil)(srcValue)) {
63
+ if (emptyValues.some((v) => srcValue === v))
62
64
  return objValue;
63
- }
64
65
  return srcValue;
65
66
  });
66
67
  }
@@ -38,5 +38,5 @@ export interface StrictQueryParams {
38
38
  }
39
39
  export type QueryParams = Partial<StrictQueryParams>;
40
40
  export type PaginationQueryParams = Pick<QueryParams, 'startRow' | 'fetchCount' | 'sortBy' | 'descending'>;
41
- export type FilterQueryParams = Omit<QueryParams, keyof PaginationQueryParams | 'counters'>;
41
+ export type FilterQueryParams = Omit<QueryParams, keyof PaginationQueryParams>;
42
42
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@win2win/shared",
3
- "version": "1.0.141",
3
+ "version": "1.0.143",
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",