@putkoff/abstract-utilities 1.0.68 → 1.0.69

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/dist/cjs/index.js CHANGED
@@ -1423,6 +1423,28 @@ const confirm_type = confirmType;
1423
1423
  const is_media_type = isMediaType;
1424
1424
  const get_mime_type = getMimeType;
1425
1425
 
1426
+ // Function to handle undefined or null values
1427
+ function getIfNone(obj, fallback) {
1428
+ return obj !== undefined && obj !== null && obj !== '' ? obj : fallback;
1429
+ }
1430
+ /**
1431
+ * Merges non-null values from multiple dictionaries.
1432
+ */
1433
+ function mergeNotNullValues(dictA, dictB, dictC, dictD, dictE) {
1434
+ var _a, _b, _c, _d;
1435
+ const result = {};
1436
+ for (const key of Object.keys(dictA)) {
1437
+ result[key] = (_d = (_c = (_b = (_a = dictA[key]) !== null && _a !== void 0 ? _a : dictB === null || dictB === void 0 ? void 0 : dictB[key]) !== null && _b !== void 0 ? _b : dictC === null || dictC === void 0 ? void 0 : dictC[key]) !== null && _c !== void 0 ? _c : dictD === null || dictD === void 0 ? void 0 : dictD[key]) !== null && _d !== void 0 ? _d : dictE === null || dictE === void 0 ? void 0 : dictE[key];
1438
+ }
1439
+ return result;
1440
+ }
1441
+ /**
1442
+ * Converts an empty object to null.
1443
+ */
1444
+ function emptyObjectToNull(value) {
1445
+ return value && typeof value === 'object' && !Array.isArray(value) && Object.keys(value).length === 0 ? null : value;
1446
+ }
1447
+
1426
1448
  function getSubstring(obj, maxLength = null, minLength = null) {
1427
1449
  const objLength = obj.length;
1428
1450
  const effectiveMaxLength = maxLength !== null && maxLength !== void 0 ? maxLength : objLength; // Use nullish coalescing for clarity
@@ -2515,6 +2537,7 @@ exports.eatOuter = eatOuter;
2515
2537
  exports.eatall = eatall;
2516
2538
  exports.eatinner = eatinner;
2517
2539
  exports.eatouter = eatouter;
2540
+ exports.emptyObjectToNull = emptyObjectToNull;
2518
2541
  exports.ends_in_quotes = ends_in_quotes;
2519
2542
  exports.ensureArray = ensureArray;
2520
2543
  exports.ensureList = ensureList;
@@ -2578,6 +2601,7 @@ exports.getFunctionsUtilsDirectory = getFunctionsUtilsDirectory;
2578
2601
  exports.getHeaders = getHeaders;
2579
2602
  exports.getHooksUtilsDirectory = getHooksUtilsDirectory;
2580
2603
  exports.getHtmlDirectory = getHtmlDirectory;
2604
+ exports.getIfNone = getIfNone;
2581
2605
  exports.getLibUtilsDirectory = getLibUtilsDirectory;
2582
2606
  exports.getMediaExts = getMediaExts;
2583
2607
  exports.getMediaMap = getMediaMap;
@@ -2633,6 +2657,7 @@ exports.makePath = makePath;
2633
2657
  exports.make_path = make_path;
2634
2658
  exports.make_sanitized_path = make_sanitized_path;
2635
2659
  exports.makepath = makepath;
2660
+ exports.mergeNotNullValues = mergeNotNullValues;
2636
2661
  exports.metersToDistance = metersToDistance;
2637
2662
  exports.mpsToSpeed = mpsToSpeed;
2638
2663
  exports.normalizeUrl = normalizeUrl;