@alextheman/utility 5.23.2 → 5.25.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 +21 -6
- package/dist/index.d.cts +16 -4
- package/dist/index.d.ts +16 -4
- package/dist/index.js +19 -7
- package/dist/internal/index.cjs +2 -2
- package/dist/internal/index.js +2 -2
- package/dist/node/index.cjs +2 -2
- package/dist/node/index.js +2 -2
- package/dist/temporal/index.cjs +35 -0
- package/dist/temporal/index.d.cts +20 -0
- package/dist/temporal/index.d.ts +20 -0
- package/dist/temporal/index.js +34 -0
- package/package.json +6 -1
package/dist/index.cjs
CHANGED
|
@@ -24,19 +24,19 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
let zod = require("zod");
|
|
25
25
|
zod = __toESM(zod, 1);
|
|
26
26
|
//#region src/root/constants/FILE_PATH_REGEX.ts
|
|
27
|
-
const
|
|
28
|
-
const FILE_PATH_REGEX = RegExp(`^${
|
|
27
|
+
const FILE_PATH_REGEX_PATTERN = String.raw`(?<directory>.+)[\/\\](?<base>[^\/\\]+)`;
|
|
28
|
+
const FILE_PATH_REGEX = RegExp(`^${FILE_PATH_REGEX_PATTERN}$`);
|
|
29
29
|
//#endregion
|
|
30
30
|
//#region src/root/constants/ONE_DAY_IN_MILLISECONDS.ts
|
|
31
31
|
const ONE_DAY_IN_MILLISECONDS = 1440 * 60 * 1e3;
|
|
32
32
|
//#endregion
|
|
33
33
|
//#region src/root/constants/UUID_REGEX.ts
|
|
34
|
-
const
|
|
35
|
-
const UUID_REGEX = new RegExp(`^${
|
|
34
|
+
const UUID_REGEX_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}";
|
|
35
|
+
const UUID_REGEX = new RegExp(`^${UUID_REGEX_PATTERN}$`);
|
|
36
36
|
//#endregion
|
|
37
37
|
//#region src/root/constants/VERSION_NUMBER_REGEX.ts
|
|
38
|
-
const
|
|
39
|
-
const VERSION_NUMBER_REGEX = RegExp(`^${
|
|
38
|
+
const VERSION_NUMBER_REGEX_PATTERN = String.raw`(?:v)?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)`;
|
|
39
|
+
const VERSION_NUMBER_REGEX = RegExp(`^${VERSION_NUMBER_REGEX_PATTERN}$`);
|
|
40
40
|
//#endregion
|
|
41
41
|
//#region src/root/deprecated/APIError.ts
|
|
42
42
|
const httpErrorCodeLookup = {
|
|
@@ -2042,17 +2042,32 @@ var DataError = class DataError extends Error {
|
|
|
2042
2042
|
}
|
|
2043
2043
|
};
|
|
2044
2044
|
//#endregion
|
|
2045
|
+
//#region src/root/deprecated/FILE_PATH_PATTERN.ts
|
|
2046
|
+
/** @deprecated This has been renamed to `FILE_PATH_REGEX_PATTERN`. */
|
|
2047
|
+
const FILE_PATH_PATTERN = FILE_PATH_REGEX_PATTERN;
|
|
2048
|
+
//#endregion
|
|
2049
|
+
//#region src/root/deprecated/UUID_PATTERN.ts
|
|
2050
|
+
/** @deprecated This has been renamed to `UUID_REGEX_PATTERN`. */
|
|
2051
|
+
const UUID_PATTERN = UUID_REGEX_PATTERN;
|
|
2052
|
+
//#endregion
|
|
2053
|
+
//#region src/root/deprecated/VERSION_NUMBER_PATTERN.ts
|
|
2054
|
+
/** @deprecated This has been renamed to `VERSION_NUMBER_REGEX_PATTERN`. */
|
|
2055
|
+
const VERSION_NUMBER_PATTERN = String.raw`^(?:v)?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$`;
|
|
2056
|
+
//#endregion
|
|
2045
2057
|
exports.APIError = APIError;
|
|
2046
2058
|
exports.DataError = DataError;
|
|
2047
2059
|
exports.Env = Env;
|
|
2048
2060
|
exports.FILE_PATH_PATTERN = FILE_PATH_PATTERN;
|
|
2049
2061
|
exports.FILE_PATH_REGEX = FILE_PATH_REGEX;
|
|
2062
|
+
exports.FILE_PATH_REGEX_PATTERN = FILE_PATH_REGEX_PATTERN;
|
|
2050
2063
|
exports.ONE_DAY_IN_MILLISECONDS = ONE_DAY_IN_MILLISECONDS;
|
|
2051
2064
|
exports.SortDirection = SortDirection;
|
|
2052
2065
|
exports.UUID_PATTERN = UUID_PATTERN;
|
|
2053
2066
|
exports.UUID_REGEX = UUID_REGEX;
|
|
2067
|
+
exports.UUID_REGEX_PATTERN = UUID_REGEX_PATTERN;
|
|
2054
2068
|
exports.VERSION_NUMBER_PATTERN = VERSION_NUMBER_PATTERN;
|
|
2055
2069
|
exports.VERSION_NUMBER_REGEX = VERSION_NUMBER_REGEX;
|
|
2070
|
+
exports.VERSION_NUMBER_REGEX_PATTERN = VERSION_NUMBER_REGEX_PATTERN;
|
|
2056
2071
|
exports.VersionNumber = VersionNumber;
|
|
2057
2072
|
exports.VersionType = VersionType;
|
|
2058
2073
|
exports.addDaysToDate = addDaysToDate;
|
package/dist/index.d.cts
CHANGED
|
@@ -2,18 +2,18 @@ import z, { ZodCoercedDate, ZodCoercedNumber, ZodError, ZodType, z as z$1 } from
|
|
|
2
2
|
import { DotenvParseOutput } from "dotenv";
|
|
3
3
|
|
|
4
4
|
//#region src/root/constants/FILE_PATH_REGEX.d.ts
|
|
5
|
-
declare const
|
|
5
|
+
declare const FILE_PATH_REGEX_PATTERN: string;
|
|
6
6
|
declare const FILE_PATH_REGEX: RegExp;
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/root/constants/ONE_DAY_IN_MILLISECONDS.d.ts
|
|
9
9
|
declare const ONE_DAY_IN_MILLISECONDS: number;
|
|
10
10
|
//#endregion
|
|
11
11
|
//#region src/root/constants/UUID_REGEX.d.ts
|
|
12
|
-
declare const
|
|
12
|
+
declare const UUID_REGEX_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
13
|
declare const UUID_REGEX: RegExp;
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/root/constants/VERSION_NUMBER_REGEX.d.ts
|
|
16
|
-
declare const
|
|
16
|
+
declare const VERSION_NUMBER_REGEX_PATTERN: string;
|
|
17
17
|
declare const VERSION_NUMBER_REGEX: RegExp;
|
|
18
18
|
//#endregion
|
|
19
19
|
//#region src/root/deprecated/APIError.d.ts
|
|
@@ -102,6 +102,18 @@ declare class DataError<DataType extends Record<PropertyKey, unknown> = Record<P
|
|
|
102
102
|
static expectErrorAsync(errorFunction: () => Promise<unknown>, options?: ExpectErrorOptions$1): Promise<DataError>;
|
|
103
103
|
}
|
|
104
104
|
//#endregion
|
|
105
|
+
//#region src/root/deprecated/FILE_PATH_PATTERN.d.ts
|
|
106
|
+
/** @deprecated This has been renamed to `FILE_PATH_REGEX_PATTERN`. */
|
|
107
|
+
declare const FILE_PATH_PATTERN: string;
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src/root/deprecated/UUID_PATTERN.d.ts
|
|
110
|
+
/** @deprecated This has been renamed to `UUID_REGEX_PATTERN`. */
|
|
111
|
+
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}";
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/root/deprecated/VERSION_NUMBER_PATTERN.d.ts
|
|
114
|
+
/** @deprecated This has been renamed to `VERSION_NUMBER_REGEX_PATTERN`. */
|
|
115
|
+
declare const VERSION_NUMBER_PATTERN: string;
|
|
116
|
+
//#endregion
|
|
105
117
|
//#region src/root/deprecated/RecordKey.d.ts
|
|
106
118
|
/**
|
|
107
119
|
* Represents the native Record's possible key type.
|
|
@@ -1487,4 +1499,4 @@ interface ZodParsingErrorData {
|
|
|
1487
1499
|
issues: Array<z.core.$ZodIssue>;
|
|
1488
1500
|
}
|
|
1489
1501
|
//#endregion
|
|
1490
|
-
export { APIError, type ArrayElement, type CallReturnType, type 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, type KebabToCamelOptions, type NonNull, type NonUndefined, type NormaliseIndentsFunction, type NormaliseIndentsOptions, type NormalizeIndentsFunction, type NormalizeIndentsOptions, type NullableOnCondition, ONE_DAY_IN_MILLISECONDS, type OptionalOnCondition, type ParallelTuple, type RecordKey, type RemoveUndefined, SortDirection, type StringListToArrayOptions, type ToTitleCaseOptions, UUID_PATTERN, UUID_REGEX, VERSION_NUMBER_PATTERN, VERSION_NUMBER_REGEX, VersionNumber, type FormatOptionsBase as VersionNumberToStringOptions, VersionType, type ZodParsingErrorData, addDaysToDate, appendSemicolon, assertNotNull, assertNotNullable, assertNotUndefined, az, calculateMonthlyDifference, camelToKebab, containsKeys, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, escapeHTML, escapeRegexPattern, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, identity, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isNonNullableObject, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, objectContainsKeys, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersionType, parseZodSchema, parseZodSchemaAsync, pickProperties, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, sortBy, stringListToArray, stringifyDotenv, toTitleCase, truncate, wait, zodVersionNumber };
|
|
1502
|
+
export { APIError, type ArrayElement, type CallReturnType, type CamelToKebabOptions, type CreateEnumType, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, DataError, type DisallowUndefined, Env, FILE_PATH_PATTERN, FILE_PATH_REGEX, FILE_PATH_REGEX_PATTERN, type FormDataArrayResolutionStrategy, type FormDataNullableResolutionStrategy, type HTTPErrorCode, type IgnoreCase, type IsTypeArgumentString, type KebabToCamelOptions, type NonNull, type NonUndefined, type NormaliseIndentsFunction, type NormaliseIndentsOptions, type NormalizeIndentsFunction, type NormalizeIndentsOptions, type NullableOnCondition, ONE_DAY_IN_MILLISECONDS, type OptionalOnCondition, type ParallelTuple, type RecordKey, type RemoveUndefined, SortDirection, type StringListToArrayOptions, type ToTitleCaseOptions, UUID_PATTERN, UUID_REGEX, UUID_REGEX_PATTERN, VERSION_NUMBER_PATTERN, VERSION_NUMBER_REGEX, VERSION_NUMBER_REGEX_PATTERN, VersionNumber, type FormatOptionsBase as VersionNumberToStringOptions, VersionType, type ZodParsingErrorData, addDaysToDate, appendSemicolon, assertNotNull, assertNotNullable, assertNotUndefined, az, calculateMonthlyDifference, camelToKebab, containsKeys, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, escapeHTML, escapeRegexPattern, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, identity, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isNonNullableObject, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, objectContainsKeys, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersionType, parseZodSchema, parseZodSchemaAsync, pickProperties, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, sortBy, stringListToArray, stringifyDotenv, toTitleCase, truncate, wait, zodVersionNumber };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,18 +2,18 @@ import z, { ZodCoercedDate, ZodCoercedNumber, ZodError, ZodType, z as z$1 } from
|
|
|
2
2
|
import { DotenvParseOutput } from "dotenv";
|
|
3
3
|
|
|
4
4
|
//#region src/root/constants/FILE_PATH_REGEX.d.ts
|
|
5
|
-
declare const
|
|
5
|
+
declare const FILE_PATH_REGEX_PATTERN: string;
|
|
6
6
|
declare const FILE_PATH_REGEX: RegExp;
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/root/constants/ONE_DAY_IN_MILLISECONDS.d.ts
|
|
9
9
|
declare const ONE_DAY_IN_MILLISECONDS: number;
|
|
10
10
|
//#endregion
|
|
11
11
|
//#region src/root/constants/UUID_REGEX.d.ts
|
|
12
|
-
declare const
|
|
12
|
+
declare const UUID_REGEX_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
13
|
declare const UUID_REGEX: RegExp;
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/root/constants/VERSION_NUMBER_REGEX.d.ts
|
|
16
|
-
declare const
|
|
16
|
+
declare const VERSION_NUMBER_REGEX_PATTERN: string;
|
|
17
17
|
declare const VERSION_NUMBER_REGEX: RegExp;
|
|
18
18
|
//#endregion
|
|
19
19
|
//#region src/root/deprecated/APIError.d.ts
|
|
@@ -102,6 +102,18 @@ declare class DataError<DataType extends Record<PropertyKey, unknown> = Record<P
|
|
|
102
102
|
static expectErrorAsync(errorFunction: () => Promise<unknown>, options?: ExpectErrorOptions$1): Promise<DataError>;
|
|
103
103
|
}
|
|
104
104
|
//#endregion
|
|
105
|
+
//#region src/root/deprecated/FILE_PATH_PATTERN.d.ts
|
|
106
|
+
/** @deprecated This has been renamed to `FILE_PATH_REGEX_PATTERN`. */
|
|
107
|
+
declare const FILE_PATH_PATTERN: string;
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src/root/deprecated/UUID_PATTERN.d.ts
|
|
110
|
+
/** @deprecated This has been renamed to `UUID_REGEX_PATTERN`. */
|
|
111
|
+
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}";
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/root/deprecated/VERSION_NUMBER_PATTERN.d.ts
|
|
114
|
+
/** @deprecated This has been renamed to `VERSION_NUMBER_REGEX_PATTERN`. */
|
|
115
|
+
declare const VERSION_NUMBER_PATTERN: string;
|
|
116
|
+
//#endregion
|
|
105
117
|
//#region src/root/deprecated/RecordKey.d.ts
|
|
106
118
|
/**
|
|
107
119
|
* Represents the native Record's possible key type.
|
|
@@ -1487,4 +1499,4 @@ interface ZodParsingErrorData {
|
|
|
1487
1499
|
issues: Array<z.core.$ZodIssue>;
|
|
1488
1500
|
}
|
|
1489
1501
|
//#endregion
|
|
1490
|
-
export { APIError, type ArrayElement, type CallReturnType, type 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, type KebabToCamelOptions, type NonNull, type NonUndefined, type NormaliseIndentsFunction, type NormaliseIndentsOptions, type NormalizeIndentsFunction, type NormalizeIndentsOptions, type NullableOnCondition, ONE_DAY_IN_MILLISECONDS, type OptionalOnCondition, type ParallelTuple, type RecordKey, type RemoveUndefined, SortDirection, type StringListToArrayOptions, type ToTitleCaseOptions, UUID_PATTERN, UUID_REGEX, VERSION_NUMBER_PATTERN, VERSION_NUMBER_REGEX, VersionNumber, type FormatOptionsBase as VersionNumberToStringOptions, VersionType, type ZodParsingErrorData, addDaysToDate, appendSemicolon, assertNotNull, assertNotNullable, assertNotUndefined, az, calculateMonthlyDifference, camelToKebab, containsKeys, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, escapeHTML, escapeRegexPattern, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, identity, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isNonNullableObject, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, objectContainsKeys, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersionType, parseZodSchema, parseZodSchemaAsync, pickProperties, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, sortBy, stringListToArray, stringifyDotenv, toTitleCase, truncate, wait, zodVersionNumber };
|
|
1502
|
+
export { APIError, type ArrayElement, type CallReturnType, type CamelToKebabOptions, type CreateEnumType, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, DataError, type DisallowUndefined, Env, FILE_PATH_PATTERN, FILE_PATH_REGEX, FILE_PATH_REGEX_PATTERN, type FormDataArrayResolutionStrategy, type FormDataNullableResolutionStrategy, type HTTPErrorCode, type IgnoreCase, type IsTypeArgumentString, type KebabToCamelOptions, type NonNull, type NonUndefined, type NormaliseIndentsFunction, type NormaliseIndentsOptions, type NormalizeIndentsFunction, type NormalizeIndentsOptions, type NullableOnCondition, ONE_DAY_IN_MILLISECONDS, type OptionalOnCondition, type ParallelTuple, type RecordKey, type RemoveUndefined, SortDirection, type StringListToArrayOptions, type ToTitleCaseOptions, UUID_PATTERN, UUID_REGEX, UUID_REGEX_PATTERN, VERSION_NUMBER_PATTERN, VERSION_NUMBER_REGEX, VERSION_NUMBER_REGEX_PATTERN, VersionNumber, type FormatOptionsBase as VersionNumberToStringOptions, VersionType, type ZodParsingErrorData, addDaysToDate, appendSemicolon, assertNotNull, assertNotNullable, assertNotUndefined, az, calculateMonthlyDifference, camelToKebab, containsKeys, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, escapeHTML, escapeRegexPattern, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, identity, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isNonNullableObject, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, objectContainsKeys, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersionType, parseZodSchema, parseZodSchemaAsync, pickProperties, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, sortBy, stringListToArray, stringifyDotenv, toTitleCase, truncate, wait, zodVersionNumber };
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import z, { z as z$1 } from "zod";
|
|
2
2
|
//#region src/root/constants/FILE_PATH_REGEX.ts
|
|
3
|
-
const
|
|
4
|
-
const FILE_PATH_REGEX = RegExp(`^${
|
|
3
|
+
const FILE_PATH_REGEX_PATTERN = String.raw`(?<directory>.+)[\/\\](?<base>[^\/\\]+)`;
|
|
4
|
+
const FILE_PATH_REGEX = RegExp(`^${FILE_PATH_REGEX_PATTERN}$`);
|
|
5
5
|
//#endregion
|
|
6
6
|
//#region src/root/constants/ONE_DAY_IN_MILLISECONDS.ts
|
|
7
7
|
const ONE_DAY_IN_MILLISECONDS = 1440 * 60 * 1e3;
|
|
8
8
|
//#endregion
|
|
9
9
|
//#region src/root/constants/UUID_REGEX.ts
|
|
10
|
-
const
|
|
11
|
-
const UUID_REGEX = new RegExp(`^${
|
|
10
|
+
const UUID_REGEX_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}";
|
|
11
|
+
const UUID_REGEX = new RegExp(`^${UUID_REGEX_PATTERN}$`);
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/root/constants/VERSION_NUMBER_REGEX.ts
|
|
14
|
-
const
|
|
15
|
-
const VERSION_NUMBER_REGEX = RegExp(`^${
|
|
14
|
+
const VERSION_NUMBER_REGEX_PATTERN = String.raw`(?:v)?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)`;
|
|
15
|
+
const VERSION_NUMBER_REGEX = RegExp(`^${VERSION_NUMBER_REGEX_PATTERN}$`);
|
|
16
16
|
//#endregion
|
|
17
17
|
//#region src/root/deprecated/APIError.ts
|
|
18
18
|
const httpErrorCodeLookup = {
|
|
@@ -2018,4 +2018,16 @@ var DataError = class DataError extends Error {
|
|
|
2018
2018
|
}
|
|
2019
2019
|
};
|
|
2020
2020
|
//#endregion
|
|
2021
|
-
|
|
2021
|
+
//#region src/root/deprecated/FILE_PATH_PATTERN.ts
|
|
2022
|
+
/** @deprecated This has been renamed to `FILE_PATH_REGEX_PATTERN`. */
|
|
2023
|
+
const FILE_PATH_PATTERN = FILE_PATH_REGEX_PATTERN;
|
|
2024
|
+
//#endregion
|
|
2025
|
+
//#region src/root/deprecated/UUID_PATTERN.ts
|
|
2026
|
+
/** @deprecated This has been renamed to `UUID_REGEX_PATTERN`. */
|
|
2027
|
+
const UUID_PATTERN = UUID_REGEX_PATTERN;
|
|
2028
|
+
//#endregion
|
|
2029
|
+
//#region src/root/deprecated/VERSION_NUMBER_PATTERN.ts
|
|
2030
|
+
/** @deprecated This has been renamed to `VERSION_NUMBER_REGEX_PATTERN`. */
|
|
2031
|
+
const VERSION_NUMBER_PATTERN = String.raw`^(?:v)?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$`;
|
|
2032
|
+
//#endregion
|
|
2033
|
+
export { APIError, DataError, Env, FILE_PATH_PATTERN, FILE_PATH_REGEX, FILE_PATH_REGEX_PATTERN, ONE_DAY_IN_MILLISECONDS, SortDirection, UUID_PATTERN, UUID_REGEX, UUID_REGEX_PATTERN, VERSION_NUMBER_PATTERN, VERSION_NUMBER_REGEX, VERSION_NUMBER_REGEX_PATTERN, VersionNumber, VersionType, addDaysToDate, appendSemicolon, assertNotNull, assertNotNullable, assertNotUndefined, az, calculateMonthlyDifference, camelToKebab, containsKeys, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, escapeHTML, escapeRegexPattern, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, identity, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isNonNullableObject, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, objectContainsKeys, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersionType, parseZodSchema, parseZodSchemaAsync, pickProperties, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, sortBy, stringListToArray, stringifyDotenv, toTitleCase, truncate, wait, zodVersionNumber };
|
package/dist/internal/index.cjs
CHANGED
|
@@ -34,8 +34,8 @@ const DependencyGroup = {
|
|
|
34
34
|
};
|
|
35
35
|
//#endregion
|
|
36
36
|
//#region src/root/constants/VERSION_NUMBER_REGEX.ts
|
|
37
|
-
const
|
|
38
|
-
const VERSION_NUMBER_REGEX = RegExp(`^${
|
|
37
|
+
const VERSION_NUMBER_REGEX_PATTERN = String.raw`(?:v)?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)`;
|
|
38
|
+
const VERSION_NUMBER_REGEX = RegExp(`^${VERSION_NUMBER_REGEX_PATTERN}$`);
|
|
39
39
|
//#endregion
|
|
40
40
|
//#region src/v6/CodeError.ts
|
|
41
41
|
/**
|
package/dist/internal/index.js
CHANGED
|
@@ -9,8 +9,8 @@ const DependencyGroup = {
|
|
|
9
9
|
};
|
|
10
10
|
//#endregion
|
|
11
11
|
//#region src/root/constants/VERSION_NUMBER_REGEX.ts
|
|
12
|
-
const
|
|
13
|
-
const VERSION_NUMBER_REGEX = RegExp(`^${
|
|
12
|
+
const VERSION_NUMBER_REGEX_PATTERN = String.raw`(?:v)?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)`;
|
|
13
|
+
const VERSION_NUMBER_REGEX = RegExp(`^${VERSION_NUMBER_REGEX_PATTERN}$`);
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/v6/CodeError.ts
|
|
16
16
|
/**
|
package/dist/node/index.cjs
CHANGED
|
@@ -60,8 +60,8 @@ function normalizeImportPath(importPath) {
|
|
|
60
60
|
const normaliseImportPath = normalizeImportPath;
|
|
61
61
|
//#endregion
|
|
62
62
|
//#region src/root/constants/FILE_PATH_REGEX.ts
|
|
63
|
-
const
|
|
64
|
-
const FILE_PATH_REGEX = RegExp(`^${
|
|
63
|
+
const FILE_PATH_REGEX_PATTERN = String.raw`(?<directory>.+)[\/\\](?<base>[^\/\\]+)`;
|
|
64
|
+
const FILE_PATH_REGEX = RegExp(`^${FILE_PATH_REGEX_PATTERN}$`);
|
|
65
65
|
//#endregion
|
|
66
66
|
//#region src/root/functions/arrayHelpers/range.ts
|
|
67
67
|
/**
|
package/dist/node/index.js
CHANGED
|
@@ -36,8 +36,8 @@ function normalizeImportPath(importPath) {
|
|
|
36
36
|
const normaliseImportPath = normalizeImportPath;
|
|
37
37
|
//#endregion
|
|
38
38
|
//#region src/root/constants/FILE_PATH_REGEX.ts
|
|
39
|
-
const
|
|
40
|
-
const FILE_PATH_REGEX = RegExp(`^${
|
|
39
|
+
const FILE_PATH_REGEX_PATTERN = String.raw`(?<directory>.+)[\/\\](?<base>[^\/\\]+)`;
|
|
40
|
+
const FILE_PATH_REGEX = RegExp(`^${FILE_PATH_REGEX_PATTERN}$`);
|
|
41
41
|
//#endregion
|
|
42
42
|
//#region src/root/functions/arrayHelpers/range.ts
|
|
43
43
|
/**
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/temporal/formatRelativeDateAndTime.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates a human-readable string describing the input date relative to the reference date.
|
|
5
|
+
*
|
|
6
|
+
* If no reference date is provided, the current local date and time is used as the reference.
|
|
7
|
+
*
|
|
8
|
+
* @category Temporal
|
|
9
|
+
*
|
|
10
|
+
* @param input - The date and time to format.
|
|
11
|
+
* @param reference - The date and time to compare the input against.
|
|
12
|
+
*
|
|
13
|
+
* @returns A human-readable string describing the input date relative to the reference date.
|
|
14
|
+
*
|
|
15
|
+
* - If the date given is today, the output will be something like `Today at HH:MM`
|
|
16
|
+
* - If the date given happened yesterday, the output will be something like `Yesterday at HH:MM`
|
|
17
|
+
* - For any other date, the output will be something like `DD/MM/YYYY, HH:MM`
|
|
18
|
+
*/
|
|
19
|
+
function formatRelativeDateAndTime(input, reference = Temporal.Now.plainDateTimeISO()) {
|
|
20
|
+
const inputPlainDate = input.toPlainDate();
|
|
21
|
+
const referencePlainDate = reference.toPlainDate();
|
|
22
|
+
const formattedTime = input.toLocaleString("en-GB", {
|
|
23
|
+
hour: "2-digit",
|
|
24
|
+
minute: "2-digit"
|
|
25
|
+
});
|
|
26
|
+
if (inputPlainDate.equals(referencePlainDate.subtract({ days: 1 }))) return `Yesterday at ${formattedTime}`;
|
|
27
|
+
if (inputPlainDate.equals(referencePlainDate)) return `Today at ${formattedTime}`;
|
|
28
|
+
return `${input.toLocaleString("en-GB", {
|
|
29
|
+
day: "2-digit",
|
|
30
|
+
month: "2-digit",
|
|
31
|
+
year: "numeric"
|
|
32
|
+
})}, ${formattedTime}`;
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
exports.formatRelativeDateAndTime = formatRelativeDateAndTime;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/temporal/formatRelativeDateAndTime.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a human-readable string describing the input date relative to the reference date.
|
|
4
|
+
*
|
|
5
|
+
* If no reference date is provided, the current local date and time is used as the reference.
|
|
6
|
+
*
|
|
7
|
+
* @category Temporal
|
|
8
|
+
*
|
|
9
|
+
* @param input - The date and time to format.
|
|
10
|
+
* @param reference - The date and time to compare the input against.
|
|
11
|
+
*
|
|
12
|
+
* @returns A human-readable string describing the input date relative to the reference date.
|
|
13
|
+
*
|
|
14
|
+
* - If the date given is today, the output will be something like `Today at HH:MM`
|
|
15
|
+
* - If the date given happened yesterday, the output will be something like `Yesterday at HH:MM`
|
|
16
|
+
* - For any other date, the output will be something like `DD/MM/YYYY, HH:MM`
|
|
17
|
+
*/
|
|
18
|
+
declare function formatRelativeDateAndTime(input: Temporal.PlainDateTime | Temporal.ZonedDateTime, reference?: Temporal.PlainDateTime | Temporal.ZonedDateTime): string;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { formatRelativeDateAndTime };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/temporal/formatRelativeDateAndTime.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a human-readable string describing the input date relative to the reference date.
|
|
4
|
+
*
|
|
5
|
+
* If no reference date is provided, the current local date and time is used as the reference.
|
|
6
|
+
*
|
|
7
|
+
* @category Temporal
|
|
8
|
+
*
|
|
9
|
+
* @param input - The date and time to format.
|
|
10
|
+
* @param reference - The date and time to compare the input against.
|
|
11
|
+
*
|
|
12
|
+
* @returns A human-readable string describing the input date relative to the reference date.
|
|
13
|
+
*
|
|
14
|
+
* - If the date given is today, the output will be something like `Today at HH:MM`
|
|
15
|
+
* - If the date given happened yesterday, the output will be something like `Yesterday at HH:MM`
|
|
16
|
+
* - For any other date, the output will be something like `DD/MM/YYYY, HH:MM`
|
|
17
|
+
*/
|
|
18
|
+
declare function formatRelativeDateAndTime(input: Temporal.PlainDateTime | Temporal.ZonedDateTime, reference?: Temporal.PlainDateTime | Temporal.ZonedDateTime): string;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { formatRelativeDateAndTime };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//#region src/temporal/formatRelativeDateAndTime.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a human-readable string describing the input date relative to the reference date.
|
|
4
|
+
*
|
|
5
|
+
* If no reference date is provided, the current local date and time is used as the reference.
|
|
6
|
+
*
|
|
7
|
+
* @category Temporal
|
|
8
|
+
*
|
|
9
|
+
* @param input - The date and time to format.
|
|
10
|
+
* @param reference - The date and time to compare the input against.
|
|
11
|
+
*
|
|
12
|
+
* @returns A human-readable string describing the input date relative to the reference date.
|
|
13
|
+
*
|
|
14
|
+
* - If the date given is today, the output will be something like `Today at HH:MM`
|
|
15
|
+
* - If the date given happened yesterday, the output will be something like `Yesterday at HH:MM`
|
|
16
|
+
* - For any other date, the output will be something like `DD/MM/YYYY, HH:MM`
|
|
17
|
+
*/
|
|
18
|
+
function formatRelativeDateAndTime(input, reference = Temporal.Now.plainDateTimeISO()) {
|
|
19
|
+
const inputPlainDate = input.toPlainDate();
|
|
20
|
+
const referencePlainDate = reference.toPlainDate();
|
|
21
|
+
const formattedTime = input.toLocaleString("en-GB", {
|
|
22
|
+
hour: "2-digit",
|
|
23
|
+
minute: "2-digit"
|
|
24
|
+
});
|
|
25
|
+
if (inputPlainDate.equals(referencePlainDate.subtract({ days: 1 }))) return `Yesterday at ${formattedTime}`;
|
|
26
|
+
if (inputPlainDate.equals(referencePlainDate)) return `Today at ${formattedTime}`;
|
|
27
|
+
return `${input.toLocaleString("en-GB", {
|
|
28
|
+
day: "2-digit",
|
|
29
|
+
month: "2-digit",
|
|
30
|
+
year: "numeric"
|
|
31
|
+
})}, ${formattedTime}`;
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
export { formatRelativeDateAndTime };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alextheman/utility",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.25.0",
|
|
4
4
|
"description": "Helpful utility functions.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,6 +26,11 @@
|
|
|
26
26
|
"import": "./dist/node/index.js",
|
|
27
27
|
"require": "./dist/node/index.cjs"
|
|
28
28
|
},
|
|
29
|
+
"./temporal": {
|
|
30
|
+
"types": "./dist/temporal/index.d.ts",
|
|
31
|
+
"import": "./dist/temporal/index.js",
|
|
32
|
+
"require": "./dist/temporal/index.cjs"
|
|
33
|
+
},
|
|
29
34
|
"./v6": {
|
|
30
35
|
"types": "./dist/v6/index.d.ts",
|
|
31
36
|
"import": "./dist/v6/index.js",
|