@alextheman/utility 2.5.0 → 2.6.0

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/index.cjs CHANGED
@@ -66,6 +66,7 @@ __export(index_exports, {
66
66
  randomiseArray: () => randomiseArray_default,
67
67
  range: () => range_default,
68
68
  removeDuplicates: () => removeDuplicates_default,
69
+ stringListToArray: () => stringListToArray_default,
69
70
  stringToBoolean: () => stringToBoolean_default,
70
71
  truncate: () => truncate_default,
71
72
  wait: () => wait_default
@@ -295,6 +296,18 @@ function removeDuplicates(array) {
295
296
  }
296
297
  var removeDuplicates_default = removeDuplicates;
297
298
 
299
+ // src/functions/stringListToArray.ts
300
+ function stringListToArray(stringList, { separator = ",", trimWhitespace = true } = {}) {
301
+ if (trimWhitespace && stringList.trim() === "") {
302
+ return [];
303
+ }
304
+ const arrayList = stringList.split(separator != null ? separator : "");
305
+ return trimWhitespace ? arrayList.map((item) => {
306
+ return item.trim();
307
+ }) : arrayList;
308
+ }
309
+ var stringListToArray_default = stringListToArray;
310
+
298
311
  // src/functions/stringToBoolean.ts
299
312
  function stringToBoolean(inputString) {
300
313
  const normalisedString = inputString.toLowerCase();
@@ -412,6 +425,7 @@ var UUID_default = parseUUID;
412
425
  randomiseArray,
413
426
  range,
414
427
  removeDuplicates,
428
+ stringListToArray,
415
429
  stringToBoolean,
416
430
  truncate,
417
431
  wait
package/dist/index.d.cts CHANGED
@@ -30,6 +30,12 @@ declare function range(start: number, stop: number, step?: number): number[];
30
30
 
31
31
  declare function removeDuplicates<T>(array: T[] | readonly T[]): T[];
32
32
 
33
+ interface StringListToArrayOptions {
34
+ separator?: string;
35
+ trimWhitespace?: boolean;
36
+ }
37
+ declare function stringListToArray(stringList: string, { separator, trimWhitespace }?: StringListToArrayOptions): string[];
38
+
33
39
  declare function stringToBoolean(inputString: string): boolean;
34
40
 
35
41
  declare function truncate(stringToTruncate: string, maxLength?: number): string;
@@ -68,4 +74,4 @@ type DisallowUndefined<T> = undefined extends T ? ["Error: Generic type cannot i
68
74
 
69
75
  type NonUndefined<T> = T extends undefined ? never : T;
70
76
 
71
- export { APIError, type DisallowUndefined, type Email, type Env, type HTTPErrorCode, type HTTPErrorCodes, type NonUndefined, type UUID, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, fillArray, formatDateAndTime, getRandomNumber, httpErrorCodeLookup, interpolateObjects, isLeapYear, isMonthlyMultiple, isSameDate, omitProperties, parseEmail, parseEnv, parseIntStrict, parseUUID, randomiseArray, range, removeDuplicates, stringToBoolean, truncate, wait };
77
+ export { APIError, type DisallowUndefined, type Email, type Env, type HTTPErrorCode, type HTTPErrorCodes, type NonUndefined, type UUID, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, fillArray, formatDateAndTime, getRandomNumber, httpErrorCodeLookup, interpolateObjects, isLeapYear, isMonthlyMultiple, isSameDate, omitProperties, parseEmail, parseEnv, parseIntStrict, parseUUID, randomiseArray, range, removeDuplicates, stringListToArray, stringToBoolean, truncate, wait };
package/dist/index.d.ts CHANGED
@@ -30,6 +30,12 @@ declare function range(start: number, stop: number, step?: number): number[];
30
30
 
31
31
  declare function removeDuplicates<T>(array: T[] | readonly T[]): T[];
32
32
 
33
+ interface StringListToArrayOptions {
34
+ separator?: string;
35
+ trimWhitespace?: boolean;
36
+ }
37
+ declare function stringListToArray(stringList: string, { separator, trimWhitespace }?: StringListToArrayOptions): string[];
38
+
33
39
  declare function stringToBoolean(inputString: string): boolean;
34
40
 
35
41
  declare function truncate(stringToTruncate: string, maxLength?: number): string;
@@ -68,4 +74,4 @@ type DisallowUndefined<T> = undefined extends T ? ["Error: Generic type cannot i
68
74
 
69
75
  type NonUndefined<T> = T extends undefined ? never : T;
70
76
 
71
- export { APIError, type DisallowUndefined, type Email, type Env, type HTTPErrorCode, type HTTPErrorCodes, type NonUndefined, type UUID, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, fillArray, formatDateAndTime, getRandomNumber, httpErrorCodeLookup, interpolateObjects, isLeapYear, isMonthlyMultiple, isSameDate, omitProperties, parseEmail, parseEnv, parseIntStrict, parseUUID, randomiseArray, range, removeDuplicates, stringToBoolean, truncate, wait };
77
+ export { APIError, type DisallowUndefined, type Email, type Env, type HTTPErrorCode, type HTTPErrorCodes, type NonUndefined, type UUID, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, fillArray, formatDateAndTime, getRandomNumber, httpErrorCodeLookup, interpolateObjects, isLeapYear, isMonthlyMultiple, isSameDate, omitProperties, parseEmail, parseEnv, parseIntStrict, parseUUID, randomiseArray, range, removeDuplicates, stringListToArray, stringToBoolean, truncate, wait };
package/dist/index.js CHANGED
@@ -239,6 +239,18 @@ function removeDuplicates(array) {
239
239
  }
240
240
  var removeDuplicates_default = removeDuplicates;
241
241
 
242
+ // src/functions/stringListToArray.ts
243
+ function stringListToArray(stringList, { separator = ",", trimWhitespace = true } = {}) {
244
+ if (trimWhitespace && stringList.trim() === "") {
245
+ return [];
246
+ }
247
+ const arrayList = stringList.split(separator != null ? separator : "");
248
+ return trimWhitespace ? arrayList.map((item) => {
249
+ return item.trim();
250
+ }) : arrayList;
251
+ }
252
+ var stringListToArray_default = stringListToArray;
253
+
242
254
  // src/functions/stringToBoolean.ts
243
255
  function stringToBoolean(inputString) {
244
256
  const normalisedString = inputString.toLowerCase();
@@ -355,6 +367,7 @@ export {
355
367
  randomiseArray_default as randomiseArray,
356
368
  range_default as range,
357
369
  removeDuplicates_default as removeDuplicates,
370
+ stringListToArray_default as stringListToArray,
358
371
  stringToBoolean_default as stringToBoolean,
359
372
  truncate_default as truncate,
360
373
  wait_default as wait
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alextheman/utility",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "description": "Helpful utility functions",
5
5
  "license": "ISC",
6
6
  "author": "alextheman",
@@ -36,20 +36,20 @@
36
36
  "zod": "^4.1.12"
37
37
  },
38
38
  "devDependencies": {
39
- "@alextheman/eslint-plugin": "^2.2.1",
40
- "@eslint/js": "^9.38.0",
41
- "@types/node": "^24.9.1",
42
- "eslint": "^9.38.0",
39
+ "@alextheman/eslint-plugin": "^2.4.1",
40
+ "@eslint/js": "^9.39.0",
41
+ "@types/node": "^24.9.2",
42
+ "eslint": "^9.39.0",
43
43
  "eslint-import-resolver-typescript": "^4.4.4",
44
44
  "eslint-plugin-import": "^2.32.0",
45
45
  "globals": "^16.4.0",
46
46
  "husky": "^9.1.7",
47
- "jsdom": "^27.0.1",
47
+ "jsdom": "^27.1.0",
48
48
  "prettier": "^3.6.2",
49
49
  "tsup": "^8.5.0",
50
50
  "typescript": "^5.9.3",
51
51
  "typescript-eslint": "^8.46.2",
52
52
  "vite-tsconfig-paths": "^5.1.4",
53
- "vitest": "^4.0.3"
53
+ "vitest": "^4.0.6"
54
54
  }
55
55
  }