@alextheman/utility 5.3.0 → 5.4.1

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
@@ -32,19 +32,22 @@ let libsodium_wrappers = require("libsodium-wrappers");
32
32
  libsodium_wrappers = __toESM(libsodium_wrappers);
33
33
 
34
34
  //#region src/root/constants/FILE_PATH_REGEX.ts
35
- const FILE_PATH_REGEX = String.raw`^(?<directory>.+)[\/\\](?<base>[^\/\\]+)$`;
36
-
37
- //#endregion
38
- //#region src/root/constants/NAMESPACE_EXPORT_REGEX.ts
39
- const NAMESPACE_EXPORT_REGEX = "export\\s+\\*\\s+from";
35
+ const FILE_PATH_PATTERN = String.raw`(?<directory>.+)[\/\\](?<base>[^\/\\]+)`;
36
+ const FILE_PATH_REGEX = RegExp(`^${FILE_PATH_PATTERN}$`);
40
37
 
41
38
  //#endregion
42
39
  //#region src/root/constants/ONE_DAY_IN_MILLISECONDS.ts
43
40
  const ONE_DAY_IN_MILLISECONDS = 1440 * 60 * 1e3;
44
41
 
42
+ //#endregion
43
+ //#region src/root/constants/UUID_REGEX.ts
44
+ const UUID_PATTERN = "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}";
45
+ const UUID_REGEX = new RegExp(`^${UUID_PATTERN}$`);
46
+
45
47
  //#endregion
46
48
  //#region src/root/constants/VERSION_NUMBER_REGEX.ts
47
- const VERSION_NUMBER_REGEX = "^(?:v)?(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$";
49
+ const VERSION_NUMBER_PATTERN = String.raw`^(?:v)?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$`;
50
+ const VERSION_NUMBER_REGEX = RegExp(`^${VERSION_NUMBER_PATTERN}$`);
48
51
 
49
52
  //#endregion
50
53
  //#region src/root/functions/arrayHelpers/fillArray.ts
@@ -1399,6 +1402,25 @@ function parseFormData(formData, dataParser) {
1399
1402
  return object;
1400
1403
  }
1401
1404
 
1405
+ //#endregion
1406
+ //#region src/root/functions/parsers/parseUUID.ts
1407
+ /**
1408
+ * Parses the input and verifies it is a valid UUID.
1409
+ *
1410
+ * @category Parsers
1411
+ *
1412
+ * @param input - The data to parse.
1413
+ *
1414
+ * @throws {DataError} If the data does not match the general UUID pattern.
1415
+ *
1416
+ * @returns The UUID again if successful.
1417
+ */
1418
+ function parseUUID(input) {
1419
+ if (!(typeof input === "string")) throw new DataError({ input }, "INVALID_TYPE", "Invalid type - expected string.");
1420
+ if (!UUID_REGEX.test(input)) throw new DataError({ input }, "INVALID_UUID", "The provided input does not match the expected shape for a UUID.");
1421
+ return input;
1422
+ }
1423
+
1402
1424
  //#endregion
1403
1425
  //#region src/root/functions/parsers/parseVersionType.ts
1404
1426
  /**
@@ -1616,9 +1638,12 @@ function truncate(stringToTruncate, maxLength = 5) {
1616
1638
  exports.APIError = APIError;
1617
1639
  exports.DataError = DataError;
1618
1640
  exports.Env = Env;
1641
+ exports.FILE_PATH_PATTERN = FILE_PATH_PATTERN;
1619
1642
  exports.FILE_PATH_REGEX = FILE_PATH_REGEX;
1620
- exports.NAMESPACE_EXPORT_REGEX = NAMESPACE_EXPORT_REGEX;
1621
1643
  exports.ONE_DAY_IN_MILLISECONDS = ONE_DAY_IN_MILLISECONDS;
1644
+ exports.UUID_PATTERN = UUID_PATTERN;
1645
+ exports.UUID_REGEX = UUID_REGEX;
1646
+ exports.VERSION_NUMBER_PATTERN = VERSION_NUMBER_PATTERN;
1622
1647
  exports.VERSION_NUMBER_REGEX = VERSION_NUMBER_REGEX;
1623
1648
  exports.VersionNumber = VersionNumber;
1624
1649
  exports.VersionType = VersionType;
@@ -1654,6 +1679,7 @@ exports.parseBoolean = parseBoolean;
1654
1679
  exports.parseEnv = parseEnv;
1655
1680
  exports.parseFormData = parseFormData;
1656
1681
  exports.parseIntStrict = parseIntStrict;
1682
+ exports.parseUUID = parseUUID;
1657
1683
  exports.parseVersionType = parseVersionType;
1658
1684
  exports.parseZodSchema = parseZodSchema;
1659
1685
  exports.parseZodSchemaAsync = parseZodSchemaAsync;
package/dist/index.d.cts CHANGED
@@ -2,16 +2,19 @@ import z, { ZodError, ZodType, z as z$1 } from "zod";
2
2
  import { DotenvParseOutput } from "dotenv";
3
3
 
4
4
  //#region src/root/constants/FILE_PATH_REGEX.d.ts
5
- declare const FILE_PATH_REGEX: string;
6
- //#endregion
7
- //#region src/root/constants/NAMESPACE_EXPORT_REGEX.d.ts
8
- declare const NAMESPACE_EXPORT_REGEX = "export\\s+\\*\\s+from";
5
+ declare const FILE_PATH_PATTERN: string;
6
+ declare const FILE_PATH_REGEX: RegExp;
9
7
  //#endregion
10
8
  //#region src/root/constants/ONE_DAY_IN_MILLISECONDS.d.ts
11
9
  declare const ONE_DAY_IN_MILLISECONDS: number;
12
10
  //#endregion
11
+ //#region src/root/constants/UUID_REGEX.d.ts
12
+ declare const UUID_PATTERN = "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}";
13
+ declare const UUID_REGEX: RegExp;
14
+ //#endregion
13
15
  //#region src/root/constants/VERSION_NUMBER_REGEX.d.ts
14
- declare const VERSION_NUMBER_REGEX: string;
16
+ declare const VERSION_NUMBER_PATTERN: string;
17
+ declare const VERSION_NUMBER_REGEX: RegExp;
15
18
  //#endregion
16
19
  //#region src/root/functions/arrayHelpers/fillArray.d.ts
17
20
  /**
@@ -737,6 +740,20 @@ declare function parseFormData(formData: FormData): Record<string, string | Blob
737
740
  */
738
741
  declare function parseIntStrict(string: string, radix?: number): number;
739
742
  //#endregion
743
+ //#region src/root/functions/parsers/parseUUID.d.ts
744
+ /**
745
+ * Parses the input and verifies it is a valid UUID.
746
+ *
747
+ * @category Parsers
748
+ *
749
+ * @param input - The data to parse.
750
+ *
751
+ * @throws {DataError} If the data does not match the general UUID pattern.
752
+ *
753
+ * @returns The UUID again if successful.
754
+ */
755
+ declare function parseUUID(input: unknown): string;
756
+ //#endregion
740
757
  //#region src/root/functions/parsers/parseVersionType.d.ts
741
758
  /**
742
759
  * Represents the three common software version types.
@@ -1083,4 +1100,4 @@ declare function normaliseIndents(strings: TemplateStringsArray, ...interpolatio
1083
1100
  */
1084
1101
  declare const normalizeIndents: typeof normaliseIndents;
1085
1102
  //#endregion
1086
- export { APIError, ArrayElement, CallReturnType, CamelToKebabOptions, CreateEnumType, CreateFormDataOptions, CreateFormDataOptionsNullableResolution, CreateFormDataOptionsUndefinedOrNullResolution, DataError, DisallowUndefined, Env, FILE_PATH_REGEX, FormDataArrayResolutionStrategy, FormDataNullableResolutionStrategy, HTTPErrorCode, IgnoreCase, IsTypeArgumentString, KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, ONE_DAY_IN_MILLISECONDS, OptionalOnCondition, ParallelTuple, RecordKey, RemoveUndefined, StringListToArrayOptions, VERSION_NUMBER_REGEX, VersionNumber, FormatOptionsBase as VersionNumberToStringOptions, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, encryptWithKey, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, stringListToArray, stringifyDotenv, truncate, wait, zodVersionNumber };
1103
+ export { APIError, ArrayElement, CallReturnType, CamelToKebabOptions, CreateEnumType, CreateFormDataOptions, CreateFormDataOptionsNullableResolution, CreateFormDataOptionsUndefinedOrNullResolution, DataError, DisallowUndefined, Env, FILE_PATH_PATTERN, FILE_PATH_REGEX, FormDataArrayResolutionStrategy, FormDataNullableResolutionStrategy, HTTPErrorCode, IgnoreCase, IsTypeArgumentString, KebabToCamelOptions, NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, ONE_DAY_IN_MILLISECONDS, OptionalOnCondition, ParallelTuple, RecordKey, RemoveUndefined, StringListToArrayOptions, UUID_PATTERN, UUID_REGEX, VERSION_NUMBER_PATTERN, VERSION_NUMBER_REGEX, VersionNumber, FormatOptionsBase as VersionNumberToStringOptions, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, encryptWithKey, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, stringListToArray, stringifyDotenv, truncate, wait, zodVersionNumber };
package/dist/index.d.ts CHANGED
@@ -2,16 +2,19 @@ import z, { ZodError, ZodType, z as z$1 } from "zod";
2
2
  import { DotenvParseOutput } from "dotenv";
3
3
 
4
4
  //#region src/root/constants/FILE_PATH_REGEX.d.ts
5
- declare const FILE_PATH_REGEX: string;
6
- //#endregion
7
- //#region src/root/constants/NAMESPACE_EXPORT_REGEX.d.ts
8
- declare const NAMESPACE_EXPORT_REGEX = "export\\s+\\*\\s+from";
5
+ declare const FILE_PATH_PATTERN: string;
6
+ declare const FILE_PATH_REGEX: RegExp;
9
7
  //#endregion
10
8
  //#region src/root/constants/ONE_DAY_IN_MILLISECONDS.d.ts
11
9
  declare const ONE_DAY_IN_MILLISECONDS: number;
12
10
  //#endregion
11
+ //#region src/root/constants/UUID_REGEX.d.ts
12
+ declare const UUID_PATTERN = "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}";
13
+ declare const UUID_REGEX: RegExp;
14
+ //#endregion
13
15
  //#region src/root/constants/VERSION_NUMBER_REGEX.d.ts
14
- declare const VERSION_NUMBER_REGEX: string;
16
+ declare const VERSION_NUMBER_PATTERN: string;
17
+ declare const VERSION_NUMBER_REGEX: RegExp;
15
18
  //#endregion
16
19
  //#region src/root/functions/arrayHelpers/fillArray.d.ts
17
20
  /**
@@ -737,6 +740,20 @@ declare function parseFormData(formData: FormData): Record<string, string | Blob
737
740
  */
738
741
  declare function parseIntStrict(string: string, radix?: number): number;
739
742
  //#endregion
743
+ //#region src/root/functions/parsers/parseUUID.d.ts
744
+ /**
745
+ * Parses the input and verifies it is a valid UUID.
746
+ *
747
+ * @category Parsers
748
+ *
749
+ * @param input - The data to parse.
750
+ *
751
+ * @throws {DataError} If the data does not match the general UUID pattern.
752
+ *
753
+ * @returns The UUID again if successful.
754
+ */
755
+ declare function parseUUID(input: unknown): string;
756
+ //#endregion
740
757
  //#region src/root/functions/parsers/parseVersionType.d.ts
741
758
  /**
742
759
  * Represents the three common software version types.
@@ -1083,4 +1100,4 @@ declare function normaliseIndents(strings: TemplateStringsArray, ...interpolatio
1083
1100
  */
1084
1101
  declare const normalizeIndents: typeof normaliseIndents;
1085
1102
  //#endregion
1086
- export { APIError, type ArrayElement, type CallReturnType, CamelToKebabOptions, type CreateEnumType, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, DataError, type DisallowUndefined, Env, FILE_PATH_REGEX, type FormDataArrayResolutionStrategy, type FormDataNullableResolutionStrategy, type HTTPErrorCode, type IgnoreCase, type IsTypeArgumentString, KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, type NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, ONE_DAY_IN_MILLISECONDS, type OptionalOnCondition, ParallelTuple, type RecordKey, type RemoveUndefined, type StringListToArrayOptions, VERSION_NUMBER_REGEX, VersionNumber, type FormatOptionsBase as VersionNumberToStringOptions, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, encryptWithKey, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, stringListToArray, stringifyDotenv, truncate, wait, zodVersionNumber };
1103
+ export { APIError, type ArrayElement, type CallReturnType, CamelToKebabOptions, type CreateEnumType, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, DataError, type DisallowUndefined, Env, FILE_PATH_PATTERN, FILE_PATH_REGEX, type FormDataArrayResolutionStrategy, type FormDataNullableResolutionStrategy, type HTTPErrorCode, type IgnoreCase, type IsTypeArgumentString, KebabToCamelOptions, type NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, ONE_DAY_IN_MILLISECONDS, type OptionalOnCondition, ParallelTuple, type RecordKey, type RemoveUndefined, type StringListToArrayOptions, UUID_PATTERN, UUID_REGEX, VERSION_NUMBER_PATTERN, VERSION_NUMBER_REGEX, VersionNumber, type FormatOptionsBase as VersionNumberToStringOptions, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, encryptWithKey, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, stringListToArray, stringifyDotenv, truncate, wait, zodVersionNumber };
package/dist/index.js CHANGED
@@ -2,19 +2,22 @@ import z, { z as z$1 } from "zod";
2
2
  import sodium from "libsodium-wrappers";
3
3
 
4
4
  //#region src/root/constants/FILE_PATH_REGEX.ts
5
- const FILE_PATH_REGEX = String.raw`^(?<directory>.+)[\/\\](?<base>[^\/\\]+)$`;
6
-
7
- //#endregion
8
- //#region src/root/constants/NAMESPACE_EXPORT_REGEX.ts
9
- const NAMESPACE_EXPORT_REGEX = "export\\s+\\*\\s+from";
5
+ const FILE_PATH_PATTERN = String.raw`(?<directory>.+)[\/\\](?<base>[^\/\\]+)`;
6
+ const FILE_PATH_REGEX = RegExp(`^${FILE_PATH_PATTERN}$`);
10
7
 
11
8
  //#endregion
12
9
  //#region src/root/constants/ONE_DAY_IN_MILLISECONDS.ts
13
10
  const ONE_DAY_IN_MILLISECONDS = 1440 * 60 * 1e3;
14
11
 
12
+ //#endregion
13
+ //#region src/root/constants/UUID_REGEX.ts
14
+ const UUID_PATTERN = "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}";
15
+ const UUID_REGEX = new RegExp(`^${UUID_PATTERN}$`);
16
+
15
17
  //#endregion
16
18
  //#region src/root/constants/VERSION_NUMBER_REGEX.ts
17
- const VERSION_NUMBER_REGEX = "^(?:v)?(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$";
19
+ const VERSION_NUMBER_PATTERN = String.raw`^(?:v)?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$`;
20
+ const VERSION_NUMBER_REGEX = RegExp(`^${VERSION_NUMBER_PATTERN}$`);
18
21
 
19
22
  //#endregion
20
23
  //#region src/root/functions/arrayHelpers/fillArray.ts
@@ -1369,6 +1372,25 @@ function parseFormData(formData, dataParser) {
1369
1372
  return object;
1370
1373
  }
1371
1374
 
1375
+ //#endregion
1376
+ //#region src/root/functions/parsers/parseUUID.ts
1377
+ /**
1378
+ * Parses the input and verifies it is a valid UUID.
1379
+ *
1380
+ * @category Parsers
1381
+ *
1382
+ * @param input - The data to parse.
1383
+ *
1384
+ * @throws {DataError} If the data does not match the general UUID pattern.
1385
+ *
1386
+ * @returns The UUID again if successful.
1387
+ */
1388
+ function parseUUID(input) {
1389
+ if (!(typeof input === "string")) throw new DataError({ input }, "INVALID_TYPE", "Invalid type - expected string.");
1390
+ if (!UUID_REGEX.test(input)) throw new DataError({ input }, "INVALID_UUID", "The provided input does not match the expected shape for a UUID.");
1391
+ return input;
1392
+ }
1393
+
1372
1394
  //#endregion
1373
1395
  //#region src/root/functions/parsers/parseVersionType.ts
1374
1396
  /**
@@ -1583,4 +1605,4 @@ function truncate(stringToTruncate, maxLength = 5) {
1583
1605
  }
1584
1606
 
1585
1607
  //#endregion
1586
- export { APIError, DataError, Env, FILE_PATH_REGEX, NAMESPACE_EXPORT_REGEX, ONE_DAY_IN_MILLISECONDS, VERSION_NUMBER_REGEX, VersionNumber, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, encryptWithKey, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, stringListToArray, stringifyDotenv, truncate, wait, zodVersionNumber };
1608
+ export { APIError, DataError, Env, FILE_PATH_PATTERN, FILE_PATH_REGEX, ONE_DAY_IN_MILLISECONDS, UUID_PATTERN, UUID_REGEX, VERSION_NUMBER_PATTERN, VERSION_NUMBER_REGEX, VersionNumber, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, encryptWithKey, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, stringListToArray, stringifyDotenv, truncate, wait, zodVersionNumber };
@@ -183,15 +183,22 @@ var DataError = class DataError extends Error {
183
183
 
184
184
  //#endregion
185
185
  //#region src/root/constants/FILE_PATH_REGEX.ts
186
- const FILE_PATH_REGEX = String.raw`^(?<directory>.+)[\/\\](?<base>[^\/\\]+)$`;
186
+ const FILE_PATH_PATTERN = String.raw`(?<directory>.+)[\/\\](?<base>[^\/\\]+)`;
187
+ const FILE_PATH_REGEX = RegExp(`^${FILE_PATH_PATTERN}$`);
187
188
 
188
189
  //#endregion
189
190
  //#region src/root/constants/ONE_DAY_IN_MILLISECONDS.ts
190
191
  const ONE_DAY_IN_MILLISECONDS = 1440 * 60 * 1e3;
191
192
 
193
+ //#endregion
194
+ //#region src/root/constants/UUID_REGEX.ts
195
+ const UUID_PATTERN = "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}";
196
+ const UUID_REGEX = new RegExp(`^${UUID_PATTERN}$`);
197
+
192
198
  //#endregion
193
199
  //#region src/root/constants/VERSION_NUMBER_REGEX.ts
194
- const VERSION_NUMBER_REGEX = "^(?:v)?(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$";
200
+ const VERSION_NUMBER_PATTERN = String.raw`^(?:v)?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$`;
201
+ const VERSION_NUMBER_REGEX = RegExp(`^${VERSION_NUMBER_PATTERN}$`);
195
202
 
196
203
  //#endregion
197
204
  //#region src/root/types/VersionNumber.ts
@@ -153,15 +153,22 @@ var DataError = class DataError extends Error {
153
153
 
154
154
  //#endregion
155
155
  //#region src/root/constants/FILE_PATH_REGEX.ts
156
- const FILE_PATH_REGEX = String.raw`^(?<directory>.+)[\/\\](?<base>[^\/\\]+)$`;
156
+ const FILE_PATH_PATTERN = String.raw`(?<directory>.+)[\/\\](?<base>[^\/\\]+)`;
157
+ const FILE_PATH_REGEX = RegExp(`^${FILE_PATH_PATTERN}$`);
157
158
 
158
159
  //#endregion
159
160
  //#region src/root/constants/ONE_DAY_IN_MILLISECONDS.ts
160
161
  const ONE_DAY_IN_MILLISECONDS = 1440 * 60 * 1e3;
161
162
 
163
+ //#endregion
164
+ //#region src/root/constants/UUID_REGEX.ts
165
+ const UUID_PATTERN = "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}";
166
+ const UUID_REGEX = new RegExp(`^${UUID_PATTERN}$`);
167
+
162
168
  //#endregion
163
169
  //#region src/root/constants/VERSION_NUMBER_REGEX.ts
164
- const VERSION_NUMBER_REGEX = "^(?:v)?(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$";
170
+ const VERSION_NUMBER_PATTERN = String.raw`^(?:v)?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$`;
171
+ const VERSION_NUMBER_REGEX = RegExp(`^${VERSION_NUMBER_PATTERN}$`);
165
172
 
166
173
  //#endregion
167
174
  //#region src/root/types/VersionNumber.ts
@@ -70,15 +70,22 @@ const normaliseImportPath = normalizeImportPath;
70
70
 
71
71
  //#endregion
72
72
  //#region src/root/constants/FILE_PATH_REGEX.ts
73
- const FILE_PATH_REGEX = String.raw`^(?<directory>.+)[\/\\](?<base>[^\/\\]+)$`;
73
+ const FILE_PATH_PATTERN = String.raw`(?<directory>.+)[\/\\](?<base>[^\/\\]+)`;
74
+ const FILE_PATH_REGEX = RegExp(`^${FILE_PATH_PATTERN}$`);
74
75
 
75
76
  //#endregion
76
77
  //#region src/root/constants/ONE_DAY_IN_MILLISECONDS.ts
77
78
  const ONE_DAY_IN_MILLISECONDS = 1440 * 60 * 1e3;
78
79
 
80
+ //#endregion
81
+ //#region src/root/constants/UUID_REGEX.ts
82
+ const UUID_PATTERN = "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}";
83
+ const UUID_REGEX = new RegExp(`^${UUID_PATTERN}$`);
84
+
79
85
  //#endregion
80
86
  //#region src/root/constants/VERSION_NUMBER_REGEX.ts
81
- const VERSION_NUMBER_REGEX = "^(?:v)?(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$";
87
+ const VERSION_NUMBER_PATTERN = String.raw`^(?:v)?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$`;
88
+ const VERSION_NUMBER_REGEX = RegExp(`^${VERSION_NUMBER_PATTERN}$`);
82
89
 
83
90
  //#endregion
84
91
  //#region src/root/functions/arrayHelpers/fillArray.ts
@@ -40,15 +40,22 @@ const normaliseImportPath = normalizeImportPath;
40
40
 
41
41
  //#endregion
42
42
  //#region src/root/constants/FILE_PATH_REGEX.ts
43
- const FILE_PATH_REGEX = String.raw`^(?<directory>.+)[\/\\](?<base>[^\/\\]+)$`;
43
+ const FILE_PATH_PATTERN = String.raw`(?<directory>.+)[\/\\](?<base>[^\/\\]+)`;
44
+ const FILE_PATH_REGEX = RegExp(`^${FILE_PATH_PATTERN}$`);
44
45
 
45
46
  //#endregion
46
47
  //#region src/root/constants/ONE_DAY_IN_MILLISECONDS.ts
47
48
  const ONE_DAY_IN_MILLISECONDS = 1440 * 60 * 1e3;
48
49
 
50
+ //#endregion
51
+ //#region src/root/constants/UUID_REGEX.ts
52
+ const UUID_PATTERN = "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}";
53
+ const UUID_REGEX = new RegExp(`^${UUID_PATTERN}$`);
54
+
49
55
  //#endregion
50
56
  //#region src/root/constants/VERSION_NUMBER_REGEX.ts
51
- const VERSION_NUMBER_REGEX = "^(?:v)?(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$";
57
+ const VERSION_NUMBER_PATTERN = String.raw`^(?:v)?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$`;
58
+ const VERSION_NUMBER_REGEX = RegExp(`^${VERSION_NUMBER_PATTERN}$`);
52
59
 
53
60
  //#endregion
54
61
  //#region src/root/functions/arrayHelpers/fillArray.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alextheman/utility",
3
- "version": "5.3.0",
3
+ "version": "5.4.1",
4
4
  "description": "Helpful utility functions.",
5
5
  "repository": {
6
6
  "type": "git",