@allgemein/base 1.6.5 → 1.6.6

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allgemein/base",
3
- "version": "1.6.5",
3
+ "version": "1.6.6",
4
4
  "description": "Library for commons moduls.",
5
5
  "main": "./index.js",
6
6
  "private": false,
@@ -63,7 +63,7 @@ class ArrayUtils {
63
63
  const sourceArray = parent.length === 0 ? source : (0, lodash_1.get)(source, parentLocation, undefined);
64
64
  if ((0, lodash_1.isArray)(sourceArray)) {
65
65
  // source array exists check if value present
66
- const exists = sourceArray.find((y) => (0, lodash_1.isEqual)(x, x.value));
66
+ const exists = sourceArray.find((y) => (0, lodash_1.isEqual)(y, x.value));
67
67
  if (!exists) {
68
68
  // add missing value
69
69
  const position = sourceArray.length;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/ArrayUtils.ts"],"names":[],"mappings":";;;AAAA,2CAAkD;AAClD,mCAAsG;AAWtG,MAAa,UAAU;IAErB,MAAM,CAAC,KAAK,CAAC,MAAW,EAAE,IAAS;QACjC,MAAM,OAAO,GAAmB,EAAE,CAAC;QACnC,qBAAS,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAa,EAAE,EAAE;YACrC,mBAAmB;YACnB,MAAM,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAEtC,IAAI,CAAC,CAAC,MAAM,EAAE;gBACZ,0BAA0B;gBAC1B,IAAI,IAAA,eAAM,EAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE;oBAC5B,cAAc;oBACd,MAAM,KAAK,GAAG,IAAA,YAAG,EAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;oBAC/C,IAAI,IAAA,oBAAW,EAAC,KAAK,CAAC,EAAE;wBACtB,+BAA+B;wBAC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AW,CAAC,EAAE;YACnC,wDAAwD;YACxD,IAAA,YAAG,EAAC,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;YACvC,OAAO,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,aAAa,EAAE,GAAG,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAC,CAAC,CAAC;SACvF;aAAM,IAAI,IAAA,qBAAY,EAAC,WAAW,CAAC,EAAE;YACpC,wCAAwC;YACxC,mCAAmC;YACnC,MAAM,IAAI,KAAK,CAAC,iFAAiF,GAAG,cAAc,GAAG,GAAG,CAAC,CAAC;SAC3H;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,uEAAuE,GAAG,cAAc,GAAG,GAAG,CAAC,CAAC;SACjH;IAEH,CAAC;CACF;AA9ED,gCA8EC","file":"ArrayUtils.js","sourcesContent":["import {TreeUtils, WalkValues} from './TreeUtils';\nimport {clone, get, isArray, isEqual, isNull, isNumber, isObjectLike, isUndefined, set} from 'lodash';\n\nexport interface IMergeChange {\n type: 'missing' | 'value' | 'push' | 'create-push';\n key: string;\n src?: any;\n dst?: any;\n position?: number;\n value?: any;\n}\n\nexport class ArrayUtils {\n\n static merge(source: any, dest: any) {\n const changes: IMergeChange[] = [];\n TreeUtils.walk(dest, (x: WalkValues) => {\n // new sub-property\n const location = x.location.join('.');\n\n if (x.isLeaf) {\n // is leaf - check content\n if (isNull(x.index) && x.key) {\n // object path\n const value = get(source, location, undefined);\n if (isUndefined(value)) {\n // not exists, append to source\n set(source, location, x.value);\n changes.push({type: 'missing', key: location});\n } else {\n if (value !== x.value) {\n set(source, location, x.value);\n changes.push({type: 'value', key: location, src: value, dst: x.value});\n }\n }\n } else if (isNumber(x.index)) {\n // array element\n this.mergeHandleArray(source, x, changes);\n } else {\n throw new Error('no object or array node on leaf');\n }\n } else {\n // is branch - check structure\n if (isNull(x.index) && x.key) {\n // object path\n const value = get(source, location, undefined);\n if (isUndefined(value)) {\n // not exists, append to source\n set(source, location, x.value);\n changes.push({type: 'missing', key: location});\n }\n } else if (isNumber(x.index)) {\n this.mergeHandleArray(source, x, changes);\n } else {\n throw new Error('no object or array node on branch');\n }\n }\n });\n return changes;\n }\n\n\n private static mergeHandleArray(source: any, x: WalkValues, changes: IMergeChange[]) {\n // array element\n const parent = clone(x.location);\n parent.pop();\n const parentLocation = parent.join('.');\n const sourceArray = parent.length === 0 ? source : get(source, parentLocation, undefined);\n if (isArray(sourceArray)) {\n // source array exists check if value present\n const exists = sourceArray.find((y: any) => isEqual(x, x.value));\n if (!exists) {\n // add missing value\n const position = sourceArray.length;\n sourceArray.push(x.value);\n changes.push({type: 'push', key: parentLocation, position: position, value: x.value});\n }\n } else if (isUndefined(sourceArray)) {\n // source parent for appending structure is not the same\n set(source, parentLocation, [x.value]);\n changes.push({type: 'create-push', key: parentLocation, position: 0, value: x.value});\n } else if (isObjectLike(sourceArray)) {\n // source parent is an object like entry\n // todo replace this with the array\n throw new Error('structural inconsistencies: needed array to add value found object-like entry [' + parentLocation + ']');\n } else {\n throw new Error('structural inconsistencies: needed array to add value found unknown [' + parentLocation + ']');\n }\n\n }\n}\n"],"sourceRoot":".."}
1
+ {"version":3,"sources":["../../../src/utils/ArrayUtils.ts"],"names":[],"mappings":";;;AAAA,2CAAkD;AAClD,mCAAsG;AAWtG,MAAa,UAAU;IAErB,MAAM,CAAC,KAAK,CAAC,MAAW,EAAE,IAAS;QACjC,MAAM,OAAO,GAAmB,EAAE,CAAC;QACnC,qBAAS,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAa,EAAE,EAAE;YACrC,mBAAmB;YACnB,MAAM,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAEtC,IAAI,CAAC,CAAC,MAAM,EAAE;gBACZ,0BAA0B;gBAC1B,IAAI,IAAA,eAAM,EAAC,CAAC,CAAC,KAAK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AC;gBAC1B,OAAO,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAC,CAAC,CAAC;aACvF;SACF;aAAM,IAAI,IAAA,oBAAW,EAAC,WAAW,CAAC,EAAE;YACnC,wDAAwD;YACxD,IAAA,YAAG,EAAC,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;YACvC,OAAO,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,aAAa,EAAE,GAAG,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAC,CAAC,CAAC;SACvF;aAAM,IAAI,IAAA,qBAAY,EAAC,WAAW,CAAC,EAAE;YACpC,wCAAwC;YACxC,mCAAmC;YACnC,MAAM,IAAI,KAAK,CAAC,iFAAiF,GAAG,cAAc,GAAG,GAAG,CAAC,CAAC;SAC3H;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,uEAAuE,GAAG,cAAc,GAAG,GAAG,CAAC,CAAC;SACjH;IAEH,CAAC;CACF;AA9ED,gCA8EC","file":"ArrayUtils.js","sourcesContent":["import {TreeUtils, WalkValues} from './TreeUtils';\nimport {clone, get, isArray, isEqual, isNull, isNumber, isObjectLike, isUndefined, set} from 'lodash';\n\nexport interface IMergeChange {\n type: 'missing' | 'value' | 'push' | 'create-push';\n key: string;\n src?: any;\n dst?: any;\n position?: number;\n value?: any;\n}\n\nexport class ArrayUtils {\n\n static merge(source: any, dest: any) {\n const changes: IMergeChange[] = [];\n TreeUtils.walk(dest, (x: WalkValues) => {\n // new sub-property\n const location = x.location.join('.');\n\n if (x.isLeaf) {\n // is leaf - check content\n if (isNull(x.index) && x.key) {\n // object path\n const value = get(source, location, undefined);\n if (isUndefined(value)) {\n // not exists, append to source\n set(source, location, x.value);\n changes.push({type: 'missing', key: location});\n } else {\n if (value !== x.value) {\n set(source, location, x.value);\n changes.push({type: 'value', key: location, src: value, dst: x.value});\n }\n }\n } else if (isNumber(x.index)) {\n // array element\n this.mergeHandleArray(source, x, changes);\n } else {\n throw new Error('no object or array node on leaf');\n }\n } else {\n // is branch - check structure\n if (isNull(x.index) && x.key) {\n // object path\n const value = get(source, location, undefined);\n if (isUndefined(value)) {\n // not exists, append to source\n set(source, location, x.value);\n changes.push({type: 'missing', key: location});\n }\n } else if (isNumber(x.index)) {\n this.mergeHandleArray(source, x, changes);\n } else {\n throw new Error('no object or array node on branch');\n }\n }\n });\n return changes;\n }\n\n\n private static mergeHandleArray(source: any, x: WalkValues, changes: IMergeChange[]) {\n // array element\n const parent = clone(x.location);\n parent.pop();\n const parentLocation = parent.join('.');\n const sourceArray = parent.length === 0 ? source : get(source, parentLocation, undefined);\n if (isArray(sourceArray)) {\n // source array exists check if value present\n const exists = sourceArray.find((y: any) => isEqual(y, x.value));\n if (!exists) {\n // add missing value\n const position = sourceArray.length;\n sourceArray.push(x.value);\n changes.push({type: 'push', key: parentLocation, position: position, value: x.value});\n }\n } else if (isUndefined(sourceArray)) {\n // source parent for appending structure is not the same\n set(source, parentLocation, [x.value]);\n changes.push({type: 'create-push', key: parentLocation, position: 0, value: x.value});\n } else if (isObjectLike(sourceArray)) {\n // source parent is an object like entry\n // todo replace this with the array\n throw new Error('structural inconsistencies: needed array to add value found object-like entry [' + parentLocation + ']');\n } else {\n throw new Error('structural inconsistencies: needed array to add value found unknown [' + parentLocation + ']');\n }\n\n }\n}\n"],"sourceRoot":".."}