@thisisagile/easy 11.2.9 → 11.3.1

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.
@@ -2,3 +2,6 @@ import { Json } from './Json';
2
2
  export declare type ArrayLike<T> = (T | T[])[];
3
3
  export declare const toArray: <T>(...items: ArrayLike<T>) => T[];
4
4
  export declare const toObject: <T>(key: keyof T, ...items: ArrayLike<T>) => Json;
5
+ export declare const array: {
6
+ merge: (first?: any[], second?: any[], firstKey?: string, secondKey?: string) => any[];
7
+ };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toObject = exports.toArray = void 0;
3
+ exports.array = exports.toObject = exports.toArray = void 0;
4
4
  const Is_1 = require("./Is");
5
5
  const toArray = (...items) => items.length > 1 ? items : (0, Is_1.isArray)(items[0]) ? items[0] : (0, Is_1.isDefined)(items[0]) ? [items[0]] : [];
6
6
  exports.toArray = toArray;
@@ -9,4 +9,10 @@ const toObject = (key, ...items) => (0, exports.toArray)(...items).reduce((o, i)
9
9
  return o;
10
10
  }, {});
11
11
  exports.toObject = toObject;
12
+ exports.array = {
13
+ merge: (first = [], second = [], firstKey = 'id', secondKey = 'id') => first.map(f => ({
14
+ ...f,
15
+ ...second.find(s => (0, Is_1.isDefined)(s[secondKey]) && (0, Is_1.isDefined)(f[firstKey]) && s[secondKey] === f[firstKey])
16
+ })),
17
+ };
12
18
  //# sourceMappingURL=Array.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Array.js","sourceRoot":"","sources":["../../src/types/Array.ts"],"names":[],"mappings":";;;AAAA,6BAA0C;AAKnC,MAAM,OAAO,GAAG,CAAI,GAAG,KAAmB,EAAO,EAAE,CACxD,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAE,KAAa,CAAC,CAAC,CAAC,IAAA,YAAO,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,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IACd,OAAO,CAAC,CAAC;AACX,CAAC,EAAE,EAAE,CAAC,CAAC;AAJI,QAAA,QAAQ,YAIZ;AAEI,QAAA,KAAK,GAAG;IACnB,KAAK,EAAE,CAAC,QAAe,EAAE,EAAE,SAAgB,EAAE,EAAE,QAAQ,GAAG,IAAI,EAAE,SAAS,GAAG,IAAI,EAAS,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAC1G,GAAG,CAAC;QACJ,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAA,cAAS,EAAC,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,IAAA,cAAS,EAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC;KACvG,CAAC,CAAC;CACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thisisagile/easy",
3
- "version": "11.2.9",
3
+ "version": "11.3.1",
4
4
  "description": "Straightforward library for building domain-driven microservice architectures",
5
5
  "author": "Sander Hoogendoorn",
6
6
  "license": "MIT",
@@ -31,7 +31,7 @@
31
31
  "access": "public"
32
32
  },
33
33
  "devDependencies": {
34
- "@thisisagile/easy-test": "11.2.9",
34
+ "@thisisagile/easy-test": "11.3.1",
35
35
  "@types/form-urlencoded": "^4.4.0",
36
36
  "@types/jsonwebtoken": "^8.5.8",
37
37
  "@types/luxon": "2.3.2",
@@ -11,3 +11,10 @@ export const toObject = <T>(key: keyof T, ...items: ArrayLike<T>): Json =>
11
11
  o[i[key]] = i;
12
12
  return o;
13
13
  }, {});
14
+
15
+ export const array = {
16
+ merge: (first: any[] = [], second: any[] = [], firstKey = 'id', secondKey = 'id'): any[] => first.map(f => ({
17
+ ...f,
18
+ ...second.find(s => isDefined(s[secondKey]) && isDefined(f[firstKey]) && s[secondKey] === f[firstKey])
19
+ })),
20
+ };