@alextheman/utility 4.16.2 → 4.17.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.cjs +23 -11
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +23 -11
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -253,27 +253,39 @@ var VersionNumber = class VersionNumber {
|
|
|
253
253
|
* - `"major"`: Change the major version `v1.2.3` → `v2.0.0`
|
|
254
254
|
* - `"minor"`: Change the minor version `v1.2.3` → `v1.3.0`
|
|
255
255
|
* - `"patch"`: Change the patch version `v1.2.3` → `v1.2.4`
|
|
256
|
+
* @param incrementAmount - The amount to increment by (defaults to 1).
|
|
256
257
|
*
|
|
257
258
|
* @returns A new instance of `VersionNumber` with the increment applied.
|
|
258
259
|
*/
|
|
259
|
-
increment(incrementType) {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
260
|
+
increment(incrementType, incrementAmount = 1) {
|
|
261
|
+
const incrementBy = parseIntStrict(String(incrementAmount));
|
|
262
|
+
const calculatedRawVersion = {
|
|
263
|
+
major: [
|
|
264
|
+
this.major + incrementBy,
|
|
263
265
|
0,
|
|
264
266
|
0
|
|
265
|
-
]
|
|
266
|
-
minor:
|
|
267
|
+
],
|
|
268
|
+
minor: [
|
|
267
269
|
this.major,
|
|
268
|
-
this.minor +
|
|
270
|
+
this.minor + incrementBy,
|
|
269
271
|
0
|
|
270
|
-
]
|
|
271
|
-
patch:
|
|
272
|
+
],
|
|
273
|
+
patch: [
|
|
272
274
|
this.major,
|
|
273
275
|
this.minor,
|
|
274
|
-
this.patch +
|
|
275
|
-
]
|
|
276
|
+
this.patch + incrementBy
|
|
277
|
+
]
|
|
276
278
|
}[incrementType];
|
|
279
|
+
try {
|
|
280
|
+
return new VersionNumber(calculatedRawVersion);
|
|
281
|
+
} catch (error) {
|
|
282
|
+
if (DataError.check(error) && error.code === "NEGATIVE_INPUTS") throw new DataError({
|
|
283
|
+
currentVersion: this.toString(),
|
|
284
|
+
calculatedRawVersion: `v${calculatedRawVersion.join(".")}`,
|
|
285
|
+
incrementAmount
|
|
286
|
+
}, "NEGATIVE_VERSION", "Cannot apply this increment amount as it would lead to a negative version number.");
|
|
287
|
+
else throw error;
|
|
288
|
+
}
|
|
277
289
|
}
|
|
278
290
|
/**
|
|
279
291
|
* Ensures that the VersionNumber behaves correctly when attempted to be coerced to a string.
|
package/dist/index.d.cts
CHANGED
|
@@ -307,10 +307,11 @@ declare class VersionNumber {
|
|
|
307
307
|
* - `"major"`: Change the major version `v1.2.3` → `v2.0.0`
|
|
308
308
|
* - `"minor"`: Change the minor version `v1.2.3` → `v1.3.0`
|
|
309
309
|
* - `"patch"`: Change the patch version `v1.2.3` → `v1.2.4`
|
|
310
|
+
* @param incrementAmount - The amount to increment by (defaults to 1).
|
|
310
311
|
*
|
|
311
312
|
* @returns A new instance of `VersionNumber` with the increment applied.
|
|
312
313
|
*/
|
|
313
|
-
increment(incrementType: VersionType): VersionNumber;
|
|
314
|
+
increment(incrementType: VersionType, incrementAmount?: number): VersionNumber;
|
|
314
315
|
/**
|
|
315
316
|
* Ensures that the VersionNumber behaves correctly when attempted to be coerced to a string.
|
|
316
317
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -307,10 +307,11 @@ declare class VersionNumber {
|
|
|
307
307
|
* - `"major"`: Change the major version `v1.2.3` → `v2.0.0`
|
|
308
308
|
* - `"minor"`: Change the minor version `v1.2.3` → `v1.3.0`
|
|
309
309
|
* - `"patch"`: Change the patch version `v1.2.3` → `v1.2.4`
|
|
310
|
+
* @param incrementAmount - The amount to increment by (defaults to 1).
|
|
310
311
|
*
|
|
311
312
|
* @returns A new instance of `VersionNumber` with the increment applied.
|
|
312
313
|
*/
|
|
313
|
-
increment(incrementType: VersionType): VersionNumber;
|
|
314
|
+
increment(incrementType: VersionType, incrementAmount?: number): VersionNumber;
|
|
314
315
|
/**
|
|
315
316
|
* Ensures that the VersionNumber behaves correctly when attempted to be coerced to a string.
|
|
316
317
|
*
|
package/dist/index.js
CHANGED
|
@@ -222,27 +222,39 @@ var VersionNumber = class VersionNumber {
|
|
|
222
222
|
* - `"major"`: Change the major version `v1.2.3` → `v2.0.0`
|
|
223
223
|
* - `"minor"`: Change the minor version `v1.2.3` → `v1.3.0`
|
|
224
224
|
* - `"patch"`: Change the patch version `v1.2.3` → `v1.2.4`
|
|
225
|
+
* @param incrementAmount - The amount to increment by (defaults to 1).
|
|
225
226
|
*
|
|
226
227
|
* @returns A new instance of `VersionNumber` with the increment applied.
|
|
227
228
|
*/
|
|
228
|
-
increment(incrementType) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
229
|
+
increment(incrementType, incrementAmount = 1) {
|
|
230
|
+
const incrementBy = parseIntStrict(String(incrementAmount));
|
|
231
|
+
const calculatedRawVersion = {
|
|
232
|
+
major: [
|
|
233
|
+
this.major + incrementBy,
|
|
232
234
|
0,
|
|
233
235
|
0
|
|
234
|
-
]
|
|
235
|
-
minor:
|
|
236
|
+
],
|
|
237
|
+
minor: [
|
|
236
238
|
this.major,
|
|
237
|
-
this.minor +
|
|
239
|
+
this.minor + incrementBy,
|
|
238
240
|
0
|
|
239
|
-
]
|
|
240
|
-
patch:
|
|
241
|
+
],
|
|
242
|
+
patch: [
|
|
241
243
|
this.major,
|
|
242
244
|
this.minor,
|
|
243
|
-
this.patch +
|
|
244
|
-
]
|
|
245
|
+
this.patch + incrementBy
|
|
246
|
+
]
|
|
245
247
|
}[incrementType];
|
|
248
|
+
try {
|
|
249
|
+
return new VersionNumber(calculatedRawVersion);
|
|
250
|
+
} catch (error) {
|
|
251
|
+
if (DataError.check(error) && error.code === "NEGATIVE_INPUTS") throw new DataError({
|
|
252
|
+
currentVersion: this.toString(),
|
|
253
|
+
calculatedRawVersion: `v${calculatedRawVersion.join(".")}`,
|
|
254
|
+
incrementAmount
|
|
255
|
+
}, "NEGATIVE_VERSION", "Cannot apply this increment amount as it would lead to a negative version number.");
|
|
256
|
+
else throw error;
|
|
257
|
+
}
|
|
246
258
|
}
|
|
247
259
|
/**
|
|
248
260
|
* Ensures that the VersionNumber behaves correctly when attempted to be coerced to a string.
|