@alextheman/utility 4.17.0 → 5.0.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
@@ -33,19 +33,19 @@ node_path = __toESM(node_path);
33
33
  let libsodium_wrappers = require("libsodium-wrappers");
34
34
  libsodium_wrappers = __toESM(libsodium_wrappers);
35
35
 
36
- //#region src/constants/FILE_PATH_REGEX.ts
36
+ //#region src/root/constants/FILE_PATH_REGEX.ts
37
37
  const FILE_PATH_REGEX = String.raw`^(?<directory>.+)[\/\\](?<base>[^\/\\]+)$`;
38
38
 
39
39
  //#endregion
40
- //#region src/constants/NAMESPACE_EXPORT_REGEX.ts
40
+ //#region src/root/constants/NAMESPACE_EXPORT_REGEX.ts
41
41
  const NAMESPACE_EXPORT_REGEX = "export\\s+\\*\\s+from";
42
42
 
43
43
  //#endregion
44
- //#region src/constants/VERSION_NUMBER_REGEX.ts
44
+ //#region src/root/constants/VERSION_NUMBER_REGEX.ts
45
45
  const VERSION_NUMBER_REGEX = "^(?:v)?(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$";
46
46
 
47
47
  //#endregion
48
- //#region src/functions/arrayHelpers/fillArray.ts
48
+ //#region src/root/functions/arrayHelpers/fillArray.ts
49
49
  /**
50
50
  * Creates a new array where each element is the result of the provided callback.
51
51
  *
@@ -72,7 +72,7 @@ function fillArray(callback, length = 1) {
72
72
  }
73
73
 
74
74
  //#endregion
75
- //#region src/functions/arrayHelpers/paralleliseArrays.ts
75
+ //#region src/root/functions/arrayHelpers/paralleliseArrays.ts
76
76
  /**
77
77
  * Creates a new array of tuples, each containing the item at the given index from both arrays.
78
78
  *
@@ -96,7 +96,7 @@ function paralleliseArrays(firstArray, secondArray) {
96
96
  }
97
97
 
98
98
  //#endregion
99
- //#region src/types/APIError.ts
99
+ //#region src/root/types/APIError.ts
100
100
  const httpErrorCodeLookup = {
101
101
  400: "BAD_REQUEST",
102
102
  401: "UNAUTHORISED",
@@ -140,11 +140,13 @@ var APIError = class APIError extends Error {
140
140
  };
141
141
 
142
142
  //#endregion
143
- //#region src/types/DataError.ts
143
+ //#region src/root/types/DataError.ts
144
144
  /**
145
145
  * Represents errors you may get that may've been caused by a specific piece of data.
146
146
  *
147
147
  * @category Types
148
+ *
149
+ * @template DataType - The type of the data that caused the error.
148
150
  */
149
151
  var DataError = class DataError extends Error {
150
152
  code;
@@ -179,7 +181,7 @@ var DataError = class DataError extends Error {
179
181
  };
180
182
 
181
183
  //#endregion
182
- //#region src/types/VersionNumber.ts
184
+ //#region src/root/types/VersionNumber.ts
183
185
  /**
184
186
  * Represents a software version number, considered to be made up of a major, minor, and patch part.
185
187
  *
@@ -202,7 +204,7 @@ var VersionNumber = class VersionNumber {
202
204
  this.minor = input.minor;
203
205
  this.patch = input.patch;
204
206
  } else if (typeof input === "string") {
205
- 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.`);
207
+ 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.`);
206
208
  const [major, minor, patch] = VersionNumber.formatString(input, { omitPrefix: true }).split(".").map((number) => {
207
209
  return parseIntStrict(number);
208
210
  });
@@ -210,10 +212,10 @@ var VersionNumber = class VersionNumber {
210
212
  this.minor = minor;
211
213
  this.patch = patch;
212
214
  } else if (Array.isArray(input)) {
213
- if (input.length !== 3) throw new DataError(input, "INVALID_LENGTH", VersionNumber.NON_NEGATIVE_TUPLE_ERROR);
215
+ if (input.length !== 3) throw new DataError({ input }, "INVALID_LENGTH", VersionNumber.NON_NEGATIVE_TUPLE_ERROR);
214
216
  const [major, minor, patch] = input.map((number) => {
215
217
  const parsedInteger = parseIntStrict(number?.toString());
216
- if (parsedInteger < 0) throw new DataError(input, "NEGATIVE_INPUTS", VersionNumber.NON_NEGATIVE_TUPLE_ERROR);
218
+ if (parsedInteger < 0) throw new DataError({ input }, "NEGATIVE_INPUTS", VersionNumber.NON_NEGATIVE_TUPLE_ERROR);
217
219
  return parsedInteger;
218
220
  });
219
221
  this.major = major;
@@ -247,6 +249,21 @@ var VersionNumber = class VersionNumber {
247
249
  return firstVersion.major === secondVersion.major && firstVersion.minor === secondVersion.minor && firstVersion.patch === secondVersion.patch;
248
250
  }
249
251
  /**
252
+ * Get a formatted string representation of the current version number
253
+ *
254
+ * @param options - Options to apply to the string formatting.
255
+ *
256
+ * @returns A formatted string representation of the current version number with the options applied.
257
+ */
258
+ format(options) {
259
+ let baseOutput = `${this.major}`;
260
+ if (!options?.omitMinor) {
261
+ baseOutput += `.${this.minor}`;
262
+ if (!options?.omitPatch) baseOutput += `.${this.patch}`;
263
+ }
264
+ return VersionNumber.formatString(baseOutput, { omitPrefix: options?.omitPrefix });
265
+ }
266
+ /**
250
267
  * Increments the current version number by the given increment type, returning the result as a new reference in memory.
251
268
  *
252
269
  * @param incrementType - The type of increment. Can be one of the following:
@@ -295,7 +312,7 @@ var VersionNumber = class VersionNumber {
295
312
  * @returns A stringified representation of the current version number, prefixed with `v`.
296
313
  */
297
314
  [Symbol.toPrimitive](hint) {
298
- if (hint === "number") throw new DataError(this.toString(), "INVALID_COERCION", "VersionNumber cannot be coerced to a number type.");
315
+ if (hint === "number") throw new DataError({ thisVersion: this.toString() }, "INVALID_COERCION", "VersionNumber cannot be coerced to a number type.");
299
316
  return this.toString();
300
317
  }
301
318
  /**
@@ -309,13 +326,11 @@ var VersionNumber = class VersionNumber {
309
326
  /**
310
327
  * Get a string representation of the current version number.
311
328
  *
312
- * @param options - Extra additional options to apply.
313
- *
314
- * @returns A stringified representation of the current version number, leaving out the prefix if `omitPrefix` option was set to true.
329
+ * @returns A stringified representation of the current version number with the prefix.
315
330
  */
316
- toString(options) {
331
+ toString() {
317
332
  const rawString = `${this.major}.${this.minor}.${this.patch}`;
318
- return VersionNumber.formatString(rawString, options);
333
+ return VersionNumber.formatString(rawString, { omitPrefix: false });
319
334
  }
320
335
  };
321
336
  const zodVersionNumber = zod.default.union([
@@ -331,7 +346,7 @@ const zodVersionNumber = zod.default.union([
331
346
  });
332
347
 
333
348
  //#endregion
334
- //#region src/functions/parsers/parseIntStrict.ts
349
+ //#region src/root/functions/parsers/parseIntStrict.ts
335
350
  /**
336
351
  * Converts a string to an integer and throws an error if it cannot be converted.
337
352
  *
@@ -350,7 +365,7 @@ function parseIntStrict(string, radix) {
350
365
  if (!(radix && radix > 10 && radix <= 36 ? new RegExp(`^[+-]?[0-9a-${maxAllowedAlphabeticalCharacter}]+$`, "i") : /^[+-]?\d+$/).test(trimmedString)) throw new DataError(radix ? {
351
366
  string,
352
367
  radix
353
- } : string, "INTEGER_PARSING_ERROR", `Only numeric values${radix && radix > 10 && radix <= 36 ? ` or character${radix !== 11 ? "s" : ""} A${radix !== 11 ? `-${maxAllowedAlphabeticalCharacter?.toUpperCase()} ` : " "}` : " "}are allowed.`);
368
+ } : { string }, "INTEGER_PARSING_ERROR", `Only numeric values${radix && radix > 10 && radix <= 36 ? ` or character${radix !== 11 ? "s" : ""} A${radix !== 11 ? `-${maxAllowedAlphabeticalCharacter?.toUpperCase()} ` : " "}` : " "}are allowed.`);
354
369
  if (radix && radix < 10 && [...trimmedString].some((character) => {
355
370
  return parseInt(character) >= radix;
356
371
  })) throw new DataError({
@@ -358,12 +373,12 @@ function parseIntStrict(string, radix) {
358
373
  radix
359
374
  }, "INTEGER_PARSING_ERROR", "Value contains one or more digits outside of the range of the given radix.");
360
375
  const parseIntResult = parseInt(trimmedString, radix);
361
- if (isNaN(parseIntResult)) throw new DataError(string, "INTEGER_PARSING_ERROR", "Value is not a valid integer.");
376
+ if (isNaN(parseIntResult)) throw new DataError({ string }, "INTEGER_PARSING_ERROR", "Value is not a valid integer.");
362
377
  return parseIntResult;
363
378
  }
364
379
 
365
380
  //#endregion
366
- //#region src/functions/miscellaneous/getRandomNumber.ts
381
+ //#region src/root/functions/miscellaneous/getRandomNumber.ts
367
382
  /**
368
383
  * Gets a random number between the given bounds.
369
384
  *
@@ -381,7 +396,7 @@ function getRandomNumber(lowerBound, upperBound) {
381
396
  }
382
397
 
383
398
  //#endregion
384
- //#region src/functions/arrayHelpers/randomiseArray.ts
399
+ //#region src/root/functions/arrayHelpers/randomiseArray.ts
385
400
  /**
386
401
  * Randomises the order of a given array and returns the result in a new array without mutating the original.
387
402
  *
@@ -404,7 +419,7 @@ function randomiseArray(array) {
404
419
  }
405
420
 
406
421
  //#endregion
407
- //#region src/functions/arrayHelpers/range.ts
422
+ //#region src/root/functions/arrayHelpers/range.ts
408
423
  /**
409
424
  * Creates an array of numbers within a given range.
410
425
  *
@@ -436,7 +451,7 @@ function range(start, stop, step = 1) {
436
451
  }
437
452
 
438
453
  //#endregion
439
- //#region src/functions/arrayHelpers/removeDuplicates.ts
454
+ //#region src/root/functions/arrayHelpers/removeDuplicates.ts
440
455
  /**
441
456
  * Removes duplicate values from an array.
442
457
  *
@@ -455,7 +470,7 @@ function removeDuplicates(array) {
455
470
  }
456
471
 
457
472
  //#endregion
458
- //#region src/functions/date/addDaysToDate.ts
473
+ //#region src/root/functions/date/addDaysToDate.ts
459
474
  /**
460
475
  * Adds a given number of days to the provided date, returning the result as a new instance of Date.
461
476
  *
@@ -473,7 +488,7 @@ function addDaysToDate(currentDate = /* @__PURE__ */ new Date(), dayIncrement =
473
488
  }
474
489
 
475
490
  //#endregion
476
- //#region src/functions/date/isSameDate.ts
491
+ //#region src/root/functions/date/isSameDate.ts
477
492
  /**
478
493
  * Checks if the provided dates happen on the exact same day, month, and year.
479
494
  *
@@ -489,7 +504,7 @@ function isSameDate(firstDate, secondDate) {
489
504
  }
490
505
 
491
506
  //#endregion
492
- //#region src/functions/date/formatDateAndTime.ts
507
+ //#region src/root/functions/date/formatDateAndTime.ts
493
508
  /**
494
509
  * Creates a human-readable string with information about the input date.
495
510
  *
@@ -513,7 +528,7 @@ function formatDateAndTime(inputDate) {
513
528
  }
514
529
 
515
530
  //#endregion
516
- //#region src/functions/date/isLeapYear.ts
531
+ //#region src/root/functions/date/isLeapYear.ts
517
532
  /**
518
533
  * Checks if the provided year is a leap year.
519
534
  *
@@ -531,7 +546,7 @@ function isLeapYear(year) {
531
546
  }
532
547
 
533
548
  //#endregion
534
- //#region src/functions/date/isAnniversary.ts
549
+ //#region src/root/functions/date/isAnniversary.ts
535
550
  function checkLeapYear(firstDate, secondDate) {
536
551
  if (isLeapYear(firstDate.getFullYear()) && firstDate.getMonth() === 1 && secondDate.getMonth() === 1) return firstDate.getDate() === 29 && secondDate.getDate() === 28;
537
552
  return false;
@@ -552,7 +567,7 @@ function isAnniversary(firstDate, secondDate) {
552
567
  }
553
568
 
554
569
  //#endregion
555
- //#region src/functions/date/isMonthlyMultiple.ts
570
+ //#region src/root/functions/date/isMonthlyMultiple.ts
556
571
  function endOfMonthChecksButNotFebruary(firstDate, secondDate) {
557
572
  if ([
558
573
  3,
@@ -601,7 +616,7 @@ function isMonthlyMultiple(firstDate, secondDate) {
601
616
  }
602
617
 
603
618
  //#endregion
604
- //#region src/functions/miscellaneous/convertFileToBase64.ts
619
+ //#region src/root/functions/miscellaneous/convertFileToBase64.ts
605
620
  /**
606
621
  * Asynchronously converts a file to a base 64 string
607
622
  *
@@ -631,7 +646,7 @@ function convertFileToBase64(file) {
631
646
  }
632
647
 
633
648
  //#endregion
634
- //#region src/functions/miscellaneous/createFormData.ts
649
+ //#region src/root/functions/miscellaneous/createFormData.ts
635
650
  function getNullableResolutionStrategy(key, strategy) {
636
651
  return (typeof strategy === "object" ? strategy[key] : strategy) ?? "empty";
637
652
  }
@@ -700,7 +715,26 @@ function createFormData(data, options = {
700
715
  }
701
716
 
702
717
  //#endregion
703
- //#region src/functions/miscellaneous/isOrdered.ts
718
+ //#region src/root/functions/miscellaneous/getDependenciesFromGroup.ts
719
+ /**
720
+ * Get the dependencies from a given dependency group in `package.json`.
721
+ *
722
+ * @category Miscellaneous
723
+ *
724
+ * @param packageInfo - The data coming from `package.json`.
725
+ * @param dependencyGroup - The group to get dependency information about (can be `dependencies` or `devDependencies`).
726
+ *
727
+ * @returns A record consisting of the package names and version ranges from the given dependency group.
728
+ */
729
+ function getDependenciesFromGroup(packageInfo, dependencyGroup) {
730
+ return {
731
+ dependencies: parseZodSchema(zod.default.record(zod.default.string(), zod.default.string()), packageInfo.dependencies ?? {}),
732
+ devDependencies: parseZodSchema(zod.default.record(zod.default.string(), zod.default.string()), packageInfo.devDependencies ?? {})
733
+ }[dependencyGroup];
734
+ }
735
+
736
+ //#endregion
737
+ //#region src/root/functions/miscellaneous/isOrdered.ts
704
738
  /**
705
739
  * Checks to see if the given array is sorted in ascending order.
706
740
  *
@@ -718,7 +752,7 @@ function isOrdered(array) {
718
752
  }
719
753
 
720
754
  //#endregion
721
- //#region src/functions/recursive/deepFreeze.ts
755
+ //#region src/root/functions/recursive/deepFreeze.ts
722
756
  /**
723
757
  * Deeply freezes an object or array such that all child objects/arrays are also frozen.
724
758
  *
@@ -742,7 +776,7 @@ function deepFreeze(object) {
742
776
  }
743
777
 
744
778
  //#endregion
745
- //#region src/functions/taggedTemplate/createTemplateStringsArray.ts
779
+ //#region src/root/functions/taggedTemplate/createTemplateStringsArray.ts
746
780
  /**
747
781
  * Creates a template strings array given a regular array of strings
748
782
  *
@@ -757,31 +791,7 @@ function createTemplateStringsArray(strings) {
757
791
  }
758
792
 
759
793
  //#endregion
760
- //#region src/functions/taggedTemplate/getInterpolations.ts
761
- /**
762
- *
763
- * Gets the strings and interpolations separately from a template string.
764
- * You can pass a template string directly by doing:
765
- *
766
- * ```typescript
767
- * getInterpolations`Template string here`.
768
- * ```
769
- *
770
- * @category Tagged Template
771
- *
772
- * @deprecated Please use `getStringsAndInterpolations` instead.
773
- *
774
- * @param strings - The strings from the template to process.
775
- * @param interpolations - An array of all interpolations from the template.
776
- *
777
- * @returns A tuple where the first item is the strings from the template, and the second is the interpolations.
778
- */
779
- function getInterpolations(strings, ...interpolations) {
780
- return [strings, interpolations];
781
- }
782
-
783
- //#endregion
784
- //#region src/functions/taggedTemplate/getStringsAndInterpolations.ts
794
+ //#region src/root/functions/taggedTemplate/getStringsAndInterpolations.ts
785
795
  /**
786
796
  *
787
797
  * Gets the strings and interpolations separately from a template string.
@@ -822,7 +832,7 @@ function getStringsAndInterpolations(strings, ...interpolations) {
822
832
  }
823
833
 
824
834
  //#endregion
825
- //#region src/functions/taggedTemplate/interpolate.ts
835
+ //#region src/root/functions/taggedTemplate/interpolate.ts
826
836
  /**
827
837
  * Returns the result of interpolating a template string when given the strings and interpolations separately.
828
838
  *
@@ -850,7 +860,7 @@ function interpolate(strings, ...interpolations) {
850
860
  }
851
861
 
852
862
  //#endregion
853
- //#region src/functions/taggedTemplate/interpolateObjects.ts
863
+ //#region src/root/functions/taggedTemplate/interpolateObjects.ts
854
864
  /**
855
865
  * Returns the result of interpolating a template string, also stringifying objects.
856
866
  *
@@ -879,7 +889,7 @@ function interpolateObjects(strings, ...interpolations) {
879
889
  }
880
890
 
881
891
  //#endregion
882
- //#region src/functions/taggedTemplate/isTemplateStringsArray.ts
892
+ //#region src/root/functions/taggedTemplate/isTemplateStringsArray.ts
883
893
  /**
884
894
  * Determines whether or not the input is a valid `TemplateStringsArray`.
885
895
  *
@@ -894,7 +904,7 @@ function isTemplateStringsArray(input) {
894
904
  }
895
905
 
896
906
  //#endregion
897
- //#region src/functions/taggedTemplate/normaliseIndents.ts
907
+ //#region src/root/functions/taggedTemplate/normaliseIndents.ts
898
908
  function calculateTabSize(line, whitespaceLength) {
899
909
  const potentialWhitespacePart = line.slice(0, whitespaceLength);
900
910
  const trimmedString = line.trimStart();
@@ -983,7 +993,7 @@ function normaliseIndents(first, ...args) {
983
993
  const normalizeIndents = normaliseIndents;
984
994
 
985
995
  //#endregion
986
- //#region src/functions/miscellaneous/sayHello.ts
996
+ //#region src/root/functions/miscellaneous/sayHello.ts
987
997
  /**
988
998
  * Returns a string representing the lyrics to the package's theme song, Commit To You
989
999
  *
@@ -1097,7 +1107,7 @@ function sayHello() {
1097
1107
  }
1098
1108
 
1099
1109
  //#endregion
1100
- //#region src/functions/miscellaneous/stringifyDotenv.ts
1110
+ //#region src/root/functions/miscellaneous/stringifyDotenv.ts
1101
1111
  /**
1102
1112
  * Converts an object into a string in .env file format.
1103
1113
  *
@@ -1133,7 +1143,7 @@ function stringifyDotenv(contents, options) {
1133
1143
  }
1134
1144
 
1135
1145
  //#endregion
1136
- //#region src/functions/miscellaneous/stringListToArray.ts
1146
+ //#region src/root/functions/miscellaneous/stringListToArray.ts
1137
1147
  /**
1138
1148
  * Converts a stringly-typed list to a proper array.
1139
1149
  *
@@ -1155,7 +1165,7 @@ function stringListToArray(stringList, { separator = ",", trimWhitespace = true
1155
1165
  }
1156
1166
 
1157
1167
  //#endregion
1158
- //#region src/functions/miscellaneous/wait.ts
1168
+ //#region src/root/functions/miscellaneous/wait.ts
1159
1169
  /**
1160
1170
  * Waits for the given number of seconds
1161
1171
  *
@@ -1174,7 +1184,7 @@ function wait(seconds) {
1174
1184
  }
1175
1185
 
1176
1186
  //#endregion
1177
- //#region src/functions/objectHelpers/getRecordKeys.ts
1187
+ //#region src/root/functions/objectHelpers/getRecordKeys.ts
1178
1188
  /**
1179
1189
  * Gets the keys from a given record object, properly typed to be an array of the key of the input object's type.
1180
1190
  *
@@ -1191,7 +1201,7 @@ function getRecordKeys(record) {
1191
1201
  }
1192
1202
 
1193
1203
  //#endregion
1194
- //#region src/functions/objectHelpers/omitProperties.ts
1204
+ //#region src/root/functions/objectHelpers/omitProperties.ts
1195
1205
  /**
1196
1206
  * Omits properties from a given object.
1197
1207
  *
@@ -1214,7 +1224,7 @@ function omitProperties(object, keysToOmit) {
1214
1224
  }
1215
1225
 
1216
1226
  //#endregion
1217
- //#region src/functions/objectHelpers/removeUndefinedFromObject.ts
1227
+ //#region src/root/functions/objectHelpers/removeUndefinedFromObject.ts
1218
1228
  /**
1219
1229
  * Removes entries whose values are `undefined` from a given object (not including null etc.).
1220
1230
  *
@@ -1229,7 +1239,7 @@ function removeUndefinedFromObject(object) {
1229
1239
  }
1230
1240
 
1231
1241
  //#endregion
1232
- //#region src/functions/parsers/parseBoolean.ts
1242
+ //#region src/root/functions/parsers/parseBoolean.ts
1233
1243
  /**
1234
1244
  * Takes a stringly-typed boolean and converts it to an actual boolean type.
1235
1245
  *
@@ -1243,13 +1253,13 @@ function removeUndefinedFromObject(object) {
1243
1253
  */
1244
1254
  function parseBoolean(inputString) {
1245
1255
  const normalisedString = inputString.toLowerCase();
1246
- if (!["true", "false"].includes(normalisedString)) throw new DataError(inputString, "INVALID_BOOLEAN_STRING", "The provided boolean string must be one of `true | false`");
1256
+ if (!["true", "false"].includes(normalisedString)) throw new DataError({ inputString }, "INVALID_BOOLEAN_STRING", "The provided boolean string must be one of `true | false`");
1247
1257
  return normalisedString === "true";
1248
1258
  }
1249
1259
 
1250
1260
  //#endregion
1251
- //#region src/functions/parsers/zod/_parseZodSchema.ts
1252
- function _parseZodSchema(parsedResult, data, onError) {
1261
+ //#region src/root/functions/parsers/zod/_parseZodSchema.ts
1262
+ function _parseZodSchema(parsedResult, input, onError) {
1253
1263
  if (!parsedResult.success) {
1254
1264
  if (onError) {
1255
1265
  if (onError instanceof Error) throw onError;
@@ -1263,7 +1273,7 @@ function _parseZodSchema(parsedResult, data, onError) {
1263
1273
  const code = issue.code.toUpperCase();
1264
1274
  allErrorCodes[code] = (allErrorCodes[code] ?? 0) + 1;
1265
1275
  }
1266
- throw new DataError(data, Object.entries(allErrorCodes).toSorted(([_, firstCount], [__, secondCount]) => {
1276
+ throw new DataError({ input }, Object.entries(allErrorCodes).toSorted(([_, firstCount], [__, secondCount]) => {
1267
1277
  return secondCount - firstCount;
1268
1278
  }).map(([code, count], _, allErrorCodes) => {
1269
1279
  return allErrorCodes.length === 1 && count === 1 ? code : `${code}×${count}`;
@@ -1273,7 +1283,7 @@ function _parseZodSchema(parsedResult, data, onError) {
1273
1283
  }
1274
1284
 
1275
1285
  //#endregion
1276
- //#region src/functions/parsers/zod/parseZodSchema.ts
1286
+ //#region src/root/functions/parsers/zod/parseZodSchema.ts
1277
1287
  /**
1278
1288
  * An alternative function to zodSchema.parse() that can be used to strictly parse Zod schemas.
1279
1289
  *
@@ -1285,19 +1295,19 @@ function _parseZodSchema(parsedResult, data, onError) {
1285
1295
  * @template ErrorType - The type of error to throw on invalid data.
1286
1296
  *
1287
1297
  * @param schema - The Zod schema to use in parsing.
1288
- * @param data - The data to parse.
1298
+ * @param input - The data to parse.
1289
1299
  * @param onError - A custom error to throw on invalid data (defaults to `DataError`). May either be the error itself, or a function that returns the error or nothing. If nothing is returned, the default error is thrown instead.
1290
1300
  *
1291
1301
  * @throws {DataError} If the given data cannot be parsed according to the schema.
1292
1302
  *
1293
1303
  * @returns The parsed data from the Zod schema.
1294
1304
  */
1295
- function parseZodSchema(schema, data, onError) {
1296
- return _parseZodSchema(schema.safeParse(data), data, onError);
1305
+ function parseZodSchema(schema, input, onError) {
1306
+ return _parseZodSchema(schema.safeParse(input), input, onError);
1297
1307
  }
1298
1308
 
1299
1309
  //#endregion
1300
- //#region src/functions/parsers/parseEnv.ts
1310
+ //#region src/root/functions/parsers/parseEnv.ts
1301
1311
  /**
1302
1312
  * Represents the three common development environments.
1303
1313
  *
@@ -1313,18 +1323,18 @@ const Env = {
1313
1323
  *
1314
1324
  * @category Parsers
1315
1325
  *
1316
- * @param data - The data to parse.
1326
+ * @param input - The data to parse.
1317
1327
  *
1318
1328
  * @throws {DataError} If the data does not match one of the environments allowed by the Env types ("test" | "development" | "production").
1319
1329
  *
1320
1330
  * @returns The specified environment if allowed.
1321
1331
  */
1322
- function parseEnv(data) {
1323
- return parseZodSchema(zod.z.enum(Env), data, new DataError(data, "INVALID_ENV", "The provided environment type must be one of `test | development | production`"));
1332
+ function parseEnv(input) {
1333
+ return parseZodSchema(zod.z.enum(Env), input, new DataError({ input }, "INVALID_ENV", "The provided environment type must be one of `test | development | production`"));
1324
1334
  }
1325
1335
 
1326
1336
  //#endregion
1327
- //#region src/functions/parsers/parseFilePath.ts
1337
+ //#region src/root/functions/parsers/parseFilePath.ts
1328
1338
  /**
1329
1339
  * Takes a file path string and parses it into the directory part, the base part, and the full path.
1330
1340
  *
@@ -1355,7 +1365,7 @@ function parseFilePath(filePath) {
1355
1365
  }
1356
1366
 
1357
1367
  //#endregion
1358
- //#region src/functions/parsers/parseFormData.ts
1368
+ //#region src/root/functions/parsers/parseFormData.ts
1359
1369
  /**
1360
1370
  * Returns an object given FormData and an optional data parser function to call on the resulting object.
1361
1371
  *
@@ -1378,7 +1388,7 @@ function parseFormData(formData, dataParser) {
1378
1388
  }
1379
1389
 
1380
1390
  //#endregion
1381
- //#region src/functions/parsers/parseVersionType.ts
1391
+ //#region src/root/functions/parsers/parseVersionType.ts
1382
1392
  /**
1383
1393
  * Represents the three common software version types.
1384
1394
  *
@@ -1394,18 +1404,18 @@ const VersionType = {
1394
1404
  *
1395
1405
  * @category Parsers
1396
1406
  *
1397
- * @param data - The data to parse.
1407
+ * @param input - The data to parse.
1398
1408
  *
1399
1409
  * @throws {DataError} If the data does not match one of the allowed version types (`"major" | "minor" | "patch"`).
1400
1410
  *
1401
1411
  * @returns The given version type if allowed.
1402
1412
  */
1403
- function parseVersionType(data) {
1404
- return parseZodSchema(zod.default.enum(VersionType), data, new DataError(data, "INVALID_VERSION_TYPE", "The provided version type must be one of `major | minor | patch`"));
1413
+ function parseVersionType(input) {
1414
+ return parseZodSchema(zod.default.enum(VersionType), input, new DataError({ input }, "INVALID_VERSION_TYPE", "The provided version type must be one of `major | minor | patch`"));
1405
1415
  }
1406
1416
 
1407
1417
  //#endregion
1408
- //#region src/functions/parsers/zod/parseZodSchemaAsync.ts
1418
+ //#region src/root/functions/parsers/zod/parseZodSchemaAsync.ts
1409
1419
  /**
1410
1420
  * An alternative function to zodSchema.parseAsync() that can be used to strictly parse asynchronous Zod schemas.
1411
1421
  *
@@ -1415,19 +1425,19 @@ function parseVersionType(data) {
1415
1425
  * @template ErrorType - The type of error to throw on invalid data.
1416
1426
  *
1417
1427
  * @param schema - The Zod schema to use in parsing.
1418
- * @param data - The data to parse.
1428
+ * @param input - The data to parse.
1419
1429
  * @param onError - A custom error to throw on invalid data (defaults to `DataError`). May either be the error itself, or a function that returns the error or nothing. If nothing is returned, the default error is thrown instead.
1420
1430
  *
1421
1431
  * @throws {DataError} If the given data cannot be parsed according to the schema.
1422
1432
  *
1423
1433
  * @returns The parsed data from the Zod schema.
1424
1434
  */
1425
- async function parseZodSchemaAsync(schema, data, onError) {
1426
- return _parseZodSchema(await schema.safeParseAsync(data), data, onError);
1435
+ async function parseZodSchemaAsync(schema, input, onError) {
1436
+ return _parseZodSchema(await schema.safeParseAsync(input), input, onError);
1427
1437
  }
1428
1438
 
1429
1439
  //#endregion
1430
- //#region src/functions/recursive/deepCopy.ts
1440
+ //#region src/root/functions/recursive/deepCopy.ts
1431
1441
  function callDeepCopy(input) {
1432
1442
  return typeof input === "object" && input !== null ? deepCopy(input) : input;
1433
1443
  }
@@ -1455,7 +1465,7 @@ function deepCopy(object) {
1455
1465
  }
1456
1466
 
1457
1467
  //#endregion
1458
- //#region src/functions/security/encryptWithKey.ts
1468
+ //#region src/root/functions/security/encryptWithKey.ts
1459
1469
  /**
1460
1470
  * Encrypt a secret given the public base64 key and the thing you want to encrypt.
1461
1471
  *
@@ -1476,32 +1486,7 @@ async function encryptWithKey(publicKey, plaintextValue) {
1476
1486
  }
1477
1487
 
1478
1488
  //#endregion
1479
- //#region src/functions/security/getPublicAndPrivateKey.ts
1480
- /**
1481
- * Returns the public key and private key, properly narrowing down types depending on the provided `outputFormat`.
1482
- *
1483
- * @deprecated Please use `sodium.crypto_box_keypair` from `libsodium-wrappers` instead.
1484
- *
1485
- * This function was initially created to deal with a typing issue with the package introduced in v0.8.1 of said package, but this seems to have been fixed in v0.8.2
1486
- *
1487
- * @param outputFormat - The format of the resulting publicKey and privateKey you would like to use.
1488
- *
1489
- * @returns An object containing both the publicKey and privateKey, along with a keyType.
1490
- */
1491
- function getPublicAndPrivateKey(outputFormat) {
1492
- const keys = libsodium_wrappers.default.crypto_box_keypair(outputFormat);
1493
- if (outputFormat === "uint8array" || outputFormat === void 0) {
1494
- if (!(keys?.publicKey instanceof Uint8Array && keys?.privateKey instanceof Uint8Array)) throw new DataError({
1495
- publicKey: `<redacted: ${keys?.publicKey?.constructor?.name ?? typeof keys?.publicKey}>`,
1496
- privateKey: `<redacted: ${keys?.privateKey?.constructor?.name ?? typeof keys?.privateKey}>`
1497
- }, "INVALID_KEY_TYPES", "Expected Uint8Array keypair from libsodium.");
1498
- return keys;
1499
- }
1500
- return keys;
1501
- }
1502
-
1503
- //#endregion
1504
- //#region src/functions/stringHelpers/appendSemicolon.ts
1489
+ //#region src/root/functions/stringHelpers/appendSemicolon.ts
1505
1490
  /**
1506
1491
  * Appends a semicolon to the end of a string, trimming where necessary first.
1507
1492
  *
@@ -1521,7 +1506,7 @@ function appendSemicolon(stringToAppendTo) {
1521
1506
  }
1522
1507
 
1523
1508
  //#endregion
1524
- //#region src/functions/stringHelpers/camelToKebab.ts
1509
+ //#region src/root/functions/stringHelpers/camelToKebab.ts
1525
1510
  /**
1526
1511
  * Converts a string from camelCase to kebab-case
1527
1512
  *
@@ -1560,7 +1545,7 @@ function camelToKebab(string, options = { preserveConsecutiveCapitals: true }) {
1560
1545
  }
1561
1546
 
1562
1547
  //#endregion
1563
- //#region src/functions/stringHelpers/kebabToCamel.ts
1548
+ //#region src/root/functions/stringHelpers/kebabToCamel.ts
1564
1549
  /**
1565
1550
  * Converts a string from kebab-case to camelCase
1566
1551
  *
@@ -1599,44 +1584,7 @@ function kebabToCamel(string, options) {
1599
1584
  }
1600
1585
 
1601
1586
  //#endregion
1602
- //#region src/functions/stringHelpers/normalizeImportPath.ts
1603
- /**
1604
- * Normalizes an import path meant for use in an import statement in JavaScript.
1605
- * When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used. If the path is a zero-length string, '.' is returned, representing the current working directory.
1606
- *
1607
- * If the path starts with ./, it is preserved (unlike what would happen with path.posix.normalize() normally).
1608
- *
1609
- * Helpful for custom linter rules that need to check (or fix) import paths.
1610
- *
1611
- * @category String Helpers
1612
- *
1613
- * @param importPath - The import path to normalize.
1614
- *
1615
- * @returns The import path normalized.
1616
- */
1617
- function normalizeImportPath(importPath) {
1618
- const normalizedPath = node_path.default.posix.normalize(importPath);
1619
- if (importPath.startsWith("./") && !normalizedPath.startsWith("./")) return `./${normalizedPath}`;
1620
- return normalizedPath;
1621
- }
1622
- /**
1623
- * Normalises an import path meant for use in an import statement in JavaScript.
1624
- * When multiple slashes are found, they're replaced by a single one; when the path contains a trailing slash, it is preserved. On Windows backslashes are used. If the path is a zero-length string, '.' is returned, representing the current working directory.
1625
- *
1626
- * If the path starts with ./, it is preserved (unlike what would happen with path.posix.normalize() normally).
1627
- *
1628
- * Helpful for custom linter rules that need to check (or fix) import paths.
1629
- *
1630
- * @category String Helpers
1631
- *
1632
- * @param importPath - The import path to normalise.
1633
- *
1634
- * @returns The import path normalised.
1635
- */
1636
- const normaliseImportPath = normalizeImportPath;
1637
-
1638
- //#endregion
1639
- //#region src/functions/stringHelpers/truncate.ts
1587
+ //#region src/root/functions/stringHelpers/truncate.ts
1640
1588
  /**
1641
1589
  * Truncates a string and appends `...` to the end of it
1642
1590
  *
@@ -1651,94 +1599,6 @@ function truncate(stringToTruncate, maxLength = 5) {
1651
1599
  return stringToTruncate.length > maxLength ? `${stringToTruncate.slice(0, maxLength)}...` : stringToTruncate;
1652
1600
  }
1653
1601
 
1654
- //#endregion
1655
- //#region src/functions/versioning/parseVersion.ts
1656
- /**
1657
- * Parses a string and verifies it is a valid package version number.
1658
- *
1659
- * Valid formats: `X.Y.Z` or `vX.Y.Z`, where X, Y, and Z are non-negative integers.
1660
- *
1661
- * @deprecated This function does not support the new class-based handling of VersionNumber. Please use `new VersionNumber(input)` instead.
1662
- *
1663
- * @param input - The version string to parse.
1664
- * @param options - Extra options to apply.
1665
- *
1666
- * @throws {DataError} If the input is not a valid version number.
1667
- *
1668
- * @returns The validated version number, prefixed with `v` if it was not already.
1669
- */
1670
- function parseVersion(input, options) {
1671
- 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.`);
1672
- if (options?.omitPrefix) return input.startsWith("v") ? input.slice(1) : input;
1673
- return input.startsWith("v") ? input : `v${input}`;
1674
- }
1675
-
1676
- //#endregion
1677
- //#region src/functions/versioning/getIndividualVersionNumbers.ts
1678
- /**
1679
- * Gets the individual version numbers from a given version number as a tuple of numbers.
1680
- *
1681
- * @deprecated This function does not support the new class-based handling of VersionNumber. Please use one of the following instead:
1682
- * ```typescript
1683
- * new VersionNumber(version).major
1684
- * new VersionNumber(version).minor
1685
- * new VersionNumber(version).patch
1686
- * ```
1687
- *
1688
- * @param version - The version number.
1689
- *
1690
- * @returns A tuple of three numbers indicating `[major, minor, patch]`.
1691
- */
1692
- function getIndividualVersionNumbers(version) {
1693
- return parseVersion(version, { omitPrefix: true }).split(".").map((versionNumber) => {
1694
- return parseIntStrict(versionNumber);
1695
- });
1696
- }
1697
-
1698
- //#endregion
1699
- //#region src/functions/versioning/determineVersionType.ts
1700
- /**
1701
- * Determines whether the given version is a major, minor, or patch version.
1702
- *
1703
- * @deprecated This function does not support the new class-based handling of VersionNumber. Please use `new VersionNumber(version).type` instead.
1704
- *
1705
- * @param version - The version number.
1706
- *
1707
- * @returns Either `"major"`, `"minor"`, or `"patch"`, depending on the version type.
1708
- */
1709
- function determineVersionType(version) {
1710
- const [_major, minor, patch] = getIndividualVersionNumbers(version);
1711
- if (minor === 0 && patch === 0) return "major";
1712
- if (patch === 0) return "minor";
1713
- return "patch";
1714
- }
1715
-
1716
- //#endregion
1717
- //#region src/functions/versioning/incrementVersion.ts
1718
- /**
1719
- * Increments the given input version depending on the given increment type.
1720
- *
1721
- * @deprecated This function does not support the new class-based handling of VersionNumber. Please use `new VersionNumber(version).increment(incrementType)` instead.
1722
- *
1723
- * @param version - The version to increment
1724
- * @param incrementType - The type of increment. Can be one of the following:
1725
- * - `"major"`: Change the major version `v1.2.3` → `v2.0.0`
1726
- * - `"minor"`: Change the minor version `v1.2.3` → `v1.3.0`
1727
- * - `"patch"`: Change the patch version `v1.2.3` → `v1.2.4`
1728
- * @param options - Extra options to apply.
1729
- *
1730
- * @returns A new string representing the version with the increment applied.
1731
- */
1732
- function incrementVersion(version, incrementType, options) {
1733
- const [major, minor, patch] = getIndividualVersionNumbers(version);
1734
- const newVersion = {
1735
- major: `${major + 1}.0.0`,
1736
- minor: `${major}.${minor + 1}.0`,
1737
- patch: `${major}.${minor}.${patch + 1}`
1738
- }[incrementType];
1739
- return parseVersion(newVersion, { omitPrefix: options?.omitPrefix });
1740
- }
1741
-
1742
1602
  //#endregion
1743
1603
  exports.APIError = APIError;
1744
1604
  exports.DataError = DataError;
@@ -1756,18 +1616,14 @@ exports.createFormData = createFormData;
1756
1616
  exports.createTemplateStringsArray = createTemplateStringsArray;
1757
1617
  exports.deepCopy = deepCopy;
1758
1618
  exports.deepFreeze = deepFreeze;
1759
- exports.determineVersionType = determineVersionType;
1760
1619
  exports.encryptWithKey = encryptWithKey;
1761
1620
  exports.fillArray = fillArray;
1762
1621
  exports.formatDateAndTime = formatDateAndTime;
1763
- exports.getIndividualVersionNumbers = getIndividualVersionNumbers;
1764
- exports.getInterpolations = getInterpolations;
1765
- exports.getPublicAndPrivateKey = getPublicAndPrivateKey;
1622
+ exports.getDependenciesFromGroup = getDependenciesFromGroup;
1766
1623
  exports.getRandomNumber = getRandomNumber;
1767
1624
  exports.getRecordKeys = getRecordKeys;
1768
1625
  exports.getStringsAndInterpolations = getStringsAndInterpolations;
1769
1626
  exports.httpErrorCodeLookup = httpErrorCodeLookup;
1770
- exports.incrementVersion = incrementVersion;
1771
1627
  exports.interpolate = interpolate;
1772
1628
  exports.interpolateObjects = interpolateObjects;
1773
1629
  exports.isAnniversary = isAnniversary;
@@ -1777,9 +1633,7 @@ exports.isOrdered = isOrdered;
1777
1633
  exports.isSameDate = isSameDate;
1778
1634
  exports.isTemplateStringsArray = isTemplateStringsArray;
1779
1635
  exports.kebabToCamel = kebabToCamel;
1780
- exports.normaliseImportPath = normaliseImportPath;
1781
1636
  exports.normaliseIndents = normaliseIndents;
1782
- exports.normalizeImportPath = normalizeImportPath;
1783
1637
  exports.normalizeIndents = normalizeIndents;
1784
1638
  exports.omitProperties = omitProperties;
1785
1639
  exports.paralleliseArrays = paralleliseArrays;
@@ -1788,7 +1642,6 @@ exports.parseEnv = parseEnv;
1788
1642
  exports.parseFilePath = parseFilePath;
1789
1643
  exports.parseFormData = parseFormData;
1790
1644
  exports.parseIntStrict = parseIntStrict;
1791
- exports.parseVersion = parseVersion;
1792
1645
  exports.parseVersionType = parseVersionType;
1793
1646
  exports.parseZodSchema = parseZodSchema;
1794
1647
  exports.parseZodSchemaAsync = parseZodSchemaAsync;