@alextheman/utility 4.3.3 → 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.
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
  *
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
  *
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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alextheman/utility",
3
- "version": "4.3.3",
3
+ "version": "4.3.4",
4
4
  "description": "Helpful utility functions",
5
5
  "repository": {
6
6
  "type": "git",