@alextheman/utility 4.13.0 → 4.14.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.js CHANGED
@@ -4,17 +4,14 @@ import sodium from "libsodium-wrappers";
4
4
 
5
5
  //#region src/constants/FILE_PATH_REGEX.ts
6
6
  const FILE_PATH_REGEX = String.raw`^(?<directory>.+)[\/\\](?<base>[^\/\\]+)$`;
7
- var FILE_PATH_REGEX_default = FILE_PATH_REGEX;
8
7
 
9
8
  //#endregion
10
9
  //#region src/constants/NAMESPACE_EXPORT_REGEX.ts
11
10
  const NAMESPACE_EXPORT_REGEX = "export\\s+\\*\\s+from";
12
- var NAMESPACE_EXPORT_REGEX_default = NAMESPACE_EXPORT_REGEX;
13
11
 
14
12
  //#endregion
15
13
  //#region src/constants/VERSION_NUMBER_REGEX.ts
16
14
  const VERSION_NUMBER_REGEX = "^(?:v)?(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$";
17
- var VERSION_NUMBER_REGEX_default = VERSION_NUMBER_REGEX;
18
15
 
19
16
  //#endregion
20
17
  //#region src/functions/arrayHelpers/fillArray.ts
@@ -42,7 +39,6 @@ function fillArray(callback, length = 1) {
42
39
  })) return Promise.all(outputArray);
43
40
  return outputArray;
44
41
  }
45
- var fillArray_default = fillArray;
46
42
 
47
43
  //#endregion
48
44
  //#region src/functions/arrayHelpers/paralleliseArrays.ts
@@ -67,7 +63,6 @@ function paralleliseArrays(firstArray, secondArray) {
67
63
  for (let i = 0; i < firstArray.length; i++) outputArray.push([firstArray[i], secondArray[i]]);
68
64
  return outputArray;
69
65
  }
70
- var paralleliseArrays_default = paralleliseArrays;
71
66
 
72
67
  //#endregion
73
68
  //#region src/types/APIError.ts
@@ -111,7 +106,6 @@ var APIError = class extends Error {
111
106
  return typeof data === "object" && data !== null && typeof data?.status === "number" && typeof data?.message === "string";
112
107
  }
113
108
  };
114
- var APIError_default = APIError;
115
109
 
116
110
  //#endregion
117
111
  //#region src/types/DataError.ts
@@ -150,7 +144,6 @@ var DataError = class extends Error {
150
144
  return typeof data === "object" && data !== null && typeof data.message === "string" && typeof data.code === "string" && "data" in data;
151
145
  }
152
146
  };
153
- var DataError_default = DataError;
154
147
 
155
148
  //#endregion
156
149
  //#region src/types/VersionNumber.ts
@@ -176,18 +169,18 @@ var VersionNumber = class VersionNumber {
176
169
  this.minor = input.minor;
177
170
  this.patch = input.patch;
178
171
  } else if (typeof input === "string") {
179
- if (!RegExp(VERSION_NUMBER_REGEX_default).test(input)) throw new DataError_default(input, "INVALID_VERSION", `"${input}" is not a valid version number. Version numbers must be of the format "X.Y.Z" or "vX.Y.Z", where X, Y, and Z are non-negative integers.`);
172
+ if (!RegExp(VERSION_NUMBER_REGEX).test(input)) throw new DataError(input, "INVALID_VERSION", `"${input}" is not a valid version number. Version numbers must be of the format "X.Y.Z" or "vX.Y.Z", where X, Y, and Z are non-negative integers.`);
180
173
  const [major, minor, patch] = VersionNumber.formatString(input, { omitPrefix: true }).split(".").map((number) => {
181
- return parseIntStrict_default(number);
174
+ return parseIntStrict(number);
182
175
  });
183
176
  this.major = major;
184
177
  this.minor = minor;
185
178
  this.patch = patch;
186
179
  } else if (Array.isArray(input)) {
187
- if (input.length !== 3) throw new DataError_default(input, "INVALID_LENGTH", VersionNumber.NON_NEGATIVE_TUPLE_ERROR);
180
+ if (input.length !== 3) throw new DataError(input, "INVALID_LENGTH", VersionNumber.NON_NEGATIVE_TUPLE_ERROR);
188
181
  const [major, minor, patch] = input.map((number) => {
189
- const parsedInteger = parseIntStrict_default(number?.toString());
190
- if (parsedInteger < 0) throw new DataError_default(input, "NEGATIVE_INPUTS", VersionNumber.NON_NEGATIVE_TUPLE_ERROR);
182
+ const parsedInteger = parseIntStrict(number?.toString());
183
+ if (parsedInteger < 0) throw new DataError(input, "NEGATIVE_INPUTS", VersionNumber.NON_NEGATIVE_TUPLE_ERROR);
191
184
  return parsedInteger;
192
185
  });
193
186
  this.major = major;
@@ -257,7 +250,7 @@ var VersionNumber = class VersionNumber {
257
250
  * @returns A stringified representation of the current version number, prefixed with `v`.
258
251
  */
259
252
  [Symbol.toPrimitive](hint) {
260
- if (hint === "number") throw new DataError_default(this.toString(), "INVALID_COERCION", "VersionNumber cannot be coerced to a number type.");
253
+ if (hint === "number") throw new DataError(this.toString(), "INVALID_COERCION", "VersionNumber cannot be coerced to a number type.");
261
254
  return this.toString();
262
255
  }
263
256
  /**
@@ -280,7 +273,6 @@ var VersionNumber = class VersionNumber {
280
273
  return VersionNumber.formatString(rawString, options);
281
274
  }
282
275
  };
283
- var VersionNumber_default = VersionNumber;
284
276
 
285
277
  //#endregion
286
278
  //#region src/functions/parsers/parseIntStrict.ts
@@ -299,21 +291,20 @@ var VersionNumber_default = VersionNumber;
299
291
  function parseIntStrict(string, radix) {
300
292
  const trimmedString = string.trim();
301
293
  const maxAllowedAlphabeticalCharacter = radix && radix > 10 && radix <= 36 ? String.fromCharCode(87 + radix - 1) : void 0;
302
- if (!(radix && radix > 10 && radix <= 36 ? new RegExp(`^[+-]?[0-9a-${maxAllowedAlphabeticalCharacter}]+$`, "i") : /^[+-]?\d+$/).test(trimmedString)) throw new DataError_default(radix ? {
294
+ if (!(radix && radix > 10 && radix <= 36 ? new RegExp(`^[+-]?[0-9a-${maxAllowedAlphabeticalCharacter}]+$`, "i") : /^[+-]?\d+$/).test(trimmedString)) throw new DataError(radix ? {
303
295
  string,
304
296
  radix
305
297
  } : string, "INTEGER_PARSING_ERROR", `Only numeric values${radix && radix > 10 && radix <= 36 ? ` or character${radix !== 11 ? "s" : ""} A${radix !== 11 ? `-${maxAllowedAlphabeticalCharacter?.toUpperCase()} ` : " "}` : " "}are allowed.`);
306
298
  if (radix && radix < 10 && [...trimmedString].some((character) => {
307
299
  return parseInt(character) >= radix;
308
- })) throw new DataError_default({
300
+ })) throw new DataError({
309
301
  string,
310
302
  radix
311
303
  }, "INTEGER_PARSING_ERROR", "Value contains one or more digits outside of the range of the given radix.");
312
304
  const parseIntResult = parseInt(trimmedString, radix);
313
- if (isNaN(parseIntResult)) throw new DataError_default(string, "INTEGER_PARSING_ERROR", "Value is not a valid integer.");
305
+ if (isNaN(parseIntResult)) throw new DataError(string, "INTEGER_PARSING_ERROR", "Value is not a valid integer.");
314
306
  return parseIntResult;
315
307
  }
316
- var parseIntStrict_default = parseIntStrict;
317
308
 
318
309
  //#endregion
319
310
  //#region src/functions/miscellaneous/getRandomNumber.ts
@@ -328,11 +319,10 @@ var parseIntStrict_default = parseIntStrict;
328
319
  * @returns A random number between the provided lower bound and upper bound.
329
320
  */
330
321
  function getRandomNumber(lowerBound, upperBound) {
331
- const parsedLowerBound = parseIntStrict_default(`${lowerBound}`);
332
- const parsedUpperBound = parseIntStrict_default(`${upperBound}`);
322
+ const parsedLowerBound = parseIntStrict(`${lowerBound}`);
323
+ const parsedUpperBound = parseIntStrict(`${upperBound}`);
333
324
  return Math.floor(Math.random() * (parsedUpperBound - parsedLowerBound + 1) + parsedLowerBound);
334
325
  }
335
- var getRandomNumber_default = getRandomNumber;
336
326
 
337
327
  //#endregion
338
328
  //#region src/functions/arrayHelpers/randomiseArray.ts
@@ -351,12 +341,11 @@ function randomiseArray(array) {
351
341
  const mutableArray = [...array];
352
342
  const outputArray = [];
353
343
  do {
354
- const indexToRemove = getRandomNumber_default(0, mutableArray.length - 1);
344
+ const indexToRemove = getRandomNumber(0, mutableArray.length - 1);
355
345
  outputArray.push(mutableArray.splice(indexToRemove, 1)[0]);
356
346
  } while (mutableArray.length > 0);
357
347
  return outputArray;
358
348
  }
359
- var randomiseArray_default = randomiseArray;
360
349
 
361
350
  //#endregion
362
351
  //#region src/functions/arrayHelpers/range.ts
@@ -389,7 +378,6 @@ function range(start, stop, step = 1) {
389
378
  }
390
379
  return numbers;
391
380
  }
392
- var range_default = range;
393
381
 
394
382
  //#endregion
395
383
  //#region src/functions/arrayHelpers/removeDuplicates.ts
@@ -409,7 +397,6 @@ function removeDuplicates(array) {
409
397
  for (const item of array) if (!outputArray.includes(item)) outputArray.push(item);
410
398
  return outputArray;
411
399
  }
412
- var removeDuplicates_default = removeDuplicates;
413
400
 
414
401
  //#endregion
415
402
  //#region src/functions/date/addDaysToDate.ts
@@ -428,7 +415,6 @@ function addDaysToDate(currentDate = /* @__PURE__ */ new Date(), dayIncrement =
428
415
  newDate.setDate(newDate.getDate() + dayIncrement);
429
416
  return newDate;
430
417
  }
431
- var addDaysToDate_default = addDaysToDate;
432
418
 
433
419
  //#endregion
434
420
  //#region src/functions/date/isSameDate.ts
@@ -445,7 +431,6 @@ var addDaysToDate_default = addDaysToDate;
445
431
  function isSameDate(firstDate, secondDate) {
446
432
  return firstDate.getDate() === secondDate.getDate() && firstDate.getMonth() === secondDate.getMonth() && firstDate.getFullYear() === secondDate.getFullYear();
447
433
  }
448
- var isSameDate_default = isSameDate;
449
434
 
450
435
  //#endregion
451
436
  //#region src/functions/date/formatDateAndTime.ts
@@ -463,14 +448,13 @@ var isSameDate_default = isSameDate;
463
448
  * - For any other date, the output will be something like `DD/MM/YYYY, HH:MM`
464
449
  */
465
450
  function formatDateAndTime(inputDate) {
466
- const yesterday = addDaysToDate_default(/* @__PURE__ */ new Date(), -1);
451
+ const yesterday = addDaysToDate(/* @__PURE__ */ new Date(), -1);
467
452
  const today = /* @__PURE__ */ new Date();
468
453
  const inputTime = `${inputDate.getHours().toString().padStart(2, "0")}:${inputDate.getMinutes().toString().padStart(2, "0")}`;
469
- if (isSameDate_default(inputDate, yesterday)) return `Yesterday at ${inputTime}`;
470
- if (isSameDate_default(inputDate, today)) return `Today at ${inputTime}`;
454
+ if (isSameDate(inputDate, yesterday)) return `Yesterday at ${inputTime}`;
455
+ if (isSameDate(inputDate, today)) return `Today at ${inputTime}`;
471
456
  return `${inputDate.getDate().toString().padStart(2, "0")}/${(inputDate.getMonth() + 1).toString().padStart(2, "0")}/${inputDate.getFullYear().toString()}, ${inputTime}`;
472
457
  }
473
- var formatDateAndTime_default = formatDateAndTime;
474
458
 
475
459
  //#endregion
476
460
  //#region src/functions/date/isLeapYear.ts
@@ -486,15 +470,14 @@ var formatDateAndTime_default = formatDateAndTime;
486
470
  * @returns True if the year is a leap year, and false otherwise.
487
471
  */
488
472
  function isLeapYear(year) {
489
- const parsedYear = parseIntStrict_default(`${year}`);
473
+ const parsedYear = parseIntStrict(`${year}`);
490
474
  return parsedYear % 4 === 0 && parsedYear % 100 !== 0 || parsedYear % 400 === 0;
491
475
  }
492
- var isLeapYear_default = isLeapYear;
493
476
 
494
477
  //#endregion
495
478
  //#region src/functions/date/isAnniversary.ts
496
479
  function checkLeapYear(firstDate, secondDate) {
497
- if (isLeapYear_default(firstDate.getFullYear()) && firstDate.getMonth() === 1 && secondDate.getMonth() === 1) return firstDate.getDate() === 29 && secondDate.getDate() === 28;
480
+ if (isLeapYear(firstDate.getFullYear()) && firstDate.getMonth() === 1 && secondDate.getMonth() === 1) return firstDate.getDate() === 29 && secondDate.getDate() === 28;
498
481
  return false;
499
482
  }
500
483
  /**
@@ -511,7 +494,6 @@ function isAnniversary(firstDate, secondDate) {
511
494
  if (checkLeapYear(firstDate, secondDate) || checkLeapYear(secondDate, firstDate)) return true;
512
495
  return firstDate.getDate() === secondDate.getDate() && firstDate.getMonth() === secondDate.getMonth();
513
496
  }
514
- var isAnniversary_default = isAnniversary;
515
497
 
516
498
  //#endregion
517
499
  //#region src/functions/date/isMonthlyMultiple.ts
@@ -526,7 +508,7 @@ function endOfMonthChecksButNotFebruary(firstDate, secondDate) {
526
508
  }
527
509
  function nonLeapYearFebruaryChecks(firstDate, secondDate) {
528
510
  if (firstDate.getMonth() === 1) {
529
- if (!isLeapYear_default(firstDate.getFullYear()) && firstDate.getDate() === 28) return [
511
+ if (!isLeapYear(firstDate.getFullYear()) && firstDate.getDate() === 28) return [
530
512
  28,
531
513
  29,
532
514
  30,
@@ -537,7 +519,7 @@ function nonLeapYearFebruaryChecks(firstDate, secondDate) {
537
519
  }
538
520
  function leapYearFebruaryChecks(firstDate, secondDate) {
539
521
  if (firstDate.getMonth() === 1) {
540
- if (isLeapYear_default(firstDate.getFullYear()) && firstDate.getDate() === 29) return [
522
+ if (isLeapYear(firstDate.getFullYear()) && firstDate.getDate() === 29) return [
541
523
  29,
542
524
  30,
543
525
  31
@@ -561,7 +543,6 @@ function isMonthlyMultiple(firstDate, secondDate) {
561
543
  if (leapYearFebruaryChecks(firstDate, secondDate) || leapYearFebruaryChecks(secondDate, firstDate)) return true;
562
544
  return firstDate.getDate() === secondDate.getDate();
563
545
  }
564
- var isMonthlyMultiple_default = isMonthlyMultiple;
565
546
 
566
547
  //#endregion
567
548
  //#region src/functions/miscellaneous/convertFileToBase64.ts
@@ -592,7 +573,6 @@ function convertFileToBase64(file) {
592
573
  };
593
574
  });
594
575
  }
595
- var convertFileToBase64_default = convertFileToBase64;
596
576
 
597
577
  //#endregion
598
578
  //#region src/functions/miscellaneous/createFormData.ts
@@ -662,7 +642,6 @@ function createFormData(data, options = {
662
642
  } else formData.append(String(key), String(value));
663
643
  return formData;
664
644
  }
665
- var createFormData_default = createFormData;
666
645
 
667
646
  //#endregion
668
647
  //#region src/functions/miscellaneous/isOrdered.ts
@@ -681,7 +660,6 @@ function isOrdered(array) {
681
660
  for (const index in newArray) if (newArray[index] !== array[index]) return false;
682
661
  return true;
683
662
  }
684
- var isOrdered_default = isOrdered;
685
663
 
686
664
  //#endregion
687
665
  //#region src/functions/recursive/deepFreeze.ts
@@ -706,7 +684,6 @@ function deepFreeze(object) {
706
684
  }
707
685
  return Object.freeze(object);
708
686
  }
709
- var deepFreeze_default = deepFreeze;
710
687
 
711
688
  //#endregion
712
689
  //#region src/functions/taggedTemplate/createTemplateStringsArray.ts
@@ -720,13 +697,13 @@ var deepFreeze_default = deepFreeze;
720
697
  * @returns A template strings array that can be passed as the first argument of any tagged template function.
721
698
  */
722
699
  function createTemplateStringsArray(strings) {
723
- return deepFreeze_default(Object.assign([...strings], { raw: [...strings] }));
700
+ return deepFreeze(Object.assign([...strings], { raw: [...strings] }));
724
701
  }
725
- var createTemplateStringsArray_default = createTemplateStringsArray;
726
702
 
727
703
  //#endregion
728
704
  //#region src/functions/taggedTemplate/getInterpolations.ts
729
705
  /**
706
+ *
730
707
  * Gets the strings and interpolations separately from a template string.
731
708
  * You can pass a template string directly by doing:
732
709
  *
@@ -736,6 +713,8 @@ var createTemplateStringsArray_default = createTemplateStringsArray;
736
713
  *
737
714
  * @category Tagged Template
738
715
  *
716
+ * @deprecated Please use `getStringsAndInterpolations` instead.
717
+ *
739
718
  * @param strings - The strings from the template to process.
740
719
  * @param interpolations - An array of all interpolations from the template.
741
720
  *
@@ -744,7 +723,47 @@ var createTemplateStringsArray_default = createTemplateStringsArray;
744
723
  function getInterpolations(strings, ...interpolations) {
745
724
  return [strings, interpolations];
746
725
  }
747
- var getInterpolations_default = getInterpolations;
726
+
727
+ //#endregion
728
+ //#region src/functions/taggedTemplate/getStringsAndInterpolations.ts
729
+ /**
730
+ *
731
+ * Gets the strings and interpolations separately from a template string.
732
+ * You can pass a template string directly by doing:
733
+ *
734
+ * ```typescript
735
+ * getStringsAndInterpolations`Template string here`;
736
+ * ```
737
+ *
738
+ * @category Tagged Template
739
+ *
740
+ * @template InterpolationsType - The type of the interpolations.
741
+ *
742
+ * @param strings - The strings from the template to process.
743
+ * @param interpolations - An array of all interpolations from the template.
744
+ *
745
+ * @returns A tuple where the first item is the strings from the template, and the remaining items are the interpolations.
746
+ *
747
+ * The return of this function may also be spread into any other tagged template function in the following way:
748
+ *
749
+ * ```typescript
750
+ * import { interpolate } from "@alextheman/utility"; // Example function
751
+ *
752
+ * const packageName = "@alextheman/utility";
753
+ * const packageManager = getPackageManager(packageName);
754
+ *
755
+ * interpolate(...getStringsAndInterpolations`The package ${packageName} uses the ${packageManager} package manager.`);
756
+ * ```
757
+ */
758
+ function getStringsAndInterpolations(strings, ...interpolations) {
759
+ if (strings.length !== interpolations.length + 1) throw new DataError({
760
+ stringsLength: strings.length,
761
+ interpolationsLength: interpolations.length,
762
+ strings,
763
+ interpolations
764
+ }, "INVALID_STRINGS_AND_INTERPOLATIONS_LENGTH", "The length of the strings must be exactly one more than the length of the interpolations.");
765
+ return [createTemplateStringsArray(strings), ...interpolations];
766
+ }
748
767
 
749
768
  //#endregion
750
769
  //#region src/functions/taggedTemplate/interpolate.ts
@@ -761,6 +780,8 @@ var getInterpolations_default = getInterpolations;
761
780
  *
762
781
  * @category Tagged Template
763
782
  *
783
+ * @template InterpolationsType - The type of the interpolations.
784
+ *
764
785
  * @param strings - The strings from the template to process.
765
786
  * @param interpolations - An array of all interpolations from the template.
766
787
  *
@@ -768,10 +789,9 @@ var getInterpolations_default = getInterpolations;
768
789
  */
769
790
  function interpolate(strings, ...interpolations) {
770
791
  let result = "";
771
- for (const [string, interpolation = ""] of paralleliseArrays_default(strings, interpolations)) result += string + interpolation;
792
+ for (const [string, interpolation = ""] of paralleliseArrays(strings, interpolations)) result += string + interpolation;
772
793
  return result;
773
794
  }
774
- var interpolate_default = interpolate;
775
795
 
776
796
  //#endregion
777
797
  //#region src/functions/taggedTemplate/interpolateObjects.ts
@@ -781,11 +801,13 @@ var interpolate_default = interpolate;
781
801
  * You can pass a template string directly by doing:
782
802
  *
783
803
  * ```typescript
784
- * interpolateObjects`Template string here ${{ my: "object" }}`.
804
+ * interpolateObjects`Template string here ${{ my: "object" }}`;
785
805
  * ```
786
806
  *
787
807
  * @category Tagged Template
788
808
  *
809
+ * @template InterpolationsType - The type of the interpolations.
810
+ *
789
811
  * @param strings - The strings from the template to process.
790
812
  * @param interpolations - An array of all interpolations from the template.
791
813
  *
@@ -799,7 +821,21 @@ function interpolateObjects(strings, ...interpolations) {
799
821
  }
800
822
  return result;
801
823
  }
802
- var interpolateObjects_default = interpolateObjects;
824
+
825
+ //#endregion
826
+ //#region src/functions/taggedTemplate/isTemplateStringsArray.ts
827
+ /**
828
+ * Determines whether or not the input is a valid `TemplateStringsArray`.
829
+ *
830
+ * @category Tagged Template
831
+ *
832
+ * @param input - The input to check
833
+ *
834
+ * @returns `true` if the input is a valid `TemplateStringsArray`, and false otherwise. The type of the input will also be narrowed down to `TemplateStringsArray` if `true`.
835
+ */
836
+ function isTemplateStringsArray(input) {
837
+ return typeof input === "object" && input !== null && "raw" in input;
838
+ }
803
839
 
804
840
  //#endregion
805
841
  //#region src/functions/taggedTemplate/normaliseIndents.ts
@@ -822,7 +858,7 @@ function reduceLines(lines, { preserveTabs = true }) {
822
858
  const whitespaceLength = getWhitespaceLength(isFirstLineEmpty ? lines : slicedLines);
823
859
  return (isFirstLineEmpty ? slicedLines : lines).map((line) => {
824
860
  const tabSize = calculateTabSize(line, whitespaceLength);
825
- return (preserveTabs ? fillArray_default(() => {
861
+ return (preserveTabs ? fillArray(() => {
826
862
  return " ";
827
863
  }, tabSize).join("") : "") + line.trimStart();
828
864
  }).join("\n");
@@ -835,7 +871,7 @@ function reduceLines(lines, { preserveTabs = true }) {
835
871
  * ```typescript
836
872
  * normaliseIndents`Template string here
837
873
  * with a new line
838
- * and another new line`.
874
+ * and another new line`;
839
875
  * ```
840
876
  *
841
877
  * You may also pass the options first, then invoke the resulting function with a template string:
@@ -843,10 +879,10 @@ function reduceLines(lines, { preserveTabs = true }) {
843
879
  * ```typescript
844
880
  * normaliseIndents({ preserveTabs: false })`Template string here
845
881
  * with a new line
846
- * and another new line`.
882
+ * and another new line`;
847
883
  * ```
848
884
  *
849
- *@category Tagged Template
885
+ * @category Tagged Template
850
886
  *
851
887
  * @param first - The strings from the template to process, or the options to apply.
852
888
  * @param args - An array of all interpolations from the template.
@@ -862,7 +898,7 @@ function normaliseIndents(first, ...args) {
862
898
  }
863
899
  const strings = first;
864
900
  const options = typeof args[args.length - 1] === "object" && !Array.isArray(args[args.length - 1]) ? args.pop() : {};
865
- return reduceLines(interpolate_default(strings, ...[...args]).split("\n"), options);
901
+ return reduceLines(interpolate(strings, ...[...args]).split("\n"), options);
866
902
  }
867
903
  /**
868
904
  * Applies any options if provided, then removes any extraneous indents from a multi-line template string.
@@ -889,7 +925,6 @@ function normaliseIndents(first, ...args) {
889
925
  * @returns An additional function to invoke, or a new string with the strings and interpolations from the template applied, and extraneous indents removed.
890
926
  */
891
927
  const normalizeIndents = normaliseIndents;
892
- var normaliseIndents_default = normaliseIndents;
893
928
 
894
929
  //#endregion
895
930
  //#region src/functions/miscellaneous/sayHello.ts
@@ -901,7 +936,7 @@ var normaliseIndents_default = normaliseIndents;
901
936
  * @returns The lyrics string in markdown format.
902
937
  */
903
938
  function sayHello() {
904
- return normaliseIndents_default`
939
+ return normaliseIndents`
905
940
  # Commit To You
906
941
 
907
942
  ### Verse 1
@@ -1004,7 +1039,6 @@ function sayHello() {
1004
1039
  I'll commit to you!
1005
1040
  `;
1006
1041
  }
1007
- var sayHello_default = sayHello;
1008
1042
 
1009
1043
  //#endregion
1010
1044
  //#region src/functions/miscellaneous/stringifyDotenv.ts
@@ -1021,8 +1055,8 @@ function stringifyDotenv(contents, options) {
1021
1055
  const { quoteStyle = "double" } = options ?? {};
1022
1056
  let result = "";
1023
1057
  for (const key in contentsCopy) {
1024
- if (/[ \t\r\n]/.test(key)) throw new DataError_default({ [key]: contentsCopy[key] }, "INVALID_KEY", "Environment variables are not allowed to have whitespace.");
1025
- if (quoteStyle === "none") if (/[ \t\r\n]/.test(contentsCopy[key]) || contentsCopy[key].includes("#") || contentsCopy[key].includes("=") || contentsCopy[key].includes("\\")) throw new DataError_default({ [key]: contentsCopy[key] }, "INCOMPATIBLE_QUOTE_STYLE", "Cannot use `{ quoteStyle: \"none\" }` when value has whitespace, #, =, or \\");
1058
+ if (/[ \t\r\n]/.test(key)) throw new DataError({ [key]: contentsCopy[key] }, "INVALID_KEY", "Environment variables are not allowed to have whitespace.");
1059
+ if (quoteStyle === "none") if (/[ \t\r\n]/.test(contentsCopy[key]) || contentsCopy[key].includes("#") || contentsCopy[key].includes("=") || contentsCopy[key].includes("\\")) throw new DataError({ [key]: contentsCopy[key] }, "INCOMPATIBLE_QUOTE_STYLE", "Cannot use `{ quoteStyle: \"none\" }` when value has whitespace, #, =, or \\");
1026
1060
  else {
1027
1061
  result += `${key}=${contentsCopy[key]}\n`;
1028
1062
  continue;
@@ -1041,7 +1075,6 @@ function stringifyDotenv(contents, options) {
1041
1075
  }
1042
1076
  return result;
1043
1077
  }
1044
- var stringifyDotenv_default = stringifyDotenv;
1045
1078
 
1046
1079
  //#endregion
1047
1080
  //#region src/functions/miscellaneous/stringListToArray.ts
@@ -1064,7 +1097,6 @@ function stringListToArray(stringList, { separator = ",", trimWhitespace = true
1064
1097
  return item.trim();
1065
1098
  }) : arrayList;
1066
1099
  }
1067
- var stringListToArray_default = stringListToArray;
1068
1100
 
1069
1101
  //#endregion
1070
1102
  //#region src/functions/miscellaneous/wait.ts
@@ -1084,7 +1116,6 @@ function wait(seconds) {
1084
1116
  }, seconds * 1e3);
1085
1117
  });
1086
1118
  }
1087
- var wait_default = wait;
1088
1119
 
1089
1120
  //#endregion
1090
1121
  //#region src/functions/objectHelpers/getRecordKeys.ts
@@ -1102,7 +1133,6 @@ var wait_default = wait;
1102
1133
  function getRecordKeys(record) {
1103
1134
  return Object.keys(record);
1104
1135
  }
1105
- var getRecordKeys_default = getRecordKeys;
1106
1136
 
1107
1137
  //#endregion
1108
1138
  //#region src/functions/objectHelpers/omitProperties.ts
@@ -1126,7 +1156,6 @@ function omitProperties(object, keysToOmit) {
1126
1156
  });
1127
1157
  return outputObject;
1128
1158
  }
1129
- var omitProperties_default = omitProperties;
1130
1159
 
1131
1160
  //#endregion
1132
1161
  //#region src/functions/objectHelpers/removeUndefinedFromObject.ts
@@ -1142,7 +1171,6 @@ function removeUndefinedFromObject(object) {
1142
1171
  return value !== void 0;
1143
1172
  }));
1144
1173
  }
1145
- var removeUndefinedFromObject_default = removeUndefinedFromObject;
1146
1174
 
1147
1175
  //#endregion
1148
1176
  //#region src/functions/parsers/parseBoolean.ts
@@ -1159,10 +1187,9 @@ var removeUndefinedFromObject_default = removeUndefinedFromObject;
1159
1187
  */
1160
1188
  function parseBoolean(inputString) {
1161
1189
  const normalisedString = inputString.toLowerCase();
1162
- if (!["true", "false"].includes(normalisedString)) throw new DataError_default(inputString, "INVALID_BOOLEAN_STRING", "The provided boolean string must be one of `true | false`");
1190
+ if (!["true", "false"].includes(normalisedString)) throw new DataError(inputString, "INVALID_BOOLEAN_STRING", "The provided boolean string must be one of `true | false`");
1163
1191
  return normalisedString === "true";
1164
1192
  }
1165
- var parseBoolean_default = parseBoolean;
1166
1193
 
1167
1194
  //#endregion
1168
1195
  //#region src/functions/parsers/zod/_parseZodSchema.ts
@@ -1180,7 +1207,7 @@ function _parseZodSchema(parsedResult, data, onError) {
1180
1207
  const code = issue.code.toUpperCase();
1181
1208
  allErrorCodes[code] = (allErrorCodes[code] ?? 0) + 1;
1182
1209
  }
1183
- throw new DataError_default(data, Object.entries(allErrorCodes).toSorted(([_, firstCount], [__, secondCount]) => {
1210
+ throw new DataError(data, Object.entries(allErrorCodes).toSorted(([_, firstCount], [__, secondCount]) => {
1184
1211
  return secondCount - firstCount;
1185
1212
  }).map(([code, count], _, allErrorCodes) => {
1186
1213
  return allErrorCodes.length === 1 && count === 1 ? code : `${code}×${count}`;
@@ -1188,7 +1215,6 @@ function _parseZodSchema(parsedResult, data, onError) {
1188
1215
  }
1189
1216
  return parsedResult.data;
1190
1217
  }
1191
- var _parseZodSchema_default = _parseZodSchema;
1192
1218
 
1193
1219
  //#endregion
1194
1220
  //#region src/functions/parsers/zod/parseZodSchema.ts
@@ -1211,9 +1237,8 @@ var _parseZodSchema_default = _parseZodSchema;
1211
1237
  * @returns The parsed data from the Zod schema.
1212
1238
  */
1213
1239
  function parseZodSchema(schema, data, onError) {
1214
- return _parseZodSchema_default(schema.safeParse(data), data, onError);
1240
+ return _parseZodSchema(schema.safeParse(data), data, onError);
1215
1241
  }
1216
- var parseZodSchema_default = parseZodSchema;
1217
1242
 
1218
1243
  //#endregion
1219
1244
  //#region src/functions/parsers/parseEnv.ts
@@ -1239,9 +1264,8 @@ const Env = {
1239
1264
  * @returns The specified environment if allowed.
1240
1265
  */
1241
1266
  function parseEnv(data) {
1242
- return parseZodSchema_default(z$1.enum(Env), data, new DataError_default(data, "INVALID_ENV", "The provided environment type must be one of `test | development | production`"));
1267
+ return parseZodSchema(z$1.enum(Env), data, new DataError(data, "INVALID_ENV", "The provided environment type must be one of `test | development | production`"));
1243
1268
  }
1244
- var parseEnv_default = parseEnv;
1245
1269
 
1246
1270
  //#endregion
1247
1271
  //#region src/functions/parsers/parseFilePath.ts
@@ -1257,23 +1281,22 @@ var parseEnv_default = parseEnv;
1257
1281
  * @returns An object representing the different ways the file path can be represented.
1258
1282
  */
1259
1283
  function parseFilePath(filePath) {
1260
- const caughtGroups = filePath.match(RegExp(FILE_PATH_REGEX_default));
1284
+ const caughtGroups = filePath.match(RegExp(FILE_PATH_REGEX));
1261
1285
  if (!caughtGroups) {
1262
1286
  if (!(filePath.includes("/") || filePath.includes("\\")) && filePath.includes(".")) return {
1263
1287
  directory: "",
1264
1288
  base: filePath,
1265
1289
  fullPath: filePath
1266
1290
  };
1267
- throw new DataError_default({ filePath }, "INVALID_FILE_PATH", "The file path you provided is not valid.");
1291
+ throw new DataError({ filePath }, "INVALID_FILE_PATH", "The file path you provided is not valid.");
1268
1292
  }
1269
- if (!caughtGroups.groups) throw new DataError_default({ filePath }, "PARSING_ERROR", "An error occurred while trying to parse the data.");
1293
+ if (!caughtGroups.groups) throw new DataError({ filePath }, "PARSING_ERROR", "An error occurred while trying to parse the data.");
1270
1294
  return {
1271
1295
  directory: caughtGroups.groups.directory,
1272
1296
  base: caughtGroups.groups.base,
1273
1297
  fullPath: path.join(caughtGroups.groups.directory.replaceAll("\\", "/"), caughtGroups.groups.base)
1274
1298
  };
1275
1299
  }
1276
- var parseFilePath_default = parseFilePath;
1277
1300
 
1278
1301
  //#endregion
1279
1302
  //#region src/functions/parsers/parseFormData.ts
@@ -1297,7 +1320,6 @@ function parseFormData(formData, dataParser) {
1297
1320
  if (dataParser) return dataParser(object);
1298
1321
  return object;
1299
1322
  }
1300
- var parseFormData_default = parseFormData;
1301
1323
 
1302
1324
  //#endregion
1303
1325
  //#region src/functions/parsers/parseVersionType.ts
@@ -1323,9 +1345,8 @@ const VersionType = {
1323
1345
  * @returns The given version type if allowed.
1324
1346
  */
1325
1347
  function parseVersionType(data) {
1326
- return parseZodSchema_default(z.enum(VersionType), data, new DataError_default(data, "INVALID_VERSION_TYPE", "The provided version type must be one of `major | minor | patch`"));
1348
+ return parseZodSchema(z.enum(VersionType), data, new DataError(data, "INVALID_VERSION_TYPE", "The provided version type must be one of `major | minor | patch`"));
1327
1349
  }
1328
- var parseVersionType_default = parseVersionType;
1329
1350
 
1330
1351
  //#endregion
1331
1352
  //#region src/functions/parsers/zod/parseZodSchemaAsync.ts
@@ -1346,9 +1367,8 @@ var parseVersionType_default = parseVersionType;
1346
1367
  * @returns The parsed data from the Zod schema.
1347
1368
  */
1348
1369
  async function parseZodSchemaAsync(schema, data, onError) {
1349
- return _parseZodSchema_default(await schema.safeParseAsync(data), data, onError);
1370
+ return _parseZodSchema(await schema.safeParseAsync(data), data, onError);
1350
1371
  }
1351
- var parseZodSchemaAsync_default = parseZodSchemaAsync;
1352
1372
 
1353
1373
  //#endregion
1354
1374
  //#region src/functions/recursive/deepCopy.ts
@@ -1377,7 +1397,6 @@ function deepCopy(object) {
1377
1397
  }
1378
1398
  return clonedObject;
1379
1399
  }
1380
- var deepCopy_default = deepCopy;
1381
1400
 
1382
1401
  //#endregion
1383
1402
  //#region src/functions/security/encryptWithKey.ts
@@ -1396,10 +1415,9 @@ async function encryptWithKey(publicKey, plaintextValue) {
1396
1415
  const encryptedValue = sodium.crypto_box_seal(plaintextValue, base64Key);
1397
1416
  return sodium.to_base64(encryptedValue, sodium.base64_variants.ORIGINAL);
1398
1417
  } catch {
1399
- throw new DataError_default({ publicKey }, "ENCRYPTION_FAILED", "Encryption failed. Please double-check that the given key is a valid base 64 string.");
1418
+ throw new DataError({ publicKey }, "ENCRYPTION_FAILED", "Encryption failed. Please double-check that the given key is a valid base 64 string.");
1400
1419
  }
1401
1420
  }
1402
- var encryptWithKey_default = encryptWithKey;
1403
1421
 
1404
1422
  //#endregion
1405
1423
  //#region src/functions/security/getPublicAndPrivateKey.ts
@@ -1417,7 +1435,7 @@ var encryptWithKey_default = encryptWithKey;
1417
1435
  function getPublicAndPrivateKey(outputFormat) {
1418
1436
  const keys = sodium.crypto_box_keypair(outputFormat);
1419
1437
  if (outputFormat === "uint8array" || outputFormat === void 0) {
1420
- if (!(keys?.publicKey instanceof Uint8Array && keys?.privateKey instanceof Uint8Array)) throw new DataError_default({
1438
+ if (!(keys?.publicKey instanceof Uint8Array && keys?.privateKey instanceof Uint8Array)) throw new DataError({
1421
1439
  publicKey: `<redacted: ${keys?.publicKey?.constructor?.name ?? typeof keys?.publicKey}>`,
1422
1440
  privateKey: `<redacted: ${keys?.privateKey?.constructor?.name ?? typeof keys?.privateKey}>`
1423
1441
  }, "INVALID_KEY_TYPES", "Expected Uint8Array keypair from libsodium.");
@@ -1425,7 +1443,6 @@ function getPublicAndPrivateKey(outputFormat) {
1425
1443
  }
1426
1444
  return keys;
1427
1445
  }
1428
- var getPublicAndPrivateKey_default = getPublicAndPrivateKey;
1429
1446
 
1430
1447
  //#endregion
1431
1448
  //#region src/functions/stringHelpers/appendSemicolon.ts
@@ -1446,7 +1463,6 @@ function appendSemicolon(stringToAppendTo) {
1446
1463
  if (stringWithNoTrailingWhitespace === "") return "";
1447
1464
  return stringWithNoTrailingWhitespace[stringWithNoTrailingWhitespace.length - 1] === ";" ? stringWithNoTrailingWhitespace : `${stringWithNoTrailingWhitespace};`;
1448
1465
  }
1449
- var appendSemicolon_default = appendSemicolon;
1450
1466
 
1451
1467
  //#endregion
1452
1468
  //#region src/functions/stringHelpers/camelToKebab.ts
@@ -1486,7 +1502,6 @@ function camelToKebab(string, options = { preserveConsecutiveCapitals: true }) {
1486
1502
  }
1487
1503
  return result;
1488
1504
  }
1489
- var camelToKebab_default = camelToKebab;
1490
1505
 
1491
1506
  //#endregion
1492
1507
  //#region src/functions/stringHelpers/kebabToCamel.ts
@@ -1510,7 +1525,7 @@ function kebabToCamel(string, options) {
1510
1525
  skip = false;
1511
1526
  continue;
1512
1527
  }
1513
- const index = parseIntStrict_default(stringIndex);
1528
+ const index = parseIntStrict(stringIndex);
1514
1529
  if (index === 0 && options?.startWithUpper) {
1515
1530
  outputString += string[index].toUpperCase();
1516
1531
  continue;
@@ -1526,7 +1541,6 @@ function kebabToCamel(string, options) {
1526
1541
  }
1527
1542
  return outputString;
1528
1543
  }
1529
- var kebabToCamel_default = kebabToCamel;
1530
1544
 
1531
1545
  //#endregion
1532
1546
  //#region src/functions/stringHelpers/normalizeImportPath.ts
@@ -1564,7 +1578,6 @@ function normalizeImportPath(importPath) {
1564
1578
  * @returns The import path normalised.
1565
1579
  */
1566
1580
  const normaliseImportPath = normalizeImportPath;
1567
- var normalizeImportPath_default = normalizeImportPath;
1568
1581
 
1569
1582
  //#endregion
1570
1583
  //#region src/functions/stringHelpers/truncate.ts
@@ -1581,7 +1594,6 @@ var normalizeImportPath_default = normalizeImportPath;
1581
1594
  function truncate(stringToTruncate, maxLength = 5) {
1582
1595
  return stringToTruncate.length > maxLength ? `${stringToTruncate.slice(0, maxLength)}...` : stringToTruncate;
1583
1596
  }
1584
- var truncate_default = truncate;
1585
1597
 
1586
1598
  //#endregion
1587
1599
  //#region src/functions/versioning/parseVersion.ts
@@ -1600,11 +1612,10 @@ var truncate_default = truncate;
1600
1612
  * @returns The validated version number, prefixed with `v` if it was not already.
1601
1613
  */
1602
1614
  function parseVersion(input, options) {
1603
- if (!RegExp(VERSION_NUMBER_REGEX_default).test(input)) throw new DataError_default(input, "INVALID_VERSION", `"${input}" is not a valid version number. Version numbers must be of the format "X.Y.Z" or "vX.Y.Z", where X, Y, and Z are non-negative integers.`);
1615
+ if (!RegExp(VERSION_NUMBER_REGEX).test(input)) throw new DataError(input, "INVALID_VERSION", `"${input}" is not a valid version number. Version numbers must be of the format "X.Y.Z" or "vX.Y.Z", where X, Y, and Z are non-negative integers.`);
1604
1616
  if (options?.omitPrefix) return input.startsWith("v") ? input.slice(1) : input;
1605
1617
  return input.startsWith("v") ? input : `v${input}`;
1606
1618
  }
1607
- var parseVersion_default = parseVersion;
1608
1619
 
1609
1620
  //#endregion
1610
1621
  //#region src/functions/versioning/getIndividualVersionNumbers.ts
@@ -1623,11 +1634,10 @@ var parseVersion_default = parseVersion;
1623
1634
  * @returns A tuple of three numbers indicating `[major, minor, patch]`.
1624
1635
  */
1625
1636
  function getIndividualVersionNumbers(version) {
1626
- return parseVersion_default(version, { omitPrefix: true }).split(".").map((versionNumber) => {
1627
- return parseIntStrict_default(versionNumber);
1637
+ return parseVersion(version, { omitPrefix: true }).split(".").map((versionNumber) => {
1638
+ return parseIntStrict(versionNumber);
1628
1639
  });
1629
1640
  }
1630
- var getIndividualVersionNumbers_default = getIndividualVersionNumbers;
1631
1641
 
1632
1642
  //#endregion
1633
1643
  //#region src/functions/versioning/determineVersionType.ts
@@ -1641,12 +1651,11 @@ var getIndividualVersionNumbers_default = getIndividualVersionNumbers;
1641
1651
  * @returns Either `"major"`, `"minor"`, or `"patch"`, depending on the version type.
1642
1652
  */
1643
1653
  function determineVersionType(version) {
1644
- const [_major, minor, patch] = getIndividualVersionNumbers_default(version);
1654
+ const [_major, minor, patch] = getIndividualVersionNumbers(version);
1645
1655
  if (minor === 0 && patch === 0) return "major";
1646
1656
  if (patch === 0) return "minor";
1647
1657
  return "patch";
1648
1658
  }
1649
- var determineVersionType_default = determineVersionType;
1650
1659
 
1651
1660
  //#endregion
1652
1661
  //#region src/functions/versioning/incrementVersion.ts
@@ -1665,15 +1674,14 @@ var determineVersionType_default = determineVersionType;
1665
1674
  * @returns A new string representing the version with the increment applied.
1666
1675
  */
1667
1676
  function incrementVersion(version, incrementType, options) {
1668
- const [major, minor, patch] = getIndividualVersionNumbers_default(version);
1677
+ const [major, minor, patch] = getIndividualVersionNumbers(version);
1669
1678
  const newVersion = {
1670
1679
  major: `${major + 1}.0.0`,
1671
1680
  minor: `${major}.${minor + 1}.0`,
1672
1681
  patch: `${major}.${minor}.${patch + 1}`
1673
1682
  }[incrementType];
1674
- return parseVersion_default(newVersion, { omitPrefix: options?.omitPrefix });
1683
+ return parseVersion(newVersion, { omitPrefix: options?.omitPrefix });
1675
1684
  }
1676
- var incrementVersion_default = incrementVersion;
1677
1685
 
1678
1686
  //#endregion
1679
- export { APIError_default as APIError, DataError_default as DataError, Env, FILE_PATH_REGEX_default as FILE_PATH_REGEX, NAMESPACE_EXPORT_REGEX_default as NAMESPACE_EXPORT_REGEX, VERSION_NUMBER_REGEX_default as VERSION_NUMBER_REGEX, VersionNumber_default as VersionNumber, VersionType, addDaysToDate_default as addDaysToDate, appendSemicolon_default as appendSemicolon, camelToKebab_default as camelToKebab, convertFileToBase64_default as convertFileToBase64, createFormData_default as createFormData, createTemplateStringsArray_default as createTemplateStringsArray, deepCopy_default as deepCopy, deepFreeze_default as deepFreeze, determineVersionType_default as determineVersionType, encryptWithKey_default as encryptWithKey, fillArray_default as fillArray, formatDateAndTime_default as formatDateAndTime, getIndividualVersionNumbers_default as getIndividualVersionNumbers, getInterpolations_default as getInterpolations, getPublicAndPrivateKey_default as getPublicAndPrivateKey, getRandomNumber_default as getRandomNumber, getRecordKeys_default as getRecordKeys, httpErrorCodeLookup, incrementVersion_default as incrementVersion, interpolate_default as interpolate, interpolateObjects_default as interpolateObjects, isAnniversary_default as isAnniversary, isLeapYear_default as isLeapYear, isMonthlyMultiple_default as isMonthlyMultiple, isOrdered_default as isOrdered, isSameDate_default as isSameDate, kebabToCamel_default as kebabToCamel, normaliseImportPath, normaliseIndents_default as normaliseIndents, normalizeImportPath_default as normalizeImportPath, normalizeIndents, omitProperties_default as omitProperties, paralleliseArrays_default as paralleliseArrays, parseBoolean_default as parseBoolean, parseEnv_default as parseEnv, parseFilePath_default as parseFilePath, parseFormData_default as parseFormData, parseIntStrict_default as parseIntStrict, parseVersion_default as parseVersion, parseVersionType_default as parseVersionType, parseZodSchema_default as parseZodSchema, parseZodSchemaAsync_default as parseZodSchemaAsync, randomiseArray_default as randomiseArray, range_default as range, removeDuplicates_default as removeDuplicates, removeUndefinedFromObject_default as removeUndefinedFromObject, sayHello_default as sayHello, stringListToArray_default as stringListToArray, stringifyDotenv_default as stringifyDotenv, truncate_default as truncate, wait_default as wait };
1687
+ export { APIError, DataError, Env, FILE_PATH_REGEX, NAMESPACE_EXPORT_REGEX, VERSION_NUMBER_REGEX, VersionNumber, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, determineVersionType, encryptWithKey, fillArray, formatDateAndTime, getIndividualVersionNumbers, getInterpolations, getPublicAndPrivateKey, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, incrementVersion, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFilePath, parseFormData, parseIntStrict, parseVersion, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, stringListToArray, stringifyDotenv, truncate, wait };