@openforis/arena-core 2.18.17 → 2.18.19

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.
@@ -1,10 +1,13 @@
1
1
  import { PointFactory } from '../pointFactory';
2
- const POINT_REGEX = /SRID=((EPSG:)?(\w+));POINT\((-?\d+(\.\d+)?) (-?\d+(\.\d+)?)\)/;
2
+ // coordinates can be in exponent notation (e.g. 1e-7), as generated by Number.toString or by PostgreSQL for very small or big numbers
3
+ const NUMBER_PATTERN = String.raw `-?\d+(?:\.\d+)?(?:[eE][-+]?\d+)?`;
4
+ const POINT_REGEX = new RegExp(String.raw `SRID=((EPSG:)?(\w+));POINT\((${NUMBER_PATTERN}) (${NUMBER_PATTERN})\)`);
3
5
  /**
4
6
  * Parses a point in the format: SRID=SRS_CODE;POINT(X Y)
5
7
  * (X and Y separated by a space). Valid examples are:
6
8
  * - SRID=EPSG:4326;POINT(12.489060 41.882788)
7
- * - SRID=4326;POINT(12 41).
9
+ * - SRID=4326;POINT(12 41)
10
+ * - SRID=4326;POINT(1e-7 41).
8
11
  *
9
12
  * @param {!(string | object)} value - The point to parse. It can be a string or an object.
10
13
  * @returns {Point} - The parsed Point object.
@@ -20,7 +23,7 @@ export const parse = (value) => {
20
23
  return null;
21
24
  const srs = match[3];
22
25
  const x = Number(match[4]);
23
- const y = Number(match[6]);
26
+ const y = Number(match[5]);
24
27
  return PointFactory.createInstance({ srs, x, y });
25
28
  }
26
29
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../../src/geo/points/parse.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C,MAAM,WAAW,GAAG,+DAA+D,CAAA;AAEnF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,KAAsB,EAAgB,EAAE;IAC5D,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAA;IAEvB,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAc,CAAA;IAEpD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACrC,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAA;QAEvB,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;QACpB,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;QAC1B,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;QAC1B,OAAO,YAAY,CAAC,cAAc,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;IACnD,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA","sourcesContent":["import { Point } from '../point'\nimport { PointFactory } from '../pointFactory'\n\nconst POINT_REGEX = /SRID=((EPSG:)?(\\w+));POINT\\((-?\\d+(\\.\\d+)?) (-?\\d+(\\.\\d+)?)\\)/\n\n/**\n * Parses a point in the format: SRID=SRS_CODE;POINT(X Y)\n * (X and Y separated by a space). Valid examples are:\n * - SRID=EPSG:4326;POINT(12.489060 41.882788)\n * - SRID=4326;POINT(12 41).\n *\n * @param {!(string | object)} value - The point to parse. It can be a string or an object.\n * @returns {Point} - The parsed Point object.\n */\nexport const parse = (value: string | object): Point | null => {\n if (!value) return null\n\n if (typeof value === 'object') return value as Point\n\n if (typeof value === 'string') {\n const match = POINT_REGEX.exec(value)\n if (!match) return null\n\n const srs = match[3]\n const x = Number(match[4])\n const y = Number(match[6])\n return PointFactory.createInstance({ srs, x, y })\n }\n return null\n}\n"]}
1
+ {"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../../src/geo/points/parse.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE9C,sIAAsI;AACtI,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAA,kCAAkC,CAAA;AACnE,MAAM,WAAW,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAA,gCAAgC,cAAc,MAAM,cAAc,KAAK,CAAC,CAAA;AAEjH;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,KAAsB,EAAgB,EAAE;IAC5D,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAA;IAEvB,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAc,CAAA;IAEpD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACrC,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAA;QAEvB,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;QACpB,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;QAC1B,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;QAC1B,OAAO,YAAY,CAAC,cAAc,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;IACnD,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA","sourcesContent":["import { Point } from '../point'\nimport { PointFactory } from '../pointFactory'\n\n// coordinates can be in exponent notation (e.g. 1e-7), as generated by Number.toString or by PostgreSQL for very small or big numbers\nconst NUMBER_PATTERN = String.raw`-?\\d+(?:\\.\\d+)?(?:[eE][-+]?\\d+)?`\nconst POINT_REGEX = new RegExp(String.raw`SRID=((EPSG:)?(\\w+));POINT\\((${NUMBER_PATTERN}) (${NUMBER_PATTERN})\\)`)\n\n/**\n * Parses a point in the format: SRID=SRS_CODE;POINT(X Y)\n * (X and Y separated by a space). Valid examples are:\n * - SRID=EPSG:4326;POINT(12.489060 41.882788)\n * - SRID=4326;POINT(12 41)\n * - SRID=4326;POINT(1e-7 41).\n *\n * @param {!(string | object)} value - The point to parse. It can be a string or an object.\n * @returns {Point} - The parsed Point object.\n */\nexport const parse = (value: string | object): Point | null => {\n if (!value) return null\n\n if (typeof value === 'object') return value as Point\n\n if (typeof value === 'string') {\n const match = POINT_REGEX.exec(value)\n if (!match) return null\n\n const srs = match[3]\n const x = Number(match[4])\n const y = Number(match[5])\n return PointFactory.createInstance({ srs, x, y })\n }\n return null\n}\n"]}
@@ -1,6 +1,7 @@
1
+ import { shallowCopy } from './shallowCopy';
1
2
  const _assocPath = (obj, path, pathIndex, value, sideEffect) => {
2
3
  // only one copy per path level (when sideEffect is false)
3
- const objUpdated = sideEffect ? obj : Object.assign({}, obj);
4
+ const objUpdated = sideEffect ? obj : shallowCopy(obj);
4
5
  if (pathIndex >= path.length)
5
6
  return objUpdated;
6
7
  const pathPart = path[pathIndex];
@@ -1 +1 @@
1
- {"version":3,"file":"assocPath.js","sourceRoot":"","sources":["../../../../src/utils/_objects/assocPath.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,GAAG,CAAC,GAAQ,EAAE,IAAc,EAAE,SAAiB,EAAE,KAAU,EAAE,UAAmB,EAAO,EAAE;IACvG,0DAA0D;IAC1D,MAAM,UAAU,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,mBAAM,GAAG,CAAE,CAAA;IAChD,IAAI,SAAS,IAAI,IAAI,CAAC,MAAM;QAAE,OAAO,UAAU,CAAA;IAE/C,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,CAAA;IAChC,UAAU,CAAC,QAAQ,CAAC;QAClB,SAAS,KAAK,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAG,QAAQ,CAAC,KAAI,EAAE,EAAE,IAAI,EAAE,SAAS,GAAG,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAA;IACnH,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAmB,MAK3C,EAAK,EAAE;IACN,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,GAAG,KAAK,EAAE,GAAG,MAAM,CAAA;IACvD,OAAO,UAAU,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAA;AACpD,CAAC,CAAA","sourcesContent":["const _assocPath = (obj: any, path: string[], pathIndex: number, value: any, sideEffect: boolean): any => {\n // only one copy per path level (when sideEffect is false)\n const objUpdated = sideEffect ? obj : { ...obj }\n if (pathIndex >= path.length) return objUpdated\n\n const pathPart = path[pathIndex]\n objUpdated[pathPart] =\n pathIndex === path.length - 1 ? value : _assocPath(obj?.[pathPart] || {}, path, pathIndex + 1, value, sideEffect)\n return objUpdated\n}\n\n/**\n * Sets the value at the specified path, creating the missing intermediate objects.\n * Returns a copy of the object (with one copy per path level), or the object itself when sideEffect is true.\n */\nexport const assocPath = <T extends object>(params: {\n obj: T\n path: string[]\n value: unknown\n sideEffect?: boolean\n}): T => {\n const { obj, path, value, sideEffect = false } = params\n return _assocPath(obj, path, 0, value, sideEffect)\n}\n"]}
1
+ {"version":3,"file":"assocPath.js","sourceRoot":"","sources":["../../../../src/utils/_objects/assocPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C,MAAM,UAAU,GAAG,CAAC,GAAQ,EAAE,IAAc,EAAE,SAAiB,EAAE,KAAU,EAAE,UAAmB,EAAO,EAAE;IACvG,0DAA0D;IAC1D,MAAM,UAAU,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;IACtD,IAAI,SAAS,IAAI,IAAI,CAAC,MAAM;QAAE,OAAO,UAAU,CAAA;IAE/C,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,CAAA;IAChC,UAAU,CAAC,QAAQ,CAAC;QAClB,SAAS,KAAK,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAG,QAAQ,CAAC,KAAI,EAAE,EAAE,IAAI,EAAE,SAAS,GAAG,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAA;IACnH,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAmB,MAK3C,EAAK,EAAE;IACN,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,GAAG,KAAK,EAAE,GAAG,MAAM,CAAA;IACvD,OAAO,UAAU,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAA;AACpD,CAAC,CAAA","sourcesContent":["import { shallowCopy } from './shallowCopy'\n\nconst _assocPath = (obj: any, path: string[], pathIndex: number, value: any, sideEffect: boolean): any => {\n // only one copy per path level (when sideEffect is false)\n const objUpdated = sideEffect ? obj : shallowCopy(obj)\n if (pathIndex >= path.length) return objUpdated\n\n const pathPart = path[pathIndex]\n objUpdated[pathPart] =\n pathIndex === path.length - 1 ? value : _assocPath(obj?.[pathPart] || {}, path, pathIndex + 1, value, sideEffect)\n return objUpdated\n}\n\n/**\n * Sets the value at the specified path, creating the missing intermediate objects.\n * Returns a copy of the object (with one copy per path level), or the object itself when sideEffect is true.\n */\nexport const assocPath = <T extends object>(params: {\n obj: T\n path: string[]\n value: unknown\n sideEffect?: boolean\n}): T => {\n const { obj, path, value, sideEffect = false } = params\n return _assocPath(obj, path, 0, value, sideEffect)\n}\n"]}
@@ -1,7 +1,8 @@
1
1
  import { isEmpty } from './isEmpty';
2
+ import { shallowCopy } from './shallowCopy';
2
3
  export const dissocPath = (params) => {
3
4
  const { obj, path, sideEffect = false } = params;
4
- const objUpdated = sideEffect ? obj : Object.assign({}, obj);
5
+ const objUpdated = sideEffect ? obj : shallowCopy(obj);
5
6
  if (path.length === 0) {
6
7
  return objUpdated;
7
8
  }
@@ -1 +1 @@
1
- {"version":3,"file":"dissocPath.js","sourceRoot":"","sources":["../../../../src/utils/_objects/dissocPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAmB,MAAwD,EAAK,EAAE;IAC1G,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,GAAG,KAAK,EAAE,GAAG,MAAM,CAAA;IAChD,MAAM,UAAU,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,mBAAM,GAAG,CAAE,CAAA;IAEhD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,UAAU,CAAA;IACnB,CAAC;IAED,MAAM,CAAC,mBAAmB,EAAE,GAAG,cAAc,CAAC,GAAG,IAAI,CAAA;IACrD,MAAM,aAAa,GAAG,mBAA8C,CAAA;IAEpE,MAAM,OAAO,GAAQ,UAAU,CAAC,aAAa,CAAC,CAAA;IAE9C,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACpD,OAAO,UAAU,CAAC,aAAa,CAAC,CAAA;QAChC,OAAO,UAAU,CAAA;IACnB,CAAC;IAED,oEAAoE;IACpE,MAAM,cAAc,GAAG,UAAU,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,CAAC,CAAA;IAErF,IAAI,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;QAC5B,OAAO,UAAU,CAAC,aAAa,CAAC,CAAA;QAChC,OAAO,UAAU,CAAA;IACnB,CAAC;IAED,UAAU,CAAC,aAAa,CAAC,GAAG,cAAc,CAAA;IAC1C,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA","sourcesContent":["import { isEmpty } from './isEmpty'\n\nexport const dissocPath = <T extends object>(params: { obj: T; path: string[]; sideEffect?: boolean }): T => {\n const { obj, path, sideEffect = false } = params\n const objUpdated = sideEffect ? obj : { ...obj }\n\n if (path.length === 0) {\n return objUpdated\n }\n\n const [firstPathPartString, ...otherPathParts] = path\n const firstPathPart = firstPathPartString as keyof typeof objUpdated\n\n const objPart: any = objUpdated[firstPathPart]\n\n if (otherPathParts.length === 0 || isEmpty(objPart)) {\n delete objUpdated[firstPathPart]\n return objUpdated\n }\n\n // objPart is copied by dissocPath itself (when sideEffect is false)\n const objPartUpdated = dissocPath({ obj: objPart, path: otherPathParts, sideEffect })\n\n if (isEmpty(objPartUpdated)) {\n delete objUpdated[firstPathPart]\n return objUpdated\n }\n\n objUpdated[firstPathPart] = objPartUpdated\n return objUpdated\n}\n"]}
1
+ {"version":3,"file":"dissocPath.js","sourceRoot":"","sources":["../../../../src/utils/_objects/dissocPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C,MAAM,CAAC,MAAM,UAAU,GAAG,CAAmB,MAAwD,EAAK,EAAE;IAC1G,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,GAAG,KAAK,EAAE,GAAG,MAAM,CAAA;IAChD,MAAM,UAAU,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;IAEtD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,UAAU,CAAA;IACnB,CAAC;IAED,MAAM,CAAC,mBAAmB,EAAE,GAAG,cAAc,CAAC,GAAG,IAAI,CAAA;IACrD,MAAM,aAAa,GAAG,mBAA8C,CAAA;IAEpE,MAAM,OAAO,GAAQ,UAAU,CAAC,aAAa,CAAC,CAAA;IAE9C,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACpD,OAAO,UAAU,CAAC,aAAa,CAAC,CAAA;QAChC,OAAO,UAAU,CAAA;IACnB,CAAC;IAED,oEAAoE;IACpE,MAAM,cAAc,GAAG,UAAU,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,CAAC,CAAA;IAErF,IAAI,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;QAC5B,OAAO,UAAU,CAAC,aAAa,CAAC,CAAA;QAChC,OAAO,UAAU,CAAA;IACnB,CAAC;IAED,UAAU,CAAC,aAAa,CAAC,GAAG,cAAc,CAAA;IAC1C,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA","sourcesContent":["import { isEmpty } from './isEmpty'\nimport { shallowCopy } from './shallowCopy'\n\nexport const dissocPath = <T extends object>(params: { obj: T; path: string[]; sideEffect?: boolean }): T => {\n const { obj, path, sideEffect = false } = params\n const objUpdated = sideEffect ? obj : shallowCopy(obj)\n\n if (path.length === 0) {\n return objUpdated\n }\n\n const [firstPathPartString, ...otherPathParts] = path\n const firstPathPart = firstPathPartString as keyof typeof objUpdated\n\n const objPart: any = objUpdated[firstPathPart]\n\n if (otherPathParts.length === 0 || isEmpty(objPart)) {\n delete objUpdated[firstPathPart]\n return objUpdated\n }\n\n // objPart is copied by dissocPath itself (when sideEffect is false)\n const objPartUpdated = dissocPath({ obj: objPart, path: otherPathParts, sideEffect })\n\n if (isEmpty(objPartUpdated)) {\n delete objUpdated[firstPathPart]\n return objUpdated\n }\n\n objUpdated[firstPathPart] = objPartUpdated\n return objUpdated\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import { isEmpty } from './isEmpty';
2
2
  /**
3
- * Sets the value at the specified path in the object itself (side effect), creating the missing intermediate objects.
3
+ * Sets the value at the specified path in the object itself (side effect), creating the missing intermediate objects
4
+ * (null or non-object intermediate values are replaced with new objects).
4
5
  * When excludeEmpty is true, empty values are not set.
5
6
  */
6
7
  export const setInPath = (params) => {
@@ -12,7 +13,9 @@ export const setInPath = (params) => {
12
13
  objCurrent[pathPart] = value;
13
14
  }
14
15
  else {
15
- if (!Object.hasOwn(objCurrent, pathPart)) {
16
+ const valueCurrent = Object.hasOwn(objCurrent, pathPart) ? objCurrent[pathPart] : undefined;
17
+ if (valueCurrent === null || (typeof valueCurrent !== 'object' && typeof valueCurrent !== 'function')) {
18
+ // missing, null or primitive intermediate value: replace it with a new object
16
19
  objCurrent[pathPart] = {};
17
20
  }
18
21
  objCurrent = objCurrent[pathPart];
@@ -1 +1 @@
1
- {"version":3,"file":"setInPath.js","sourceRoot":"","sources":["../../../../src/utils/_objects/setInPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAmB,MAK3C,EAAK,EAAE;IACN,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,MAAM,CAAA;IACjD,IAAI,CAAC,YAAY,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACrC,IAAI,UAAU,GAAQ,GAAG,CAAA;QACzB,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE;YAC3B,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC1B,UAAU,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAA;YAC9B,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAE,CAAC;oBACzC,UAAU,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAA;gBAC3B,CAAC;gBACD,UAAU,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAA;YACnC,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA","sourcesContent":["import { isEmpty } from './isEmpty'\n\n/**\n * Sets the value at the specified path in the object itself (side effect), creating the missing intermediate objects.\n * When excludeEmpty is true, empty values are not set.\n */\nexport const setInPath = <T extends object>(params: {\n obj: T\n path: string[]\n value: unknown\n excludeEmpty?: boolean\n}): T => {\n const { obj, path, value, excludeEmpty } = params\n if (!excludeEmpty || !isEmpty(value)) {\n let objCurrent: any = obj\n path.forEach((pathPart, i) => {\n if (i === path.length - 1) {\n objCurrent[pathPart] = value\n } else {\n if (!Object.hasOwn(objCurrent, pathPart)) {\n objCurrent[pathPart] = {}\n }\n objCurrent = objCurrent[pathPart]\n }\n })\n }\n return obj\n}\n"]}
1
+ {"version":3,"file":"setInPath.js","sourceRoot":"","sources":["../../../../src/utils/_objects/setInPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAmB,MAK3C,EAAK,EAAE;IACN,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,MAAM,CAAA;IACjD,IAAI,CAAC,YAAY,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACrC,IAAI,UAAU,GAAQ,GAAG,CAAA;QACzB,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE;YAC3B,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC1B,UAAU,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAA;YAC9B,CAAC;iBAAM,CAAC;gBACN,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;gBAC3F,IAAI,YAAY,KAAK,IAAI,IAAI,CAAC,OAAO,YAAY,KAAK,QAAQ,IAAI,OAAO,YAAY,KAAK,UAAU,CAAC,EAAE,CAAC;oBACtG,8EAA8E;oBAC9E,UAAU,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAA;gBAC3B,CAAC;gBACD,UAAU,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAA;YACnC,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA","sourcesContent":["import { isEmpty } from './isEmpty'\n\n/**\n * Sets the value at the specified path in the object itself (side effect), creating the missing intermediate objects\n * (null or non-object intermediate values are replaced with new objects).\n * When excludeEmpty is true, empty values are not set.\n */\nexport const setInPath = <T extends object>(params: {\n obj: T\n path: string[]\n value: unknown\n excludeEmpty?: boolean\n}): T => {\n const { obj, path, value, excludeEmpty } = params\n if (!excludeEmpty || !isEmpty(value)) {\n let objCurrent: any = obj\n path.forEach((pathPart, i) => {\n if (i === path.length - 1) {\n objCurrent[pathPart] = value\n } else {\n const valueCurrent = Object.hasOwn(objCurrent, pathPart) ? objCurrent[pathPart] : undefined\n if (valueCurrent === null || (typeof valueCurrent !== 'object' && typeof valueCurrent !== 'function')) {\n // missing, null or primitive intermediate value: replace it with a new object\n objCurrent[pathPart] = {}\n }\n objCurrent = objCurrent[pathPart]\n }\n })\n }\n return obj\n}\n"]}
@@ -0,0 +1,3 @@
1
+ // arrays are copied as arrays
2
+ export const shallowCopy = (obj) => (Array.isArray(obj) ? [...obj] : Object.assign({}, obj));
3
+ //# sourceMappingURL=shallowCopy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shallowCopy.js","sourceRoot":"","sources":["../../../../src/utils/_objects/shallowCopy.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAC9B,MAAM,CAAC,MAAM,WAAW,GAAG,CAAmB,GAAM,EAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,mBAAM,GAAG,CAAE,CAAM,CAAA","sourcesContent":["// arrays are copied as arrays\nexport const shallowCopy = <T extends object>(obj: T): T => (Array.isArray(obj) ? [...obj] : { ...obj }) as T\n"]}
@@ -3,7 +3,8 @@ import { Point } from '../point';
3
3
  * Parses a point in the format: SRID=SRS_CODE;POINT(X Y)
4
4
  * (X and Y separated by a space). Valid examples are:
5
5
  * - SRID=EPSG:4326;POINT(12.489060 41.882788)
6
- * - SRID=4326;POINT(12 41).
6
+ * - SRID=4326;POINT(12 41)
7
+ * - SRID=4326;POINT(1e-7 41).
7
8
  *
8
9
  * @param {!(string | object)} value - The point to parse. It can be a string or an object.
9
10
  * @returns {Point} - The parsed Point object.
@@ -2,12 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parse = void 0;
4
4
  const pointFactory_1 = require("../pointFactory");
5
- const POINT_REGEX = /SRID=((EPSG:)?(\w+));POINT\((-?\d+(\.\d+)?) (-?\d+(\.\d+)?)\)/;
5
+ // coordinates can be in exponent notation (e.g. 1e-7), as generated by Number.toString or by PostgreSQL for very small or big numbers
6
+ const NUMBER_PATTERN = String.raw `-?\d+(?:\.\d+)?(?:[eE][-+]?\d+)?`;
7
+ const POINT_REGEX = new RegExp(String.raw `SRID=((EPSG:)?(\w+));POINT\((${NUMBER_PATTERN}) (${NUMBER_PATTERN})\)`);
6
8
  /**
7
9
  * Parses a point in the format: SRID=SRS_CODE;POINT(X Y)
8
10
  * (X and Y separated by a space). Valid examples are:
9
11
  * - SRID=EPSG:4326;POINT(12.489060 41.882788)
10
- * - SRID=4326;POINT(12 41).
12
+ * - SRID=4326;POINT(12 41)
13
+ * - SRID=4326;POINT(1e-7 41).
11
14
  *
12
15
  * @param {!(string | object)} value - The point to parse. It can be a string or an object.
13
16
  * @returns {Point} - The parsed Point object.
@@ -23,7 +26,7 @@ const parse = (value) => {
23
26
  return null;
24
27
  const srs = match[3];
25
28
  const x = Number(match[4]);
26
- const y = Number(match[6]);
29
+ const y = Number(match[5]);
27
30
  return pointFactory_1.PointFactory.createInstance({ srs, x, y });
28
31
  }
29
32
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../src/geo/points/parse.ts"],"names":[],"mappings":";;;AACA,kDAA8C;AAE9C,MAAM,WAAW,GAAG,+DAA+D,CAAA;AAEnF;;;;;;;;GAQG;AACI,MAAM,KAAK,GAAG,CAAC,KAAsB,EAAgB,EAAE;IAC5D,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAA;IAEvB,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAc,CAAA;IAEpD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACrC,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAA;QAEvB,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;QACpB,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;QAC1B,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;QAC1B,OAAO,2BAAY,CAAC,cAAc,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;IACnD,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAfY,QAAA,KAAK,GAAL,KAAK,CAejB","sourcesContent":["import { Point } from '../point'\nimport { PointFactory } from '../pointFactory'\n\nconst POINT_REGEX = /SRID=((EPSG:)?(\\w+));POINT\\((-?\\d+(\\.\\d+)?) (-?\\d+(\\.\\d+)?)\\)/\n\n/**\n * Parses a point in the format: SRID=SRS_CODE;POINT(X Y)\n * (X and Y separated by a space). Valid examples are:\n * - SRID=EPSG:4326;POINT(12.489060 41.882788)\n * - SRID=4326;POINT(12 41).\n *\n * @param {!(string | object)} value - The point to parse. It can be a string or an object.\n * @returns {Point} - The parsed Point object.\n */\nexport const parse = (value: string | object): Point | null => {\n if (!value) return null\n\n if (typeof value === 'object') return value as Point\n\n if (typeof value === 'string') {\n const match = POINT_REGEX.exec(value)\n if (!match) return null\n\n const srs = match[3]\n const x = Number(match[4])\n const y = Number(match[6])\n return PointFactory.createInstance({ srs, x, y })\n }\n return null\n}\n"]}
1
+ {"version":3,"file":"parse.js","sourceRoot":"","sources":["../../../src/geo/points/parse.ts"],"names":[],"mappings":";;;AACA,kDAA8C;AAE9C,sIAAsI;AACtI,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAA,kCAAkC,CAAA;AACnE,MAAM,WAAW,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAA,gCAAgC,cAAc,MAAM,cAAc,KAAK,CAAC,CAAA;AAEjH;;;;;;;;;GASG;AACI,MAAM,KAAK,GAAG,CAAC,KAAsB,EAAgB,EAAE;IAC5D,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAA;IAEvB,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAc,CAAA;IAEpD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACrC,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAA;QAEvB,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;QACpB,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;QAC1B,MAAM,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;QAC1B,OAAO,2BAAY,CAAC,cAAc,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;IACnD,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAfY,QAAA,KAAK,GAAL,KAAK,CAejB","sourcesContent":["import { Point } from '../point'\nimport { PointFactory } from '../pointFactory'\n\n// coordinates can be in exponent notation (e.g. 1e-7), as generated by Number.toString or by PostgreSQL for very small or big numbers\nconst NUMBER_PATTERN = String.raw`-?\\d+(?:\\.\\d+)?(?:[eE][-+]?\\d+)?`\nconst POINT_REGEX = new RegExp(String.raw`SRID=((EPSG:)?(\\w+));POINT\\((${NUMBER_PATTERN}) (${NUMBER_PATTERN})\\)`)\n\n/**\n * Parses a point in the format: SRID=SRS_CODE;POINT(X Y)\n * (X and Y separated by a space). Valid examples are:\n * - SRID=EPSG:4326;POINT(12.489060 41.882788)\n * - SRID=4326;POINT(12 41)\n * - SRID=4326;POINT(1e-7 41).\n *\n * @param {!(string | object)} value - The point to parse. It can be a string or an object.\n * @returns {Point} - The parsed Point object.\n */\nexport const parse = (value: string | object): Point | null => {\n if (!value) return null\n\n if (typeof value === 'object') return value as Point\n\n if (typeof value === 'string') {\n const match = POINT_REGEX.exec(value)\n if (!match) return null\n\n const srs = match[3]\n const x = Number(match[4])\n const y = Number(match[5])\n return PointFactory.createInstance({ srs, x, y })\n }\n return null\n}\n"]}
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.assocPath = void 0;
4
+ const shallowCopy_1 = require("./shallowCopy");
4
5
  const _assocPath = (obj, path, pathIndex, value, sideEffect) => {
5
6
  // only one copy per path level (when sideEffect is false)
6
- const objUpdated = sideEffect ? obj : Object.assign({}, obj);
7
+ const objUpdated = sideEffect ? obj : (0, shallowCopy_1.shallowCopy)(obj);
7
8
  if (pathIndex >= path.length)
8
9
  return objUpdated;
9
10
  const pathPart = path[pathIndex];
@@ -1 +1 @@
1
- {"version":3,"file":"assocPath.js","sourceRoot":"","sources":["../../../src/utils/_objects/assocPath.ts"],"names":[],"mappings":";;;AAAA,MAAM,UAAU,GAAG,CAAC,GAAQ,EAAE,IAAc,EAAE,SAAiB,EAAE,KAAU,EAAE,UAAmB,EAAO,EAAE;IACvG,0DAA0D;IAC1D,MAAM,UAAU,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,mBAAM,GAAG,CAAE,CAAA;IAChD,IAAI,SAAS,IAAI,IAAI,CAAC,MAAM;QAAE,OAAO,UAAU,CAAA;IAE/C,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,CAAA;IAChC,UAAU,CAAC,QAAQ,CAAC;QAClB,SAAS,KAAK,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAG,QAAQ,CAAC,KAAI,EAAE,EAAE,IAAI,EAAE,SAAS,GAAG,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAA;IACnH,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA;AAED;;;GAGG;AACI,MAAM,SAAS,GAAG,CAAmB,MAK3C,EAAK,EAAE;IACN,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,GAAG,KAAK,EAAE,GAAG,MAAM,CAAA;IACvD,OAAO,UAAU,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAA;AACpD,CAAC,CAAA;AARY,QAAA,SAAS,GAAT,SAAS,CAQrB","sourcesContent":["const _assocPath = (obj: any, path: string[], pathIndex: number, value: any, sideEffect: boolean): any => {\n // only one copy per path level (when sideEffect is false)\n const objUpdated = sideEffect ? obj : { ...obj }\n if (pathIndex >= path.length) return objUpdated\n\n const pathPart = path[pathIndex]\n objUpdated[pathPart] =\n pathIndex === path.length - 1 ? value : _assocPath(obj?.[pathPart] || {}, path, pathIndex + 1, value, sideEffect)\n return objUpdated\n}\n\n/**\n * Sets the value at the specified path, creating the missing intermediate objects.\n * Returns a copy of the object (with one copy per path level), or the object itself when sideEffect is true.\n */\nexport const assocPath = <T extends object>(params: {\n obj: T\n path: string[]\n value: unknown\n sideEffect?: boolean\n}): T => {\n const { obj, path, value, sideEffect = false } = params\n return _assocPath(obj, path, 0, value, sideEffect)\n}\n"]}
1
+ {"version":3,"file":"assocPath.js","sourceRoot":"","sources":["../../../src/utils/_objects/assocPath.ts"],"names":[],"mappings":";;;AAAA,+CAA2C;AAE3C,MAAM,UAAU,GAAG,CAAC,GAAQ,EAAE,IAAc,EAAE,SAAiB,EAAE,KAAU,EAAE,UAAmB,EAAO,EAAE;IACvG,0DAA0D;IAC1D,MAAM,UAAU,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAA,yBAAW,EAAC,GAAG,CAAC,CAAA;IACtD,IAAI,SAAS,IAAI,IAAI,CAAC,MAAM;QAAE,OAAO,UAAU,CAAA;IAE/C,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,CAAA;IAChC,UAAU,CAAC,QAAQ,CAAC;QAClB,SAAS,KAAK,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAG,QAAQ,CAAC,KAAI,EAAE,EAAE,IAAI,EAAE,SAAS,GAAG,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAA;IACnH,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA;AAED;;;GAGG;AACI,MAAM,SAAS,GAAG,CAAmB,MAK3C,EAAK,EAAE;IACN,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,GAAG,KAAK,EAAE,GAAG,MAAM,CAAA;IACvD,OAAO,UAAU,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAA;AACpD,CAAC,CAAA;AARY,QAAA,SAAS,GAAT,SAAS,CAQrB","sourcesContent":["import { shallowCopy } from './shallowCopy'\n\nconst _assocPath = (obj: any, path: string[], pathIndex: number, value: any, sideEffect: boolean): any => {\n // only one copy per path level (when sideEffect is false)\n const objUpdated = sideEffect ? obj : shallowCopy(obj)\n if (pathIndex >= path.length) return objUpdated\n\n const pathPart = path[pathIndex]\n objUpdated[pathPart] =\n pathIndex === path.length - 1 ? value : _assocPath(obj?.[pathPart] || {}, path, pathIndex + 1, value, sideEffect)\n return objUpdated\n}\n\n/**\n * Sets the value at the specified path, creating the missing intermediate objects.\n * Returns a copy of the object (with one copy per path level), or the object itself when sideEffect is true.\n */\nexport const assocPath = <T extends object>(params: {\n obj: T\n path: string[]\n value: unknown\n sideEffect?: boolean\n}): T => {\n const { obj, path, value, sideEffect = false } = params\n return _assocPath(obj, path, 0, value, sideEffect)\n}\n"]}
@@ -2,9 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.dissocPath = void 0;
4
4
  const isEmpty_1 = require("./isEmpty");
5
+ const shallowCopy_1 = require("./shallowCopy");
5
6
  const dissocPath = (params) => {
6
7
  const { obj, path, sideEffect = false } = params;
7
- const objUpdated = sideEffect ? obj : Object.assign({}, obj);
8
+ const objUpdated = sideEffect ? obj : (0, shallowCopy_1.shallowCopy)(obj);
8
9
  if (path.length === 0) {
9
10
  return objUpdated;
10
11
  }
@@ -1 +1 @@
1
- {"version":3,"file":"dissocPath.js","sourceRoot":"","sources":["../../../src/utils/_objects/dissocPath.ts"],"names":[],"mappings":";;;AAAA,uCAAmC;AAE5B,MAAM,UAAU,GAAG,CAAmB,MAAwD,EAAK,EAAE;IAC1G,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,GAAG,KAAK,EAAE,GAAG,MAAM,CAAA;IAChD,MAAM,UAAU,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,mBAAM,GAAG,CAAE,CAAA;IAEhD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,UAAU,CAAA;IACnB,CAAC;IAED,MAAM,CAAC,mBAAmB,EAAE,GAAG,cAAc,CAAC,GAAG,IAAI,CAAA;IACrD,MAAM,aAAa,GAAG,mBAA8C,CAAA;IAEpE,MAAM,OAAO,GAAQ,UAAU,CAAC,aAAa,CAAC,CAAA;IAE9C,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,IAAI,IAAA,iBAAO,EAAC,OAAO,CAAC,EAAE,CAAC;QACpD,OAAO,UAAU,CAAC,aAAa,CAAC,CAAA;QAChC,OAAO,UAAU,CAAA;IACnB,CAAC;IAED,oEAAoE;IACpE,MAAM,cAAc,GAAG,IAAA,QAAA,UAAU,EAAC,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,CAAC,CAAA;IAErF,IAAI,IAAA,iBAAO,EAAC,cAAc,CAAC,EAAE,CAAC;QAC5B,OAAO,UAAU,CAAC,aAAa,CAAC,CAAA;QAChC,OAAO,UAAU,CAAA;IACnB,CAAC;IAED,UAAU,CAAC,aAAa,CAAC,GAAG,cAAc,CAAA;IAC1C,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA;AA5BY,QAAA,UAAU,GAAV,UAAU,CA4BtB","sourcesContent":["import { isEmpty } from './isEmpty'\n\nexport const dissocPath = <T extends object>(params: { obj: T; path: string[]; sideEffect?: boolean }): T => {\n const { obj, path, sideEffect = false } = params\n const objUpdated = sideEffect ? obj : { ...obj }\n\n if (path.length === 0) {\n return objUpdated\n }\n\n const [firstPathPartString, ...otherPathParts] = path\n const firstPathPart = firstPathPartString as keyof typeof objUpdated\n\n const objPart: any = objUpdated[firstPathPart]\n\n if (otherPathParts.length === 0 || isEmpty(objPart)) {\n delete objUpdated[firstPathPart]\n return objUpdated\n }\n\n // objPart is copied by dissocPath itself (when sideEffect is false)\n const objPartUpdated = dissocPath({ obj: objPart, path: otherPathParts, sideEffect })\n\n if (isEmpty(objPartUpdated)) {\n delete objUpdated[firstPathPart]\n return objUpdated\n }\n\n objUpdated[firstPathPart] = objPartUpdated\n return objUpdated\n}\n"]}
1
+ {"version":3,"file":"dissocPath.js","sourceRoot":"","sources":["../../../src/utils/_objects/dissocPath.ts"],"names":[],"mappings":";;;AAAA,uCAAmC;AACnC,+CAA2C;AAEpC,MAAM,UAAU,GAAG,CAAmB,MAAwD,EAAK,EAAE;IAC1G,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,GAAG,KAAK,EAAE,GAAG,MAAM,CAAA;IAChD,MAAM,UAAU,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAA,yBAAW,EAAC,GAAG,CAAC,CAAA;IAEtD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,OAAO,UAAU,CAAA;IACnB,CAAC;IAED,MAAM,CAAC,mBAAmB,EAAE,GAAG,cAAc,CAAC,GAAG,IAAI,CAAA;IACrD,MAAM,aAAa,GAAG,mBAA8C,CAAA;IAEpE,MAAM,OAAO,GAAQ,UAAU,CAAC,aAAa,CAAC,CAAA;IAE9C,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,IAAI,IAAA,iBAAO,EAAC,OAAO,CAAC,EAAE,CAAC;QACpD,OAAO,UAAU,CAAC,aAAa,CAAC,CAAA;QAChC,OAAO,UAAU,CAAA;IACnB,CAAC;IAED,oEAAoE;IACpE,MAAM,cAAc,GAAG,IAAA,QAAA,UAAU,EAAC,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,CAAC,CAAA;IAErF,IAAI,IAAA,iBAAO,EAAC,cAAc,CAAC,EAAE,CAAC;QAC5B,OAAO,UAAU,CAAC,aAAa,CAAC,CAAA;QAChC,OAAO,UAAU,CAAA;IACnB,CAAC;IAED,UAAU,CAAC,aAAa,CAAC,GAAG,cAAc,CAAA;IAC1C,OAAO,UAAU,CAAA;AACnB,CAAC,CAAA;AA5BY,QAAA,UAAU,GAAV,UAAU,CA4BtB","sourcesContent":["import { isEmpty } from './isEmpty'\nimport { shallowCopy } from './shallowCopy'\n\nexport const dissocPath = <T extends object>(params: { obj: T; path: string[]; sideEffect?: boolean }): T => {\n const { obj, path, sideEffect = false } = params\n const objUpdated = sideEffect ? obj : shallowCopy(obj)\n\n if (path.length === 0) {\n return objUpdated\n }\n\n const [firstPathPartString, ...otherPathParts] = path\n const firstPathPart = firstPathPartString as keyof typeof objUpdated\n\n const objPart: any = objUpdated[firstPathPart]\n\n if (otherPathParts.length === 0 || isEmpty(objPart)) {\n delete objUpdated[firstPathPart]\n return objUpdated\n }\n\n // objPart is copied by dissocPath itself (when sideEffect is false)\n const objPartUpdated = dissocPath({ obj: objPart, path: otherPathParts, sideEffect })\n\n if (isEmpty(objPartUpdated)) {\n delete objUpdated[firstPathPart]\n return objUpdated\n }\n\n objUpdated[firstPathPart] = objPartUpdated\n return objUpdated\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  /**
2
- * Sets the value at the specified path in the object itself (side effect), creating the missing intermediate objects.
2
+ * Sets the value at the specified path in the object itself (side effect), creating the missing intermediate objects
3
+ * (null or non-object intermediate values are replaced with new objects).
3
4
  * When excludeEmpty is true, empty values are not set.
4
5
  */
5
6
  export declare const setInPath: <T extends object>(params: {
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.setInPath = void 0;
4
4
  const isEmpty_1 = require("./isEmpty");
5
5
  /**
6
- * Sets the value at the specified path in the object itself (side effect), creating the missing intermediate objects.
6
+ * Sets the value at the specified path in the object itself (side effect), creating the missing intermediate objects
7
+ * (null or non-object intermediate values are replaced with new objects).
7
8
  * When excludeEmpty is true, empty values are not set.
8
9
  */
9
10
  const setInPath = (params) => {
@@ -15,7 +16,9 @@ const setInPath = (params) => {
15
16
  objCurrent[pathPart] = value;
16
17
  }
17
18
  else {
18
- if (!Object.hasOwn(objCurrent, pathPart)) {
19
+ const valueCurrent = Object.hasOwn(objCurrent, pathPart) ? objCurrent[pathPart] : undefined;
20
+ if (valueCurrent === null || (typeof valueCurrent !== 'object' && typeof valueCurrent !== 'function')) {
21
+ // missing, null or primitive intermediate value: replace it with a new object
19
22
  objCurrent[pathPart] = {};
20
23
  }
21
24
  objCurrent = objCurrent[pathPart];
@@ -1 +1 @@
1
- {"version":3,"file":"setInPath.js","sourceRoot":"","sources":["../../../src/utils/_objects/setInPath.ts"],"names":[],"mappings":";;;AAAA,uCAAmC;AAEnC;;;GAGG;AACI,MAAM,SAAS,GAAG,CAAmB,MAK3C,EAAK,EAAE;IACN,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,MAAM,CAAA;IACjD,IAAI,CAAC,YAAY,IAAI,CAAC,IAAA,iBAAO,EAAC,KAAK,CAAC,EAAE,CAAC;QACrC,IAAI,UAAU,GAAQ,GAAG,CAAA;QACzB,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE;YAC3B,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC1B,UAAU,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAA;YAC9B,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,EAAE,CAAC;oBACzC,UAAU,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAA;gBAC3B,CAAC;gBACD,UAAU,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAA;YACnC,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AArBY,QAAA,SAAS,GAAT,SAAS,CAqBrB","sourcesContent":["import { isEmpty } from './isEmpty'\n\n/**\n * Sets the value at the specified path in the object itself (side effect), creating the missing intermediate objects.\n * When excludeEmpty is true, empty values are not set.\n */\nexport const setInPath = <T extends object>(params: {\n obj: T\n path: string[]\n value: unknown\n excludeEmpty?: boolean\n}): T => {\n const { obj, path, value, excludeEmpty } = params\n if (!excludeEmpty || !isEmpty(value)) {\n let objCurrent: any = obj\n path.forEach((pathPart, i) => {\n if (i === path.length - 1) {\n objCurrent[pathPart] = value\n } else {\n if (!Object.hasOwn(objCurrent, pathPart)) {\n objCurrent[pathPart] = {}\n }\n objCurrent = objCurrent[pathPart]\n }\n })\n }\n return obj\n}\n"]}
1
+ {"version":3,"file":"setInPath.js","sourceRoot":"","sources":["../../../src/utils/_objects/setInPath.ts"],"names":[],"mappings":";;;AAAA,uCAAmC;AAEnC;;;;GAIG;AACI,MAAM,SAAS,GAAG,CAAmB,MAK3C,EAAK,EAAE;IACN,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,MAAM,CAAA;IACjD,IAAI,CAAC,YAAY,IAAI,CAAC,IAAA,iBAAO,EAAC,KAAK,CAAC,EAAE,CAAC;QACrC,IAAI,UAAU,GAAQ,GAAG,CAAA;QACzB,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE;YAC3B,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC1B,UAAU,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAA;YAC9B,CAAC;iBAAM,CAAC;gBACN,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;gBAC3F,IAAI,YAAY,KAAK,IAAI,IAAI,CAAC,OAAO,YAAY,KAAK,QAAQ,IAAI,OAAO,YAAY,KAAK,UAAU,CAAC,EAAE,CAAC;oBACtG,8EAA8E;oBAC9E,UAAU,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAA;gBAC3B,CAAC;gBACD,UAAU,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAA;YACnC,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAvBY,QAAA,SAAS,GAAT,SAAS,CAuBrB","sourcesContent":["import { isEmpty } from './isEmpty'\n\n/**\n * Sets the value at the specified path in the object itself (side effect), creating the missing intermediate objects\n * (null or non-object intermediate values are replaced with new objects).\n * When excludeEmpty is true, empty values are not set.\n */\nexport const setInPath = <T extends object>(params: {\n obj: T\n path: string[]\n value: unknown\n excludeEmpty?: boolean\n}): T => {\n const { obj, path, value, excludeEmpty } = params\n if (!excludeEmpty || !isEmpty(value)) {\n let objCurrent: any = obj\n path.forEach((pathPart, i) => {\n if (i === path.length - 1) {\n objCurrent[pathPart] = value\n } else {\n const valueCurrent = Object.hasOwn(objCurrent, pathPart) ? objCurrent[pathPart] : undefined\n if (valueCurrent === null || (typeof valueCurrent !== 'object' && typeof valueCurrent !== 'function')) {\n // missing, null or primitive intermediate value: replace it with a new object\n objCurrent[pathPart] = {}\n }\n objCurrent = objCurrent[pathPart]\n }\n })\n }\n return obj\n}\n"]}
@@ -0,0 +1 @@
1
+ export declare const shallowCopy: <T extends object>(obj: T) => T;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.shallowCopy = void 0;
4
+ // arrays are copied as arrays
5
+ const shallowCopy = (obj) => (Array.isArray(obj) ? [...obj] : Object.assign({}, obj));
6
+ exports.shallowCopy = shallowCopy;
7
+ //# sourceMappingURL=shallowCopy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shallowCopy.js","sourceRoot":"","sources":["../../../src/utils/_objects/shallowCopy.ts"],"names":[],"mappings":";;;AAAA,8BAA8B;AACvB,MAAM,WAAW,GAAG,CAAmB,GAAM,EAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,mBAAM,GAAG,CAAE,CAAM,CAAA;AAAhG,QAAA,WAAW,GAAX,WAAW,CAAqF","sourcesContent":["// arrays are copied as arrays\nexport const shallowCopy = <T extends object>(obj: T): T => (Array.isArray(obj) ? [...obj] : { ...obj }) as T\n"]}
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "name": "OpenForis",
5
5
  "email": "openforis.arena@gmail.com"
6
6
  },
7
- "version": "2.18.17",
7
+ "version": "2.18.19",
8
8
  "description": "Arena core module",
9
9
  "repository": {
10
10
  "type": "git",