@putkoff/abstract-utilities 1.0.67 → 1.0.68

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
@@ -1061,6 +1061,26 @@ function get(obj, keys, defaultValue = null) {
1061
1061
  }
1062
1062
  return defaultValue;
1063
1063
  }
1064
+ // Create the accountInfo table if it doesn't already exist
1065
+ function findKeyValue(obj, keyToFind) {
1066
+ if (keyToFind in obj)
1067
+ return obj[keyToFind];
1068
+ for (const key in obj) {
1069
+ if (typeof obj[key] === 'object' && obj[key] !== null) {
1070
+ const result = findKeyValue(obj[key], keyToFind);
1071
+ if (result !== undefined)
1072
+ return result;
1073
+ }
1074
+ }
1075
+ return undefined;
1076
+ }
1077
+ function omitKeys(obj, ...keys) {
1078
+ const newObj = Object.assign({}, obj);
1079
+ keys.forEach(key => {
1080
+ delete newObj[key];
1081
+ });
1082
+ return newObj;
1083
+ }
1064
1084
 
1065
1085
  function isType(obj, type) {
1066
1086
  if (typeof obj === type) {
@@ -1416,6 +1436,14 @@ function getSubstring(obj, maxLength = null, minLength = null) {
1416
1436
  }
1417
1437
  return obj.substring(clampedMinLength, clampedMaxLength);
1418
1438
  }
1439
+ /**
1440
+ * Sanitize a string by removing null bytes and trimming whitespace.
1441
+ */
1442
+ function sanitizeString(input) {
1443
+ if (!input)
1444
+ return input;
1445
+ return input.replace(/\u0000/g, "").trim(); // Remove null bytes and whitespace
1446
+ }
1419
1447
  function truncateString(obj, maxLength = 20) {
1420
1448
  const objLength = obj.length;
1421
1449
  if (objLength > maxLength && maxLength) {
@@ -1574,6 +1602,24 @@ function eatouter(str, listObjects) {
1574
1602
  return eatOuter(str, listObjects);
1575
1603
  }
1576
1604
 
1605
+ /**
1606
+ * Checks if a value is enclosed in quotes.
1607
+ */
1608
+ function ends_in_quotes(value) {
1609
+ if (typeof value === 'string') {
1610
+ if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
1611
+ return true;
1612
+ }
1613
+ }
1614
+ return false;
1615
+ }
1616
+ function stripQuotes(value) {
1617
+ if (ends_in_quotes(value)) {
1618
+ return value.slice(1, -1); // Remove the first and last characters
1619
+ }
1620
+ return value; // Return the input unchanged for all other cases
1621
+ }
1622
+
1577
1623
  /**
1578
1624
  * In the browser we already have a WHATWG URL constructor on window.
1579
1625
  * Here we re-export it as “url” so other modules can import it.
@@ -1883,6 +1929,12 @@ function roundPercentage(x) {
1883
1929
  function exponential(i, k) {
1884
1930
  return i * (10 ** (k));
1885
1931
  }
1932
+ function isZero(obj) {
1933
+ if (obj == 0) {
1934
+ return true;
1935
+ }
1936
+ return false;
1937
+ }
1886
1938
 
1887
1939
  const SECOND = 1;
1888
1940
  const ZEPTOSECOND = exponential(SECOND, -21);
@@ -2049,6 +2101,11 @@ const fromMps = (v, dist_unit, time_unit) => mpsToSpeed(v, dist_unit, time_unit)
2049
2101
  const isFiniteNum = (x) => Number.isFinite(x);
2050
2102
  const fmt = (n, digits = 2) => isFiniteNum(n) ? n.toFixed(digits) : "N/A";
2051
2103
 
2104
+ // Function to check time interval
2105
+ function isTimeInterval(timeObj, interval) {
2106
+ return (Date.now() / 1000 - timeObj) < (interval - 1);
2107
+ }
2108
+
2052
2109
  function getSafeDocument() {
2053
2110
  return typeof document !== 'undefined' ? document : undefined;
2054
2111
  }
@@ -2458,6 +2515,7 @@ exports.eatOuter = eatOuter;
2458
2515
  exports.eatall = eatall;
2459
2516
  exports.eatinner = eatinner;
2460
2517
  exports.eatouter = eatouter;
2518
+ exports.ends_in_quotes = ends_in_quotes;
2461
2519
  exports.ensureArray = ensureArray;
2462
2520
  exports.ensureList = ensureList;
2463
2521
  exports.ensureNumber = ensureNumber;
@@ -2474,6 +2532,7 @@ exports.exponential = exponential;
2474
2532
  exports.fetchIndexHtml = fetchIndexHtml;
2475
2533
  exports.fetchIndexHtmlContainer = fetchIndexHtmlContainer;
2476
2534
  exports.fetchIt = fetchIt;
2535
+ exports.findKeyValue = findKeyValue;
2477
2536
  exports.fmt = fmt;
2478
2537
  exports.formatNumber = formatNumber;
2479
2538
  exports.fromMeters = fromMeters;
@@ -2564,8 +2623,10 @@ exports.isFiniteNum = isFiniteNum;
2564
2623
  exports.isMediaType = isMediaType;
2565
2624
  exports.isNum = isNum;
2566
2625
  exports.isStrInString = isStrInString;
2626
+ exports.isTimeInterval = isTimeInterval;
2567
2627
  exports.isTokenExpired = isTokenExpired;
2568
2628
  exports.isType = isType;
2629
+ exports.isZero = isZero;
2569
2630
  exports.is_media_type = is_media_type;
2570
2631
  exports.loadConfig = loadConfig;
2571
2632
  exports.makePath = makePath;
@@ -2575,6 +2636,7 @@ exports.makepath = makepath;
2575
2636
  exports.metersToDistance = metersToDistance;
2576
2637
  exports.mpsToSpeed = mpsToSpeed;
2577
2638
  exports.normalizeUrl = normalizeUrl;
2639
+ exports.omitKeys = omitKeys;
2578
2640
  exports.parseResult = parseResult;
2579
2641
  exports.pathJoin = pathJoin;
2580
2642
  exports.path_join = path_join;
@@ -2589,9 +2651,11 @@ exports.safeMultiply = safeMultiply;
2589
2651
  exports.safeNums = safeNums;
2590
2652
  exports.safeStorage = safeStorage;
2591
2653
  exports.sanitizeFilename = sanitizeFilename;
2654
+ exports.sanitizeString = sanitizeString;
2592
2655
  exports.secondsToTime = secondsToTime;
2593
2656
  exports.speedToMps = speedToMps;
2594
2657
  exports.stripPrefixes = stripPrefixes;
2658
+ exports.stripQuotes = stripQuotes;
2595
2659
  exports.timeToSeconds = timeToSeconds;
2596
2660
  exports.toMeters = toMeters;
2597
2661
  exports.toSeconds = toSeconds;