@trackunit/shared-utils 0.0.4-alpha-d7497395ac.0 → 0.0.4

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/index.cjs.js CHANGED
@@ -2146,6 +2146,13 @@ const unionArraysByKey = (key, previous, newArray) => {
2146
2146
  };
2147
2147
  /** Ensures if an array is equal to another array */
2148
2148
  const isStringArrayEqual = (first = [], second = []) => first.length === second.length && first.every((val, i) => val === second[i]);
2149
+ /**
2150
+ * Checks if an array is not empty.
2151
+ *
2152
+ * @param array - The array to check.
2153
+ * @returns The array if not empty, otherwise undefined.
2154
+ */
2155
+ const arrayNotEmpty = (array) => (array && array.length > 0 ? array : undefined);
2149
2156
 
2150
2157
  const align = {
2151
2158
  LEFT: "left",
@@ -2458,6 +2465,13 @@ const deleteUndefinedKeys = (obj) => {
2458
2465
  });
2459
2466
  return obj;
2460
2467
  };
2468
+ /**
2469
+ * Checks if an object is not empty.
2470
+ *
2471
+ * @param obj - The object to check.
2472
+ * @returns The object if not empty, otherwise undefined.
2473
+ */
2474
+ const objNotEmpty = (obj) => obj && Object.keys(obj).length > 0 ? obj : undefined;
2461
2475
 
2462
2476
  /**
2463
2477
  * @param path the path to manipulate
@@ -8619,6 +8633,7 @@ exports.Search = Search;
8619
8633
  exports.UNKNOWN_VALUE = UNKNOWN_VALUE;
8620
8634
  exports.align = align;
8621
8635
  exports.arrayLengthCompare = arrayLengthCompare;
8636
+ exports.arrayNotEmpty = arrayNotEmpty;
8622
8637
  exports.booleanCompare = booleanCompare;
8623
8638
  exports.capitalize = capitalize;
8624
8639
  exports.convertBlobToBase64 = convertBlobToBase64;
@@ -8655,6 +8670,7 @@ exports.isValidImage = isValidImage;
8655
8670
  exports.nonNullable = nonNullable;
8656
8671
  exports.numberCompare = numberCompare;
8657
8672
  exports.numberCompareUnknownAfterHighest = numberCompareUnknownAfterHighest;
8673
+ exports.objNotEmpty = objNotEmpty;
8658
8674
  exports.removeLeftPadding = removeLeftPadding;
8659
8675
  exports.resizeBlob = resizeBlob;
8660
8676
  exports.resizeImage = resizeImage;
package/index.esm.js CHANGED
@@ -2142,6 +2142,13 @@ const unionArraysByKey = (key, previous, newArray) => {
2142
2142
  };
2143
2143
  /** Ensures if an array is equal to another array */
2144
2144
  const isStringArrayEqual = (first = [], second = []) => first.length === second.length && first.every((val, i) => val === second[i]);
2145
+ /**
2146
+ * Checks if an array is not empty.
2147
+ *
2148
+ * @param array - The array to check.
2149
+ * @returns The array if not empty, otherwise undefined.
2150
+ */
2151
+ const arrayNotEmpty = (array) => (array && array.length > 0 ? array : undefined);
2145
2152
 
2146
2153
  const align = {
2147
2154
  LEFT: "left",
@@ -2454,6 +2461,13 @@ const deleteUndefinedKeys = (obj) => {
2454
2461
  });
2455
2462
  return obj;
2456
2463
  };
2464
+ /**
2465
+ * Checks if an object is not empty.
2466
+ *
2467
+ * @param obj - The object to check.
2468
+ * @returns The object if not empty, otherwise undefined.
2469
+ */
2470
+ const objNotEmpty = (obj) => obj && Object.keys(obj).length > 0 ? obj : undefined;
2457
2471
 
2458
2472
  /**
2459
2473
  * @param path the path to manipulate
@@ -8611,4 +8625,4 @@ function toDates(period) {
8611
8625
  };
8612
8626
  }
8613
8627
 
8614
- export { DateTimeFormat, DayPeriod, HoursAndMinutesFormat, Search, TimePeriod, UNKNOWN_VALUE, align, arrayLengthCompare, booleanCompare, capitalize, convertBlobToBase64, convertMetersToYards, convertYardsToMeters, dateCompare, deleteUndefinedKeys, difference, doNothing, ensureArray, enumFromValue, enumFromValueTypesafe, enumOrUndefinedFromValue, exhaustiveCheck, filterByMultiple, formatAddress, formatCoordinates, fuzzySearch, getDifferenceBetweenDates, getDimensionValues, getEndOfDay, getFirstItemAndLogIfMore, getISOStringFromDate, getMultipleCoordinatesFromGeoJsonObject, getPointCoordinateFromGeoJsonObject, getResizedDimensions, getStartOfDay, groupBy, hourIntervals, intersection, isStringArrayEqual, isUUID, isValidImage, nonNullable, numberCompare, numberCompareUnknownAfterHighest, removeLeftPadding, resizeBlob, resizeImage, size, stringCompare, stringCompareFromKey, stringNaturalCompare, titleCase, toDailyIntervals, toDates, toID, toIDs, toInterval, toUUID, toggle, trimIds, trimPath, truthy, unionArraysByKey };
8628
+ export { DateTimeFormat, DayPeriod, HoursAndMinutesFormat, Search, TimePeriod, UNKNOWN_VALUE, align, arrayLengthCompare, arrayNotEmpty, booleanCompare, capitalize, convertBlobToBase64, convertMetersToYards, convertYardsToMeters, dateCompare, deleteUndefinedKeys, difference, doNothing, ensureArray, enumFromValue, enumFromValueTypesafe, enumOrUndefinedFromValue, exhaustiveCheck, filterByMultiple, formatAddress, formatCoordinates, fuzzySearch, getDifferenceBetweenDates, getDimensionValues, getEndOfDay, getFirstItemAndLogIfMore, getISOStringFromDate, getMultipleCoordinatesFromGeoJsonObject, getPointCoordinateFromGeoJsonObject, getResizedDimensions, getStartOfDay, groupBy, hourIntervals, intersection, isStringArrayEqual, isUUID, isValidImage, nonNullable, numberCompare, numberCompareUnknownAfterHighest, objNotEmpty, removeLeftPadding, resizeBlob, resizeImage, size, stringCompare, stringCompareFromKey, stringNaturalCompare, titleCase, toDailyIntervals, toDates, toID, toIDs, toInterval, toUUID, toggle, trimIds, trimPath, truthy, unionArraysByKey };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/shared-utils",
3
- "version": "0.0.4-alpha-d7497395ac.0",
3
+ "version": "0.0.4",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -22,3 +22,10 @@ export declare const getFirstItemAndLogIfMore: <T>(array?: T[] | null | undefine
22
22
  export declare const unionArraysByKey: <T extends object>(key: keyof T, previous: T[] | null | undefined, newArray: T[] | null | undefined) => T[];
23
23
  /** Ensures if an array is equal to another array */
24
24
  export declare const isStringArrayEqual: (first?: string[], second?: string[]) => boolean;
25
+ /**
26
+ * Checks if an array is not empty.
27
+ *
28
+ * @param array - The array to check.
29
+ * @returns The array if not empty, otherwise undefined.
30
+ */
31
+ export declare const arrayNotEmpty: <T>(array?: T[] | undefined) => T[] | undefined;
@@ -6,3 +6,10 @@
6
6
  * @example deleteUndefinedKeys({ a: 1, b: undefined }) // { a: 1 }
7
7
  */
8
8
  export declare const deleteUndefinedKeys: <T extends Record<string, unknown>>(obj: T) => T;
9
+ /**
10
+ * Checks if an object is not empty.
11
+ *
12
+ * @param obj - The object to check.
13
+ * @returns The object if not empty, otherwise undefined.
14
+ */
15
+ export declare const objNotEmpty: <T extends {}>(obj?: T | undefined) => T | undefined;