@alextheman/utility 4.3.2 → 4.3.4

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 CHANGED
@@ -244,7 +244,7 @@ var VersionNumber = class VersionNumber {
244
244
  return firstVersion.major === secondVersion.major && firstVersion.minor === secondVersion.minor && firstVersion.patch === secondVersion.patch;
245
245
  }
246
246
  /**
247
- * Determines whether the current instance of `VersionNumber` is a major, minor, or patch version.
247
+ * Increments the current version number by the given increment type, returning the result as a new reference in memory.
248
248
  *
249
249
  * @param incrementType - The type of increment. Can be one of the following:
250
250
  * - `"major"`: Change the major version `v1.2.3` → `v2.0.0`
@@ -273,6 +273,25 @@ var VersionNumber = class VersionNumber {
273
273
  }[incrementType];
274
274
  }
275
275
  /**
276
+ * Ensures that the VersionNumber behaves correctly when attempted to be coerced to a string.
277
+ *
278
+ * @param hint - Not used as of now, but generally used to help with numeric coercion, I think (which we most likely do not need for version numbers).
279
+ *
280
+ * @returns A stringified representation of the current version number, prefixed with `v`.
281
+ */
282
+ [Symbol.toPrimitive](hint) {
283
+ if (hint === "number") throw new DataError_default(this.toString(), "INVALID_COERCION", "VersionNumber cannot be coerced to a number type.");
284
+ return this.toString();
285
+ }
286
+ /**
287
+ * Ensures that the VersionNumber behaves correctly when attempted to be converted to JSON.
288
+ *
289
+ * @returns A stringified representation of the current version number, prefixed with `v`.
290
+ */
291
+ toJSON() {
292
+ return this.toString();
293
+ }
294
+ /**
276
295
  * Get a string representation of the current version number.
277
296
  *
278
297
  * @param options - Extra additional options to apply.
@@ -1125,6 +1144,28 @@ function createTemplateStringsArray(strings) {
1125
1144
  }
1126
1145
  var createTemplateStringsArray_default = createTemplateStringsArray;
1127
1146
 
1147
+ //#endregion
1148
+ //#region src/functions/taggedTemplate/getInterpolations.ts
1149
+ /**
1150
+ * Gets the strings and interpolations separately from a template string.
1151
+ * You can pass a template string directly by doing:
1152
+ *
1153
+ * ```typescript
1154
+ * getInterpolations`Template string here`.
1155
+ * ```
1156
+ *
1157
+ * @category Tagged Template
1158
+ *
1159
+ * @param strings - The strings from the template to process.
1160
+ * @param interpolations - An array of all interpolations from the template.
1161
+ *
1162
+ * @returns A tuple where the first item is the strings from the template, and the second is the interpolations.
1163
+ */
1164
+ function getInterpolations(strings, ...interpolations) {
1165
+ return [strings, interpolations];
1166
+ }
1167
+ var getInterpolations_default = getInterpolations;
1168
+
1128
1169
  //#endregion
1129
1170
  //#region src/functions/taggedTemplate/interpolate.ts
1130
1171
  /**
@@ -1382,6 +1423,7 @@ exports.determineVersionType = determineVersionType_default;
1382
1423
  exports.fillArray = fillArray_default;
1383
1424
  exports.formatDateAndTime = formatDateAndTime_default;
1384
1425
  exports.getIndividualVersionNumbers = getIndividualVersionNumbers_default;
1426
+ exports.getInterpolations = getInterpolations_default;
1385
1427
  exports.getRandomNumber = getRandomNumber_default;
1386
1428
  exports.getRecordKeys = getRecordKeys_default;
1387
1429
  exports.httpErrorCodeLookup = httpErrorCodeLookup;
package/dist/index.d.cts CHANGED
@@ -296,7 +296,7 @@ declare class VersionNumber {
296
296
  */
297
297
  static isEqual(firstVersion: VersionNumber, secondVersion: VersionNumber): boolean;
298
298
  /**
299
- * Determines whether the current instance of `VersionNumber` is a major, minor, or patch version.
299
+ * Increments the current version number by the given increment type, returning the result as a new reference in memory.
300
300
  *
301
301
  * @param incrementType - The type of increment. Can be one of the following:
302
302
  * - `"major"`: Change the major version `v1.2.3` → `v2.0.0`
@@ -306,6 +306,20 @@ declare class VersionNumber {
306
306
  * @returns A new instance of `VersionNumber` with the increment applied.
307
307
  */
308
308
  increment(incrementType: VersionType): VersionNumber;
309
+ /**
310
+ * Ensures that the VersionNumber behaves correctly when attempted to be coerced to a string.
311
+ *
312
+ * @param hint - Not used as of now, but generally used to help with numeric coercion, I think (which we most likely do not need for version numbers).
313
+ *
314
+ * @returns A stringified representation of the current version number, prefixed with `v`.
315
+ */
316
+ [Symbol.toPrimitive](hint: "default" | "string" | "number"): string;
317
+ /**
318
+ * Ensures that the VersionNumber behaves correctly when attempted to be converted to JSON.
319
+ *
320
+ * @returns A stringified representation of the current version number, prefixed with `v`.
321
+ */
322
+ toJSON(): string;
309
323
  /**
310
324
  * Get a string representation of the current version number.
311
325
  *
@@ -814,6 +828,24 @@ declare function truncate(stringToTruncate: string, maxLength?: number): string;
814
828
  */
815
829
  declare function createTemplateStringsArray(strings: readonly string[]): TemplateStringsArray;
816
830
  //#endregion
831
+ //#region src/functions/taggedTemplate/getInterpolations.d.ts
832
+ /**
833
+ * Gets the strings and interpolations separately from a template string.
834
+ * You can pass a template string directly by doing:
835
+ *
836
+ * ```typescript
837
+ * getInterpolations`Template string here`.
838
+ * ```
839
+ *
840
+ * @category Tagged Template
841
+ *
842
+ * @param strings - The strings from the template to process.
843
+ * @param interpolations - An array of all interpolations from the template.
844
+ *
845
+ * @returns A tuple where the first item is the strings from the template, and the second is the interpolations.
846
+ */
847
+ declare function getInterpolations(strings: TemplateStringsArray, ...interpolations: unknown[]): [TemplateStringsArray, unknown[]];
848
+ //#endregion
817
849
  //#region src/functions/taggedTemplate/interpolate.d.ts
818
850
  /**
819
851
  * Returns the result of interpolating a template string when given the strings and interpolations separately.
@@ -993,4 +1025,4 @@ interface ParseVersionOptions {
993
1025
  */
994
1026
  declare function parseVersion(input: string, options?: ParseVersionOptions): string;
995
1027
  //#endregion
996
- export { APIError, ArrayElement, CamelToKebabOptions, CreateEnumType, CreateFormDataOptions, CreateFormDataOptionsNullableResolution, CreateFormDataOptionsUndefinedOrNullResolution, DataError, DisallowUndefined, Env, FormDataArrayResolutionStrategy, FormDataNullableResolutionStrategy, HTTPErrorCode, IgnoreCase, IncrementVersionOptions, KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, OptionalOnCondition, ParallelTuple, ParseVersionOptions, RecordKey, StringListToArrayOptions, VERSION_NUMBER_REGEX, VersionNumber, VersionNumberToStringOptions, 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, parseEnv, parseFormData, parseIntStrict, parseVersion, parseVersionType, parseZodSchema, randomiseArray, range, removeDuplicates, stringListToArray, truncate, wait };
1028
+ export { APIError, ArrayElement, CamelToKebabOptions, CreateEnumType, CreateFormDataOptions, CreateFormDataOptionsNullableResolution, CreateFormDataOptionsUndefinedOrNullResolution, DataError, DisallowUndefined, Env, FormDataArrayResolutionStrategy, FormDataNullableResolutionStrategy, HTTPErrorCode, IgnoreCase, IncrementVersionOptions, KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, OptionalOnCondition, ParallelTuple, ParseVersionOptions, RecordKey, StringListToArrayOptions, VERSION_NUMBER_REGEX, VersionNumber, VersionNumberToStringOptions, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, determineVersionType, fillArray, formatDateAndTime, getIndividualVersionNumbers, getInterpolations, getRandomNumber, getRecordKeys, httpErrorCodeLookup, incrementVersion, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseVersion, parseVersionType, parseZodSchema, randomiseArray, range, removeDuplicates, stringListToArray, truncate, wait };
package/dist/index.d.ts CHANGED
@@ -296,7 +296,7 @@ declare class VersionNumber {
296
296
  */
297
297
  static isEqual(firstVersion: VersionNumber, secondVersion: VersionNumber): boolean;
298
298
  /**
299
- * Determines whether the current instance of `VersionNumber` is a major, minor, or patch version.
299
+ * Increments the current version number by the given increment type, returning the result as a new reference in memory.
300
300
  *
301
301
  * @param incrementType - The type of increment. Can be one of the following:
302
302
  * - `"major"`: Change the major version `v1.2.3` → `v2.0.0`
@@ -306,6 +306,20 @@ declare class VersionNumber {
306
306
  * @returns A new instance of `VersionNumber` with the increment applied.
307
307
  */
308
308
  increment(incrementType: VersionType): VersionNumber;
309
+ /**
310
+ * Ensures that the VersionNumber behaves correctly when attempted to be coerced to a string.
311
+ *
312
+ * @param hint - Not used as of now, but generally used to help with numeric coercion, I think (which we most likely do not need for version numbers).
313
+ *
314
+ * @returns A stringified representation of the current version number, prefixed with `v`.
315
+ */
316
+ [Symbol.toPrimitive](hint: "default" | "string" | "number"): string;
317
+ /**
318
+ * Ensures that the VersionNumber behaves correctly when attempted to be converted to JSON.
319
+ *
320
+ * @returns A stringified representation of the current version number, prefixed with `v`.
321
+ */
322
+ toJSON(): string;
309
323
  /**
310
324
  * Get a string representation of the current version number.
311
325
  *
@@ -814,6 +828,24 @@ declare function truncate(stringToTruncate: string, maxLength?: number): string;
814
828
  */
815
829
  declare function createTemplateStringsArray(strings: readonly string[]): TemplateStringsArray;
816
830
  //#endregion
831
+ //#region src/functions/taggedTemplate/getInterpolations.d.ts
832
+ /**
833
+ * Gets the strings and interpolations separately from a template string.
834
+ * You can pass a template string directly by doing:
835
+ *
836
+ * ```typescript
837
+ * getInterpolations`Template string here`.
838
+ * ```
839
+ *
840
+ * @category Tagged Template
841
+ *
842
+ * @param strings - The strings from the template to process.
843
+ * @param interpolations - An array of all interpolations from the template.
844
+ *
845
+ * @returns A tuple where the first item is the strings from the template, and the second is the interpolations.
846
+ */
847
+ declare function getInterpolations(strings: TemplateStringsArray, ...interpolations: unknown[]): [TemplateStringsArray, unknown[]];
848
+ //#endregion
817
849
  //#region src/functions/taggedTemplate/interpolate.d.ts
818
850
  /**
819
851
  * Returns the result of interpolating a template string when given the strings and interpolations separately.
@@ -993,4 +1025,4 @@ interface ParseVersionOptions {
993
1025
  */
994
1026
  declare function parseVersion(input: string, options?: ParseVersionOptions): string;
995
1027
  //#endregion
996
- export { APIError, ArrayElement, CamelToKebabOptions, CreateEnumType, CreateFormDataOptions, CreateFormDataOptionsNullableResolution, CreateFormDataOptionsUndefinedOrNullResolution, DataError, DisallowUndefined, Env, FormDataArrayResolutionStrategy, FormDataNullableResolutionStrategy, HTTPErrorCode, IgnoreCase, type IncrementVersionOptions, KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, OptionalOnCondition, ParallelTuple, type ParseVersionOptions, RecordKey, StringListToArrayOptions, VERSION_NUMBER_REGEX, VersionNumber, VersionNumberToStringOptions, 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, parseEnv, parseFormData, parseIntStrict, parseVersion, parseVersionType, parseZodSchema, randomiseArray, range, removeDuplicates, stringListToArray, truncate, wait };
1028
+ export { APIError, ArrayElement, CamelToKebabOptions, CreateEnumType, CreateFormDataOptions, CreateFormDataOptionsNullableResolution, CreateFormDataOptionsUndefinedOrNullResolution, DataError, DisallowUndefined, Env, FormDataArrayResolutionStrategy, FormDataNullableResolutionStrategy, HTTPErrorCode, IgnoreCase, type IncrementVersionOptions, KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, OptionalOnCondition, ParallelTuple, type ParseVersionOptions, RecordKey, StringListToArrayOptions, VERSION_NUMBER_REGEX, VersionNumber, VersionNumberToStringOptions, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, determineVersionType, fillArray, formatDateAndTime, getIndividualVersionNumbers, getInterpolations, getRandomNumber, getRecordKeys, httpErrorCodeLookup, incrementVersion, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseVersion, parseVersionType, parseZodSchema, randomiseArray, range, removeDuplicates, stringListToArray, truncate, wait };
package/dist/index.js CHANGED
@@ -215,7 +215,7 @@ var VersionNumber = class VersionNumber {
215
215
  return firstVersion.major === secondVersion.major && firstVersion.minor === secondVersion.minor && firstVersion.patch === secondVersion.patch;
216
216
  }
217
217
  /**
218
- * Determines whether the current instance of `VersionNumber` is a major, minor, or patch version.
218
+ * Increments the current version number by the given increment type, returning the result as a new reference in memory.
219
219
  *
220
220
  * @param incrementType - The type of increment. Can be one of the following:
221
221
  * - `"major"`: Change the major version `v1.2.3` → `v2.0.0`
@@ -244,6 +244,25 @@ var VersionNumber = class VersionNumber {
244
244
  }[incrementType];
245
245
  }
246
246
  /**
247
+ * Ensures that the VersionNumber behaves correctly when attempted to be coerced to a string.
248
+ *
249
+ * @param hint - Not used as of now, but generally used to help with numeric coercion, I think (which we most likely do not need for version numbers).
250
+ *
251
+ * @returns A stringified representation of the current version number, prefixed with `v`.
252
+ */
253
+ [Symbol.toPrimitive](hint) {
254
+ if (hint === "number") throw new DataError_default(this.toString(), "INVALID_COERCION", "VersionNumber cannot be coerced to a number type.");
255
+ return this.toString();
256
+ }
257
+ /**
258
+ * Ensures that the VersionNumber behaves correctly when attempted to be converted to JSON.
259
+ *
260
+ * @returns A stringified representation of the current version number, prefixed with `v`.
261
+ */
262
+ toJSON() {
263
+ return this.toString();
264
+ }
265
+ /**
247
266
  * Get a string representation of the current version number.
248
267
  *
249
268
  * @param options - Extra additional options to apply.
@@ -1096,6 +1115,28 @@ function createTemplateStringsArray(strings) {
1096
1115
  }
1097
1116
  var createTemplateStringsArray_default = createTemplateStringsArray;
1098
1117
 
1118
+ //#endregion
1119
+ //#region src/functions/taggedTemplate/getInterpolations.ts
1120
+ /**
1121
+ * Gets the strings and interpolations separately from a template string.
1122
+ * You can pass a template string directly by doing:
1123
+ *
1124
+ * ```typescript
1125
+ * getInterpolations`Template string here`.
1126
+ * ```
1127
+ *
1128
+ * @category Tagged Template
1129
+ *
1130
+ * @param strings - The strings from the template to process.
1131
+ * @param interpolations - An array of all interpolations from the template.
1132
+ *
1133
+ * @returns A tuple where the first item is the strings from the template, and the second is the interpolations.
1134
+ */
1135
+ function getInterpolations(strings, ...interpolations) {
1136
+ return [strings, interpolations];
1137
+ }
1138
+ var getInterpolations_default = getInterpolations;
1139
+
1099
1140
  //#endregion
1100
1141
  //#region src/functions/taggedTemplate/interpolate.ts
1101
1142
  /**
@@ -1334,4 +1375,4 @@ function incrementVersion(version, incrementType, options) {
1334
1375
  var incrementVersion_default = incrementVersion;
1335
1376
 
1336
1377
  //#endregion
1337
- export { APIError_default as APIError, DataError_default as DataError, Env, NAMESPACE_EXPORT_REGEX_default as NAMESPACE_EXPORT_REGEX, VERSION_NUMBER_REGEX_default as VERSION_NUMBER_REGEX, VersionNumber_default as VersionNumber, VersionType, 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, parseEnv_default as parseEnv, parseFormData_default as parseFormData, parseIntStrict_default as parseIntStrict, parseVersion_default as parseVersion, parseVersionType_default as parseVersionType, parseZodSchema_default as parseZodSchema, randomiseArray_default as randomiseArray, range_default as range, removeDuplicates_default as removeDuplicates, stringListToArray_default as stringListToArray, truncate_default as truncate, wait_default as wait };
1378
+ export { APIError_default as APIError, DataError_default as DataError, Env, NAMESPACE_EXPORT_REGEX_default as NAMESPACE_EXPORT_REGEX, VERSION_NUMBER_REGEX_default as VERSION_NUMBER_REGEX, VersionNumber_default as VersionNumber, VersionType, 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, getInterpolations_default as getInterpolations, 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, parseEnv_default as parseEnv, parseFormData_default as parseFormData, parseIntStrict_default as parseIntStrict, parseVersion_default as parseVersion, parseVersionType_default as parseVersionType, parseZodSchema_default as parseZodSchema, randomiseArray_default as randomiseArray, range_default as range, removeDuplicates_default as removeDuplicates, stringListToArray_default as stringListToArray, truncate_default as truncate, wait_default as wait };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alextheman/utility",
3
- "version": "4.3.2",
3
+ "version": "4.3.4",
4
4
  "description": "Helpful utility functions",
5
5
  "repository": {
6
6
  "type": "git",