@hkdigital/lib-sveltekit 0.0.51 → 0.0.52

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.
@@ -48,6 +48,16 @@ export function toArrayAsync(value: AsyncIterator<any, any, any> | mixed): any[]
48
48
  * @returns {string[]} array path (e.g. ["some", "path", "to"])
49
49
  */
50
50
  export function toArrayPath(path: string | string[], pathSeparator?: string): string[];
51
+ /**
52
+ * Push a value to an array if it is not null, undefined or an empty string
53
+ *
54
+ * @template {arrray} T
55
+ * @param {T} arr
56
+ * @param {*} value
57
+ *
58
+ * @returns {T} arr
59
+ */
60
+ export function pushNotEmpty<T extends arrray>(arr: T, value: any): T;
51
61
  /**
52
62
  * Loop over the supplied array and call the callback for every element
53
63
  * - The callback will receive the current element of the array as
@@ -145,6 +145,27 @@ export function toArrayPath(path, pathSeparator = PATH_SEPARATOR) {
145
145
 
146
146
  // -----------------------------------------------------------------------------
147
147
 
148
+ /**
149
+ * Push a value to an array if it is not null, undefined or an empty string
150
+ *
151
+ * @template {arrray} T
152
+ * @param {T} arr
153
+ * @param {*} value
154
+ *
155
+ * @returns {T} arr
156
+ */
157
+ export function pushNotEmpty(arr, value) {
158
+ expect.array(arr);
159
+
160
+ if (value !== null && value !== undefined && value !== '') {
161
+ arr.push(value);
162
+ }
163
+
164
+ return arr;
165
+ }
166
+
167
+ // -----------------------------------------------------------------------------
168
+
148
169
  /**
149
170
  * Loop over the supplied array and call the callback for every element
150
171
  * - The callback will receive the current element of the array as
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hkdigital/lib-sveltekit",
3
- "version": "0.0.51",
3
+ "version": "0.0.52",
4
4
  "author": "Jens Kleinhout, HKdigital (https://hkdigital.nl)",
5
5
  "license": "ISC",
6
6
  "repository": {