@alextheman/utility 4.13.0 → 4.14.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 +173 -160
- package/dist/index.d.cts +57 -6
- package/dist/index.d.ts +57 -6
- package/dist/index.js +116 -106
- package/package.json +8 -8
package/dist/index.d.cts
CHANGED
|
@@ -977,6 +977,7 @@ declare function createTemplateStringsArray(strings: readonly string[]): Templat
|
|
|
977
977
|
//#endregion
|
|
978
978
|
//#region src/functions/taggedTemplate/getInterpolations.d.ts
|
|
979
979
|
/**
|
|
980
|
+
*
|
|
980
981
|
* Gets the strings and interpolations separately from a template string.
|
|
981
982
|
* You can pass a template string directly by doing:
|
|
982
983
|
*
|
|
@@ -986,6 +987,8 @@ declare function createTemplateStringsArray(strings: readonly string[]): Templat
|
|
|
986
987
|
*
|
|
987
988
|
* @category Tagged Template
|
|
988
989
|
*
|
|
990
|
+
* @deprecated Please use `getStringsAndInterpolations` instead.
|
|
991
|
+
*
|
|
989
992
|
* @param strings - The strings from the template to process.
|
|
990
993
|
* @param interpolations - An array of all interpolations from the template.
|
|
991
994
|
*
|
|
@@ -993,6 +996,38 @@ declare function createTemplateStringsArray(strings: readonly string[]): Templat
|
|
|
993
996
|
*/
|
|
994
997
|
declare function getInterpolations(strings: TemplateStringsArray, ...interpolations: unknown[]): [TemplateStringsArray, unknown[]];
|
|
995
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
|
|
996
1031
|
//#region src/functions/taggedTemplate/interpolate.d.ts
|
|
997
1032
|
/**
|
|
998
1033
|
* Returns the result of interpolating a template string when given the strings and interpolations separately.
|
|
@@ -1007,12 +1042,14 @@ declare function getInterpolations(strings: TemplateStringsArray, ...interpolati
|
|
|
1007
1042
|
*
|
|
1008
1043
|
* @category Tagged Template
|
|
1009
1044
|
*
|
|
1045
|
+
* @template InterpolationsType - The type of the interpolations.
|
|
1046
|
+
*
|
|
1010
1047
|
* @param strings - The strings from the template to process.
|
|
1011
1048
|
* @param interpolations - An array of all interpolations from the template.
|
|
1012
1049
|
*
|
|
1013
1050
|
* @returns A new string with the strings and interpolations from the template applied.
|
|
1014
1051
|
*/
|
|
1015
|
-
declare function interpolate(strings: TemplateStringsArray, ...interpolations:
|
|
1052
|
+
declare function interpolate<const InterpolationsType extends readonly unknown[]>(strings: TemplateStringsArray, ...interpolations: InterpolationsType): string;
|
|
1016
1053
|
//#endregion
|
|
1017
1054
|
//#region src/functions/taggedTemplate/interpolateObjects.d.ts
|
|
1018
1055
|
/**
|
|
@@ -1021,17 +1058,31 @@ declare function interpolate(strings: TemplateStringsArray, ...interpolations: u
|
|
|
1021
1058
|
* You can pass a template string directly by doing:
|
|
1022
1059
|
*
|
|
1023
1060
|
* ```typescript
|
|
1024
|
-
* interpolateObjects`Template string here ${{ my: "object" }}
|
|
1061
|
+
* interpolateObjects`Template string here ${{ my: "object" }}`;
|
|
1025
1062
|
* ```
|
|
1026
1063
|
*
|
|
1027
1064
|
* @category Tagged Template
|
|
1028
1065
|
*
|
|
1066
|
+
* @template InterpolationsType - The type of the interpolations.
|
|
1067
|
+
*
|
|
1029
1068
|
* @param strings - The strings from the template to process.
|
|
1030
1069
|
* @param interpolations - An array of all interpolations from the template.
|
|
1031
1070
|
*
|
|
1032
1071
|
* @returns A new string with the strings and interpolations from the template applied, with objects stringified.
|
|
1033
1072
|
*/
|
|
1034
|
-
declare function interpolateObjects(strings: TemplateStringsArray, ...interpolations:
|
|
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;
|
|
1035
1086
|
//#endregion
|
|
1036
1087
|
//#region src/functions/taggedTemplate/normaliseIndents.d.ts
|
|
1037
1088
|
/**
|
|
@@ -1064,10 +1115,10 @@ declare function normaliseIndents(options: NormaliseIndentsOptions): NormaliseIn
|
|
|
1064
1115
|
* ```typescript
|
|
1065
1116
|
* normaliseIndents`Template string here
|
|
1066
1117
|
* with a new line
|
|
1067
|
-
* and another new line
|
|
1118
|
+
* and another new line`;
|
|
1068
1119
|
* ```
|
|
1069
1120
|
*
|
|
1070
|
-
|
|
1121
|
+
* @template InterpolationsType - The type of the interpolations.
|
|
1071
1122
|
*
|
|
1072
1123
|
* @param strings - The strings from the template to process.
|
|
1073
1124
|
* @param interpolations - An array of all interpolations from the template.
|
|
@@ -1172,4 +1223,4 @@ interface ParseVersionOptions {
|
|
|
1172
1223
|
*/
|
|
1173
1224
|
declare function parseVersion(input: string, options?: ParseVersionOptions): string;
|
|
1174
1225
|
//#endregion
|
|
1175
|
-
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, sayHello, 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
|
@@ -977,6 +977,7 @@ declare function createTemplateStringsArray(strings: readonly string[]): Templat
|
|
|
977
977
|
//#endregion
|
|
978
978
|
//#region src/functions/taggedTemplate/getInterpolations.d.ts
|
|
979
979
|
/**
|
|
980
|
+
*
|
|
980
981
|
* Gets the strings and interpolations separately from a template string.
|
|
981
982
|
* You can pass a template string directly by doing:
|
|
982
983
|
*
|
|
@@ -986,6 +987,8 @@ declare function createTemplateStringsArray(strings: readonly string[]): Templat
|
|
|
986
987
|
*
|
|
987
988
|
* @category Tagged Template
|
|
988
989
|
*
|
|
990
|
+
* @deprecated Please use `getStringsAndInterpolations` instead.
|
|
991
|
+
*
|
|
989
992
|
* @param strings - The strings from the template to process.
|
|
990
993
|
* @param interpolations - An array of all interpolations from the template.
|
|
991
994
|
*
|
|
@@ -993,6 +996,38 @@ declare function createTemplateStringsArray(strings: readonly string[]): Templat
|
|
|
993
996
|
*/
|
|
994
997
|
declare function getInterpolations(strings: TemplateStringsArray, ...interpolations: unknown[]): [TemplateStringsArray, unknown[]];
|
|
995
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
|
|
996
1031
|
//#region src/functions/taggedTemplate/interpolate.d.ts
|
|
997
1032
|
/**
|
|
998
1033
|
* Returns the result of interpolating a template string when given the strings and interpolations separately.
|
|
@@ -1007,12 +1042,14 @@ declare function getInterpolations(strings: TemplateStringsArray, ...interpolati
|
|
|
1007
1042
|
*
|
|
1008
1043
|
* @category Tagged Template
|
|
1009
1044
|
*
|
|
1045
|
+
* @template InterpolationsType - The type of the interpolations.
|
|
1046
|
+
*
|
|
1010
1047
|
* @param strings - The strings from the template to process.
|
|
1011
1048
|
* @param interpolations - An array of all interpolations from the template.
|
|
1012
1049
|
*
|
|
1013
1050
|
* @returns A new string with the strings and interpolations from the template applied.
|
|
1014
1051
|
*/
|
|
1015
|
-
declare function interpolate(strings: TemplateStringsArray, ...interpolations:
|
|
1052
|
+
declare function interpolate<const InterpolationsType extends readonly unknown[]>(strings: TemplateStringsArray, ...interpolations: InterpolationsType): string;
|
|
1016
1053
|
//#endregion
|
|
1017
1054
|
//#region src/functions/taggedTemplate/interpolateObjects.d.ts
|
|
1018
1055
|
/**
|
|
@@ -1021,17 +1058,31 @@ declare function interpolate(strings: TemplateStringsArray, ...interpolations: u
|
|
|
1021
1058
|
* You can pass a template string directly by doing:
|
|
1022
1059
|
*
|
|
1023
1060
|
* ```typescript
|
|
1024
|
-
* interpolateObjects`Template string here ${{ my: "object" }}
|
|
1061
|
+
* interpolateObjects`Template string here ${{ my: "object" }}`;
|
|
1025
1062
|
* ```
|
|
1026
1063
|
*
|
|
1027
1064
|
* @category Tagged Template
|
|
1028
1065
|
*
|
|
1066
|
+
* @template InterpolationsType - The type of the interpolations.
|
|
1067
|
+
*
|
|
1029
1068
|
* @param strings - The strings from the template to process.
|
|
1030
1069
|
* @param interpolations - An array of all interpolations from the template.
|
|
1031
1070
|
*
|
|
1032
1071
|
* @returns A new string with the strings and interpolations from the template applied, with objects stringified.
|
|
1033
1072
|
*/
|
|
1034
|
-
declare function interpolateObjects(strings: TemplateStringsArray, ...interpolations:
|
|
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;
|
|
1035
1086
|
//#endregion
|
|
1036
1087
|
//#region src/functions/taggedTemplate/normaliseIndents.d.ts
|
|
1037
1088
|
/**
|
|
@@ -1064,10 +1115,10 @@ declare function normaliseIndents(options: NormaliseIndentsOptions): NormaliseIn
|
|
|
1064
1115
|
* ```typescript
|
|
1065
1116
|
* normaliseIndents`Template string here
|
|
1066
1117
|
* with a new line
|
|
1067
|
-
* and another new line
|
|
1118
|
+
* and another new line`;
|
|
1068
1119
|
* ```
|
|
1069
1120
|
*
|
|
1070
|
-
|
|
1121
|
+
* @template InterpolationsType - The type of the interpolations.
|
|
1071
1122
|
*
|
|
1072
1123
|
* @param strings - The strings from the template to process.
|
|
1073
1124
|
* @param interpolations - An array of all interpolations from the template.
|
|
@@ -1172,4 +1223,4 @@ interface ParseVersionOptions {
|
|
|
1172
1223
|
*/
|
|
1173
1224
|
declare function parseVersion(input: string, options?: ParseVersionOptions): string;
|
|
1174
1225
|
//#endregion
|
|
1175
|
-
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, sayHello, 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 };
|