@alextheman/utility 4.13.0 → 4.14.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 +169 -158
- package/dist/index.d.cts +57 -6
- package/dist/index.d.ts +57 -6
- package/dist/index.js +112 -104
- package/package.json +8 -8
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
2
3
|
var __create = Object.create;
|
|
3
4
|
var __defProp = Object.defineProperty;
|
|
4
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -34,17 +35,14 @@ libsodium_wrappers = __toESM(libsodium_wrappers);
|
|
|
34
35
|
|
|
35
36
|
//#region src/constants/FILE_PATH_REGEX.ts
|
|
36
37
|
const FILE_PATH_REGEX = String.raw`^(?<directory>.+)[\/\\](?<base>[^\/\\]+)$`;
|
|
37
|
-
var FILE_PATH_REGEX_default = FILE_PATH_REGEX;
|
|
38
38
|
|
|
39
39
|
//#endregion
|
|
40
40
|
//#region src/constants/NAMESPACE_EXPORT_REGEX.ts
|
|
41
41
|
const NAMESPACE_EXPORT_REGEX = "export\\s+\\*\\s+from";
|
|
42
|
-
var NAMESPACE_EXPORT_REGEX_default = NAMESPACE_EXPORT_REGEX;
|
|
43
42
|
|
|
44
43
|
//#endregion
|
|
45
44
|
//#region src/constants/VERSION_NUMBER_REGEX.ts
|
|
46
45
|
const VERSION_NUMBER_REGEX = "^(?:v)?(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$";
|
|
47
|
-
var VERSION_NUMBER_REGEX_default = VERSION_NUMBER_REGEX;
|
|
48
46
|
|
|
49
47
|
//#endregion
|
|
50
48
|
//#region src/functions/arrayHelpers/fillArray.ts
|
|
@@ -72,7 +70,6 @@ function fillArray(callback, length = 1) {
|
|
|
72
70
|
})) return Promise.all(outputArray);
|
|
73
71
|
return outputArray;
|
|
74
72
|
}
|
|
75
|
-
var fillArray_default = fillArray;
|
|
76
73
|
|
|
77
74
|
//#endregion
|
|
78
75
|
//#region src/functions/arrayHelpers/paralleliseArrays.ts
|
|
@@ -97,7 +94,6 @@ function paralleliseArrays(firstArray, secondArray) {
|
|
|
97
94
|
for (let i = 0; i < firstArray.length; i++) outputArray.push([firstArray[i], secondArray[i]]);
|
|
98
95
|
return outputArray;
|
|
99
96
|
}
|
|
100
|
-
var paralleliseArrays_default = paralleliseArrays;
|
|
101
97
|
|
|
102
98
|
//#endregion
|
|
103
99
|
//#region src/types/APIError.ts
|
|
@@ -141,7 +137,6 @@ var APIError = class extends Error {
|
|
|
141
137
|
return typeof data === "object" && data !== null && typeof data?.status === "number" && typeof data?.message === "string";
|
|
142
138
|
}
|
|
143
139
|
};
|
|
144
|
-
var APIError_default = APIError;
|
|
145
140
|
|
|
146
141
|
//#endregion
|
|
147
142
|
//#region src/types/DataError.ts
|
|
@@ -180,7 +175,6 @@ var DataError = class extends Error {
|
|
|
180
175
|
return typeof data === "object" && data !== null && typeof data.message === "string" && typeof data.code === "string" && "data" in data;
|
|
181
176
|
}
|
|
182
177
|
};
|
|
183
|
-
var DataError_default = DataError;
|
|
184
178
|
|
|
185
179
|
//#endregion
|
|
186
180
|
//#region src/types/VersionNumber.ts
|
|
@@ -206,18 +200,18 @@ var VersionNumber = class VersionNumber {
|
|
|
206
200
|
this.minor = input.minor;
|
|
207
201
|
this.patch = input.patch;
|
|
208
202
|
} else if (typeof input === "string") {
|
|
209
|
-
if (!RegExp(
|
|
203
|
+
if (!RegExp(VERSION_NUMBER_REGEX).test(input)) throw new DataError(input, "INVALID_VERSION", `"${input}" is not a valid version number. Version numbers must be of the format "X.Y.Z" or "vX.Y.Z", where X, Y, and Z are non-negative integers.`);
|
|
210
204
|
const [major, minor, patch] = VersionNumber.formatString(input, { omitPrefix: true }).split(".").map((number) => {
|
|
211
|
-
return
|
|
205
|
+
return parseIntStrict(number);
|
|
212
206
|
});
|
|
213
207
|
this.major = major;
|
|
214
208
|
this.minor = minor;
|
|
215
209
|
this.patch = patch;
|
|
216
210
|
} else if (Array.isArray(input)) {
|
|
217
|
-
if (input.length !== 3) throw new
|
|
211
|
+
if (input.length !== 3) throw new DataError(input, "INVALID_LENGTH", VersionNumber.NON_NEGATIVE_TUPLE_ERROR);
|
|
218
212
|
const [major, minor, patch] = input.map((number) => {
|
|
219
|
-
const parsedInteger =
|
|
220
|
-
if (parsedInteger < 0) throw new
|
|
213
|
+
const parsedInteger = parseIntStrict(number?.toString());
|
|
214
|
+
if (parsedInteger < 0) throw new DataError(input, "NEGATIVE_INPUTS", VersionNumber.NON_NEGATIVE_TUPLE_ERROR);
|
|
221
215
|
return parsedInteger;
|
|
222
216
|
});
|
|
223
217
|
this.major = major;
|
|
@@ -287,7 +281,7 @@ var VersionNumber = class VersionNumber {
|
|
|
287
281
|
* @returns A stringified representation of the current version number, prefixed with `v`.
|
|
288
282
|
*/
|
|
289
283
|
[Symbol.toPrimitive](hint) {
|
|
290
|
-
if (hint === "number") throw new
|
|
284
|
+
if (hint === "number") throw new DataError(this.toString(), "INVALID_COERCION", "VersionNumber cannot be coerced to a number type.");
|
|
291
285
|
return this.toString();
|
|
292
286
|
}
|
|
293
287
|
/**
|
|
@@ -310,7 +304,6 @@ var VersionNumber = class VersionNumber {
|
|
|
310
304
|
return VersionNumber.formatString(rawString, options);
|
|
311
305
|
}
|
|
312
306
|
};
|
|
313
|
-
var VersionNumber_default = VersionNumber;
|
|
314
307
|
|
|
315
308
|
//#endregion
|
|
316
309
|
//#region src/functions/parsers/parseIntStrict.ts
|
|
@@ -329,21 +322,20 @@ var VersionNumber_default = VersionNumber;
|
|
|
329
322
|
function parseIntStrict(string, radix) {
|
|
330
323
|
const trimmedString = string.trim();
|
|
331
324
|
const maxAllowedAlphabeticalCharacter = radix && radix > 10 && radix <= 36 ? String.fromCharCode(87 + radix - 1) : void 0;
|
|
332
|
-
if (!(radix && radix > 10 && radix <= 36 ? new RegExp(`^[+-]?[0-9a-${maxAllowedAlphabeticalCharacter}]+$`, "i") : /^[+-]?\d+$/).test(trimmedString)) throw new
|
|
325
|
+
if (!(radix && radix > 10 && radix <= 36 ? new RegExp(`^[+-]?[0-9a-${maxAllowedAlphabeticalCharacter}]+$`, "i") : /^[+-]?\d+$/).test(trimmedString)) throw new DataError(radix ? {
|
|
333
326
|
string,
|
|
334
327
|
radix
|
|
335
328
|
} : string, "INTEGER_PARSING_ERROR", `Only numeric values${radix && radix > 10 && radix <= 36 ? ` or character${radix !== 11 ? "s" : ""} A${radix !== 11 ? `-${maxAllowedAlphabeticalCharacter?.toUpperCase()} ` : " "}` : " "}are allowed.`);
|
|
336
329
|
if (radix && radix < 10 && [...trimmedString].some((character) => {
|
|
337
330
|
return parseInt(character) >= radix;
|
|
338
|
-
})) throw new
|
|
331
|
+
})) throw new DataError({
|
|
339
332
|
string,
|
|
340
333
|
radix
|
|
341
334
|
}, "INTEGER_PARSING_ERROR", "Value contains one or more digits outside of the range of the given radix.");
|
|
342
335
|
const parseIntResult = parseInt(trimmedString, radix);
|
|
343
|
-
if (isNaN(parseIntResult)) throw new
|
|
336
|
+
if (isNaN(parseIntResult)) throw new DataError(string, "INTEGER_PARSING_ERROR", "Value is not a valid integer.");
|
|
344
337
|
return parseIntResult;
|
|
345
338
|
}
|
|
346
|
-
var parseIntStrict_default = parseIntStrict;
|
|
347
339
|
|
|
348
340
|
//#endregion
|
|
349
341
|
//#region src/functions/miscellaneous/getRandomNumber.ts
|
|
@@ -358,11 +350,10 @@ var parseIntStrict_default = parseIntStrict;
|
|
|
358
350
|
* @returns A random number between the provided lower bound and upper bound.
|
|
359
351
|
*/
|
|
360
352
|
function getRandomNumber(lowerBound, upperBound) {
|
|
361
|
-
const parsedLowerBound =
|
|
362
|
-
const parsedUpperBound =
|
|
353
|
+
const parsedLowerBound = parseIntStrict(`${lowerBound}`);
|
|
354
|
+
const parsedUpperBound = parseIntStrict(`${upperBound}`);
|
|
363
355
|
return Math.floor(Math.random() * (parsedUpperBound - parsedLowerBound + 1) + parsedLowerBound);
|
|
364
356
|
}
|
|
365
|
-
var getRandomNumber_default = getRandomNumber;
|
|
366
357
|
|
|
367
358
|
//#endregion
|
|
368
359
|
//#region src/functions/arrayHelpers/randomiseArray.ts
|
|
@@ -381,12 +372,11 @@ function randomiseArray(array) {
|
|
|
381
372
|
const mutableArray = [...array];
|
|
382
373
|
const outputArray = [];
|
|
383
374
|
do {
|
|
384
|
-
const indexToRemove =
|
|
375
|
+
const indexToRemove = getRandomNumber(0, mutableArray.length - 1);
|
|
385
376
|
outputArray.push(mutableArray.splice(indexToRemove, 1)[0]);
|
|
386
377
|
} while (mutableArray.length > 0);
|
|
387
378
|
return outputArray;
|
|
388
379
|
}
|
|
389
|
-
var randomiseArray_default = randomiseArray;
|
|
390
380
|
|
|
391
381
|
//#endregion
|
|
392
382
|
//#region src/functions/arrayHelpers/range.ts
|
|
@@ -419,7 +409,6 @@ function range(start, stop, step = 1) {
|
|
|
419
409
|
}
|
|
420
410
|
return numbers;
|
|
421
411
|
}
|
|
422
|
-
var range_default = range;
|
|
423
412
|
|
|
424
413
|
//#endregion
|
|
425
414
|
//#region src/functions/arrayHelpers/removeDuplicates.ts
|
|
@@ -439,7 +428,6 @@ function removeDuplicates(array) {
|
|
|
439
428
|
for (const item of array) if (!outputArray.includes(item)) outputArray.push(item);
|
|
440
429
|
return outputArray;
|
|
441
430
|
}
|
|
442
|
-
var removeDuplicates_default = removeDuplicates;
|
|
443
431
|
|
|
444
432
|
//#endregion
|
|
445
433
|
//#region src/functions/date/addDaysToDate.ts
|
|
@@ -458,7 +446,6 @@ function addDaysToDate(currentDate = /* @__PURE__ */ new Date(), dayIncrement =
|
|
|
458
446
|
newDate.setDate(newDate.getDate() + dayIncrement);
|
|
459
447
|
return newDate;
|
|
460
448
|
}
|
|
461
|
-
var addDaysToDate_default = addDaysToDate;
|
|
462
449
|
|
|
463
450
|
//#endregion
|
|
464
451
|
//#region src/functions/date/isSameDate.ts
|
|
@@ -475,7 +462,6 @@ var addDaysToDate_default = addDaysToDate;
|
|
|
475
462
|
function isSameDate(firstDate, secondDate) {
|
|
476
463
|
return firstDate.getDate() === secondDate.getDate() && firstDate.getMonth() === secondDate.getMonth() && firstDate.getFullYear() === secondDate.getFullYear();
|
|
477
464
|
}
|
|
478
|
-
var isSameDate_default = isSameDate;
|
|
479
465
|
|
|
480
466
|
//#endregion
|
|
481
467
|
//#region src/functions/date/formatDateAndTime.ts
|
|
@@ -493,14 +479,13 @@ var isSameDate_default = isSameDate;
|
|
|
493
479
|
* - For any other date, the output will be something like `DD/MM/YYYY, HH:MM`
|
|
494
480
|
*/
|
|
495
481
|
function formatDateAndTime(inputDate) {
|
|
496
|
-
const yesterday =
|
|
482
|
+
const yesterday = addDaysToDate(/* @__PURE__ */ new Date(), -1);
|
|
497
483
|
const today = /* @__PURE__ */ new Date();
|
|
498
484
|
const inputTime = `${inputDate.getHours().toString().padStart(2, "0")}:${inputDate.getMinutes().toString().padStart(2, "0")}`;
|
|
499
|
-
if (
|
|
500
|
-
if (
|
|
485
|
+
if (isSameDate(inputDate, yesterday)) return `Yesterday at ${inputTime}`;
|
|
486
|
+
if (isSameDate(inputDate, today)) return `Today at ${inputTime}`;
|
|
501
487
|
return `${inputDate.getDate().toString().padStart(2, "0")}/${(inputDate.getMonth() + 1).toString().padStart(2, "0")}/${inputDate.getFullYear().toString()}, ${inputTime}`;
|
|
502
488
|
}
|
|
503
|
-
var formatDateAndTime_default = formatDateAndTime;
|
|
504
489
|
|
|
505
490
|
//#endregion
|
|
506
491
|
//#region src/functions/date/isLeapYear.ts
|
|
@@ -516,15 +501,14 @@ var formatDateAndTime_default = formatDateAndTime;
|
|
|
516
501
|
* @returns True if the year is a leap year, and false otherwise.
|
|
517
502
|
*/
|
|
518
503
|
function isLeapYear(year) {
|
|
519
|
-
const parsedYear =
|
|
504
|
+
const parsedYear = parseIntStrict(`${year}`);
|
|
520
505
|
return parsedYear % 4 === 0 && parsedYear % 100 !== 0 || parsedYear % 400 === 0;
|
|
521
506
|
}
|
|
522
|
-
var isLeapYear_default = isLeapYear;
|
|
523
507
|
|
|
524
508
|
//#endregion
|
|
525
509
|
//#region src/functions/date/isAnniversary.ts
|
|
526
510
|
function checkLeapYear(firstDate, secondDate) {
|
|
527
|
-
if (
|
|
511
|
+
if (isLeapYear(firstDate.getFullYear()) && firstDate.getMonth() === 1 && secondDate.getMonth() === 1) return firstDate.getDate() === 29 && secondDate.getDate() === 28;
|
|
528
512
|
return false;
|
|
529
513
|
}
|
|
530
514
|
/**
|
|
@@ -541,7 +525,6 @@ function isAnniversary(firstDate, secondDate) {
|
|
|
541
525
|
if (checkLeapYear(firstDate, secondDate) || checkLeapYear(secondDate, firstDate)) return true;
|
|
542
526
|
return firstDate.getDate() === secondDate.getDate() && firstDate.getMonth() === secondDate.getMonth();
|
|
543
527
|
}
|
|
544
|
-
var isAnniversary_default = isAnniversary;
|
|
545
528
|
|
|
546
529
|
//#endregion
|
|
547
530
|
//#region src/functions/date/isMonthlyMultiple.ts
|
|
@@ -556,7 +539,7 @@ function endOfMonthChecksButNotFebruary(firstDate, secondDate) {
|
|
|
556
539
|
}
|
|
557
540
|
function nonLeapYearFebruaryChecks(firstDate, secondDate) {
|
|
558
541
|
if (firstDate.getMonth() === 1) {
|
|
559
|
-
if (!
|
|
542
|
+
if (!isLeapYear(firstDate.getFullYear()) && firstDate.getDate() === 28) return [
|
|
560
543
|
28,
|
|
561
544
|
29,
|
|
562
545
|
30,
|
|
@@ -567,7 +550,7 @@ function nonLeapYearFebruaryChecks(firstDate, secondDate) {
|
|
|
567
550
|
}
|
|
568
551
|
function leapYearFebruaryChecks(firstDate, secondDate) {
|
|
569
552
|
if (firstDate.getMonth() === 1) {
|
|
570
|
-
if (
|
|
553
|
+
if (isLeapYear(firstDate.getFullYear()) && firstDate.getDate() === 29) return [
|
|
571
554
|
29,
|
|
572
555
|
30,
|
|
573
556
|
31
|
|
@@ -591,7 +574,6 @@ function isMonthlyMultiple(firstDate, secondDate) {
|
|
|
591
574
|
if (leapYearFebruaryChecks(firstDate, secondDate) || leapYearFebruaryChecks(secondDate, firstDate)) return true;
|
|
592
575
|
return firstDate.getDate() === secondDate.getDate();
|
|
593
576
|
}
|
|
594
|
-
var isMonthlyMultiple_default = isMonthlyMultiple;
|
|
595
577
|
|
|
596
578
|
//#endregion
|
|
597
579
|
//#region src/functions/miscellaneous/convertFileToBase64.ts
|
|
@@ -622,7 +604,6 @@ function convertFileToBase64(file) {
|
|
|
622
604
|
};
|
|
623
605
|
});
|
|
624
606
|
}
|
|
625
|
-
var convertFileToBase64_default = convertFileToBase64;
|
|
626
607
|
|
|
627
608
|
//#endregion
|
|
628
609
|
//#region src/functions/miscellaneous/createFormData.ts
|
|
@@ -692,7 +673,6 @@ function createFormData(data, options = {
|
|
|
692
673
|
} else formData.append(String(key), String(value));
|
|
693
674
|
return formData;
|
|
694
675
|
}
|
|
695
|
-
var createFormData_default = createFormData;
|
|
696
676
|
|
|
697
677
|
//#endregion
|
|
698
678
|
//#region src/functions/miscellaneous/isOrdered.ts
|
|
@@ -711,7 +691,6 @@ function isOrdered(array) {
|
|
|
711
691
|
for (const index in newArray) if (newArray[index] !== array[index]) return false;
|
|
712
692
|
return true;
|
|
713
693
|
}
|
|
714
|
-
var isOrdered_default = isOrdered;
|
|
715
694
|
|
|
716
695
|
//#endregion
|
|
717
696
|
//#region src/functions/recursive/deepFreeze.ts
|
|
@@ -736,7 +715,6 @@ function deepFreeze(object) {
|
|
|
736
715
|
}
|
|
737
716
|
return Object.freeze(object);
|
|
738
717
|
}
|
|
739
|
-
var deepFreeze_default = deepFreeze;
|
|
740
718
|
|
|
741
719
|
//#endregion
|
|
742
720
|
//#region src/functions/taggedTemplate/createTemplateStringsArray.ts
|
|
@@ -750,13 +728,13 @@ var deepFreeze_default = deepFreeze;
|
|
|
750
728
|
* @returns A template strings array that can be passed as the first argument of any tagged template function.
|
|
751
729
|
*/
|
|
752
730
|
function createTemplateStringsArray(strings) {
|
|
753
|
-
return
|
|
731
|
+
return deepFreeze(Object.assign([...strings], { raw: [...strings] }));
|
|
754
732
|
}
|
|
755
|
-
var createTemplateStringsArray_default = createTemplateStringsArray;
|
|
756
733
|
|
|
757
734
|
//#endregion
|
|
758
735
|
//#region src/functions/taggedTemplate/getInterpolations.ts
|
|
759
736
|
/**
|
|
737
|
+
*
|
|
760
738
|
* Gets the strings and interpolations separately from a template string.
|
|
761
739
|
* You can pass a template string directly by doing:
|
|
762
740
|
*
|
|
@@ -766,6 +744,8 @@ var createTemplateStringsArray_default = createTemplateStringsArray;
|
|
|
766
744
|
*
|
|
767
745
|
* @category Tagged Template
|
|
768
746
|
*
|
|
747
|
+
* @deprecated Please use `getStringsAndInterpolations` instead.
|
|
748
|
+
*
|
|
769
749
|
* @param strings - The strings from the template to process.
|
|
770
750
|
* @param interpolations - An array of all interpolations from the template.
|
|
771
751
|
*
|
|
@@ -774,7 +754,47 @@ var createTemplateStringsArray_default = createTemplateStringsArray;
|
|
|
774
754
|
function getInterpolations(strings, ...interpolations) {
|
|
775
755
|
return [strings, interpolations];
|
|
776
756
|
}
|
|
777
|
-
|
|
757
|
+
|
|
758
|
+
//#endregion
|
|
759
|
+
//#region src/functions/taggedTemplate/getStringsAndInterpolations.ts
|
|
760
|
+
/**
|
|
761
|
+
*
|
|
762
|
+
* Gets the strings and interpolations separately from a template string.
|
|
763
|
+
* You can pass a template string directly by doing:
|
|
764
|
+
*
|
|
765
|
+
* ```typescript
|
|
766
|
+
* getStringsAndInterpolations`Template string here`;
|
|
767
|
+
* ```
|
|
768
|
+
*
|
|
769
|
+
* @category Tagged Template
|
|
770
|
+
*
|
|
771
|
+
* @template InterpolationsType - The type of the interpolations.
|
|
772
|
+
*
|
|
773
|
+
* @param strings - The strings from the template to process.
|
|
774
|
+
* @param interpolations - An array of all interpolations from the template.
|
|
775
|
+
*
|
|
776
|
+
* @returns A tuple where the first item is the strings from the template, and the remaining items are the interpolations.
|
|
777
|
+
*
|
|
778
|
+
* The return of this function may also be spread into any other tagged template function in the following way:
|
|
779
|
+
*
|
|
780
|
+
* ```typescript
|
|
781
|
+
* import { interpolate } from "@alextheman/utility"; // Example function
|
|
782
|
+
*
|
|
783
|
+
* const packageName = "@alextheman/utility";
|
|
784
|
+
* const packageManager = getPackageManager(packageName);
|
|
785
|
+
*
|
|
786
|
+
* interpolate(...getStringsAndInterpolations`The package ${packageName} uses the ${packageManager} package manager.`);
|
|
787
|
+
* ```
|
|
788
|
+
*/
|
|
789
|
+
function getStringsAndInterpolations(strings, ...interpolations) {
|
|
790
|
+
if (strings.length !== interpolations.length + 1) throw new DataError({
|
|
791
|
+
stringsLength: strings.length,
|
|
792
|
+
interpolationsLength: interpolations.length,
|
|
793
|
+
strings,
|
|
794
|
+
interpolations
|
|
795
|
+
}, "INVALID_STRINGS_AND_INTERPOLATIONS_LENGTH", "The length of the strings must be exactly one more than the length of the interpolations.");
|
|
796
|
+
return [createTemplateStringsArray(strings), ...interpolations];
|
|
797
|
+
}
|
|
778
798
|
|
|
779
799
|
//#endregion
|
|
780
800
|
//#region src/functions/taggedTemplate/interpolate.ts
|
|
@@ -791,6 +811,8 @@ var getInterpolations_default = getInterpolations;
|
|
|
791
811
|
*
|
|
792
812
|
* @category Tagged Template
|
|
793
813
|
*
|
|
814
|
+
* @template InterpolationsType - The type of the interpolations.
|
|
815
|
+
*
|
|
794
816
|
* @param strings - The strings from the template to process.
|
|
795
817
|
* @param interpolations - An array of all interpolations from the template.
|
|
796
818
|
*
|
|
@@ -798,10 +820,9 @@ var getInterpolations_default = getInterpolations;
|
|
|
798
820
|
*/
|
|
799
821
|
function interpolate(strings, ...interpolations) {
|
|
800
822
|
let result = "";
|
|
801
|
-
for (const [string, interpolation = ""] of
|
|
823
|
+
for (const [string, interpolation = ""] of paralleliseArrays(strings, interpolations)) result += string + interpolation;
|
|
802
824
|
return result;
|
|
803
825
|
}
|
|
804
|
-
var interpolate_default = interpolate;
|
|
805
826
|
|
|
806
827
|
//#endregion
|
|
807
828
|
//#region src/functions/taggedTemplate/interpolateObjects.ts
|
|
@@ -811,11 +832,13 @@ var interpolate_default = interpolate;
|
|
|
811
832
|
* You can pass a template string directly by doing:
|
|
812
833
|
*
|
|
813
834
|
* ```typescript
|
|
814
|
-
* interpolateObjects`Template string here ${{ my: "object" }}
|
|
835
|
+
* interpolateObjects`Template string here ${{ my: "object" }}`;
|
|
815
836
|
* ```
|
|
816
837
|
*
|
|
817
838
|
* @category Tagged Template
|
|
818
839
|
*
|
|
840
|
+
* @template InterpolationsType - The type of the interpolations.
|
|
841
|
+
*
|
|
819
842
|
* @param strings - The strings from the template to process.
|
|
820
843
|
* @param interpolations - An array of all interpolations from the template.
|
|
821
844
|
*
|
|
@@ -829,7 +852,21 @@ function interpolateObjects(strings, ...interpolations) {
|
|
|
829
852
|
}
|
|
830
853
|
return result;
|
|
831
854
|
}
|
|
832
|
-
|
|
855
|
+
|
|
856
|
+
//#endregion
|
|
857
|
+
//#region src/functions/taggedTemplate/isTemplateStringsArray.ts
|
|
858
|
+
/**
|
|
859
|
+
* Determines whether or not the input is a valid `TemplateStringsArray`.
|
|
860
|
+
*
|
|
861
|
+
* @category Tagged Template
|
|
862
|
+
*
|
|
863
|
+
* @param input - The input to check
|
|
864
|
+
*
|
|
865
|
+
* @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`.
|
|
866
|
+
*/
|
|
867
|
+
function isTemplateStringsArray(input) {
|
|
868
|
+
return typeof input === "object" && input !== null && "raw" in input;
|
|
869
|
+
}
|
|
833
870
|
|
|
834
871
|
//#endregion
|
|
835
872
|
//#region src/functions/taggedTemplate/normaliseIndents.ts
|
|
@@ -852,7 +889,7 @@ function reduceLines(lines, { preserveTabs = true }) {
|
|
|
852
889
|
const whitespaceLength = getWhitespaceLength(isFirstLineEmpty ? lines : slicedLines);
|
|
853
890
|
return (isFirstLineEmpty ? slicedLines : lines).map((line) => {
|
|
854
891
|
const tabSize = calculateTabSize(line, whitespaceLength);
|
|
855
|
-
return (preserveTabs ?
|
|
892
|
+
return (preserveTabs ? fillArray(() => {
|
|
856
893
|
return " ";
|
|
857
894
|
}, tabSize).join("") : "") + line.trimStart();
|
|
858
895
|
}).join("\n");
|
|
@@ -865,7 +902,7 @@ function reduceLines(lines, { preserveTabs = true }) {
|
|
|
865
902
|
* ```typescript
|
|
866
903
|
* normaliseIndents`Template string here
|
|
867
904
|
* with a new line
|
|
868
|
-
* and another new line
|
|
905
|
+
* and another new line`;
|
|
869
906
|
* ```
|
|
870
907
|
*
|
|
871
908
|
* You may also pass the options first, then invoke the resulting function with a template string:
|
|
@@ -873,10 +910,10 @@ function reduceLines(lines, { preserveTabs = true }) {
|
|
|
873
910
|
* ```typescript
|
|
874
911
|
* normaliseIndents({ preserveTabs: false })`Template string here
|
|
875
912
|
* with a new line
|
|
876
|
-
* and another new line
|
|
913
|
+
* and another new line`;
|
|
877
914
|
* ```
|
|
878
915
|
*
|
|
879
|
-
|
|
916
|
+
* @category Tagged Template
|
|
880
917
|
*
|
|
881
918
|
* @param first - The strings from the template to process, or the options to apply.
|
|
882
919
|
* @param args - An array of all interpolations from the template.
|
|
@@ -892,7 +929,7 @@ function normaliseIndents(first, ...args) {
|
|
|
892
929
|
}
|
|
893
930
|
const strings = first;
|
|
894
931
|
const options = typeof args[args.length - 1] === "object" && !Array.isArray(args[args.length - 1]) ? args.pop() : {};
|
|
895
|
-
return reduceLines(
|
|
932
|
+
return reduceLines(interpolate(strings, ...[...args]).split("\n"), options);
|
|
896
933
|
}
|
|
897
934
|
/**
|
|
898
935
|
* Applies any options if provided, then removes any extraneous indents from a multi-line template string.
|
|
@@ -919,7 +956,6 @@ function normaliseIndents(first, ...args) {
|
|
|
919
956
|
* @returns An additional function to invoke, or a new string with the strings and interpolations from the template applied, and extraneous indents removed.
|
|
920
957
|
*/
|
|
921
958
|
const normalizeIndents = normaliseIndents;
|
|
922
|
-
var normaliseIndents_default = normaliseIndents;
|
|
923
959
|
|
|
924
960
|
//#endregion
|
|
925
961
|
//#region src/functions/miscellaneous/sayHello.ts
|
|
@@ -931,7 +967,7 @@ var normaliseIndents_default = normaliseIndents;
|
|
|
931
967
|
* @returns The lyrics string in markdown format.
|
|
932
968
|
*/
|
|
933
969
|
function sayHello() {
|
|
934
|
-
return
|
|
970
|
+
return normaliseIndents`
|
|
935
971
|
# Commit To You
|
|
936
972
|
|
|
937
973
|
### Verse 1
|
|
@@ -1034,7 +1070,6 @@ function sayHello() {
|
|
|
1034
1070
|
I'll commit to you!
|
|
1035
1071
|
`;
|
|
1036
1072
|
}
|
|
1037
|
-
var sayHello_default = sayHello;
|
|
1038
1073
|
|
|
1039
1074
|
//#endregion
|
|
1040
1075
|
//#region src/functions/miscellaneous/stringifyDotenv.ts
|
|
@@ -1051,8 +1086,8 @@ function stringifyDotenv(contents, options) {
|
|
|
1051
1086
|
const { quoteStyle = "double" } = options ?? {};
|
|
1052
1087
|
let result = "";
|
|
1053
1088
|
for (const key in contentsCopy) {
|
|
1054
|
-
if (/[ \t\r\n]/.test(key)) throw new
|
|
1055
|
-
if (quoteStyle === "none") if (/[ \t\r\n]/.test(contentsCopy[key]) || contentsCopy[key].includes("#") || contentsCopy[key].includes("=") || contentsCopy[key].includes("\\")) throw new
|
|
1089
|
+
if (/[ \t\r\n]/.test(key)) throw new DataError({ [key]: contentsCopy[key] }, "INVALID_KEY", "Environment variables are not allowed to have whitespace.");
|
|
1090
|
+
if (quoteStyle === "none") if (/[ \t\r\n]/.test(contentsCopy[key]) || contentsCopy[key].includes("#") || contentsCopy[key].includes("=") || contentsCopy[key].includes("\\")) throw new DataError({ [key]: contentsCopy[key] }, "INCOMPATIBLE_QUOTE_STYLE", "Cannot use `{ quoteStyle: \"none\" }` when value has whitespace, #, =, or \\");
|
|
1056
1091
|
else {
|
|
1057
1092
|
result += `${key}=${contentsCopy[key]}\n`;
|
|
1058
1093
|
continue;
|
|
@@ -1071,7 +1106,6 @@ function stringifyDotenv(contents, options) {
|
|
|
1071
1106
|
}
|
|
1072
1107
|
return result;
|
|
1073
1108
|
}
|
|
1074
|
-
var stringifyDotenv_default = stringifyDotenv;
|
|
1075
1109
|
|
|
1076
1110
|
//#endregion
|
|
1077
1111
|
//#region src/functions/miscellaneous/stringListToArray.ts
|
|
@@ -1094,7 +1128,6 @@ function stringListToArray(stringList, { separator = ",", trimWhitespace = true
|
|
|
1094
1128
|
return item.trim();
|
|
1095
1129
|
}) : arrayList;
|
|
1096
1130
|
}
|
|
1097
|
-
var stringListToArray_default = stringListToArray;
|
|
1098
1131
|
|
|
1099
1132
|
//#endregion
|
|
1100
1133
|
//#region src/functions/miscellaneous/wait.ts
|
|
@@ -1114,7 +1147,6 @@ function wait(seconds) {
|
|
|
1114
1147
|
}, seconds * 1e3);
|
|
1115
1148
|
});
|
|
1116
1149
|
}
|
|
1117
|
-
var wait_default = wait;
|
|
1118
1150
|
|
|
1119
1151
|
//#endregion
|
|
1120
1152
|
//#region src/functions/objectHelpers/getRecordKeys.ts
|
|
@@ -1132,7 +1164,6 @@ var wait_default = wait;
|
|
|
1132
1164
|
function getRecordKeys(record) {
|
|
1133
1165
|
return Object.keys(record);
|
|
1134
1166
|
}
|
|
1135
|
-
var getRecordKeys_default = getRecordKeys;
|
|
1136
1167
|
|
|
1137
1168
|
//#endregion
|
|
1138
1169
|
//#region src/functions/objectHelpers/omitProperties.ts
|
|
@@ -1156,7 +1187,6 @@ function omitProperties(object, keysToOmit) {
|
|
|
1156
1187
|
});
|
|
1157
1188
|
return outputObject;
|
|
1158
1189
|
}
|
|
1159
|
-
var omitProperties_default = omitProperties;
|
|
1160
1190
|
|
|
1161
1191
|
//#endregion
|
|
1162
1192
|
//#region src/functions/objectHelpers/removeUndefinedFromObject.ts
|
|
@@ -1172,7 +1202,6 @@ function removeUndefinedFromObject(object) {
|
|
|
1172
1202
|
return value !== void 0;
|
|
1173
1203
|
}));
|
|
1174
1204
|
}
|
|
1175
|
-
var removeUndefinedFromObject_default = removeUndefinedFromObject;
|
|
1176
1205
|
|
|
1177
1206
|
//#endregion
|
|
1178
1207
|
//#region src/functions/parsers/parseBoolean.ts
|
|
@@ -1189,10 +1218,9 @@ var removeUndefinedFromObject_default = removeUndefinedFromObject;
|
|
|
1189
1218
|
*/
|
|
1190
1219
|
function parseBoolean(inputString) {
|
|
1191
1220
|
const normalisedString = inputString.toLowerCase();
|
|
1192
|
-
if (!["true", "false"].includes(normalisedString)) throw new
|
|
1221
|
+
if (!["true", "false"].includes(normalisedString)) throw new DataError(inputString, "INVALID_BOOLEAN_STRING", "The provided boolean string must be one of `true | false`");
|
|
1193
1222
|
return normalisedString === "true";
|
|
1194
1223
|
}
|
|
1195
|
-
var parseBoolean_default = parseBoolean;
|
|
1196
1224
|
|
|
1197
1225
|
//#endregion
|
|
1198
1226
|
//#region src/functions/parsers/zod/_parseZodSchema.ts
|
|
@@ -1210,7 +1238,7 @@ function _parseZodSchema(parsedResult, data, onError) {
|
|
|
1210
1238
|
const code = issue.code.toUpperCase();
|
|
1211
1239
|
allErrorCodes[code] = (allErrorCodes[code] ?? 0) + 1;
|
|
1212
1240
|
}
|
|
1213
|
-
throw new
|
|
1241
|
+
throw new DataError(data, Object.entries(allErrorCodes).toSorted(([_, firstCount], [__, secondCount]) => {
|
|
1214
1242
|
return secondCount - firstCount;
|
|
1215
1243
|
}).map(([code, count], _, allErrorCodes) => {
|
|
1216
1244
|
return allErrorCodes.length === 1 && count === 1 ? code : `${code}×${count}`;
|
|
@@ -1218,7 +1246,6 @@ function _parseZodSchema(parsedResult, data, onError) {
|
|
|
1218
1246
|
}
|
|
1219
1247
|
return parsedResult.data;
|
|
1220
1248
|
}
|
|
1221
|
-
var _parseZodSchema_default = _parseZodSchema;
|
|
1222
1249
|
|
|
1223
1250
|
//#endregion
|
|
1224
1251
|
//#region src/functions/parsers/zod/parseZodSchema.ts
|
|
@@ -1241,9 +1268,8 @@ var _parseZodSchema_default = _parseZodSchema;
|
|
|
1241
1268
|
* @returns The parsed data from the Zod schema.
|
|
1242
1269
|
*/
|
|
1243
1270
|
function parseZodSchema(schema, data, onError) {
|
|
1244
|
-
return
|
|
1271
|
+
return _parseZodSchema(schema.safeParse(data), data, onError);
|
|
1245
1272
|
}
|
|
1246
|
-
var parseZodSchema_default = parseZodSchema;
|
|
1247
1273
|
|
|
1248
1274
|
//#endregion
|
|
1249
1275
|
//#region src/functions/parsers/parseEnv.ts
|
|
@@ -1269,9 +1295,8 @@ const Env = {
|
|
|
1269
1295
|
* @returns The specified environment if allowed.
|
|
1270
1296
|
*/
|
|
1271
1297
|
function parseEnv(data) {
|
|
1272
|
-
return
|
|
1298
|
+
return parseZodSchema(zod.z.enum(Env), data, new DataError(data, "INVALID_ENV", "The provided environment type must be one of `test | development | production`"));
|
|
1273
1299
|
}
|
|
1274
|
-
var parseEnv_default = parseEnv;
|
|
1275
1300
|
|
|
1276
1301
|
//#endregion
|
|
1277
1302
|
//#region src/functions/parsers/parseFilePath.ts
|
|
@@ -1287,23 +1312,22 @@ var parseEnv_default = parseEnv;
|
|
|
1287
1312
|
* @returns An object representing the different ways the file path can be represented.
|
|
1288
1313
|
*/
|
|
1289
1314
|
function parseFilePath(filePath) {
|
|
1290
|
-
const caughtGroups = filePath.match(RegExp(
|
|
1315
|
+
const caughtGroups = filePath.match(RegExp(FILE_PATH_REGEX));
|
|
1291
1316
|
if (!caughtGroups) {
|
|
1292
1317
|
if (!(filePath.includes("/") || filePath.includes("\\")) && filePath.includes(".")) return {
|
|
1293
1318
|
directory: "",
|
|
1294
1319
|
base: filePath,
|
|
1295
1320
|
fullPath: filePath
|
|
1296
1321
|
};
|
|
1297
|
-
throw new
|
|
1322
|
+
throw new DataError({ filePath }, "INVALID_FILE_PATH", "The file path you provided is not valid.");
|
|
1298
1323
|
}
|
|
1299
|
-
if (!caughtGroups.groups) throw new
|
|
1324
|
+
if (!caughtGroups.groups) throw new DataError({ filePath }, "PARSING_ERROR", "An error occurred while trying to parse the data.");
|
|
1300
1325
|
return {
|
|
1301
1326
|
directory: caughtGroups.groups.directory,
|
|
1302
1327
|
base: caughtGroups.groups.base,
|
|
1303
1328
|
fullPath: node_path.default.join(caughtGroups.groups.directory.replaceAll("\\", "/"), caughtGroups.groups.base)
|
|
1304
1329
|
};
|
|
1305
1330
|
}
|
|
1306
|
-
var parseFilePath_default = parseFilePath;
|
|
1307
1331
|
|
|
1308
1332
|
//#endregion
|
|
1309
1333
|
//#region src/functions/parsers/parseFormData.ts
|
|
@@ -1327,7 +1351,6 @@ function parseFormData(formData, dataParser) {
|
|
|
1327
1351
|
if (dataParser) return dataParser(object);
|
|
1328
1352
|
return object;
|
|
1329
1353
|
}
|
|
1330
|
-
var parseFormData_default = parseFormData;
|
|
1331
1354
|
|
|
1332
1355
|
//#endregion
|
|
1333
1356
|
//#region src/functions/parsers/parseVersionType.ts
|
|
@@ -1353,9 +1376,8 @@ const VersionType = {
|
|
|
1353
1376
|
* @returns The given version type if allowed.
|
|
1354
1377
|
*/
|
|
1355
1378
|
function parseVersionType(data) {
|
|
1356
|
-
return
|
|
1379
|
+
return parseZodSchema(zod.default.enum(VersionType), data, new DataError(data, "INVALID_VERSION_TYPE", "The provided version type must be one of `major | minor | patch`"));
|
|
1357
1380
|
}
|
|
1358
|
-
var parseVersionType_default = parseVersionType;
|
|
1359
1381
|
|
|
1360
1382
|
//#endregion
|
|
1361
1383
|
//#region src/functions/parsers/zod/parseZodSchemaAsync.ts
|
|
@@ -1376,9 +1398,8 @@ var parseVersionType_default = parseVersionType;
|
|
|
1376
1398
|
* @returns The parsed data from the Zod schema.
|
|
1377
1399
|
*/
|
|
1378
1400
|
async function parseZodSchemaAsync(schema, data, onError) {
|
|
1379
|
-
return
|
|
1401
|
+
return _parseZodSchema(await schema.safeParseAsync(data), data, onError);
|
|
1380
1402
|
}
|
|
1381
|
-
var parseZodSchemaAsync_default = parseZodSchemaAsync;
|
|
1382
1403
|
|
|
1383
1404
|
//#endregion
|
|
1384
1405
|
//#region src/functions/recursive/deepCopy.ts
|
|
@@ -1407,7 +1428,6 @@ function deepCopy(object) {
|
|
|
1407
1428
|
}
|
|
1408
1429
|
return clonedObject;
|
|
1409
1430
|
}
|
|
1410
|
-
var deepCopy_default = deepCopy;
|
|
1411
1431
|
|
|
1412
1432
|
//#endregion
|
|
1413
1433
|
//#region src/functions/security/encryptWithKey.ts
|
|
@@ -1426,10 +1446,9 @@ async function encryptWithKey(publicKey, plaintextValue) {
|
|
|
1426
1446
|
const encryptedValue = libsodium_wrappers.default.crypto_box_seal(plaintextValue, base64Key);
|
|
1427
1447
|
return libsodium_wrappers.default.to_base64(encryptedValue, libsodium_wrappers.default.base64_variants.ORIGINAL);
|
|
1428
1448
|
} catch {
|
|
1429
|
-
throw new
|
|
1449
|
+
throw new DataError({ publicKey }, "ENCRYPTION_FAILED", "Encryption failed. Please double-check that the given key is a valid base 64 string.");
|
|
1430
1450
|
}
|
|
1431
1451
|
}
|
|
1432
|
-
var encryptWithKey_default = encryptWithKey;
|
|
1433
1452
|
|
|
1434
1453
|
//#endregion
|
|
1435
1454
|
//#region src/functions/security/getPublicAndPrivateKey.ts
|
|
@@ -1447,7 +1466,7 @@ var encryptWithKey_default = encryptWithKey;
|
|
|
1447
1466
|
function getPublicAndPrivateKey(outputFormat) {
|
|
1448
1467
|
const keys = libsodium_wrappers.default.crypto_box_keypair(outputFormat);
|
|
1449
1468
|
if (outputFormat === "uint8array" || outputFormat === void 0) {
|
|
1450
|
-
if (!(keys?.publicKey instanceof Uint8Array && keys?.privateKey instanceof Uint8Array)) throw new
|
|
1469
|
+
if (!(keys?.publicKey instanceof Uint8Array && keys?.privateKey instanceof Uint8Array)) throw new DataError({
|
|
1451
1470
|
publicKey: `<redacted: ${keys?.publicKey?.constructor?.name ?? typeof keys?.publicKey}>`,
|
|
1452
1471
|
privateKey: `<redacted: ${keys?.privateKey?.constructor?.name ?? typeof keys?.privateKey}>`
|
|
1453
1472
|
}, "INVALID_KEY_TYPES", "Expected Uint8Array keypair from libsodium.");
|
|
@@ -1455,7 +1474,6 @@ function getPublicAndPrivateKey(outputFormat) {
|
|
|
1455
1474
|
}
|
|
1456
1475
|
return keys;
|
|
1457
1476
|
}
|
|
1458
|
-
var getPublicAndPrivateKey_default = getPublicAndPrivateKey;
|
|
1459
1477
|
|
|
1460
1478
|
//#endregion
|
|
1461
1479
|
//#region src/functions/stringHelpers/appendSemicolon.ts
|
|
@@ -1476,7 +1494,6 @@ function appendSemicolon(stringToAppendTo) {
|
|
|
1476
1494
|
if (stringWithNoTrailingWhitespace === "") return "";
|
|
1477
1495
|
return stringWithNoTrailingWhitespace[stringWithNoTrailingWhitespace.length - 1] === ";" ? stringWithNoTrailingWhitespace : `${stringWithNoTrailingWhitespace};`;
|
|
1478
1496
|
}
|
|
1479
|
-
var appendSemicolon_default = appendSemicolon;
|
|
1480
1497
|
|
|
1481
1498
|
//#endregion
|
|
1482
1499
|
//#region src/functions/stringHelpers/camelToKebab.ts
|
|
@@ -1516,7 +1533,6 @@ function camelToKebab(string, options = { preserveConsecutiveCapitals: true }) {
|
|
|
1516
1533
|
}
|
|
1517
1534
|
return result;
|
|
1518
1535
|
}
|
|
1519
|
-
var camelToKebab_default = camelToKebab;
|
|
1520
1536
|
|
|
1521
1537
|
//#endregion
|
|
1522
1538
|
//#region src/functions/stringHelpers/kebabToCamel.ts
|
|
@@ -1540,7 +1556,7 @@ function kebabToCamel(string, options) {
|
|
|
1540
1556
|
skip = false;
|
|
1541
1557
|
continue;
|
|
1542
1558
|
}
|
|
1543
|
-
const index =
|
|
1559
|
+
const index = parseIntStrict(stringIndex);
|
|
1544
1560
|
if (index === 0 && options?.startWithUpper) {
|
|
1545
1561
|
outputString += string[index].toUpperCase();
|
|
1546
1562
|
continue;
|
|
@@ -1556,7 +1572,6 @@ function kebabToCamel(string, options) {
|
|
|
1556
1572
|
}
|
|
1557
1573
|
return outputString;
|
|
1558
1574
|
}
|
|
1559
|
-
var kebabToCamel_default = kebabToCamel;
|
|
1560
1575
|
|
|
1561
1576
|
//#endregion
|
|
1562
1577
|
//#region src/functions/stringHelpers/normalizeImportPath.ts
|
|
@@ -1594,7 +1609,6 @@ function normalizeImportPath(importPath) {
|
|
|
1594
1609
|
* @returns The import path normalised.
|
|
1595
1610
|
*/
|
|
1596
1611
|
const normaliseImportPath = normalizeImportPath;
|
|
1597
|
-
var normalizeImportPath_default = normalizeImportPath;
|
|
1598
1612
|
|
|
1599
1613
|
//#endregion
|
|
1600
1614
|
//#region src/functions/stringHelpers/truncate.ts
|
|
@@ -1611,7 +1625,6 @@ var normalizeImportPath_default = normalizeImportPath;
|
|
|
1611
1625
|
function truncate(stringToTruncate, maxLength = 5) {
|
|
1612
1626
|
return stringToTruncate.length > maxLength ? `${stringToTruncate.slice(0, maxLength)}...` : stringToTruncate;
|
|
1613
1627
|
}
|
|
1614
|
-
var truncate_default = truncate;
|
|
1615
1628
|
|
|
1616
1629
|
//#endregion
|
|
1617
1630
|
//#region src/functions/versioning/parseVersion.ts
|
|
@@ -1630,11 +1643,10 @@ var truncate_default = truncate;
|
|
|
1630
1643
|
* @returns The validated version number, prefixed with `v` if it was not already.
|
|
1631
1644
|
*/
|
|
1632
1645
|
function parseVersion(input, options) {
|
|
1633
|
-
if (!RegExp(
|
|
1646
|
+
if (!RegExp(VERSION_NUMBER_REGEX).test(input)) throw new DataError(input, "INVALID_VERSION", `"${input}" is not a valid version number. Version numbers must be of the format "X.Y.Z" or "vX.Y.Z", where X, Y, and Z are non-negative integers.`);
|
|
1634
1647
|
if (options?.omitPrefix) return input.startsWith("v") ? input.slice(1) : input;
|
|
1635
1648
|
return input.startsWith("v") ? input : `v${input}`;
|
|
1636
1649
|
}
|
|
1637
|
-
var parseVersion_default = parseVersion;
|
|
1638
1650
|
|
|
1639
1651
|
//#endregion
|
|
1640
1652
|
//#region src/functions/versioning/getIndividualVersionNumbers.ts
|
|
@@ -1653,11 +1665,10 @@ var parseVersion_default = parseVersion;
|
|
|
1653
1665
|
* @returns A tuple of three numbers indicating `[major, minor, patch]`.
|
|
1654
1666
|
*/
|
|
1655
1667
|
function getIndividualVersionNumbers(version) {
|
|
1656
|
-
return
|
|
1657
|
-
return
|
|
1668
|
+
return parseVersion(version, { omitPrefix: true }).split(".").map((versionNumber) => {
|
|
1669
|
+
return parseIntStrict(versionNumber);
|
|
1658
1670
|
});
|
|
1659
1671
|
}
|
|
1660
|
-
var getIndividualVersionNumbers_default = getIndividualVersionNumbers;
|
|
1661
1672
|
|
|
1662
1673
|
//#endregion
|
|
1663
1674
|
//#region src/functions/versioning/determineVersionType.ts
|
|
@@ -1671,12 +1682,11 @@ var getIndividualVersionNumbers_default = getIndividualVersionNumbers;
|
|
|
1671
1682
|
* @returns Either `"major"`, `"minor"`, or `"patch"`, depending on the version type.
|
|
1672
1683
|
*/
|
|
1673
1684
|
function determineVersionType(version) {
|
|
1674
|
-
const [_major, minor, patch] =
|
|
1685
|
+
const [_major, minor, patch] = getIndividualVersionNumbers(version);
|
|
1675
1686
|
if (minor === 0 && patch === 0) return "major";
|
|
1676
1687
|
if (patch === 0) return "minor";
|
|
1677
1688
|
return "patch";
|
|
1678
1689
|
}
|
|
1679
|
-
var determineVersionType_default = determineVersionType;
|
|
1680
1690
|
|
|
1681
1691
|
//#endregion
|
|
1682
1692
|
//#region src/functions/versioning/incrementVersion.ts
|
|
@@ -1695,73 +1705,74 @@ var determineVersionType_default = determineVersionType;
|
|
|
1695
1705
|
* @returns A new string representing the version with the increment applied.
|
|
1696
1706
|
*/
|
|
1697
1707
|
function incrementVersion(version, incrementType, options) {
|
|
1698
|
-
const [major, minor, patch] =
|
|
1708
|
+
const [major, minor, patch] = getIndividualVersionNumbers(version);
|
|
1699
1709
|
const newVersion = {
|
|
1700
1710
|
major: `${major + 1}.0.0`,
|
|
1701
1711
|
minor: `${major}.${minor + 1}.0`,
|
|
1702
1712
|
patch: `${major}.${minor}.${patch + 1}`
|
|
1703
1713
|
}[incrementType];
|
|
1704
|
-
return
|
|
1714
|
+
return parseVersion(newVersion, { omitPrefix: options?.omitPrefix });
|
|
1705
1715
|
}
|
|
1706
|
-
var incrementVersion_default = incrementVersion;
|
|
1707
1716
|
|
|
1708
1717
|
//#endregion
|
|
1709
|
-
exports.APIError =
|
|
1710
|
-
exports.DataError =
|
|
1718
|
+
exports.APIError = APIError;
|
|
1719
|
+
exports.DataError = DataError;
|
|
1711
1720
|
exports.Env = Env;
|
|
1712
|
-
exports.FILE_PATH_REGEX =
|
|
1713
|
-
exports.NAMESPACE_EXPORT_REGEX =
|
|
1714
|
-
exports.VERSION_NUMBER_REGEX =
|
|
1715
|
-
exports.VersionNumber =
|
|
1721
|
+
exports.FILE_PATH_REGEX = FILE_PATH_REGEX;
|
|
1722
|
+
exports.NAMESPACE_EXPORT_REGEX = NAMESPACE_EXPORT_REGEX;
|
|
1723
|
+
exports.VERSION_NUMBER_REGEX = VERSION_NUMBER_REGEX;
|
|
1724
|
+
exports.VersionNumber = VersionNumber;
|
|
1716
1725
|
exports.VersionType = VersionType;
|
|
1717
|
-
exports.addDaysToDate =
|
|
1718
|
-
exports.appendSemicolon =
|
|
1719
|
-
exports.camelToKebab =
|
|
1720
|
-
exports.convertFileToBase64 =
|
|
1721
|
-
exports.createFormData =
|
|
1722
|
-
exports.createTemplateStringsArray =
|
|
1723
|
-
exports.deepCopy =
|
|
1724
|
-
exports.deepFreeze =
|
|
1725
|
-
exports.determineVersionType =
|
|
1726
|
-
exports.encryptWithKey =
|
|
1727
|
-
exports.fillArray =
|
|
1728
|
-
exports.formatDateAndTime =
|
|
1729
|
-
exports.getIndividualVersionNumbers =
|
|
1730
|
-
exports.getInterpolations =
|
|
1731
|
-
exports.getPublicAndPrivateKey =
|
|
1732
|
-
exports.getRandomNumber =
|
|
1733
|
-
exports.getRecordKeys =
|
|
1726
|
+
exports.addDaysToDate = addDaysToDate;
|
|
1727
|
+
exports.appendSemicolon = appendSemicolon;
|
|
1728
|
+
exports.camelToKebab = camelToKebab;
|
|
1729
|
+
exports.convertFileToBase64 = convertFileToBase64;
|
|
1730
|
+
exports.createFormData = createFormData;
|
|
1731
|
+
exports.createTemplateStringsArray = createTemplateStringsArray;
|
|
1732
|
+
exports.deepCopy = deepCopy;
|
|
1733
|
+
exports.deepFreeze = deepFreeze;
|
|
1734
|
+
exports.determineVersionType = determineVersionType;
|
|
1735
|
+
exports.encryptWithKey = encryptWithKey;
|
|
1736
|
+
exports.fillArray = fillArray;
|
|
1737
|
+
exports.formatDateAndTime = formatDateAndTime;
|
|
1738
|
+
exports.getIndividualVersionNumbers = getIndividualVersionNumbers;
|
|
1739
|
+
exports.getInterpolations = getInterpolations;
|
|
1740
|
+
exports.getPublicAndPrivateKey = getPublicAndPrivateKey;
|
|
1741
|
+
exports.getRandomNumber = getRandomNumber;
|
|
1742
|
+
exports.getRecordKeys = getRecordKeys;
|
|
1743
|
+
exports.getStringsAndInterpolations = getStringsAndInterpolations;
|
|
1734
1744
|
exports.httpErrorCodeLookup = httpErrorCodeLookup;
|
|
1735
|
-
exports.incrementVersion =
|
|
1736
|
-
exports.interpolate =
|
|
1737
|
-
exports.interpolateObjects =
|
|
1738
|
-
exports.isAnniversary =
|
|
1739
|
-
exports.isLeapYear =
|
|
1740
|
-
exports.isMonthlyMultiple =
|
|
1741
|
-
exports.isOrdered =
|
|
1742
|
-
exports.isSameDate =
|
|
1743
|
-
exports.
|
|
1745
|
+
exports.incrementVersion = incrementVersion;
|
|
1746
|
+
exports.interpolate = interpolate;
|
|
1747
|
+
exports.interpolateObjects = interpolateObjects;
|
|
1748
|
+
exports.isAnniversary = isAnniversary;
|
|
1749
|
+
exports.isLeapYear = isLeapYear;
|
|
1750
|
+
exports.isMonthlyMultiple = isMonthlyMultiple;
|
|
1751
|
+
exports.isOrdered = isOrdered;
|
|
1752
|
+
exports.isSameDate = isSameDate;
|
|
1753
|
+
exports.isTemplateStringsArray = isTemplateStringsArray;
|
|
1754
|
+
exports.kebabToCamel = kebabToCamel;
|
|
1744
1755
|
exports.normaliseImportPath = normaliseImportPath;
|
|
1745
|
-
exports.normaliseIndents =
|
|
1746
|
-
exports.normalizeImportPath =
|
|
1756
|
+
exports.normaliseIndents = normaliseIndents;
|
|
1757
|
+
exports.normalizeImportPath = normalizeImportPath;
|
|
1747
1758
|
exports.normalizeIndents = normalizeIndents;
|
|
1748
|
-
exports.omitProperties =
|
|
1749
|
-
exports.paralleliseArrays =
|
|
1750
|
-
exports.parseBoolean =
|
|
1751
|
-
exports.parseEnv =
|
|
1752
|
-
exports.parseFilePath =
|
|
1753
|
-
exports.parseFormData =
|
|
1754
|
-
exports.parseIntStrict =
|
|
1755
|
-
exports.parseVersion =
|
|
1756
|
-
exports.parseVersionType =
|
|
1757
|
-
exports.parseZodSchema =
|
|
1758
|
-
exports.parseZodSchemaAsync =
|
|
1759
|
-
exports.randomiseArray =
|
|
1760
|
-
exports.range =
|
|
1761
|
-
exports.removeDuplicates =
|
|
1762
|
-
exports.removeUndefinedFromObject =
|
|
1763
|
-
exports.sayHello =
|
|
1764
|
-
exports.stringListToArray =
|
|
1765
|
-
exports.stringifyDotenv =
|
|
1766
|
-
exports.truncate =
|
|
1767
|
-
exports.wait =
|
|
1759
|
+
exports.omitProperties = omitProperties;
|
|
1760
|
+
exports.paralleliseArrays = paralleliseArrays;
|
|
1761
|
+
exports.parseBoolean = parseBoolean;
|
|
1762
|
+
exports.parseEnv = parseEnv;
|
|
1763
|
+
exports.parseFilePath = parseFilePath;
|
|
1764
|
+
exports.parseFormData = parseFormData;
|
|
1765
|
+
exports.parseIntStrict = parseIntStrict;
|
|
1766
|
+
exports.parseVersion = parseVersion;
|
|
1767
|
+
exports.parseVersionType = parseVersionType;
|
|
1768
|
+
exports.parseZodSchema = parseZodSchema;
|
|
1769
|
+
exports.parseZodSchemaAsync = parseZodSchemaAsync;
|
|
1770
|
+
exports.randomiseArray = randomiseArray;
|
|
1771
|
+
exports.range = range;
|
|
1772
|
+
exports.removeDuplicates = removeDuplicates;
|
|
1773
|
+
exports.removeUndefinedFromObject = removeUndefinedFromObject;
|
|
1774
|
+
exports.sayHello = sayHello;
|
|
1775
|
+
exports.stringListToArray = stringListToArray;
|
|
1776
|
+
exports.stringifyDotenv = stringifyDotenv;
|
|
1777
|
+
exports.truncate = truncate;
|
|
1778
|
+
exports.wait = wait;
|