@alextheman/utility 4.3.3 → 4.3.5
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 +21 -2
- package/dist/index.d.cts +17 -3
- package/dist/index.d.ts +17 -3
- package/dist/index.js +21 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -49,7 +49,7 @@ var VERSION_NUMBER_REGEX_default = VERSION_NUMBER_REGEX;
|
|
|
49
49
|
*
|
|
50
50
|
* @category Array Helpers
|
|
51
51
|
*
|
|
52
|
-
* @template ItemType
|
|
52
|
+
* @template ItemType - The return type of the callback (awaited if any items are a Promise) that becomes the type of the array items.
|
|
53
53
|
*
|
|
54
54
|
* @param callback - A function invoked with the current index. May return a value or a Promise.
|
|
55
55
|
* @param length - The desired length of the resulting array.
|
|
@@ -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
|
-
*
|
|
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
|
@@ -13,7 +13,7 @@ declare const VERSION_NUMBER_REGEX: string;
|
|
|
13
13
|
* The callback will be invoked once for each index from `0` to `length - 1`.
|
|
14
14
|
* If no length is provided, a single-element array will be produced.
|
|
15
15
|
*
|
|
16
|
-
* @template ItemType
|
|
16
|
+
* @template ItemType - The awaited return type of the callback that becomes the type of the array items.
|
|
17
17
|
*
|
|
18
18
|
* @param callback - An asynchronous function invoked with the current index.
|
|
19
19
|
* @param length - The desired length of the resulting array.
|
|
@@ -27,7 +27,7 @@ declare function fillArray<ItemType>(callback: (index: number) => Promise<ItemTy
|
|
|
27
27
|
* The callback will be invoked once for each index from `0` to `length - 1`.
|
|
28
28
|
* If no length is provided, a single-element array will be produced.
|
|
29
29
|
*
|
|
30
|
-
* @template ItemType
|
|
30
|
+
* @template ItemType - The return type of the callback that becomes the type of the array items.
|
|
31
31
|
*
|
|
32
32
|
* @param callback - A synchronous function invoked with the current index.
|
|
33
33
|
* @param length - The desired length of the resulting array.
|
|
@@ -296,7 +296,7 @@ declare class VersionNumber {
|
|
|
296
296
|
*/
|
|
297
297
|
static isEqual(firstVersion: VersionNumber, secondVersion: VersionNumber): boolean;
|
|
298
298
|
/**
|
|
299
|
-
*
|
|
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
|
@@ -13,7 +13,7 @@ declare const VERSION_NUMBER_REGEX: string;
|
|
|
13
13
|
* The callback will be invoked once for each index from `0` to `length - 1`.
|
|
14
14
|
* If no length is provided, a single-element array will be produced.
|
|
15
15
|
*
|
|
16
|
-
* @template ItemType
|
|
16
|
+
* @template ItemType - The awaited return type of the callback that becomes the type of the array items.
|
|
17
17
|
*
|
|
18
18
|
* @param callback - An asynchronous function invoked with the current index.
|
|
19
19
|
* @param length - The desired length of the resulting array.
|
|
@@ -27,7 +27,7 @@ declare function fillArray<ItemType>(callback: (index: number) => Promise<ItemTy
|
|
|
27
27
|
* The callback will be invoked once for each index from `0` to `length - 1`.
|
|
28
28
|
* If no length is provided, a single-element array will be produced.
|
|
29
29
|
*
|
|
30
|
-
* @template ItemType
|
|
30
|
+
* @template ItemType - The return type of the callback that becomes the type of the array items.
|
|
31
31
|
*
|
|
32
32
|
* @param callback - A synchronous function invoked with the current index.
|
|
33
33
|
* @param length - The desired length of the resulting array.
|
|
@@ -296,7 +296,7 @@ declare class VersionNumber {
|
|
|
296
296
|
*/
|
|
297
297
|
static isEqual(firstVersion: VersionNumber, secondVersion: VersionNumber): boolean;
|
|
298
298
|
/**
|
|
299
|
-
*
|
|
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
|
@@ -20,7 +20,7 @@ var VERSION_NUMBER_REGEX_default = VERSION_NUMBER_REGEX;
|
|
|
20
20
|
*
|
|
21
21
|
* @category Array Helpers
|
|
22
22
|
*
|
|
23
|
-
* @template ItemType
|
|
23
|
+
* @template ItemType - The return type of the callback (awaited if any items are a Promise) that becomes the type of the array items.
|
|
24
24
|
*
|
|
25
25
|
* @param callback - A function invoked with the current index. May return a value or a Promise.
|
|
26
26
|
* @param length - The desired length of the resulting array.
|
|
@@ -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
|
-
*
|
|
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.
|