@alextheman/utility 4.12.3 → 4.14.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.d.cts CHANGED
@@ -498,6 +498,16 @@ declare function getRandomNumber(lowerBound: number, upperBound: number): number
498
498
  */
499
499
  declare function isOrdered(array: readonly number[]): boolean;
500
500
  //#endregion
501
+ //#region src/functions/miscellaneous/sayHello.d.ts
502
+ /**
503
+ * Returns a string representing the lyrics to the package's theme song, Commit To You
504
+ *
505
+ * [Pls listen!](https://www.youtube.com/watch?v=mH-Sg-8EnxM)
506
+ *
507
+ * @returns The lyrics string in markdown format.
508
+ */
509
+ declare function sayHello(): string;
510
+ //#endregion
501
511
  //#region src/functions/miscellaneous/stringifyDotenv.d.ts
502
512
  type QuoteStyle = "double" | "single" | "none";
503
513
  interface StringifyDotenvOptions {
@@ -967,6 +977,7 @@ declare function createTemplateStringsArray(strings: readonly string[]): Templat
967
977
  //#endregion
968
978
  //#region src/functions/taggedTemplate/getInterpolations.d.ts
969
979
  /**
980
+ *
970
981
  * Gets the strings and interpolations separately from a template string.
971
982
  * You can pass a template string directly by doing:
972
983
  *
@@ -976,6 +987,8 @@ declare function createTemplateStringsArray(strings: readonly string[]): Templat
976
987
  *
977
988
  * @category Tagged Template
978
989
  *
990
+ * @deprecated Please use `getStringsAndInterpolations` instead.
991
+ *
979
992
  * @param strings - The strings from the template to process.
980
993
  * @param interpolations - An array of all interpolations from the template.
981
994
  *
@@ -983,6 +996,38 @@ declare function createTemplateStringsArray(strings: readonly string[]): Templat
983
996
  */
984
997
  declare function getInterpolations(strings: TemplateStringsArray, ...interpolations: unknown[]): [TemplateStringsArray, unknown[]];
985
998
  //#endregion
999
+ //#region src/functions/taggedTemplate/getStringsAndInterpolations.d.ts
1000
+ /**
1001
+ *
1002
+ * Gets the strings and interpolations separately from a template string.
1003
+ * You can pass a template string directly by doing:
1004
+ *
1005
+ * ```typescript
1006
+ * getStringsAndInterpolations`Template string here`;
1007
+ * ```
1008
+ *
1009
+ * @category Tagged Template
1010
+ *
1011
+ * @template InterpolationsType - The type of the interpolations.
1012
+ *
1013
+ * @param strings - The strings from the template to process.
1014
+ * @param interpolations - An array of all interpolations from the template.
1015
+ *
1016
+ * @returns A tuple where the first item is the strings from the template, and the remaining items are the interpolations.
1017
+ *
1018
+ * The return of this function may also be spread into any other tagged template function in the following way:
1019
+ *
1020
+ * ```typescript
1021
+ * import { interpolate } from "@alextheman/utility"; // Example function
1022
+ *
1023
+ * const packageName = "@alextheman/utility";
1024
+ * const packageManager = getPackageManager(packageName);
1025
+ *
1026
+ * interpolate(...getStringsAndInterpolations`The package ${packageName} uses the ${packageManager} package manager.`);
1027
+ * ```
1028
+ */
1029
+ declare function getStringsAndInterpolations<const InterpolationsType extends readonly unknown[]>(strings: TemplateStringsArray, ...interpolations: InterpolationsType): [TemplateStringsArray, ...InterpolationsType];
1030
+ //#endregion
986
1031
  //#region src/functions/taggedTemplate/interpolate.d.ts
987
1032
  /**
988
1033
  * Returns the result of interpolating a template string when given the strings and interpolations separately.
@@ -997,12 +1042,14 @@ declare function getInterpolations(strings: TemplateStringsArray, ...interpolati
997
1042
  *
998
1043
  * @category Tagged Template
999
1044
  *
1045
+ * @template InterpolationsType - The type of the interpolations.
1046
+ *
1000
1047
  * @param strings - The strings from the template to process.
1001
1048
  * @param interpolations - An array of all interpolations from the template.
1002
1049
  *
1003
1050
  * @returns A new string with the strings and interpolations from the template applied.
1004
1051
  */
1005
- declare function interpolate(strings: TemplateStringsArray, ...interpolations: unknown[]): string;
1052
+ declare function interpolate<const InterpolationsType extends readonly unknown[]>(strings: TemplateStringsArray, ...interpolations: InterpolationsType): string;
1006
1053
  //#endregion
1007
1054
  //#region src/functions/taggedTemplate/interpolateObjects.d.ts
1008
1055
  /**
@@ -1011,17 +1058,31 @@ declare function interpolate(strings: TemplateStringsArray, ...interpolations: u
1011
1058
  * You can pass a template string directly by doing:
1012
1059
  *
1013
1060
  * ```typescript
1014
- * interpolateObjects`Template string here ${{ my: "object" }}`.
1061
+ * interpolateObjects`Template string here ${{ my: "object" }}`;
1015
1062
  * ```
1016
1063
  *
1017
1064
  * @category Tagged Template
1018
1065
  *
1066
+ * @template InterpolationsType - The type of the interpolations.
1067
+ *
1019
1068
  * @param strings - The strings from the template to process.
1020
1069
  * @param interpolations - An array of all interpolations from the template.
1021
1070
  *
1022
1071
  * @returns A new string with the strings and interpolations from the template applied, with objects stringified.
1023
1072
  */
1024
- declare function interpolateObjects(strings: TemplateStringsArray, ...interpolations: unknown[]): string;
1073
+ declare function interpolateObjects<const InterpolationsType extends readonly unknown[]>(strings: TemplateStringsArray, ...interpolations: InterpolationsType): string;
1074
+ //#endregion
1075
+ //#region src/functions/taggedTemplate/isTemplateStringsArray.d.ts
1076
+ /**
1077
+ * Determines whether or not the input is a valid `TemplateStringsArray`.
1078
+ *
1079
+ * @category Tagged Template
1080
+ *
1081
+ * @param input - The input to check
1082
+ *
1083
+ * @returns `true` if the input is a valid `TemplateStringsArray`, and false otherwise. The type of the input will also be narrowed down to `TemplateStringsArray` if `true`.
1084
+ */
1085
+ declare function isTemplateStringsArray(input: unknown): input is TemplateStringsArray;
1025
1086
  //#endregion
1026
1087
  //#region src/functions/taggedTemplate/normaliseIndents.d.ts
1027
1088
  /**
@@ -1054,10 +1115,10 @@ declare function normaliseIndents(options: NormaliseIndentsOptions): NormaliseIn
1054
1115
  * ```typescript
1055
1116
  * normaliseIndents`Template string here
1056
1117
  * with a new line
1057
- * and another new line`.
1118
+ * and another new line`;
1058
1119
  * ```
1059
1120
  *
1060
- *@category Tagged Template
1121
+ * @template InterpolationsType - The type of the interpolations.
1061
1122
  *
1062
1123
  * @param strings - The strings from the template to process.
1063
1124
  * @param interpolations - An array of all interpolations from the template.
@@ -1162,4 +1223,4 @@ interface ParseVersionOptions {
1162
1223
  */
1163
1224
  declare function parseVersion(input: string, options?: ParseVersionOptions): string;
1164
1225
  //#endregion
1165
- export { APIError, ArrayElement, CallReturnType, CamelToKebabOptions, CreateEnumType, CreateFormDataOptions, CreateFormDataOptionsNullableResolution, CreateFormDataOptionsUndefinedOrNullResolution, DataError, DisallowUndefined, Env, FILE_PATH_REGEX, FormDataArrayResolutionStrategy, FormDataNullableResolutionStrategy, HTTPErrorCode, IgnoreCase, IncrementVersionOptions, KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, OptionalOnCondition, ParallelTuple, ParseVersionOptions, PublicAndPrivateKey, RecordKey, RemoveUndefined, StringListToArrayOptions, VERSION_NUMBER_REGEX, VersionNumber, VersionNumberToStringOptions, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, determineVersionType, encryptWithKey, fillArray, formatDateAndTime, getIndividualVersionNumbers, getInterpolations, getPublicAndPrivateKey, getRandomNumber, getRecordKeys, httpErrorCodeLookup, incrementVersion, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFilePath, parseFormData, parseIntStrict, parseVersion, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, stringListToArray, stringifyDotenv, truncate, wait };
1226
+ export { APIError, ArrayElement, CallReturnType, CamelToKebabOptions, CreateEnumType, CreateFormDataOptions, CreateFormDataOptionsNullableResolution, CreateFormDataOptionsUndefinedOrNullResolution, DataError, DisallowUndefined, Env, FILE_PATH_REGEX, FormDataArrayResolutionStrategy, FormDataNullableResolutionStrategy, HTTPErrorCode, IgnoreCase, IncrementVersionOptions, KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, OptionalOnCondition, ParallelTuple, ParseVersionOptions, PublicAndPrivateKey, RecordKey, RemoveUndefined, StringListToArrayOptions, VERSION_NUMBER_REGEX, VersionNumber, VersionNumberToStringOptions, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, determineVersionType, encryptWithKey, fillArray, formatDateAndTime, getIndividualVersionNumbers, getInterpolations, getPublicAndPrivateKey, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, incrementVersion, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFilePath, parseFormData, parseIntStrict, parseVersion, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, stringListToArray, stringifyDotenv, truncate, wait };
package/dist/index.d.ts CHANGED
@@ -498,6 +498,16 @@ declare function getRandomNumber(lowerBound: number, upperBound: number): number
498
498
  */
499
499
  declare function isOrdered(array: readonly number[]): boolean;
500
500
  //#endregion
501
+ //#region src/functions/miscellaneous/sayHello.d.ts
502
+ /**
503
+ * Returns a string representing the lyrics to the package's theme song, Commit To You
504
+ *
505
+ * [Pls listen!](https://www.youtube.com/watch?v=mH-Sg-8EnxM)
506
+ *
507
+ * @returns The lyrics string in markdown format.
508
+ */
509
+ declare function sayHello(): string;
510
+ //#endregion
501
511
  //#region src/functions/miscellaneous/stringifyDotenv.d.ts
502
512
  type QuoteStyle = "double" | "single" | "none";
503
513
  interface StringifyDotenvOptions {
@@ -967,6 +977,7 @@ declare function createTemplateStringsArray(strings: readonly string[]): Templat
967
977
  //#endregion
968
978
  //#region src/functions/taggedTemplate/getInterpolations.d.ts
969
979
  /**
980
+ *
970
981
  * Gets the strings and interpolations separately from a template string.
971
982
  * You can pass a template string directly by doing:
972
983
  *
@@ -976,6 +987,8 @@ declare function createTemplateStringsArray(strings: readonly string[]): Templat
976
987
  *
977
988
  * @category Tagged Template
978
989
  *
990
+ * @deprecated Please use `getStringsAndInterpolations` instead.
991
+ *
979
992
  * @param strings - The strings from the template to process.
980
993
  * @param interpolations - An array of all interpolations from the template.
981
994
  *
@@ -983,6 +996,38 @@ declare function createTemplateStringsArray(strings: readonly string[]): Templat
983
996
  */
984
997
  declare function getInterpolations(strings: TemplateStringsArray, ...interpolations: unknown[]): [TemplateStringsArray, unknown[]];
985
998
  //#endregion
999
+ //#region src/functions/taggedTemplate/getStringsAndInterpolations.d.ts
1000
+ /**
1001
+ *
1002
+ * Gets the strings and interpolations separately from a template string.
1003
+ * You can pass a template string directly by doing:
1004
+ *
1005
+ * ```typescript
1006
+ * getStringsAndInterpolations`Template string here`;
1007
+ * ```
1008
+ *
1009
+ * @category Tagged Template
1010
+ *
1011
+ * @template InterpolationsType - The type of the interpolations.
1012
+ *
1013
+ * @param strings - The strings from the template to process.
1014
+ * @param interpolations - An array of all interpolations from the template.
1015
+ *
1016
+ * @returns A tuple where the first item is the strings from the template, and the remaining items are the interpolations.
1017
+ *
1018
+ * The return of this function may also be spread into any other tagged template function in the following way:
1019
+ *
1020
+ * ```typescript
1021
+ * import { interpolate } from "@alextheman/utility"; // Example function
1022
+ *
1023
+ * const packageName = "@alextheman/utility";
1024
+ * const packageManager = getPackageManager(packageName);
1025
+ *
1026
+ * interpolate(...getStringsAndInterpolations`The package ${packageName} uses the ${packageManager} package manager.`);
1027
+ * ```
1028
+ */
1029
+ declare function getStringsAndInterpolations<const InterpolationsType extends readonly unknown[]>(strings: TemplateStringsArray, ...interpolations: InterpolationsType): [TemplateStringsArray, ...InterpolationsType];
1030
+ //#endregion
986
1031
  //#region src/functions/taggedTemplate/interpolate.d.ts
987
1032
  /**
988
1033
  * Returns the result of interpolating a template string when given the strings and interpolations separately.
@@ -997,12 +1042,14 @@ declare function getInterpolations(strings: TemplateStringsArray, ...interpolati
997
1042
  *
998
1043
  * @category Tagged Template
999
1044
  *
1045
+ * @template InterpolationsType - The type of the interpolations.
1046
+ *
1000
1047
  * @param strings - The strings from the template to process.
1001
1048
  * @param interpolations - An array of all interpolations from the template.
1002
1049
  *
1003
1050
  * @returns A new string with the strings and interpolations from the template applied.
1004
1051
  */
1005
- declare function interpolate(strings: TemplateStringsArray, ...interpolations: unknown[]): string;
1052
+ declare function interpolate<const InterpolationsType extends readonly unknown[]>(strings: TemplateStringsArray, ...interpolations: InterpolationsType): string;
1006
1053
  //#endregion
1007
1054
  //#region src/functions/taggedTemplate/interpolateObjects.d.ts
1008
1055
  /**
@@ -1011,17 +1058,31 @@ declare function interpolate(strings: TemplateStringsArray, ...interpolations: u
1011
1058
  * You can pass a template string directly by doing:
1012
1059
  *
1013
1060
  * ```typescript
1014
- * interpolateObjects`Template string here ${{ my: "object" }}`.
1061
+ * interpolateObjects`Template string here ${{ my: "object" }}`;
1015
1062
  * ```
1016
1063
  *
1017
1064
  * @category Tagged Template
1018
1065
  *
1066
+ * @template InterpolationsType - The type of the interpolations.
1067
+ *
1019
1068
  * @param strings - The strings from the template to process.
1020
1069
  * @param interpolations - An array of all interpolations from the template.
1021
1070
  *
1022
1071
  * @returns A new string with the strings and interpolations from the template applied, with objects stringified.
1023
1072
  */
1024
- declare function interpolateObjects(strings: TemplateStringsArray, ...interpolations: unknown[]): string;
1073
+ declare function interpolateObjects<const InterpolationsType extends readonly unknown[]>(strings: TemplateStringsArray, ...interpolations: InterpolationsType): string;
1074
+ //#endregion
1075
+ //#region src/functions/taggedTemplate/isTemplateStringsArray.d.ts
1076
+ /**
1077
+ * Determines whether or not the input is a valid `TemplateStringsArray`.
1078
+ *
1079
+ * @category Tagged Template
1080
+ *
1081
+ * @param input - The input to check
1082
+ *
1083
+ * @returns `true` if the input is a valid `TemplateStringsArray`, and false otherwise. The type of the input will also be narrowed down to `TemplateStringsArray` if `true`.
1084
+ */
1085
+ declare function isTemplateStringsArray(input: unknown): input is TemplateStringsArray;
1025
1086
  //#endregion
1026
1087
  //#region src/functions/taggedTemplate/normaliseIndents.d.ts
1027
1088
  /**
@@ -1054,10 +1115,10 @@ declare function normaliseIndents(options: NormaliseIndentsOptions): NormaliseIn
1054
1115
  * ```typescript
1055
1116
  * normaliseIndents`Template string here
1056
1117
  * with a new line
1057
- * and another new line`.
1118
+ * and another new line`;
1058
1119
  * ```
1059
1120
  *
1060
- *@category Tagged Template
1121
+ * @template InterpolationsType - The type of the interpolations.
1061
1122
  *
1062
1123
  * @param strings - The strings from the template to process.
1063
1124
  * @param interpolations - An array of all interpolations from the template.
@@ -1162,4 +1223,4 @@ interface ParseVersionOptions {
1162
1223
  */
1163
1224
  declare function parseVersion(input: string, options?: ParseVersionOptions): string;
1164
1225
  //#endregion
1165
- export { APIError, ArrayElement, CallReturnType, CamelToKebabOptions, CreateEnumType, CreateFormDataOptions, CreateFormDataOptionsNullableResolution, CreateFormDataOptionsUndefinedOrNullResolution, DataError, DisallowUndefined, Env, FILE_PATH_REGEX, FormDataArrayResolutionStrategy, FormDataNullableResolutionStrategy, HTTPErrorCode, IgnoreCase, type IncrementVersionOptions, KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, OptionalOnCondition, ParallelTuple, type ParseVersionOptions, type PublicAndPrivateKey, RecordKey, RemoveUndefined, StringListToArrayOptions, VERSION_NUMBER_REGEX, VersionNumber, VersionNumberToStringOptions, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, determineVersionType, encryptWithKey, fillArray, formatDateAndTime, getIndividualVersionNumbers, getInterpolations, getPublicAndPrivateKey, getRandomNumber, getRecordKeys, httpErrorCodeLookup, incrementVersion, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFilePath, parseFormData, parseIntStrict, parseVersion, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, stringListToArray, stringifyDotenv, truncate, wait };
1226
+ export { APIError, ArrayElement, CallReturnType, CamelToKebabOptions, CreateEnumType, CreateFormDataOptions, CreateFormDataOptionsNullableResolution, CreateFormDataOptionsUndefinedOrNullResolution, DataError, DisallowUndefined, Env, FILE_PATH_REGEX, FormDataArrayResolutionStrategy, FormDataNullableResolutionStrategy, HTTPErrorCode, IgnoreCase, type IncrementVersionOptions, KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, OptionalOnCondition, ParallelTuple, type ParseVersionOptions, type PublicAndPrivateKey, RecordKey, RemoveUndefined, StringListToArrayOptions, VERSION_NUMBER_REGEX, VersionNumber, VersionNumberToStringOptions, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, determineVersionType, encryptWithKey, fillArray, formatDateAndTime, getIndividualVersionNumbers, getInterpolations, getPublicAndPrivateKey, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, incrementVersion, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFilePath, parseFormData, parseIntStrict, parseVersion, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, stringListToArray, stringifyDotenv, truncate, wait };