@alextheman/utility 5.25.0 → 5.26.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 +24 -2
- package/dist/index.d.cts +19 -7
- package/dist/index.d.ts +19 -7
- package/dist/index.js +23 -2
- package/dist/internal/index.cjs +1 -1
- package/dist/internal/index.d.cts +2 -1
- package/dist/internal/index.d.ts +1 -0
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.d.cts +2 -0
- package/dist/node/index.d.ts +2 -0
- package/dist/v6/index.d.cts +2 -0
- package/dist/v6/index.d.ts +2 -0
- package/package.json +16 -15
package/dist/index.cjs
CHANGED
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
20
20
|
value: mod,
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
|
@@ -28,7 +28,7 @@ const FILE_PATH_REGEX_PATTERN = String.raw`(?<directory>.+)[\/\\](?<base>[^\/\\]
|
|
|
28
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
|
-
const ONE_DAY_IN_MILLISECONDS =
|
|
31
|
+
const ONE_DAY_IN_MILLISECONDS = 864e5;
|
|
32
32
|
//#endregion
|
|
33
33
|
//#region src/root/constants/UUID_REGEX.ts
|
|
34
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}";
|
|
@@ -858,6 +858,27 @@ function isOrdered(array) {
|
|
|
858
858
|
return true;
|
|
859
859
|
}
|
|
860
860
|
//#endregion
|
|
861
|
+
//#region src/root/functions/miscellaneous/memoizeAsync.ts
|
|
862
|
+
/**
|
|
863
|
+
* Memoizes the Promise returned by an asynchronous callback.
|
|
864
|
+
*
|
|
865
|
+
* Note that the callback is invoked at most once. Arguments supplied to subsequent calls are ignored because the Promise from the first invocation is always returned.
|
|
866
|
+
*
|
|
867
|
+
* @template ArgsType - The type of the function arguments.
|
|
868
|
+
* @template ResolvedType - The type of the Promise when resolved.
|
|
869
|
+
*
|
|
870
|
+
* @param callback - The function to memoize.
|
|
871
|
+
*
|
|
872
|
+
* @returns A callback with the Promise memoized. Multiple calls of this function should always point to the same Promise.
|
|
873
|
+
*/
|
|
874
|
+
function memoizeAsync(callback) {
|
|
875
|
+
let promise;
|
|
876
|
+
return (...args) => {
|
|
877
|
+
promise ??= callback(...args);
|
|
878
|
+
return promise;
|
|
879
|
+
};
|
|
880
|
+
}
|
|
881
|
+
//#endregion
|
|
861
882
|
//#region src/root/functions/miscellaneous/sayHello.ts
|
|
862
883
|
/**
|
|
863
884
|
* Returns a string representing the lyrics to the package's theme song, Commit To You
|
|
@@ -2103,6 +2124,7 @@ exports.isOrdered = isOrdered;
|
|
|
2103
2124
|
exports.isSameDate = isSameDate;
|
|
2104
2125
|
exports.isTemplateStringsArray = isTemplateStringsArray;
|
|
2105
2126
|
exports.kebabToCamel = kebabToCamel;
|
|
2127
|
+
exports.memoizeAsync = memoizeAsync;
|
|
2106
2128
|
exports.normaliseIndents = normaliseIndents;
|
|
2107
2129
|
exports.normalizeIndents = normalizeIndents;
|
|
2108
2130
|
exports.objectContainsKeys = objectContainsKeys;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import z, { ZodCoercedDate, ZodCoercedNumber, ZodError, ZodType, z as z$1 } from "zod";
|
|
2
2
|
import { DotenvParseOutput } from "dotenv";
|
|
3
|
-
|
|
4
3
|
//#region src/root/constants/FILE_PATH_REGEX.d.ts
|
|
5
4
|
declare const FILE_PATH_REGEX_PATTERN: string;
|
|
6
5
|
declare const FILE_PATH_REGEX: RegExp;
|
|
@@ -438,6 +437,22 @@ declare function identity<InputType>(input: InputType): InputType;
|
|
|
438
437
|
*/
|
|
439
438
|
declare function isOrdered(array: ReadonlyArray<number>): boolean;
|
|
440
439
|
//#endregion
|
|
440
|
+
//#region src/root/functions/miscellaneous/memoizeAsync.d.ts
|
|
441
|
+
type Callback<ArgsType extends ReadonlyArray<unknown>, ResolvedType> = (...args: ArgsType) => Promise<ResolvedType>;
|
|
442
|
+
/**
|
|
443
|
+
* Memoizes the Promise returned by an asynchronous callback.
|
|
444
|
+
*
|
|
445
|
+
* Note that the callback is invoked at most once. Arguments supplied to subsequent calls are ignored because the Promise from the first invocation is always returned.
|
|
446
|
+
*
|
|
447
|
+
* @template ArgsType - The type of the function arguments.
|
|
448
|
+
* @template ResolvedType - The type of the Promise when resolved.
|
|
449
|
+
*
|
|
450
|
+
* @param callback - The function to memoize.
|
|
451
|
+
*
|
|
452
|
+
* @returns A callback with the Promise memoized. Multiple calls of this function should always point to the same Promise.
|
|
453
|
+
*/
|
|
454
|
+
declare function memoizeAsync<ArgsType extends ReadonlyArray<unknown>, ResolvedType>(callback: Callback<ArgsType, ResolvedType>): Callback<ArgsType, ResolvedType>;
|
|
455
|
+
//#endregion
|
|
441
456
|
//#region src/root/functions/miscellaneous/sayHello.d.ts
|
|
442
457
|
/**
|
|
443
458
|
* Returns a string representing the lyrics to the package's theme song, Commit To You
|
|
@@ -697,10 +712,7 @@ interface StringListToArrayOptions {
|
|
|
697
712
|
*
|
|
698
713
|
* @returns A new array with each item being an item from the given list.
|
|
699
714
|
*/
|
|
700
|
-
declare function stringListToArray(stringList: string, {
|
|
701
|
-
separator,
|
|
702
|
-
trimWhitespace
|
|
703
|
-
}?: StringListToArrayOptions): Array<string>;
|
|
715
|
+
declare function stringListToArray(stringList: string, { separator, trimWhitespace }?: StringListToArrayOptions): Array<string>;
|
|
704
716
|
//#endregion
|
|
705
717
|
//#region src/root/functions/miscellaneous/wait.d.ts
|
|
706
718
|
/**
|
|
@@ -761,7 +773,7 @@ declare function omitProperties<ObjectType extends object, KeysToOmit extends ke
|
|
|
761
773
|
declare function pickProperties<ObjectType extends object, KeysToPick extends keyof ObjectType>(object: ObjectType, keysToPick: KeysToPick | ReadonlyArray<KeysToPick>): Pick<ObjectType, KeysToPick>;
|
|
762
774
|
//#endregion
|
|
763
775
|
//#region src/root/functions/objectHelpers/removeUndefinedFromObject.d.ts
|
|
764
|
-
type RemoveUndefined<RecordType extends Record<PropertyKey, unknown>> = { [Key in keyof RecordType]: Exclude<RecordType[Key], undefined
|
|
776
|
+
type RemoveUndefined<RecordType extends Record<PropertyKey, unknown>> = { [Key in keyof RecordType]: Exclude<RecordType[Key], undefined>; };
|
|
765
777
|
/**
|
|
766
778
|
* Removes entries whose values are `undefined` from a given object (not including null etc.).
|
|
767
779
|
*
|
|
@@ -1499,4 +1511,4 @@ interface ZodParsingErrorData {
|
|
|
1499
1511
|
issues: Array<z.core.$ZodIssue>;
|
|
1500
1512
|
}
|
|
1501
1513
|
//#endregion
|
|
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 };
|
|
1514
|
+
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, memoizeAsync, 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
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import z, { ZodCoercedDate, ZodCoercedNumber, ZodError, ZodType, z as z$1 } from "zod";
|
|
2
2
|
import { DotenvParseOutput } from "dotenv";
|
|
3
|
-
|
|
4
3
|
//#region src/root/constants/FILE_PATH_REGEX.d.ts
|
|
5
4
|
declare const FILE_PATH_REGEX_PATTERN: string;
|
|
6
5
|
declare const FILE_PATH_REGEX: RegExp;
|
|
@@ -438,6 +437,22 @@ declare function identity<InputType>(input: InputType): InputType;
|
|
|
438
437
|
*/
|
|
439
438
|
declare function isOrdered(array: ReadonlyArray<number>): boolean;
|
|
440
439
|
//#endregion
|
|
440
|
+
//#region src/root/functions/miscellaneous/memoizeAsync.d.ts
|
|
441
|
+
type Callback<ArgsType extends ReadonlyArray<unknown>, ResolvedType> = (...args: ArgsType) => Promise<ResolvedType>;
|
|
442
|
+
/**
|
|
443
|
+
* Memoizes the Promise returned by an asynchronous callback.
|
|
444
|
+
*
|
|
445
|
+
* Note that the callback is invoked at most once. Arguments supplied to subsequent calls are ignored because the Promise from the first invocation is always returned.
|
|
446
|
+
*
|
|
447
|
+
* @template ArgsType - The type of the function arguments.
|
|
448
|
+
* @template ResolvedType - The type of the Promise when resolved.
|
|
449
|
+
*
|
|
450
|
+
* @param callback - The function to memoize.
|
|
451
|
+
*
|
|
452
|
+
* @returns A callback with the Promise memoized. Multiple calls of this function should always point to the same Promise.
|
|
453
|
+
*/
|
|
454
|
+
declare function memoizeAsync<ArgsType extends ReadonlyArray<unknown>, ResolvedType>(callback: Callback<ArgsType, ResolvedType>): Callback<ArgsType, ResolvedType>;
|
|
455
|
+
//#endregion
|
|
441
456
|
//#region src/root/functions/miscellaneous/sayHello.d.ts
|
|
442
457
|
/**
|
|
443
458
|
* Returns a string representing the lyrics to the package's theme song, Commit To You
|
|
@@ -697,10 +712,7 @@ interface StringListToArrayOptions {
|
|
|
697
712
|
*
|
|
698
713
|
* @returns A new array with each item being an item from the given list.
|
|
699
714
|
*/
|
|
700
|
-
declare function stringListToArray(stringList: string, {
|
|
701
|
-
separator,
|
|
702
|
-
trimWhitespace
|
|
703
|
-
}?: StringListToArrayOptions): Array<string>;
|
|
715
|
+
declare function stringListToArray(stringList: string, { separator, trimWhitespace }?: StringListToArrayOptions): Array<string>;
|
|
704
716
|
//#endregion
|
|
705
717
|
//#region src/root/functions/miscellaneous/wait.d.ts
|
|
706
718
|
/**
|
|
@@ -761,7 +773,7 @@ declare function omitProperties<ObjectType extends object, KeysToOmit extends ke
|
|
|
761
773
|
declare function pickProperties<ObjectType extends object, KeysToPick extends keyof ObjectType>(object: ObjectType, keysToPick: KeysToPick | ReadonlyArray<KeysToPick>): Pick<ObjectType, KeysToPick>;
|
|
762
774
|
//#endregion
|
|
763
775
|
//#region src/root/functions/objectHelpers/removeUndefinedFromObject.d.ts
|
|
764
|
-
type RemoveUndefined<RecordType extends Record<PropertyKey, unknown>> = { [Key in keyof RecordType]: Exclude<RecordType[Key], undefined
|
|
776
|
+
type RemoveUndefined<RecordType extends Record<PropertyKey, unknown>> = { [Key in keyof RecordType]: Exclude<RecordType[Key], undefined>; };
|
|
765
777
|
/**
|
|
766
778
|
* Removes entries whose values are `undefined` from a given object (not including null etc.).
|
|
767
779
|
*
|
|
@@ -1499,4 +1511,4 @@ interface ZodParsingErrorData {
|
|
|
1499
1511
|
issues: Array<z.core.$ZodIssue>;
|
|
1500
1512
|
}
|
|
1501
1513
|
//#endregion
|
|
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 };
|
|
1514
|
+
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, memoizeAsync, 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
|
@@ -4,7 +4,7 @@ const FILE_PATH_REGEX_PATTERN = String.raw`(?<directory>.+)[\/\\](?<base>[^\/\\]
|
|
|
4
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
|
-
const ONE_DAY_IN_MILLISECONDS =
|
|
7
|
+
const ONE_DAY_IN_MILLISECONDS = 864e5;
|
|
8
8
|
//#endregion
|
|
9
9
|
//#region src/root/constants/UUID_REGEX.ts
|
|
10
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}";
|
|
@@ -834,6 +834,27 @@ function isOrdered(array) {
|
|
|
834
834
|
return true;
|
|
835
835
|
}
|
|
836
836
|
//#endregion
|
|
837
|
+
//#region src/root/functions/miscellaneous/memoizeAsync.ts
|
|
838
|
+
/**
|
|
839
|
+
* Memoizes the Promise returned by an asynchronous callback.
|
|
840
|
+
*
|
|
841
|
+
* Note that the callback is invoked at most once. Arguments supplied to subsequent calls are ignored because the Promise from the first invocation is always returned.
|
|
842
|
+
*
|
|
843
|
+
* @template ArgsType - The type of the function arguments.
|
|
844
|
+
* @template ResolvedType - The type of the Promise when resolved.
|
|
845
|
+
*
|
|
846
|
+
* @param callback - The function to memoize.
|
|
847
|
+
*
|
|
848
|
+
* @returns A callback with the Promise memoized. Multiple calls of this function should always point to the same Promise.
|
|
849
|
+
*/
|
|
850
|
+
function memoizeAsync(callback) {
|
|
851
|
+
let promise;
|
|
852
|
+
return (...args) => {
|
|
853
|
+
promise ??= callback(...args);
|
|
854
|
+
return promise;
|
|
855
|
+
};
|
|
856
|
+
}
|
|
857
|
+
//#endregion
|
|
837
858
|
//#region src/root/functions/miscellaneous/sayHello.ts
|
|
838
859
|
/**
|
|
839
860
|
* Returns a string representing the lyrics to the package's theme song, Commit To You
|
|
@@ -2030,4 +2051,4 @@ const UUID_PATTERN = UUID_REGEX_PATTERN;
|
|
|
2030
2051
|
/** @deprecated This has been renamed to `VERSION_NUMBER_REGEX_PATTERN`. */
|
|
2031
2052
|
const VERSION_NUMBER_PATTERN = String.raw`^(?:v)?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$`;
|
|
2032
2053
|
//#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 };
|
|
2054
|
+
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, memoizeAsync, 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
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
20
20
|
value: mod,
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
package/dist/internal/index.d.ts
CHANGED
package/dist/node/index.cjs
CHANGED
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
20
20
|
value: mod,
|
|
21
21
|
enumerable: true
|
|
22
22
|
}) : target, mod));
|
package/dist/node/index.d.cts
CHANGED
package/dist/node/index.d.ts
CHANGED
package/dist/v6/index.d.cts
CHANGED
package/dist/v6/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alextheman/utility",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.26.1",
|
|
4
4
|
"description": "Helpful utility functions.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -42,30 +42,30 @@
|
|
|
42
42
|
],
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"dotenv": "17.4.2",
|
|
45
|
-
"execa": "
|
|
45
|
+
"execa": "10.0.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@alextheman/eslint-plugin": "5.18.0",
|
|
49
|
-
"@types/node": "26.1.
|
|
50
|
-
"alex-c-line": "2.
|
|
49
|
+
"@types/node": "26.1.2",
|
|
50
|
+
"alex-c-line": "2.13.0",
|
|
51
51
|
"cross-env": "10.1.0",
|
|
52
52
|
"dotenv-cli": "11.0.0",
|
|
53
|
-
"eslint": "10.
|
|
54
|
-
"globals": "17.
|
|
53
|
+
"eslint": "10.8.0",
|
|
54
|
+
"globals": "17.8.0",
|
|
55
55
|
"husky": "9.1.7",
|
|
56
|
-
"jsdom": "
|
|
57
|
-
"markdownlint-cli2": "0.23.
|
|
58
|
-
"prettier": "3.9.
|
|
56
|
+
"jsdom": "30.0.1",
|
|
57
|
+
"markdownlint-cli2": "0.23.2",
|
|
58
|
+
"prettier": "3.9.6",
|
|
59
59
|
"tempy": "3.2.0",
|
|
60
|
-
"tsdown": "0.22.
|
|
61
|
-
"tsx": "4.23.
|
|
62
|
-
"typedoc": "0.28.
|
|
60
|
+
"tsdown": "0.22.14",
|
|
61
|
+
"tsx": "4.23.1",
|
|
62
|
+
"typedoc": "0.28.20",
|
|
63
63
|
"typedoc-plugin-markdown": "4.12.0",
|
|
64
64
|
"typedoc-rhineai-theme": "1.2.0",
|
|
65
65
|
"typescript": "6.0.3",
|
|
66
|
-
"typescript-eslint": "8.
|
|
67
|
-
"vite": "8.
|
|
68
|
-
"vitest": "4.1.
|
|
66
|
+
"typescript-eslint": "8.65.0",
|
|
67
|
+
"vite": "8.2.0",
|
|
68
|
+
"vitest": "4.1.10",
|
|
69
69
|
"zod": "4.4.3"
|
|
70
70
|
},
|
|
71
71
|
"engines": {
|
|
@@ -79,6 +79,7 @@
|
|
|
79
79
|
"build-configs": "tsdown --config tsdown.configs.config.ts",
|
|
80
80
|
"create-feature-docs": "typedoc",
|
|
81
81
|
"create-local-package": "pnpm run build && rm -f alextheman-utility-*.tgz && pnpm pack",
|
|
82
|
+
"create-release": "bash -c 'git pull origin main && alex-c-line template release-note create $@ --status \"Released\" --update-version' --",
|
|
82
83
|
"create-release-note": "bash -c 'git pull origin main && alex-c-line template release-note create $@' --",
|
|
83
84
|
"format": "pnpm run format-prettier && pnpm run format-eslint && pnpm run format-markdownlint",
|
|
84
85
|
"format-eslint": "eslint --fix --suppress-all \"package.json\" \"{src,tests,configs}/**/*.ts\" && rm -f eslint-suppressions.json",
|