@alextheman/utility 3.9.0 → 3.10.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 +23 -1
- package/dist/index.d.cts +20 -5
- package/dist/index.d.ts +20 -5
- package/dist/index.js +23 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -94,7 +94,7 @@ const IntegerParsingError = /* @__PURE__ */ new TypeError("INTEGER_PARSING_ERROR
|
|
|
94
94
|
/**
|
|
95
95
|
* Converts a string to an integer and throws an error if it cannot be converted.
|
|
96
96
|
*
|
|
97
|
-
* @param string
|
|
97
|
+
* @param string - A string to convert into a number.
|
|
98
98
|
* @param radix - A value between 2 and 36 that specifies the base of the number in string. If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. All other strings are considered decimal.
|
|
99
99
|
*
|
|
100
100
|
* @throws {TypeError} If the provided string cannot safely be converted to an integer.
|
|
@@ -711,6 +711,27 @@ function parseZodSchema(schema, data) {
|
|
|
711
711
|
}
|
|
712
712
|
var parseZodSchema_default = parseZodSchema;
|
|
713
713
|
|
|
714
|
+
//#endregion
|
|
715
|
+
//#region src/functions/parsers/parseVersionType.ts
|
|
716
|
+
const versionTypeSchema = zod.default.enum([
|
|
717
|
+
"major",
|
|
718
|
+
"minor",
|
|
719
|
+
"patch"
|
|
720
|
+
]);
|
|
721
|
+
/**
|
|
722
|
+
* Parses the input and verifies it is a valid software version type (i.e. `"major" | "minor" | "patch"`)
|
|
723
|
+
*
|
|
724
|
+
* @param data - The data to parse.
|
|
725
|
+
*
|
|
726
|
+
* @throws {DataError} If the data does not match one of the allowed version types (`"major" | "minor" | "patch"`).
|
|
727
|
+
*
|
|
728
|
+
* @returns The given version type if allowed.
|
|
729
|
+
*/
|
|
730
|
+
function parseVersionType(data) {
|
|
731
|
+
return parseZodSchema_default(versionTypeSchema, data);
|
|
732
|
+
}
|
|
733
|
+
var parseVersionType_default = parseVersionType;
|
|
734
|
+
|
|
714
735
|
//#endregion
|
|
715
736
|
//#region src/functions/recursive/deepCopy.ts
|
|
716
737
|
function callDeepCopy(input) {
|
|
@@ -1184,6 +1205,7 @@ exports.parseFormData = parseFormData_default;
|
|
|
1184
1205
|
exports.parseIntStrict = parseIntStrict_default;
|
|
1185
1206
|
exports.parseUUID = UUID_default;
|
|
1186
1207
|
exports.parseVersion = parseVersion_default;
|
|
1208
|
+
exports.parseVersionType = parseVersionType_default;
|
|
1187
1209
|
exports.parseZodSchema = parseZodSchema_default;
|
|
1188
1210
|
exports.randomiseArray = randomiseArray_default;
|
|
1189
1211
|
exports.range = range_default;
|
package/dist/index.d.cts
CHANGED
|
@@ -285,9 +285,6 @@ type OptionalOnCondition<Condition extends boolean, ResolvedTypeIfTrue> = Condit
|
|
|
285
285
|
/** Represents the native Record's possible key type. */
|
|
286
286
|
type RecordKey = string | number | symbol;
|
|
287
287
|
//#endregion
|
|
288
|
-
//#region src/types/VersionType.d.ts
|
|
289
|
-
type VersionType = "major" | "minor" | "patch";
|
|
290
|
-
//#endregion
|
|
291
288
|
//#region src/functions/miscellaneous/createFormData.d.ts
|
|
292
289
|
type FormDataNullableResolutionStrategy = "stringify" | "empty" | "omit";
|
|
293
290
|
type FormDataArrayResolutionStrategy = "stringify" | "multiple";
|
|
@@ -461,7 +458,7 @@ declare function parseFormData(formData: FormData): Record<string, string | Blob
|
|
|
461
458
|
/**
|
|
462
459
|
* Converts a string to an integer and throws an error if it cannot be converted.
|
|
463
460
|
*
|
|
464
|
-
* @param string
|
|
461
|
+
* @param string - A string to convert into a number.
|
|
465
462
|
* @param radix - A value between 2 and 36 that specifies the base of the number in string. If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. All other strings are considered decimal.
|
|
466
463
|
*
|
|
467
464
|
* @throws {TypeError} If the provided string cannot safely be converted to an integer.
|
|
@@ -470,6 +467,24 @@ declare function parseFormData(formData: FormData): Record<string, string | Blob
|
|
|
470
467
|
*/
|
|
471
468
|
declare function parseIntStrict(string: string, radix?: number): number;
|
|
472
469
|
//#endregion
|
|
470
|
+
//#region src/functions/parsers/parseVersionType.d.ts
|
|
471
|
+
declare const versionTypeSchema: z.ZodEnum<{
|
|
472
|
+
major: "major";
|
|
473
|
+
minor: "minor";
|
|
474
|
+
patch: "patch";
|
|
475
|
+
}>;
|
|
476
|
+
type VersionType = z.infer<typeof versionTypeSchema>;
|
|
477
|
+
/**
|
|
478
|
+
* Parses the input and verifies it is a valid software version type (i.e. `"major" | "minor" | "patch"`)
|
|
479
|
+
*
|
|
480
|
+
* @param data - The data to parse.
|
|
481
|
+
*
|
|
482
|
+
* @throws {DataError} If the data does not match one of the allowed version types (`"major" | "minor" | "patch"`).
|
|
483
|
+
*
|
|
484
|
+
* @returns The given version type if allowed.
|
|
485
|
+
*/
|
|
486
|
+
declare function parseVersionType(data: unknown): VersionType;
|
|
487
|
+
//#endregion
|
|
473
488
|
//#region src/functions/parsers/parseZodSchema.d.ts
|
|
474
489
|
/**
|
|
475
490
|
* An alternative function to zodSchema.parse() that can be used to strictly parse Zod schemas.
|
|
@@ -762,4 +777,4 @@ interface ParseVersionOptions {
|
|
|
762
777
|
*/
|
|
763
778
|
declare function parseVersion(input: string, options?: ParseVersionOptions): string;
|
|
764
779
|
//#endregion
|
|
765
|
-
export { APIError, ArrayElement, CreateFormDataOptions, CreateFormDataOptionsNullableResolution, CreateFormDataOptionsUndefinedOrNullResolution, DataError, DeepReadonly, DisallowUndefined, Email, Env, FormDataArrayResolutionStrategy, FormDataNullableResolutionStrategy, HTTPErrorCode, IgnoreCase, IncrementVersionOptions, KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, OptionalOnCondition, ParseVersionOptions, RecordKey, RemoveIndentsFunction, RemoveIndentsOptions, StringListToArrayOptions, UUID, VERSION_NUMBER_REGEX, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, determineVersionType, fillArray, formatDateAndTime, getIndividualVersionNumbers, getRandomNumber, getRecordKeys, httpErrorCodeLookup, incrementVersion, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEmail, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersion, parseZodSchema, randomiseArray, range, removeDuplicates, removeIndents, stringListToArray, stringToBoolean, truncate, wait };
|
|
780
|
+
export { APIError, ArrayElement, CreateFormDataOptions, CreateFormDataOptionsNullableResolution, CreateFormDataOptionsUndefinedOrNullResolution, DataError, DeepReadonly, DisallowUndefined, Email, Env, FormDataArrayResolutionStrategy, FormDataNullableResolutionStrategy, HTTPErrorCode, IgnoreCase, IncrementVersionOptions, KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, OptionalOnCondition, ParseVersionOptions, RecordKey, RemoveIndentsFunction, RemoveIndentsOptions, StringListToArrayOptions, UUID, VERSION_NUMBER_REGEX, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, determineVersionType, fillArray, formatDateAndTime, getIndividualVersionNumbers, getRandomNumber, getRecordKeys, httpErrorCodeLookup, incrementVersion, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEmail, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersion, parseVersionType, parseZodSchema, randomiseArray, range, removeDuplicates, removeIndents, stringListToArray, stringToBoolean, truncate, wait };
|
package/dist/index.d.ts
CHANGED
|
@@ -285,9 +285,6 @@ type OptionalOnCondition<Condition extends boolean, ResolvedTypeIfTrue> = Condit
|
|
|
285
285
|
/** Represents the native Record's possible key type. */
|
|
286
286
|
type RecordKey = string | number | symbol;
|
|
287
287
|
//#endregion
|
|
288
|
-
//#region src/types/VersionType.d.ts
|
|
289
|
-
type VersionType = "major" | "minor" | "patch";
|
|
290
|
-
//#endregion
|
|
291
288
|
//#region src/functions/miscellaneous/createFormData.d.ts
|
|
292
289
|
type FormDataNullableResolutionStrategy = "stringify" | "empty" | "omit";
|
|
293
290
|
type FormDataArrayResolutionStrategy = "stringify" | "multiple";
|
|
@@ -461,7 +458,7 @@ declare function parseFormData(formData: FormData): Record<string, string | Blob
|
|
|
461
458
|
/**
|
|
462
459
|
* Converts a string to an integer and throws an error if it cannot be converted.
|
|
463
460
|
*
|
|
464
|
-
* @param string
|
|
461
|
+
* @param string - A string to convert into a number.
|
|
465
462
|
* @param radix - A value between 2 and 36 that specifies the base of the number in string. If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. All other strings are considered decimal.
|
|
466
463
|
*
|
|
467
464
|
* @throws {TypeError} If the provided string cannot safely be converted to an integer.
|
|
@@ -470,6 +467,24 @@ declare function parseFormData(formData: FormData): Record<string, string | Blob
|
|
|
470
467
|
*/
|
|
471
468
|
declare function parseIntStrict(string: string, radix?: number): number;
|
|
472
469
|
//#endregion
|
|
470
|
+
//#region src/functions/parsers/parseVersionType.d.ts
|
|
471
|
+
declare const versionTypeSchema: z.ZodEnum<{
|
|
472
|
+
major: "major";
|
|
473
|
+
minor: "minor";
|
|
474
|
+
patch: "patch";
|
|
475
|
+
}>;
|
|
476
|
+
type VersionType = z.infer<typeof versionTypeSchema>;
|
|
477
|
+
/**
|
|
478
|
+
* Parses the input and verifies it is a valid software version type (i.e. `"major" | "minor" | "patch"`)
|
|
479
|
+
*
|
|
480
|
+
* @param data - The data to parse.
|
|
481
|
+
*
|
|
482
|
+
* @throws {DataError} If the data does not match one of the allowed version types (`"major" | "minor" | "patch"`).
|
|
483
|
+
*
|
|
484
|
+
* @returns The given version type if allowed.
|
|
485
|
+
*/
|
|
486
|
+
declare function parseVersionType(data: unknown): VersionType;
|
|
487
|
+
//#endregion
|
|
473
488
|
//#region src/functions/parsers/parseZodSchema.d.ts
|
|
474
489
|
/**
|
|
475
490
|
* An alternative function to zodSchema.parse() that can be used to strictly parse Zod schemas.
|
|
@@ -762,4 +777,4 @@ interface ParseVersionOptions {
|
|
|
762
777
|
*/
|
|
763
778
|
declare function parseVersion(input: string, options?: ParseVersionOptions): string;
|
|
764
779
|
//#endregion
|
|
765
|
-
export { APIError, type ArrayElement, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, DataError, type DeepReadonly, type DisallowUndefined, type Email, type Env, type FormDataArrayResolutionStrategy, type FormDataNullableResolutionStrategy, type HTTPErrorCode, type IgnoreCase, type IncrementVersionOptions, KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, type NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, type OptionalOnCondition, type ParseVersionOptions, type RecordKey, RemoveIndentsFunction, RemoveIndentsOptions, type StringListToArrayOptions, type UUID, VERSION_NUMBER_REGEX, type VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, determineVersionType, fillArray, formatDateAndTime, getIndividualVersionNumbers, getRandomNumber, getRecordKeys, httpErrorCodeLookup, incrementVersion, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEmail, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersion, parseZodSchema, randomiseArray, range, removeDuplicates, removeIndents, stringListToArray, stringToBoolean, truncate, wait };
|
|
780
|
+
export { APIError, type ArrayElement, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, DataError, type DeepReadonly, type DisallowUndefined, type Email, type Env, type FormDataArrayResolutionStrategy, type FormDataNullableResolutionStrategy, type HTTPErrorCode, type IgnoreCase, type IncrementVersionOptions, KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, type NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, type OptionalOnCondition, type ParseVersionOptions, type RecordKey, RemoveIndentsFunction, RemoveIndentsOptions, type StringListToArrayOptions, type UUID, VERSION_NUMBER_REGEX, type VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, determineVersionType, fillArray, formatDateAndTime, getIndividualVersionNumbers, getRandomNumber, getRecordKeys, httpErrorCodeLookup, incrementVersion, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEmail, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersion, parseVersionType, parseZodSchema, randomiseArray, range, removeDuplicates, removeIndents, stringListToArray, stringToBoolean, truncate, wait };
|
package/dist/index.js
CHANGED
|
@@ -65,7 +65,7 @@ const IntegerParsingError = /* @__PURE__ */ new TypeError("INTEGER_PARSING_ERROR
|
|
|
65
65
|
/**
|
|
66
66
|
* Converts a string to an integer and throws an error if it cannot be converted.
|
|
67
67
|
*
|
|
68
|
-
* @param string
|
|
68
|
+
* @param string - A string to convert into a number.
|
|
69
69
|
* @param radix - A value between 2 and 36 that specifies the base of the number in string. If this argument is not supplied, strings with a prefix of '0x' are considered hexadecimal. All other strings are considered decimal.
|
|
70
70
|
*
|
|
71
71
|
* @throws {TypeError} If the provided string cannot safely be converted to an integer.
|
|
@@ -682,6 +682,27 @@ function parseZodSchema(schema, data) {
|
|
|
682
682
|
}
|
|
683
683
|
var parseZodSchema_default = parseZodSchema;
|
|
684
684
|
|
|
685
|
+
//#endregion
|
|
686
|
+
//#region src/functions/parsers/parseVersionType.ts
|
|
687
|
+
const versionTypeSchema = z.enum([
|
|
688
|
+
"major",
|
|
689
|
+
"minor",
|
|
690
|
+
"patch"
|
|
691
|
+
]);
|
|
692
|
+
/**
|
|
693
|
+
* Parses the input and verifies it is a valid software version type (i.e. `"major" | "minor" | "patch"`)
|
|
694
|
+
*
|
|
695
|
+
* @param data - The data to parse.
|
|
696
|
+
*
|
|
697
|
+
* @throws {DataError} If the data does not match one of the allowed version types (`"major" | "minor" | "patch"`).
|
|
698
|
+
*
|
|
699
|
+
* @returns The given version type if allowed.
|
|
700
|
+
*/
|
|
701
|
+
function parseVersionType(data) {
|
|
702
|
+
return parseZodSchema_default(versionTypeSchema, data);
|
|
703
|
+
}
|
|
704
|
+
var parseVersionType_default = parseVersionType;
|
|
705
|
+
|
|
685
706
|
//#endregion
|
|
686
707
|
//#region src/functions/recursive/deepCopy.ts
|
|
687
708
|
function callDeepCopy(input) {
|
|
@@ -1114,4 +1135,4 @@ function incrementVersion(version, incrementType, options) {
|
|
|
1114
1135
|
var incrementVersion_default = incrementVersion;
|
|
1115
1136
|
|
|
1116
1137
|
//#endregion
|
|
1117
|
-
export { APIError_default as APIError, DataError_default as DataError, NAMESPACE_EXPORT_REGEX_default as NAMESPACE_EXPORT_REGEX, VERSION_NUMBER_REGEX_default as VERSION_NUMBER_REGEX, addDaysToDate_default as addDaysToDate, appendSemicolon_default as appendSemicolon, camelToKebab_default as camelToKebab, convertFileToBase64_default as convertFileToBase64, createFormData_default as createFormData, createTemplateStringsArray_default as createTemplateStringsArray, deepCopy_default as deepCopy, deepFreeze_default as deepFreeze, determineVersionType_default as determineVersionType, fillArray_default as fillArray, formatDateAndTime_default as formatDateAndTime, getIndividualVersionNumbers_default as getIndividualVersionNumbers, getRandomNumber_default as getRandomNumber, getRecordKeys_default as getRecordKeys, httpErrorCodeLookup, incrementVersion_default as incrementVersion, interpolate_default as interpolate, interpolateObjects_default as interpolateObjects, isAnniversary_default as isAnniversary, isLeapYear_default as isLeapYear, isMonthlyMultiple_default as isMonthlyMultiple, isOrdered_default as isOrdered, isSameDate_default as isSameDate, kebabToCamel_default as kebabToCamel, normaliseImportPath, normaliseIndents_default as normaliseIndents, normalizeImportPath_default as normalizeImportPath, normalizeIndents, omitProperties_default as omitProperties, paralleliseArrays_default as paralleliseArrays, parseBoolean_default as parseBoolean, Email_default as parseEmail, parseEnv_default as parseEnv, parseFormData_default as parseFormData, parseIntStrict_default as parseIntStrict, UUID_default as parseUUID, parseVersion_default as parseVersion, parseZodSchema_default as parseZodSchema, randomiseArray_default as randomiseArray, range_default as range, removeDuplicates_default as removeDuplicates, removeIndents_default as removeIndents, stringListToArray_default as stringListToArray, stringToBoolean, truncate_default as truncate, wait_default as wait };
|
|
1138
|
+
export { APIError_default as APIError, DataError_default as DataError, NAMESPACE_EXPORT_REGEX_default as NAMESPACE_EXPORT_REGEX, VERSION_NUMBER_REGEX_default as VERSION_NUMBER_REGEX, addDaysToDate_default as addDaysToDate, appendSemicolon_default as appendSemicolon, camelToKebab_default as camelToKebab, convertFileToBase64_default as convertFileToBase64, createFormData_default as createFormData, createTemplateStringsArray_default as createTemplateStringsArray, deepCopy_default as deepCopy, deepFreeze_default as deepFreeze, determineVersionType_default as determineVersionType, fillArray_default as fillArray, formatDateAndTime_default as formatDateAndTime, getIndividualVersionNumbers_default as getIndividualVersionNumbers, getRandomNumber_default as getRandomNumber, getRecordKeys_default as getRecordKeys, httpErrorCodeLookup, incrementVersion_default as incrementVersion, interpolate_default as interpolate, interpolateObjects_default as interpolateObjects, isAnniversary_default as isAnniversary, isLeapYear_default as isLeapYear, isMonthlyMultiple_default as isMonthlyMultiple, isOrdered_default as isOrdered, isSameDate_default as isSameDate, kebabToCamel_default as kebabToCamel, normaliseImportPath, normaliseIndents_default as normaliseIndents, normalizeImportPath_default as normalizeImportPath, normalizeIndents, omitProperties_default as omitProperties, paralleliseArrays_default as paralleliseArrays, parseBoolean_default as parseBoolean, Email_default as parseEmail, parseEnv_default as parseEnv, parseFormData_default as parseFormData, parseIntStrict_default as parseIntStrict, UUID_default as parseUUID, parseVersion_default as parseVersion, parseVersionType_default as parseVersionType, parseZodSchema_default as parseZodSchema, randomiseArray_default as randomiseArray, range_default as range, removeDuplicates_default as removeDuplicates, removeIndents_default as removeIndents, stringListToArray_default as stringListToArray, stringToBoolean, truncate_default as truncate, wait_default as wait };
|