@alextheman/utility 2.15.0 → 2.16.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
@@ -61,7 +61,9 @@ __export(index_exports, {
61
61
  isMonthlyMultiple: () => isMonthlyMultiple_default,
62
62
  isOrdered: () => isOrdered_default,
63
63
  isSameDate: () => isSameDate_default,
64
+ kebabToCamel: () => kebabToCamel_default,
64
65
  omitProperties: () => omitProperties_default,
66
+ paralleliseArrays: () => paralleliseArrays_default,
65
67
  parseEmail: () => Email_default,
66
68
  parseEnv: () => Env_default,
67
69
  parseIntStrict: () => parseIntStrict_default,
@@ -343,6 +345,41 @@ function isOrdered(array) {
343
345
  }
344
346
  var isOrdered_default = isOrdered;
345
347
 
348
+ // src/functions/kebabToCamel.ts
349
+ function kebabToCamel(string, options) {
350
+ if (string !== string.toLowerCase()) {
351
+ throw new Error("INVALID_KEBAB_CASE_INPUT");
352
+ }
353
+ if (string.startsWith("-") || string.endsWith("-") || string.includes("--")) {
354
+ throw new Error("INVALID_KEBAB_CASE_INPUT");
355
+ }
356
+ let outputString = "";
357
+ let skip = false;
358
+ for (const stringIndex in [...string]) {
359
+ if (skip) {
360
+ skip = false;
361
+ continue;
362
+ }
363
+ const index = parseIntStrict_default(stringIndex);
364
+ if (index === 0 && (options == null ? void 0 : options.startWithUpper)) {
365
+ outputString += string[index].toUpperCase();
366
+ continue;
367
+ }
368
+ if (index === string.length - 1) {
369
+ outputString += string[index];
370
+ break;
371
+ }
372
+ if (string[index] === "-" && /^[a-zA-Z]+$/.test(string[index + 1])) {
373
+ outputString += string[index + 1].toUpperCase();
374
+ skip = true;
375
+ } else {
376
+ outputString += string[index];
377
+ }
378
+ }
379
+ return outputString;
380
+ }
381
+ var kebabToCamel_default = kebabToCamel;
382
+
346
383
  // src/functions/omitProperties.ts
347
384
  function omitProperties(object, keysToOmit) {
348
385
  const outputObject = __spreadValues({}, object);
@@ -354,6 +391,16 @@ function omitProperties(object, keysToOmit) {
354
391
  }
355
392
  var omitProperties_default = omitProperties;
356
393
 
394
+ // src/functions/paralleliseArrays.ts
395
+ function paralleliseArrays(firstArray, secondArray) {
396
+ const outputArray = [];
397
+ for (let i = 0; i < firstArray.length; i++) {
398
+ outputArray.push([firstArray[i], secondArray[i]]);
399
+ }
400
+ return outputArray;
401
+ }
402
+ var paralleliseArrays_default = paralleliseArrays;
403
+
357
404
  // src/functions/randomiseArray.ts
358
405
  function randomiseArray(array) {
359
406
  const mutableArray = [...array];
@@ -526,7 +573,9 @@ var UUID_default = parseUUID;
526
573
  isMonthlyMultiple,
527
574
  isOrdered,
528
575
  isSameDate,
576
+ kebabToCamel,
529
577
  omitProperties,
578
+ paralleliseArrays,
530
579
  parseEmail,
531
580
  parseEnv,
532
581
  parseIntStrict,
package/dist/index.d.cts CHANGED
@@ -79,8 +79,16 @@ declare function isOrdered(array: readonly number[] | number[]): boolean;
79
79
 
80
80
  declare function isSameDate(firstDate: Date, secondDate: Date): boolean;
81
81
 
82
+ interface KebabToCamelOptions {
83
+ startWithUpper?: boolean;
84
+ }
85
+ declare function kebabToCamel(string: string, options?: KebabToCamelOptions): string;
86
+
82
87
  declare function omitProperties<T extends Record<string, unknown> | Readonly<Record<string, unknown>>, K extends keyof T>(object: T, keysToOmit: K | readonly K[]): Omit<T, K>;
83
88
 
89
+ type ParallelTuple<A, B> = [A, B | undefined];
90
+ declare function paralleliseArrays<FirstArrayItem, SecondArrayItem>(firstArray: FirstArrayItem[], secondArray: SecondArrayItem[]): ParallelTuple<FirstArrayItem, SecondArrayItem>[];
91
+
84
92
  declare function parseIntStrict(...[string, radix]: Parameters<typeof parseInt>): number;
85
93
 
86
94
  declare function randomiseArray<T>(array: T[]): T[];
@@ -103,4 +111,4 @@ declare function wait(seconds: number): Promise<void>;
103
111
 
104
112
  declare function interpolateObjects(strings: TemplateStringsArray, ...values: unknown[]): string;
105
113
 
106
- export { APIError, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, type DisallowUndefined, type Email, type Env, type FormDataNullableResolutionStrategy as FormDataResolutionStrategy, type HTTPErrorCode, type HTTPErrorCodes, type IgnoreCase, type NonUndefined, type OptionalOnCondition, type RecordKey, type StringListToArrayOptions, type UUID, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, httpErrorCodeLookup, interpolateObjects, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, omitProperties, parseEmail, parseEnv, parseIntStrict, parseUUID, randomiseArray, range, removeDuplicates, stringListToArray, stringToBoolean, truncate, wait };
114
+ export { APIError, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, type DisallowUndefined, type Email, type Env, type FormDataNullableResolutionStrategy as FormDataResolutionStrategy, type HTTPErrorCode, type HTTPErrorCodes, type IgnoreCase, type KebabToCamelOptions, type NonUndefined, type OptionalOnCondition, type RecordKey, type StringListToArrayOptions, type UUID, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, httpErrorCodeLookup, interpolateObjects, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, kebabToCamel, omitProperties, paralleliseArrays, parseEmail, parseEnv, parseIntStrict, parseUUID, randomiseArray, range, removeDuplicates, stringListToArray, stringToBoolean, truncate, wait };
package/dist/index.d.ts CHANGED
@@ -79,8 +79,16 @@ declare function isOrdered(array: readonly number[] | number[]): boolean;
79
79
 
80
80
  declare function isSameDate(firstDate: Date, secondDate: Date): boolean;
81
81
 
82
+ interface KebabToCamelOptions {
83
+ startWithUpper?: boolean;
84
+ }
85
+ declare function kebabToCamel(string: string, options?: KebabToCamelOptions): string;
86
+
82
87
  declare function omitProperties<T extends Record<string, unknown> | Readonly<Record<string, unknown>>, K extends keyof T>(object: T, keysToOmit: K | readonly K[]): Omit<T, K>;
83
88
 
89
+ type ParallelTuple<A, B> = [A, B | undefined];
90
+ declare function paralleliseArrays<FirstArrayItem, SecondArrayItem>(firstArray: FirstArrayItem[], secondArray: SecondArrayItem[]): ParallelTuple<FirstArrayItem, SecondArrayItem>[];
91
+
84
92
  declare function parseIntStrict(...[string, radix]: Parameters<typeof parseInt>): number;
85
93
 
86
94
  declare function randomiseArray<T>(array: T[]): T[];
@@ -103,4 +111,4 @@ declare function wait(seconds: number): Promise<void>;
103
111
 
104
112
  declare function interpolateObjects(strings: TemplateStringsArray, ...values: unknown[]): string;
105
113
 
106
- export { APIError, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, type DisallowUndefined, type Email, type Env, type FormDataNullableResolutionStrategy as FormDataResolutionStrategy, type HTTPErrorCode, type HTTPErrorCodes, type IgnoreCase, type NonUndefined, type OptionalOnCondition, type RecordKey, type StringListToArrayOptions, type UUID, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, httpErrorCodeLookup, interpolateObjects, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, omitProperties, parseEmail, parseEnv, parseIntStrict, parseUUID, randomiseArray, range, removeDuplicates, stringListToArray, stringToBoolean, truncate, wait };
114
+ export { APIError, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, type DisallowUndefined, type Email, type Env, type FormDataNullableResolutionStrategy as FormDataResolutionStrategy, type HTTPErrorCode, type HTTPErrorCodes, type IgnoreCase, type KebabToCamelOptions, type NonUndefined, type OptionalOnCondition, type RecordKey, type StringListToArrayOptions, type UUID, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, httpErrorCodeLookup, interpolateObjects, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, kebabToCamel, omitProperties, paralleliseArrays, parseEmail, parseEnv, parseIntStrict, parseUUID, randomiseArray, range, removeDuplicates, stringListToArray, stringToBoolean, truncate, wait };
package/dist/index.js CHANGED
@@ -283,6 +283,41 @@ function isOrdered(array) {
283
283
  }
284
284
  var isOrdered_default = isOrdered;
285
285
 
286
+ // src/functions/kebabToCamel.ts
287
+ function kebabToCamel(string, options) {
288
+ if (string !== string.toLowerCase()) {
289
+ throw new Error("INVALID_KEBAB_CASE_INPUT");
290
+ }
291
+ if (string.startsWith("-") || string.endsWith("-") || string.includes("--")) {
292
+ throw new Error("INVALID_KEBAB_CASE_INPUT");
293
+ }
294
+ let outputString = "";
295
+ let skip = false;
296
+ for (const stringIndex in [...string]) {
297
+ if (skip) {
298
+ skip = false;
299
+ continue;
300
+ }
301
+ const index = parseIntStrict_default(stringIndex);
302
+ if (index === 0 && (options == null ? void 0 : options.startWithUpper)) {
303
+ outputString += string[index].toUpperCase();
304
+ continue;
305
+ }
306
+ if (index === string.length - 1) {
307
+ outputString += string[index];
308
+ break;
309
+ }
310
+ if (string[index] === "-" && /^[a-zA-Z]+$/.test(string[index + 1])) {
311
+ outputString += string[index + 1].toUpperCase();
312
+ skip = true;
313
+ } else {
314
+ outputString += string[index];
315
+ }
316
+ }
317
+ return outputString;
318
+ }
319
+ var kebabToCamel_default = kebabToCamel;
320
+
286
321
  // src/functions/omitProperties.ts
287
322
  function omitProperties(object, keysToOmit) {
288
323
  const outputObject = __spreadValues({}, object);
@@ -294,6 +329,16 @@ function omitProperties(object, keysToOmit) {
294
329
  }
295
330
  var omitProperties_default = omitProperties;
296
331
 
332
+ // src/functions/paralleliseArrays.ts
333
+ function paralleliseArrays(firstArray, secondArray) {
334
+ const outputArray = [];
335
+ for (let i = 0; i < firstArray.length; i++) {
336
+ outputArray.push([firstArray[i], secondArray[i]]);
337
+ }
338
+ return outputArray;
339
+ }
340
+ var paralleliseArrays_default = paralleliseArrays;
341
+
297
342
  // src/functions/randomiseArray.ts
298
343
  function randomiseArray(array) {
299
344
  const mutableArray = [...array];
@@ -465,7 +510,9 @@ export {
465
510
  isMonthlyMultiple_default as isMonthlyMultiple,
466
511
  isOrdered_default as isOrdered,
467
512
  isSameDate_default as isSameDate,
513
+ kebabToCamel_default as kebabToCamel,
468
514
  omitProperties_default as omitProperties,
515
+ paralleliseArrays_default as paralleliseArrays,
469
516
  Email_default as parseEmail,
470
517
  Env_default as parseEnv,
471
518
  parseIntStrict_default as parseIntStrict,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alextheman/utility",
3
- "version": "2.15.0",
3
+ "version": "2.16.0",
4
4
  "description": "Helpful utility functions",
5
5
  "repository": {
6
6
  "type": "git",
@@ -40,20 +40,16 @@
40
40
  "zod": "^4.1.12"
41
41
  },
42
42
  "devDependencies": {
43
- "@alextheman/eslint-plugin": "^2.6.2",
44
- "@eslint/js": "^9.39.1",
45
- "@types/node": "^24.10.0",
43
+ "@alextheman/eslint-plugin": "^3.0.0",
44
+ "@types/node": "^24.10.1",
46
45
  "eslint": "^9.39.1",
47
- "eslint-import-resolver-typescript": "^4.4.4",
48
- "eslint-plugin-import": "^2.32.0",
49
46
  "globals": "^16.5.0",
50
47
  "husky": "^9.1.7",
51
- "jsdom": "^27.1.0",
48
+ "jsdom": "^27.2.0",
52
49
  "prettier": "^3.6.2",
53
- "tsup": "^8.5.0",
50
+ "tsup": "^8.5.1",
54
51
  "typescript": "^5.9.3",
55
- "typescript-eslint": "^8.46.3",
56
52
  "vite-tsconfig-paths": "^5.1.4",
57
- "vitest": "^4.0.8"
53
+ "vitest": "^4.0.9"
58
54
  }
59
55
  }