@putkoff/abstract-utilities 1.0.67 → 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/esm/index.js CHANGED
@@ -1058,6 +1058,26 @@ function get(obj, keys, defaultValue = null) {
1058
1058
  }
1059
1059
  return defaultValue;
1060
1060
  }
1061
+ // Create the accountInfo table if it doesn't already exist
1062
+ function findKeyValue(obj, keyToFind) {
1063
+ if (keyToFind in obj)
1064
+ return obj[keyToFind];
1065
+ for (const key in obj) {
1066
+ if (typeof obj[key] === 'object' && obj[key] !== null) {
1067
+ const result = findKeyValue(obj[key], keyToFind);
1068
+ if (result !== undefined)
1069
+ return result;
1070
+ }
1071
+ }
1072
+ return undefined;
1073
+ }
1074
+ function omitKeys(obj, ...keys) {
1075
+ const newObj = Object.assign({}, obj);
1076
+ keys.forEach(key => {
1077
+ delete newObj[key];
1078
+ });
1079
+ return newObj;
1080
+ }
1061
1081
 
1062
1082
  function isType(obj, type) {
1063
1083
  if (typeof obj === type) {
@@ -1430,6 +1450,28 @@ const confirm_type = confirmType;
1430
1450
  const is_media_type = isMediaType;
1431
1451
  const get_mime_type = getMimeType;
1432
1452
 
1453
+ // Function to handle undefined or null values
1454
+ function getIfNone(obj, fallback) {
1455
+ return obj !== undefined && obj !== null && obj !== '' ? obj : fallback;
1456
+ }
1457
+ /**
1458
+ * Merges non-null values from multiple dictionaries.
1459
+ */
1460
+ function mergeNotNullValues(dictA, dictB, dictC, dictD, dictE) {
1461
+ var _a, _b, _c, _d;
1462
+ const result = {};
1463
+ for (const key of Object.keys(dictA)) {
1464
+ 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];
1465
+ }
1466
+ return result;
1467
+ }
1468
+ /**
1469
+ * Converts an empty object to null.
1470
+ */
1471
+ function emptyObjectToNull(value) {
1472
+ return value && typeof value === 'object' && !Array.isArray(value) && Object.keys(value).length === 0 ? null : value;
1473
+ }
1474
+
1433
1475
  function getSubstring(obj, maxLength = null, minLength = null) {
1434
1476
  const objLength = obj.length;
1435
1477
  const effectiveMaxLength = maxLength !== null && maxLength !== void 0 ? maxLength : objLength; // Use nullish coalescing for clarity
@@ -1443,6 +1485,14 @@ function getSubstring(obj, maxLength = null, minLength = null) {
1443
1485
  }
1444
1486
  return obj.substring(clampedMinLength, clampedMaxLength);
1445
1487
  }
1488
+ /**
1489
+ * Sanitize a string by removing null bytes and trimming whitespace.
1490
+ */
1491
+ function sanitizeString(input) {
1492
+ if (!input)
1493
+ return input;
1494
+ return input.replace(/\u0000/g, "").trim(); // Remove null bytes and whitespace
1495
+ }
1446
1496
  function truncateString(obj, maxLength = 20) {
1447
1497
  const objLength = obj.length;
1448
1498
  if (objLength > maxLength && maxLength) {
@@ -1601,6 +1651,24 @@ function eatouter(str, listObjects) {
1601
1651
  return eatOuter(str, listObjects);
1602
1652
  }
1603
1653
 
1654
+ /**
1655
+ * Checks if a value is enclosed in quotes.
1656
+ */
1657
+ function ends_in_quotes(value) {
1658
+ if (typeof value === 'string') {
1659
+ if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
1660
+ return true;
1661
+ }
1662
+ }
1663
+ return false;
1664
+ }
1665
+ function stripQuotes(value) {
1666
+ if (ends_in_quotes(value)) {
1667
+ return value.slice(1, -1); // Remove the first and last characters
1668
+ }
1669
+ return value; // Return the input unchanged for all other cases
1670
+ }
1671
+
1604
1672
  /**
1605
1673
  * In the browser we already have a WHATWG URL constructor on window.
1606
1674
  * Here we re-export it as “url” so other modules can import it.
@@ -1910,6 +1978,12 @@ function roundPercentage(x) {
1910
1978
  function exponential(i, k) {
1911
1979
  return i * (10 ** (k));
1912
1980
  }
1981
+ function isZero(obj) {
1982
+ if (obj == 0) {
1983
+ return true;
1984
+ }
1985
+ return false;
1986
+ }
1913
1987
 
1914
1988
  const SECOND = 1;
1915
1989
  const ZEPTOSECOND = exponential(SECOND, -21);
@@ -2076,6 +2150,11 @@ const fromMps = (v, dist_unit, time_unit) => mpsToSpeed(v, dist_unit, time_unit)
2076
2150
  const isFiniteNum = (x) => Number.isFinite(x);
2077
2151
  const fmt = (n, digits = 2) => isFiniteNum(n) ? n.toFixed(digits) : "N/A";
2078
2152
 
2153
+ // Function to check time interval
2154
+ function isTimeInterval(timeObj, interval) {
2155
+ return (Date.now() / 1000 - timeObj) < (interval - 1);
2156
+ }
2157
+
2079
2158
  function getSafeDocument() {
2080
2159
  return typeof document !== 'undefined' ? document : undefined;
2081
2160
  }
@@ -2399,5 +2478,5 @@ function get_keyword_string(keywords) {
2399
2478
  return allString;
2400
2479
  }
2401
2480
 
2402
- export { API_PREFIX, ATTOSECOND, BASE_URL, CENTISECOND, DAY, DAY_IN_S, DECISECOND, DEV_PREFIX, DIST_ALIASES, DIST_FACTORS, DOMAIN_NAME, DistanceConverter, FEET_PER_METER, FEMTOSECOND, HOUR, HOUR_IN_S, KMS_PER_METER, MEDIA_TYPES, METERS_PER_FOOT, METERS_PER_KM, METERS_PER_MILE, MICROSECOND, MILES_PER_METER, MILISECOND, MIME_TYPES, MINUTE, MIN_IN_S, MONTH, MONTH_IN_S, MPerS_TO_MiPerH, MiPerH_TO_MPerS, NANOSECOND, PI, PI2, PICOSECOND, PROD_PREFIX, PROTOCOL, SECOND, SECONDS_PER_DAY, SECONDS_PER_HOUR, SECONDS_PER_MINUTE, SUB_DIR, SpeedConverter, TIME_ALIASES, TIME_FACTORS, TimeConverter, YEAR, YEAR_IN_S, ZEPTOSECOND, alertit, assureArray, assureList, assureNumber, assureString, assure_array, assure_list, assure_number, assure_string, assurearray, assurelist, assurenumber, assurestring, callStorage, callWindowMethod, canonDist, canonTime, capitalize, capitalize_str, checkResponse, cleanArray, cleanText, confirmType, confirm_type, convertDistance, convertSpeed, convertTime, create_list_string, decodeJwt, distanceToMeters, eatAll, eatElse, eatInner, eatOuter, eatall, eatinner, eatouter, ensureArray, ensureList, ensureNumber, ensureString, ensure_array, ensure_list, ensure_number, ensure_string, ensurearray, ensurelist, ensurenumber, ensurestring, exponential, fetchIndexHtml, fetchIndexHtmlContainer, fetchIt, fmt, formatNumber, fromMeters, fromMps, fromSeconds, geAuthsUtilsDirectory, geBackupsUtilsDirectory, geConstantsUtilsDirectory, geEnvUtilsDirectory, geFetchUtilsDirectory, geFileUtilsDirectory, gePathUtilsDirectory, geStaticDirectory, geStringUtilsDirectory, geTypeUtilsDirectory, get, getAbsDir, getAbsPath, getAllFileTypes, getAllFileTypesSync, getAlphaNum, getAlphas, getBaseDir, getBasename, getBody, getChar, getCleanArray, getComponentsUtilsDirectory, getConfig, getConfigContent, getConfigVar, getDbConfigsPath, getDirname, getDistDir, getDocumentProp, getEnvDir, getEnvPath, getExtname, getFetchVars, getFilename, getFunctionsDir, getFunctionsUtilsDirectory, getHeaders, getHooksUtilsDirectory, getHtmlDirectory, getLibUtilsDirectory, getMediaExts, getMediaMap, getMethod, getMimeType, getNums, getPublicDir, getResult, getSafeDocument, getSafeLocalStorage, getSafeWindow, getSchemasDirPath, getSchemasPath, getSplitext, getSrcDir, getSubstring, getWindowHost, getWindowProp, get_all_file_types, get_basename, get_dirname, get_extname, get_filename, get_full_path, get_full_url, get_key_value, get_keyword_string, get_media_exts, get_media_map, get_mime_type, get_relative_path, get_splitext, get_window, get_window_location, get_window_parts, get_window_pathname, getbasename, getdirname, getextname, getfilename, getsplitext, isFiniteNum, isMediaType, isNum, isStrInString, isTokenExpired, isType, is_media_type, loadConfig, makePath, make_path, make_sanitized_path, makepath, metersToDistance, mpsToSpeed, normalizeUrl, parseResult, pathJoin, path_join, path_to_url, pathjoin, processKeywords, readJsonFile, roundPercentage, safeDivide, safeGlobalProp, safeMultiply, safeNums, safeStorage, sanitizeFilename, secondsToTime, speedToMps, stripPrefixes, timeToSeconds, toMeters, toSeconds, truncateString, tryEatPrefix, tryParse, urlJoin, url_to_path, urljoin, velocityFromMs, velocityToMs };
2481
+ export { API_PREFIX, ATTOSECOND, BASE_URL, CENTISECOND, DAY, DAY_IN_S, DECISECOND, DEV_PREFIX, DIST_ALIASES, DIST_FACTORS, DOMAIN_NAME, DistanceConverter, FEET_PER_METER, FEMTOSECOND, HOUR, HOUR_IN_S, KMS_PER_METER, MEDIA_TYPES, METERS_PER_FOOT, METERS_PER_KM, METERS_PER_MILE, MICROSECOND, MILES_PER_METER, MILISECOND, MIME_TYPES, MINUTE, MIN_IN_S, MONTH, MONTH_IN_S, MPerS_TO_MiPerH, MiPerH_TO_MPerS, NANOSECOND, PI, PI2, PICOSECOND, PROD_PREFIX, PROTOCOL, SECOND, SECONDS_PER_DAY, SECONDS_PER_HOUR, SECONDS_PER_MINUTE, SUB_DIR, SpeedConverter, TIME_ALIASES, TIME_FACTORS, TimeConverter, YEAR, YEAR_IN_S, ZEPTOSECOND, alertit, assureArray, assureList, assureNumber, assureString, assure_array, assure_list, assure_number, assure_string, assurearray, assurelist, assurenumber, assurestring, callStorage, callWindowMethod, canonDist, canonTime, capitalize, capitalize_str, checkResponse, cleanArray, cleanText, confirmType, confirm_type, convertDistance, convertSpeed, convertTime, create_list_string, decodeJwt, distanceToMeters, eatAll, eatElse, eatInner, eatOuter, eatall, eatinner, eatouter, emptyObjectToNull, ends_in_quotes, ensureArray, ensureList, ensureNumber, ensureString, ensure_array, ensure_list, ensure_number, ensure_string, ensurearray, ensurelist, ensurenumber, ensurestring, exponential, fetchIndexHtml, fetchIndexHtmlContainer, fetchIt, findKeyValue, fmt, formatNumber, fromMeters, fromMps, fromSeconds, geAuthsUtilsDirectory, geBackupsUtilsDirectory, geConstantsUtilsDirectory, geEnvUtilsDirectory, geFetchUtilsDirectory, geFileUtilsDirectory, gePathUtilsDirectory, geStaticDirectory, geStringUtilsDirectory, geTypeUtilsDirectory, get, getAbsDir, getAbsPath, getAllFileTypes, getAllFileTypesSync, getAlphaNum, getAlphas, getBaseDir, getBasename, getBody, getChar, getCleanArray, getComponentsUtilsDirectory, getConfig, getConfigContent, getConfigVar, getDbConfigsPath, getDirname, getDistDir, getDocumentProp, getEnvDir, getEnvPath, getExtname, getFetchVars, getFilename, getFunctionsDir, getFunctionsUtilsDirectory, getHeaders, getHooksUtilsDirectory, getHtmlDirectory, getIfNone, getLibUtilsDirectory, getMediaExts, getMediaMap, getMethod, getMimeType, getNums, getPublicDir, getResult, getSafeDocument, getSafeLocalStorage, getSafeWindow, getSchemasDirPath, getSchemasPath, getSplitext, getSrcDir, getSubstring, getWindowHost, getWindowProp, get_all_file_types, get_basename, get_dirname, get_extname, get_filename, get_full_path, get_full_url, get_key_value, get_keyword_string, get_media_exts, get_media_map, get_mime_type, get_relative_path, get_splitext, get_window, get_window_location, get_window_parts, get_window_pathname, getbasename, getdirname, getextname, getfilename, getsplitext, isFiniteNum, isMediaType, isNum, isStrInString, isTimeInterval, isTokenExpired, isType, isZero, is_media_type, loadConfig, makePath, make_path, make_sanitized_path, makepath, mergeNotNullValues, metersToDistance, mpsToSpeed, normalizeUrl, omitKeys, parseResult, pathJoin, path_join, path_to_url, pathjoin, processKeywords, readJsonFile, roundPercentage, safeDivide, safeGlobalProp, safeMultiply, safeNums, safeStorage, sanitizeFilename, sanitizeString, secondsToTime, speedToMps, stripPrefixes, stripQuotes, timeToSeconds, toMeters, toSeconds, truncateString, tryEatPrefix, tryParse, urlJoin, url_to_path, urljoin, velocityFromMs, velocityToMs };
2403
2482
  //# sourceMappingURL=index.js.map