@alextheman/utility 4.12.3 → 4.13.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 CHANGED
@@ -713,6 +713,329 @@ function isOrdered(array) {
713
713
  }
714
714
  var isOrdered_default = isOrdered;
715
715
 
716
+ //#endregion
717
+ //#region src/functions/recursive/deepFreeze.ts
718
+ /**
719
+ * Deeply freezes an object or array such that all child objects/arrays are also frozen.
720
+ *
721
+ * Note that this will also freeze the input itself as well.
722
+ * If the intent is to create a newly frozen object with a different reference in memory, pass your object through deepCopy first before passing to deepFreeze.
723
+ *
724
+ * @category Recursive
725
+ *
726
+ * @template ObjectType - The type of the input object.
727
+ *
728
+ * @param object - The object to freeze. May also be an array.
729
+ *
730
+ * @returns The input object completely frozen.
731
+ */
732
+ function deepFreeze(object) {
733
+ for (const value of Object.values(object)) {
734
+ if (typeof value === "function") continue;
735
+ if (value && typeof value === "object") deepFreeze(value);
736
+ }
737
+ return Object.freeze(object);
738
+ }
739
+ var deepFreeze_default = deepFreeze;
740
+
741
+ //#endregion
742
+ //#region src/functions/taggedTemplate/createTemplateStringsArray.ts
743
+ /**
744
+ * Creates a template strings array given a regular array of strings
745
+ *
746
+ * @category Tagged Template
747
+ *
748
+ * @param strings - The array of strings.
749
+ *
750
+ * @returns A template strings array that can be passed as the first argument of any tagged template function.
751
+ */
752
+ function createTemplateStringsArray(strings) {
753
+ return deepFreeze_default(Object.assign([...strings], { raw: [...strings] }));
754
+ }
755
+ var createTemplateStringsArray_default = createTemplateStringsArray;
756
+
757
+ //#endregion
758
+ //#region src/functions/taggedTemplate/getInterpolations.ts
759
+ /**
760
+ * Gets the strings and interpolations separately from a template string.
761
+ * You can pass a template string directly by doing:
762
+ *
763
+ * ```typescript
764
+ * getInterpolations`Template string here`.
765
+ * ```
766
+ *
767
+ * @category Tagged Template
768
+ *
769
+ * @param strings - The strings from the template to process.
770
+ * @param interpolations - An array of all interpolations from the template.
771
+ *
772
+ * @returns A tuple where the first item is the strings from the template, and the second is the interpolations.
773
+ */
774
+ function getInterpolations(strings, ...interpolations) {
775
+ return [strings, interpolations];
776
+ }
777
+ var getInterpolations_default = getInterpolations;
778
+
779
+ //#endregion
780
+ //#region src/functions/taggedTemplate/interpolate.ts
781
+ /**
782
+ * Returns the result of interpolating a template string when given the strings and interpolations separately.
783
+ *
784
+ * You can pass a template string directly by doing:
785
+ *
786
+ * ```
787
+ * interpolate`Template string here`;
788
+ * ```
789
+ *
790
+ * In this case, it will be functionally the same as if you just wrote the template string by itself.
791
+ *
792
+ * @category Tagged Template
793
+ *
794
+ * @param strings - The strings from the template to process.
795
+ * @param interpolations - An array of all interpolations from the template.
796
+ *
797
+ * @returns A new string with the strings and interpolations from the template applied.
798
+ */
799
+ function interpolate(strings, ...interpolations) {
800
+ let result = "";
801
+ for (const [string, interpolation = ""] of paralleliseArrays_default(strings, interpolations)) result += string + interpolation;
802
+ return result;
803
+ }
804
+ var interpolate_default = interpolate;
805
+
806
+ //#endregion
807
+ //#region src/functions/taggedTemplate/interpolateObjects.ts
808
+ /**
809
+ * Returns the result of interpolating a template string, also stringifying objects.
810
+ *
811
+ * You can pass a template string directly by doing:
812
+ *
813
+ * ```typescript
814
+ * interpolateObjects`Template string here ${{ my: "object" }}`.
815
+ * ```
816
+ *
817
+ * @category Tagged Template
818
+ *
819
+ * @param strings - The strings from the template to process.
820
+ * @param interpolations - An array of all interpolations from the template.
821
+ *
822
+ * @returns A new string with the strings and interpolations from the template applied, with objects stringified.
823
+ */
824
+ function interpolateObjects(strings, ...interpolations) {
825
+ let result = "";
826
+ for (let i = 0; i < strings.length; i++) {
827
+ result += strings[i];
828
+ if (i !== strings.length - 1) result += interpolations[i] && typeof interpolations[i] === "object" ? JSON.stringify(interpolations[i]) : interpolations[i];
829
+ }
830
+ return result;
831
+ }
832
+ var interpolateObjects_default = interpolateObjects;
833
+
834
+ //#endregion
835
+ //#region src/functions/taggedTemplate/normaliseIndents.ts
836
+ function calculateTabSize(line, whitespaceLength) {
837
+ const potentialWhitespacePart = line.slice(0, whitespaceLength);
838
+ const trimmedString = line.trimStart();
839
+ if (potentialWhitespacePart.trim() !== "") return 0;
840
+ const tabSize = line.length - (trimmedString.length + whitespaceLength);
841
+ return tabSize < 0 ? 0 : tabSize;
842
+ }
843
+ function getWhitespaceLength(lines) {
844
+ const [firstNonEmptyLine] = lines.filter((line) => {
845
+ return line.trim() !== "";
846
+ });
847
+ return firstNonEmptyLine.length - firstNonEmptyLine.trimStart().length;
848
+ }
849
+ function reduceLines(lines, { preserveTabs = true }) {
850
+ const slicedLines = lines.slice(1);
851
+ const isFirstLineEmpty = lines[0].trim() === "";
852
+ const whitespaceLength = getWhitespaceLength(isFirstLineEmpty ? lines : slicedLines);
853
+ return (isFirstLineEmpty ? slicedLines : lines).map((line) => {
854
+ const tabSize = calculateTabSize(line, whitespaceLength);
855
+ return (preserveTabs ? fillArray_default(() => {
856
+ return " ";
857
+ }, tabSize).join("") : "") + line.trimStart();
858
+ }).join("\n");
859
+ }
860
+ /**
861
+ * Applies any options if provided, then removes any extraneous indents from a multi-line template string.
862
+ *
863
+ * You can pass a template string directly by doing:
864
+ *
865
+ * ```typescript
866
+ * normaliseIndents`Template string here
867
+ * with a new line
868
+ * and another new line`.
869
+ * ```
870
+ *
871
+ * You may also pass the options first, then invoke the resulting function with a template string:
872
+ *
873
+ * ```typescript
874
+ * normaliseIndents({ preserveTabs: false })`Template string here
875
+ * with a new line
876
+ * and another new line`.
877
+ * ```
878
+ *
879
+ *@category Tagged Template
880
+ *
881
+ * @param first - The strings from the template to process, or the options to apply.
882
+ * @param args - An array of all interpolations from the template.
883
+ *
884
+ * @returns An additional function to invoke, or a new string with the strings and interpolations from the template applied, and extraneous indents removed.
885
+ */
886
+ function normaliseIndents(first, ...args) {
887
+ if (typeof first === "object" && first !== null && !Array.isArray(first)) {
888
+ const options = first;
889
+ return (strings, ...interpolations) => {
890
+ return normaliseIndents(strings, ...interpolations, options);
891
+ };
892
+ }
893
+ const strings = first;
894
+ const options = typeof args[args.length - 1] === "object" && !Array.isArray(args[args.length - 1]) ? args.pop() : {};
895
+ return reduceLines(interpolate_default(strings, ...[...args]).split("\n"), options);
896
+ }
897
+ /**
898
+ * Applies any options if provided, then removes any extraneous indents from a multi-line template string.
899
+ *
900
+ * You can pass a template string directly by doing:
901
+ *
902
+ * ```typescript
903
+ * normalizeIndents`Template string here
904
+ * with a new line
905
+ * and another new line`.
906
+ * ```
907
+ *
908
+ * You may also pass the options first, then invoke the resulting function with a template string:
909
+ *
910
+ * ```typescript
911
+ * normalizeIndents({ preserveTabs: false })`Template string here
912
+ * with a new line
913
+ * and another new line`.
914
+ * ```
915
+ *
916
+ * @param first - The strings from the template to process, or the options to apply.
917
+ * @param args - An array of all interpolations from the template.
918
+ *
919
+ * @returns An additional function to invoke, or a new string with the strings and interpolations from the template applied, and extraneous indents removed.
920
+ */
921
+ const normalizeIndents = normaliseIndents;
922
+ var normaliseIndents_default = normaliseIndents;
923
+
924
+ //#endregion
925
+ //#region src/functions/miscellaneous/sayHello.ts
926
+ /**
927
+ * Returns a string representing the lyrics to the package's theme song, Commit To You
928
+ *
929
+ * [Pls listen!](https://www.youtube.com/watch?v=mH-Sg-8EnxM)
930
+ *
931
+ * @returns The lyrics string in markdown format.
932
+ */
933
+ function sayHello() {
934
+ return normaliseIndents_default`
935
+ # Commit To You
936
+
937
+ ### Verse 1
938
+
939
+ I know you've been checking me out,
940
+ Shall we take it to the next level now?
941
+ 'Cause I really wanna be there all for you,
942
+ All for you!
943
+ Come on now, let's make a fresh start!
944
+ Pin my number, then you can take me out!
945
+ Can't you see I really do care about you,
946
+ About you!
947
+
948
+ ### Pre-chorus 1
949
+ Although our calendars are imperfect, at best,
950
+ I'd like to organise time with you! (with you!).
951
+ Just tell me when and I'll make it clear,
952
+ All clear for you,
953
+ All clear for you!
954
+ (One, two, three, go!)
955
+
956
+ ### Chorus
957
+ I wanna be of utility, I'll help you on the run!
958
+ I'll be the one here in the back, while you go have some fun!
959
+ Looking out for you tonight, I'll be the one you can rely on!
960
+ Watch you go and watch me pass by,
961
+ I'll be here!
962
+ I'll commit to you!
963
+
964
+ ### Verse 2
965
+ Though sometimes it won't be easy,
966
+ You'll be here to bring out the best in me,
967
+ And I'll hold myself to high standards for you!
968
+ All for you!
969
+ We'll grow as a pair, you and me,
970
+ We'll build up a healthy dependency,
971
+ You can build with me and I'll develop with you!
972
+ I'm with you!
973
+
974
+ ### Pre-chorus 2
975
+ I'll be with you when you're up or you're down,
976
+ We'll deal with all our problems together (together!)
977
+ Just tell me what you want, I'll make it clear,
978
+ All clear for you,
979
+ All clear for you!
980
+ (One, three, one, go!)
981
+
982
+ ### Chorus
983
+ I wanna be of utility, I'll help you on the run!
984
+ (help you on the run!)
985
+ I'll be the one here in the back, while you go have some fun!
986
+ (you go have some fun!)
987
+ Looking out for you tonight, I'll be the one you can rely on!
988
+ Watch you go and watch me pass by,
989
+ I'll be here!
990
+ I'll commit to you!
991
+
992
+ ### Bridge
993
+ Looking into our stack!
994
+ I'll commit to you!
995
+ We've got a lot to unpack!
996
+ I'll commit to you!
997
+ The environment that we're in!
998
+ I'll commit to you!
999
+ Delicate as a string!
1000
+ I'll commit to you!
1001
+
1002
+ But I think you're my type!
1003
+ I'll commit to you!
1004
+ Oh, this feels all so right!
1005
+ I'll commit to you!
1006
+ Nothing stopping us now!
1007
+ I'll commit to you!
1008
+ Let's show them what we're about!
1009
+ Two, three, four, go!
1010
+
1011
+ ### Final Chorus
1012
+ I wanna be of utility, I'll help you on the run!
1013
+ (help you on the run!)
1014
+ I'll be the one here in the back, while you go have some fun!
1015
+ (you go have some fun!)
1016
+ Looking out for you tonight, I'll be the one you can rely on!
1017
+ Watch you go and watch me pass by,
1018
+ I'll be here!
1019
+ I'll commit to you!
1020
+
1021
+ I wanna be of utility, I'll help you on the run!
1022
+ (I'll commit to you!)
1023
+ I'll be the one here in the back, while you go have some fun!
1024
+ (I'll commit to you!)
1025
+ Looking out for you tonight, I'll be the one you can rely on!
1026
+ (I'll commit to you!)
1027
+ Watch you go and watch me pass by,
1028
+ (I'll commit to you!)
1029
+ I'll be here!
1030
+
1031
+ ### Outro
1032
+ I'll commit to you!
1033
+ I'll commit to you!
1034
+ I'll commit to you!
1035
+ `;
1036
+ }
1037
+ var sayHello_default = sayHello;
1038
+
716
1039
  //#endregion
717
1040
  //#region src/functions/miscellaneous/stringifyDotenv.ts
718
1041
  /**
@@ -1086,31 +1409,6 @@ function deepCopy(object) {
1086
1409
  }
1087
1410
  var deepCopy_default = deepCopy;
1088
1411
 
1089
- //#endregion
1090
- //#region src/functions/recursive/deepFreeze.ts
1091
- /**
1092
- * Deeply freezes an object or array such that all child objects/arrays are also frozen.
1093
- *
1094
- * Note that this will also freeze the input itself as well.
1095
- * If the intent is to create a newly frozen object with a different reference in memory, pass your object through deepCopy first before passing to deepFreeze.
1096
- *
1097
- * @category Recursive
1098
- *
1099
- * @template ObjectType - The type of the input object.
1100
- *
1101
- * @param object - The object to freeze. May also be an array.
1102
- *
1103
- * @returns The input object completely frozen.
1104
- */
1105
- function deepFreeze(object) {
1106
- for (const value of Object.values(object)) {
1107
- if (typeof value === "function") continue;
1108
- if (value && typeof value === "object") deepFreeze(value);
1109
- }
1110
- return Object.freeze(object);
1111
- }
1112
- var deepFreeze_default = deepFreeze;
1113
-
1114
1412
  //#endregion
1115
1413
  //#region src/functions/security/encryptWithKey.ts
1116
1414
  /**
@@ -1315,189 +1613,6 @@ function truncate(stringToTruncate, maxLength = 5) {
1315
1613
  }
1316
1614
  var truncate_default = truncate;
1317
1615
 
1318
- //#endregion
1319
- //#region src/functions/taggedTemplate/createTemplateStringsArray.ts
1320
- /**
1321
- * Creates a template strings array given a regular array of strings
1322
- *
1323
- * @category Tagged Template
1324
- *
1325
- * @param strings - The array of strings.
1326
- *
1327
- * @returns A template strings array that can be passed as the first argument of any tagged template function.
1328
- */
1329
- function createTemplateStringsArray(strings) {
1330
- return deepFreeze_default(Object.assign([...strings], { raw: [...strings] }));
1331
- }
1332
- var createTemplateStringsArray_default = createTemplateStringsArray;
1333
-
1334
- //#endregion
1335
- //#region src/functions/taggedTemplate/getInterpolations.ts
1336
- /**
1337
- * Gets the strings and interpolations separately from a template string.
1338
- * You can pass a template string directly by doing:
1339
- *
1340
- * ```typescript
1341
- * getInterpolations`Template string here`.
1342
- * ```
1343
- *
1344
- * @category Tagged Template
1345
- *
1346
- * @param strings - The strings from the template to process.
1347
- * @param interpolations - An array of all interpolations from the template.
1348
- *
1349
- * @returns A tuple where the first item is the strings from the template, and the second is the interpolations.
1350
- */
1351
- function getInterpolations(strings, ...interpolations) {
1352
- return [strings, interpolations];
1353
- }
1354
- var getInterpolations_default = getInterpolations;
1355
-
1356
- //#endregion
1357
- //#region src/functions/taggedTemplate/interpolate.ts
1358
- /**
1359
- * Returns the result of interpolating a template string when given the strings and interpolations separately.
1360
- *
1361
- * You can pass a template string directly by doing:
1362
- *
1363
- * ```
1364
- * interpolate`Template string here`;
1365
- * ```
1366
- *
1367
- * In this case, it will be functionally the same as if you just wrote the template string by itself.
1368
- *
1369
- * @category Tagged Template
1370
- *
1371
- * @param strings - The strings from the template to process.
1372
- * @param interpolations - An array of all interpolations from the template.
1373
- *
1374
- * @returns A new string with the strings and interpolations from the template applied.
1375
- */
1376
- function interpolate(strings, ...interpolations) {
1377
- let result = "";
1378
- for (const [string, interpolation = ""] of paralleliseArrays_default(strings, interpolations)) result += string + interpolation;
1379
- return result;
1380
- }
1381
- var interpolate_default = interpolate;
1382
-
1383
- //#endregion
1384
- //#region src/functions/taggedTemplate/interpolateObjects.ts
1385
- /**
1386
- * Returns the result of interpolating a template string, also stringifying objects.
1387
- *
1388
- * You can pass a template string directly by doing:
1389
- *
1390
- * ```typescript
1391
- * interpolateObjects`Template string here ${{ my: "object" }}`.
1392
- * ```
1393
- *
1394
- * @category Tagged Template
1395
- *
1396
- * @param strings - The strings from the template to process.
1397
- * @param interpolations - An array of all interpolations from the template.
1398
- *
1399
- * @returns A new string with the strings and interpolations from the template applied, with objects stringified.
1400
- */
1401
- function interpolateObjects(strings, ...interpolations) {
1402
- let result = "";
1403
- for (let i = 0; i < strings.length; i++) {
1404
- result += strings[i];
1405
- if (i !== strings.length - 1) result += interpolations[i] && typeof interpolations[i] === "object" ? JSON.stringify(interpolations[i]) : interpolations[i];
1406
- }
1407
- return result;
1408
- }
1409
- var interpolateObjects_default = interpolateObjects;
1410
-
1411
- //#endregion
1412
- //#region src/functions/taggedTemplate/normaliseIndents.ts
1413
- function calculateTabSize(line, whitespaceLength) {
1414
- const potentialWhitespacePart = line.slice(0, whitespaceLength);
1415
- const trimmedString = line.trimStart();
1416
- if (potentialWhitespacePart.trim() !== "") return 0;
1417
- const tabSize = line.length - (trimmedString.length + whitespaceLength);
1418
- return tabSize < 0 ? 0 : tabSize;
1419
- }
1420
- function getWhitespaceLength(lines) {
1421
- const [firstNonEmptyLine] = lines.filter((line) => {
1422
- return line.trim() !== "";
1423
- });
1424
- return firstNonEmptyLine.length - firstNonEmptyLine.trimStart().length;
1425
- }
1426
- function reduceLines(lines, { preserveTabs = true }) {
1427
- const slicedLines = lines.slice(1);
1428
- const isFirstLineEmpty = lines[0].trim() === "";
1429
- const whitespaceLength = getWhitespaceLength(isFirstLineEmpty ? lines : slicedLines);
1430
- return (isFirstLineEmpty ? slicedLines : lines).map((line) => {
1431
- const tabSize = calculateTabSize(line, whitespaceLength);
1432
- return (preserveTabs ? fillArray_default(() => {
1433
- return " ";
1434
- }, tabSize).join("") : "") + line.trimStart();
1435
- }).join("\n");
1436
- }
1437
- /**
1438
- * Applies any options if provided, then removes any extraneous indents from a multi-line template string.
1439
- *
1440
- * You can pass a template string directly by doing:
1441
- *
1442
- * ```typescript
1443
- * normaliseIndents`Template string here
1444
- * with a new line
1445
- * and another new line`.
1446
- * ```
1447
- *
1448
- * You may also pass the options first, then invoke the resulting function with a template string:
1449
- *
1450
- * ```typescript
1451
- * normaliseIndents({ preserveTabs: false })`Template string here
1452
- * with a new line
1453
- * and another new line`.
1454
- * ```
1455
- *
1456
- *@category Tagged Template
1457
- *
1458
- * @param first - The strings from the template to process, or the options to apply.
1459
- * @param args - An array of all interpolations from the template.
1460
- *
1461
- * @returns An additional function to invoke, or a new string with the strings and interpolations from the template applied, and extraneous indents removed.
1462
- */
1463
- function normaliseIndents(first, ...args) {
1464
- if (typeof first === "object" && first !== null && !Array.isArray(first)) {
1465
- const options = first;
1466
- return (strings, ...interpolations) => {
1467
- return normaliseIndents(strings, ...interpolations, options);
1468
- };
1469
- }
1470
- const strings = first;
1471
- const options = typeof args[args.length - 1] === "object" && !Array.isArray(args[args.length - 1]) ? args.pop() : {};
1472
- return reduceLines(interpolate_default(strings, ...[...args]).split("\n"), options);
1473
- }
1474
- /**
1475
- * Applies any options if provided, then removes any extraneous indents from a multi-line template string.
1476
- *
1477
- * You can pass a template string directly by doing:
1478
- *
1479
- * ```typescript
1480
- * normalizeIndents`Template string here
1481
- * with a new line
1482
- * and another new line`.
1483
- * ```
1484
- *
1485
- * You may also pass the options first, then invoke the resulting function with a template string:
1486
- *
1487
- * ```typescript
1488
- * normalizeIndents({ preserveTabs: false })`Template string here
1489
- * with a new line
1490
- * and another new line`.
1491
- * ```
1492
- *
1493
- * @param first - The strings from the template to process, or the options to apply.
1494
- * @param args - An array of all interpolations from the template.
1495
- *
1496
- * @returns An additional function to invoke, or a new string with the strings and interpolations from the template applied, and extraneous indents removed.
1497
- */
1498
- const normalizeIndents = normaliseIndents;
1499
- var normaliseIndents_default = normaliseIndents;
1500
-
1501
1616
  //#endregion
1502
1617
  //#region src/functions/versioning/parseVersion.ts
1503
1618
  /**
@@ -1645,6 +1760,7 @@ exports.randomiseArray = randomiseArray_default;
1645
1760
  exports.range = range_default;
1646
1761
  exports.removeDuplicates = removeDuplicates_default;
1647
1762
  exports.removeUndefinedFromObject = removeUndefinedFromObject_default;
1763
+ exports.sayHello = sayHello_default;
1648
1764
  exports.stringListToArray = stringListToArray_default;
1649
1765
  exports.stringifyDotenv = stringifyDotenv_default;
1650
1766
  exports.truncate = truncate_default;
package/dist/index.d.cts CHANGED
@@ -498,6 +498,16 @@ declare function getRandomNumber(lowerBound: number, upperBound: number): number
498
498
  */
499
499
  declare function isOrdered(array: readonly number[]): boolean;
500
500
  //#endregion
501
+ //#region src/functions/miscellaneous/sayHello.d.ts
502
+ /**
503
+ * Returns a string representing the lyrics to the package's theme song, Commit To You
504
+ *
505
+ * [Pls listen!](https://www.youtube.com/watch?v=mH-Sg-8EnxM)
506
+ *
507
+ * @returns The lyrics string in markdown format.
508
+ */
509
+ declare function sayHello(): string;
510
+ //#endregion
501
511
  //#region src/functions/miscellaneous/stringifyDotenv.d.ts
502
512
  type QuoteStyle = "double" | "single" | "none";
503
513
  interface StringifyDotenvOptions {
@@ -1162,4 +1172,4 @@ interface ParseVersionOptions {
1162
1172
  */
1163
1173
  declare function parseVersion(input: string, options?: ParseVersionOptions): string;
1164
1174
  //#endregion
1165
- export { APIError, ArrayElement, CallReturnType, CamelToKebabOptions, CreateEnumType, CreateFormDataOptions, CreateFormDataOptionsNullableResolution, CreateFormDataOptionsUndefinedOrNullResolution, DataError, DisallowUndefined, Env, FILE_PATH_REGEX, FormDataArrayResolutionStrategy, FormDataNullableResolutionStrategy, HTTPErrorCode, IgnoreCase, IncrementVersionOptions, KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, OptionalOnCondition, ParallelTuple, ParseVersionOptions, PublicAndPrivateKey, RecordKey, RemoveUndefined, StringListToArrayOptions, VERSION_NUMBER_REGEX, VersionNumber, VersionNumberToStringOptions, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, determineVersionType, encryptWithKey, fillArray, formatDateAndTime, getIndividualVersionNumbers, getInterpolations, getPublicAndPrivateKey, getRandomNumber, getRecordKeys, httpErrorCodeLookup, incrementVersion, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFilePath, parseFormData, parseIntStrict, parseVersion, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, stringListToArray, stringifyDotenv, truncate, wait };
1175
+ export { APIError, ArrayElement, CallReturnType, CamelToKebabOptions, CreateEnumType, CreateFormDataOptions, CreateFormDataOptionsNullableResolution, CreateFormDataOptionsUndefinedOrNullResolution, DataError, DisallowUndefined, Env, FILE_PATH_REGEX, FormDataArrayResolutionStrategy, FormDataNullableResolutionStrategy, HTTPErrorCode, IgnoreCase, IncrementVersionOptions, KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, OptionalOnCondition, ParallelTuple, ParseVersionOptions, PublicAndPrivateKey, RecordKey, RemoveUndefined, StringListToArrayOptions, VERSION_NUMBER_REGEX, VersionNumber, VersionNumberToStringOptions, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, determineVersionType, encryptWithKey, fillArray, formatDateAndTime, getIndividualVersionNumbers, getInterpolations, getPublicAndPrivateKey, getRandomNumber, getRecordKeys, httpErrorCodeLookup, incrementVersion, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFilePath, parseFormData, parseIntStrict, parseVersion, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, stringListToArray, stringifyDotenv, truncate, wait };
package/dist/index.d.ts CHANGED
@@ -498,6 +498,16 @@ declare function getRandomNumber(lowerBound: number, upperBound: number): number
498
498
  */
499
499
  declare function isOrdered(array: readonly number[]): boolean;
500
500
  //#endregion
501
+ //#region src/functions/miscellaneous/sayHello.d.ts
502
+ /**
503
+ * Returns a string representing the lyrics to the package's theme song, Commit To You
504
+ *
505
+ * [Pls listen!](https://www.youtube.com/watch?v=mH-Sg-8EnxM)
506
+ *
507
+ * @returns The lyrics string in markdown format.
508
+ */
509
+ declare function sayHello(): string;
510
+ //#endregion
501
511
  //#region src/functions/miscellaneous/stringifyDotenv.d.ts
502
512
  type QuoteStyle = "double" | "single" | "none";
503
513
  interface StringifyDotenvOptions {
@@ -1162,4 +1172,4 @@ interface ParseVersionOptions {
1162
1172
  */
1163
1173
  declare function parseVersion(input: string, options?: ParseVersionOptions): string;
1164
1174
  //#endregion
1165
- export { APIError, ArrayElement, CallReturnType, CamelToKebabOptions, CreateEnumType, CreateFormDataOptions, CreateFormDataOptionsNullableResolution, CreateFormDataOptionsUndefinedOrNullResolution, DataError, DisallowUndefined, Env, FILE_PATH_REGEX, FormDataArrayResolutionStrategy, FormDataNullableResolutionStrategy, HTTPErrorCode, IgnoreCase, type IncrementVersionOptions, KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, OptionalOnCondition, ParallelTuple, type ParseVersionOptions, type PublicAndPrivateKey, RecordKey, RemoveUndefined, StringListToArrayOptions, VERSION_NUMBER_REGEX, VersionNumber, VersionNumberToStringOptions, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, determineVersionType, encryptWithKey, fillArray, formatDateAndTime, getIndividualVersionNumbers, getInterpolations, getPublicAndPrivateKey, getRandomNumber, getRecordKeys, httpErrorCodeLookup, incrementVersion, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFilePath, parseFormData, parseIntStrict, parseVersion, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, stringListToArray, stringifyDotenv, truncate, wait };
1175
+ export { APIError, ArrayElement, CallReturnType, CamelToKebabOptions, CreateEnumType, CreateFormDataOptions, CreateFormDataOptionsNullableResolution, CreateFormDataOptionsUndefinedOrNullResolution, DataError, DisallowUndefined, Env, FILE_PATH_REGEX, FormDataArrayResolutionStrategy, FormDataNullableResolutionStrategy, HTTPErrorCode, IgnoreCase, type IncrementVersionOptions, KebabToCamelOptions, NAMESPACE_EXPORT_REGEX, NonUndefined, NormaliseIndentsFunction, NormaliseIndentsOptions, NormalizeIndentsFunction, NormalizeIndentsOptions, OptionalOnCondition, ParallelTuple, type ParseVersionOptions, type PublicAndPrivateKey, RecordKey, RemoveUndefined, StringListToArrayOptions, VERSION_NUMBER_REGEX, VersionNumber, VersionNumberToStringOptions, VersionType, addDaysToDate, appendSemicolon, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, determineVersionType, encryptWithKey, fillArray, formatDateAndTime, getIndividualVersionNumbers, getInterpolations, getPublicAndPrivateKey, getRandomNumber, getRecordKeys, httpErrorCodeLookup, incrementVersion, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, kebabToCamel, normaliseImportPath, normaliseIndents, normalizeImportPath, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFilePath, parseFormData, parseIntStrict, parseVersion, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, stringListToArray, stringifyDotenv, truncate, wait };
package/dist/index.js CHANGED
@@ -683,6 +683,329 @@ function isOrdered(array) {
683
683
  }
684
684
  var isOrdered_default = isOrdered;
685
685
 
686
+ //#endregion
687
+ //#region src/functions/recursive/deepFreeze.ts
688
+ /**
689
+ * Deeply freezes an object or array such that all child objects/arrays are also frozen.
690
+ *
691
+ * Note that this will also freeze the input itself as well.
692
+ * If the intent is to create a newly frozen object with a different reference in memory, pass your object through deepCopy first before passing to deepFreeze.
693
+ *
694
+ * @category Recursive
695
+ *
696
+ * @template ObjectType - The type of the input object.
697
+ *
698
+ * @param object - The object to freeze. May also be an array.
699
+ *
700
+ * @returns The input object completely frozen.
701
+ */
702
+ function deepFreeze(object) {
703
+ for (const value of Object.values(object)) {
704
+ if (typeof value === "function") continue;
705
+ if (value && typeof value === "object") deepFreeze(value);
706
+ }
707
+ return Object.freeze(object);
708
+ }
709
+ var deepFreeze_default = deepFreeze;
710
+
711
+ //#endregion
712
+ //#region src/functions/taggedTemplate/createTemplateStringsArray.ts
713
+ /**
714
+ * Creates a template strings array given a regular array of strings
715
+ *
716
+ * @category Tagged Template
717
+ *
718
+ * @param strings - The array of strings.
719
+ *
720
+ * @returns A template strings array that can be passed as the first argument of any tagged template function.
721
+ */
722
+ function createTemplateStringsArray(strings) {
723
+ return deepFreeze_default(Object.assign([...strings], { raw: [...strings] }));
724
+ }
725
+ var createTemplateStringsArray_default = createTemplateStringsArray;
726
+
727
+ //#endregion
728
+ //#region src/functions/taggedTemplate/getInterpolations.ts
729
+ /**
730
+ * Gets the strings and interpolations separately from a template string.
731
+ * You can pass a template string directly by doing:
732
+ *
733
+ * ```typescript
734
+ * getInterpolations`Template string here`.
735
+ * ```
736
+ *
737
+ * @category Tagged Template
738
+ *
739
+ * @param strings - The strings from the template to process.
740
+ * @param interpolations - An array of all interpolations from the template.
741
+ *
742
+ * @returns A tuple where the first item is the strings from the template, and the second is the interpolations.
743
+ */
744
+ function getInterpolations(strings, ...interpolations) {
745
+ return [strings, interpolations];
746
+ }
747
+ var getInterpolations_default = getInterpolations;
748
+
749
+ //#endregion
750
+ //#region src/functions/taggedTemplate/interpolate.ts
751
+ /**
752
+ * Returns the result of interpolating a template string when given the strings and interpolations separately.
753
+ *
754
+ * You can pass a template string directly by doing:
755
+ *
756
+ * ```
757
+ * interpolate`Template string here`;
758
+ * ```
759
+ *
760
+ * In this case, it will be functionally the same as if you just wrote the template string by itself.
761
+ *
762
+ * @category Tagged Template
763
+ *
764
+ * @param strings - The strings from the template to process.
765
+ * @param interpolations - An array of all interpolations from the template.
766
+ *
767
+ * @returns A new string with the strings and interpolations from the template applied.
768
+ */
769
+ function interpolate(strings, ...interpolations) {
770
+ let result = "";
771
+ for (const [string, interpolation = ""] of paralleliseArrays_default(strings, interpolations)) result += string + interpolation;
772
+ return result;
773
+ }
774
+ var interpolate_default = interpolate;
775
+
776
+ //#endregion
777
+ //#region src/functions/taggedTemplate/interpolateObjects.ts
778
+ /**
779
+ * Returns the result of interpolating a template string, also stringifying objects.
780
+ *
781
+ * You can pass a template string directly by doing:
782
+ *
783
+ * ```typescript
784
+ * interpolateObjects`Template string here ${{ my: "object" }}`.
785
+ * ```
786
+ *
787
+ * @category Tagged Template
788
+ *
789
+ * @param strings - The strings from the template to process.
790
+ * @param interpolations - An array of all interpolations from the template.
791
+ *
792
+ * @returns A new string with the strings and interpolations from the template applied, with objects stringified.
793
+ */
794
+ function interpolateObjects(strings, ...interpolations) {
795
+ let result = "";
796
+ for (let i = 0; i < strings.length; i++) {
797
+ result += strings[i];
798
+ if (i !== strings.length - 1) result += interpolations[i] && typeof interpolations[i] === "object" ? JSON.stringify(interpolations[i]) : interpolations[i];
799
+ }
800
+ return result;
801
+ }
802
+ var interpolateObjects_default = interpolateObjects;
803
+
804
+ //#endregion
805
+ //#region src/functions/taggedTemplate/normaliseIndents.ts
806
+ function calculateTabSize(line, whitespaceLength) {
807
+ const potentialWhitespacePart = line.slice(0, whitespaceLength);
808
+ const trimmedString = line.trimStart();
809
+ if (potentialWhitespacePart.trim() !== "") return 0;
810
+ const tabSize = line.length - (trimmedString.length + whitespaceLength);
811
+ return tabSize < 0 ? 0 : tabSize;
812
+ }
813
+ function getWhitespaceLength(lines) {
814
+ const [firstNonEmptyLine] = lines.filter((line) => {
815
+ return line.trim() !== "";
816
+ });
817
+ return firstNonEmptyLine.length - firstNonEmptyLine.trimStart().length;
818
+ }
819
+ function reduceLines(lines, { preserveTabs = true }) {
820
+ const slicedLines = lines.slice(1);
821
+ const isFirstLineEmpty = lines[0].trim() === "";
822
+ const whitespaceLength = getWhitespaceLength(isFirstLineEmpty ? lines : slicedLines);
823
+ return (isFirstLineEmpty ? slicedLines : lines).map((line) => {
824
+ const tabSize = calculateTabSize(line, whitespaceLength);
825
+ return (preserveTabs ? fillArray_default(() => {
826
+ return " ";
827
+ }, tabSize).join("") : "") + line.trimStart();
828
+ }).join("\n");
829
+ }
830
+ /**
831
+ * Applies any options if provided, then removes any extraneous indents from a multi-line template string.
832
+ *
833
+ * You can pass a template string directly by doing:
834
+ *
835
+ * ```typescript
836
+ * normaliseIndents`Template string here
837
+ * with a new line
838
+ * and another new line`.
839
+ * ```
840
+ *
841
+ * You may also pass the options first, then invoke the resulting function with a template string:
842
+ *
843
+ * ```typescript
844
+ * normaliseIndents({ preserveTabs: false })`Template string here
845
+ * with a new line
846
+ * and another new line`.
847
+ * ```
848
+ *
849
+ *@category Tagged Template
850
+ *
851
+ * @param first - The strings from the template to process, or the options to apply.
852
+ * @param args - An array of all interpolations from the template.
853
+ *
854
+ * @returns An additional function to invoke, or a new string with the strings and interpolations from the template applied, and extraneous indents removed.
855
+ */
856
+ function normaliseIndents(first, ...args) {
857
+ if (typeof first === "object" && first !== null && !Array.isArray(first)) {
858
+ const options = first;
859
+ return (strings, ...interpolations) => {
860
+ return normaliseIndents(strings, ...interpolations, options);
861
+ };
862
+ }
863
+ const strings = first;
864
+ const options = typeof args[args.length - 1] === "object" && !Array.isArray(args[args.length - 1]) ? args.pop() : {};
865
+ return reduceLines(interpolate_default(strings, ...[...args]).split("\n"), options);
866
+ }
867
+ /**
868
+ * Applies any options if provided, then removes any extraneous indents from a multi-line template string.
869
+ *
870
+ * You can pass a template string directly by doing:
871
+ *
872
+ * ```typescript
873
+ * normalizeIndents`Template string here
874
+ * with a new line
875
+ * and another new line`.
876
+ * ```
877
+ *
878
+ * You may also pass the options first, then invoke the resulting function with a template string:
879
+ *
880
+ * ```typescript
881
+ * normalizeIndents({ preserveTabs: false })`Template string here
882
+ * with a new line
883
+ * and another new line`.
884
+ * ```
885
+ *
886
+ * @param first - The strings from the template to process, or the options to apply.
887
+ * @param args - An array of all interpolations from the template.
888
+ *
889
+ * @returns An additional function to invoke, or a new string with the strings and interpolations from the template applied, and extraneous indents removed.
890
+ */
891
+ const normalizeIndents = normaliseIndents;
892
+ var normaliseIndents_default = normaliseIndents;
893
+
894
+ //#endregion
895
+ //#region src/functions/miscellaneous/sayHello.ts
896
+ /**
897
+ * Returns a string representing the lyrics to the package's theme song, Commit To You
898
+ *
899
+ * [Pls listen!](https://www.youtube.com/watch?v=mH-Sg-8EnxM)
900
+ *
901
+ * @returns The lyrics string in markdown format.
902
+ */
903
+ function sayHello() {
904
+ return normaliseIndents_default`
905
+ # Commit To You
906
+
907
+ ### Verse 1
908
+
909
+ I know you've been checking me out,
910
+ Shall we take it to the next level now?
911
+ 'Cause I really wanna be there all for you,
912
+ All for you!
913
+ Come on now, let's make a fresh start!
914
+ Pin my number, then you can take me out!
915
+ Can't you see I really do care about you,
916
+ About you!
917
+
918
+ ### Pre-chorus 1
919
+ Although our calendars are imperfect, at best,
920
+ I'd like to organise time with you! (with you!).
921
+ Just tell me when and I'll make it clear,
922
+ All clear for you,
923
+ All clear for you!
924
+ (One, two, three, go!)
925
+
926
+ ### Chorus
927
+ I wanna be of utility, I'll help you on the run!
928
+ I'll be the one here in the back, while you go have some fun!
929
+ Looking out for you tonight, I'll be the one you can rely on!
930
+ Watch you go and watch me pass by,
931
+ I'll be here!
932
+ I'll commit to you!
933
+
934
+ ### Verse 2
935
+ Though sometimes it won't be easy,
936
+ You'll be here to bring out the best in me,
937
+ And I'll hold myself to high standards for you!
938
+ All for you!
939
+ We'll grow as a pair, you and me,
940
+ We'll build up a healthy dependency,
941
+ You can build with me and I'll develop with you!
942
+ I'm with you!
943
+
944
+ ### Pre-chorus 2
945
+ I'll be with you when you're up or you're down,
946
+ We'll deal with all our problems together (together!)
947
+ Just tell me what you want, I'll make it clear,
948
+ All clear for you,
949
+ All clear for you!
950
+ (One, three, one, go!)
951
+
952
+ ### Chorus
953
+ I wanna be of utility, I'll help you on the run!
954
+ (help you on the run!)
955
+ I'll be the one here in the back, while you go have some fun!
956
+ (you go have some fun!)
957
+ Looking out for you tonight, I'll be the one you can rely on!
958
+ Watch you go and watch me pass by,
959
+ I'll be here!
960
+ I'll commit to you!
961
+
962
+ ### Bridge
963
+ Looking into our stack!
964
+ I'll commit to you!
965
+ We've got a lot to unpack!
966
+ I'll commit to you!
967
+ The environment that we're in!
968
+ I'll commit to you!
969
+ Delicate as a string!
970
+ I'll commit to you!
971
+
972
+ But I think you're my type!
973
+ I'll commit to you!
974
+ Oh, this feels all so right!
975
+ I'll commit to you!
976
+ Nothing stopping us now!
977
+ I'll commit to you!
978
+ Let's show them what we're about!
979
+ Two, three, four, go!
980
+
981
+ ### Final Chorus
982
+ I wanna be of utility, I'll help you on the run!
983
+ (help you on the run!)
984
+ I'll be the one here in the back, while you go have some fun!
985
+ (you go have some fun!)
986
+ Looking out for you tonight, I'll be the one you can rely on!
987
+ Watch you go and watch me pass by,
988
+ I'll be here!
989
+ I'll commit to you!
990
+
991
+ I wanna be of utility, I'll help you on the run!
992
+ (I'll commit to you!)
993
+ I'll be the one here in the back, while you go have some fun!
994
+ (I'll commit to you!)
995
+ Looking out for you tonight, I'll be the one you can rely on!
996
+ (I'll commit to you!)
997
+ Watch you go and watch me pass by,
998
+ (I'll commit to you!)
999
+ I'll be here!
1000
+
1001
+ ### Outro
1002
+ I'll commit to you!
1003
+ I'll commit to you!
1004
+ I'll commit to you!
1005
+ `;
1006
+ }
1007
+ var sayHello_default = sayHello;
1008
+
686
1009
  //#endregion
687
1010
  //#region src/functions/miscellaneous/stringifyDotenv.ts
688
1011
  /**
@@ -1056,31 +1379,6 @@ function deepCopy(object) {
1056
1379
  }
1057
1380
  var deepCopy_default = deepCopy;
1058
1381
 
1059
- //#endregion
1060
- //#region src/functions/recursive/deepFreeze.ts
1061
- /**
1062
- * Deeply freezes an object or array such that all child objects/arrays are also frozen.
1063
- *
1064
- * Note that this will also freeze the input itself as well.
1065
- * If the intent is to create a newly frozen object with a different reference in memory, pass your object through deepCopy first before passing to deepFreeze.
1066
- *
1067
- * @category Recursive
1068
- *
1069
- * @template ObjectType - The type of the input object.
1070
- *
1071
- * @param object - The object to freeze. May also be an array.
1072
- *
1073
- * @returns The input object completely frozen.
1074
- */
1075
- function deepFreeze(object) {
1076
- for (const value of Object.values(object)) {
1077
- if (typeof value === "function") continue;
1078
- if (value && typeof value === "object") deepFreeze(value);
1079
- }
1080
- return Object.freeze(object);
1081
- }
1082
- var deepFreeze_default = deepFreeze;
1083
-
1084
1382
  //#endregion
1085
1383
  //#region src/functions/security/encryptWithKey.ts
1086
1384
  /**
@@ -1285,189 +1583,6 @@ function truncate(stringToTruncate, maxLength = 5) {
1285
1583
  }
1286
1584
  var truncate_default = truncate;
1287
1585
 
1288
- //#endregion
1289
- //#region src/functions/taggedTemplate/createTemplateStringsArray.ts
1290
- /**
1291
- * Creates a template strings array given a regular array of strings
1292
- *
1293
- * @category Tagged Template
1294
- *
1295
- * @param strings - The array of strings.
1296
- *
1297
- * @returns A template strings array that can be passed as the first argument of any tagged template function.
1298
- */
1299
- function createTemplateStringsArray(strings) {
1300
- return deepFreeze_default(Object.assign([...strings], { raw: [...strings] }));
1301
- }
1302
- var createTemplateStringsArray_default = createTemplateStringsArray;
1303
-
1304
- //#endregion
1305
- //#region src/functions/taggedTemplate/getInterpolations.ts
1306
- /**
1307
- * Gets the strings and interpolations separately from a template string.
1308
- * You can pass a template string directly by doing:
1309
- *
1310
- * ```typescript
1311
- * getInterpolations`Template string here`.
1312
- * ```
1313
- *
1314
- * @category Tagged Template
1315
- *
1316
- * @param strings - The strings from the template to process.
1317
- * @param interpolations - An array of all interpolations from the template.
1318
- *
1319
- * @returns A tuple where the first item is the strings from the template, and the second is the interpolations.
1320
- */
1321
- function getInterpolations(strings, ...interpolations) {
1322
- return [strings, interpolations];
1323
- }
1324
- var getInterpolations_default = getInterpolations;
1325
-
1326
- //#endregion
1327
- //#region src/functions/taggedTemplate/interpolate.ts
1328
- /**
1329
- * Returns the result of interpolating a template string when given the strings and interpolations separately.
1330
- *
1331
- * You can pass a template string directly by doing:
1332
- *
1333
- * ```
1334
- * interpolate`Template string here`;
1335
- * ```
1336
- *
1337
- * In this case, it will be functionally the same as if you just wrote the template string by itself.
1338
- *
1339
- * @category Tagged Template
1340
- *
1341
- * @param strings - The strings from the template to process.
1342
- * @param interpolations - An array of all interpolations from the template.
1343
- *
1344
- * @returns A new string with the strings and interpolations from the template applied.
1345
- */
1346
- function interpolate(strings, ...interpolations) {
1347
- let result = "";
1348
- for (const [string, interpolation = ""] of paralleliseArrays_default(strings, interpolations)) result += string + interpolation;
1349
- return result;
1350
- }
1351
- var interpolate_default = interpolate;
1352
-
1353
- //#endregion
1354
- //#region src/functions/taggedTemplate/interpolateObjects.ts
1355
- /**
1356
- * Returns the result of interpolating a template string, also stringifying objects.
1357
- *
1358
- * You can pass a template string directly by doing:
1359
- *
1360
- * ```typescript
1361
- * interpolateObjects`Template string here ${{ my: "object" }}`.
1362
- * ```
1363
- *
1364
- * @category Tagged Template
1365
- *
1366
- * @param strings - The strings from the template to process.
1367
- * @param interpolations - An array of all interpolations from the template.
1368
- *
1369
- * @returns A new string with the strings and interpolations from the template applied, with objects stringified.
1370
- */
1371
- function interpolateObjects(strings, ...interpolations) {
1372
- let result = "";
1373
- for (let i = 0; i < strings.length; i++) {
1374
- result += strings[i];
1375
- if (i !== strings.length - 1) result += interpolations[i] && typeof interpolations[i] === "object" ? JSON.stringify(interpolations[i]) : interpolations[i];
1376
- }
1377
- return result;
1378
- }
1379
- var interpolateObjects_default = interpolateObjects;
1380
-
1381
- //#endregion
1382
- //#region src/functions/taggedTemplate/normaliseIndents.ts
1383
- function calculateTabSize(line, whitespaceLength) {
1384
- const potentialWhitespacePart = line.slice(0, whitespaceLength);
1385
- const trimmedString = line.trimStart();
1386
- if (potentialWhitespacePart.trim() !== "") return 0;
1387
- const tabSize = line.length - (trimmedString.length + whitespaceLength);
1388
- return tabSize < 0 ? 0 : tabSize;
1389
- }
1390
- function getWhitespaceLength(lines) {
1391
- const [firstNonEmptyLine] = lines.filter((line) => {
1392
- return line.trim() !== "";
1393
- });
1394
- return firstNonEmptyLine.length - firstNonEmptyLine.trimStart().length;
1395
- }
1396
- function reduceLines(lines, { preserveTabs = true }) {
1397
- const slicedLines = lines.slice(1);
1398
- const isFirstLineEmpty = lines[0].trim() === "";
1399
- const whitespaceLength = getWhitespaceLength(isFirstLineEmpty ? lines : slicedLines);
1400
- return (isFirstLineEmpty ? slicedLines : lines).map((line) => {
1401
- const tabSize = calculateTabSize(line, whitespaceLength);
1402
- return (preserveTabs ? fillArray_default(() => {
1403
- return " ";
1404
- }, tabSize).join("") : "") + line.trimStart();
1405
- }).join("\n");
1406
- }
1407
- /**
1408
- * Applies any options if provided, then removes any extraneous indents from a multi-line template string.
1409
- *
1410
- * You can pass a template string directly by doing:
1411
- *
1412
- * ```typescript
1413
- * normaliseIndents`Template string here
1414
- * with a new line
1415
- * and another new line`.
1416
- * ```
1417
- *
1418
- * You may also pass the options first, then invoke the resulting function with a template string:
1419
- *
1420
- * ```typescript
1421
- * normaliseIndents({ preserveTabs: false })`Template string here
1422
- * with a new line
1423
- * and another new line`.
1424
- * ```
1425
- *
1426
- *@category Tagged Template
1427
- *
1428
- * @param first - The strings from the template to process, or the options to apply.
1429
- * @param args - An array of all interpolations from the template.
1430
- *
1431
- * @returns An additional function to invoke, or a new string with the strings and interpolations from the template applied, and extraneous indents removed.
1432
- */
1433
- function normaliseIndents(first, ...args) {
1434
- if (typeof first === "object" && first !== null && !Array.isArray(first)) {
1435
- const options = first;
1436
- return (strings, ...interpolations) => {
1437
- return normaliseIndents(strings, ...interpolations, options);
1438
- };
1439
- }
1440
- const strings = first;
1441
- const options = typeof args[args.length - 1] === "object" && !Array.isArray(args[args.length - 1]) ? args.pop() : {};
1442
- return reduceLines(interpolate_default(strings, ...[...args]).split("\n"), options);
1443
- }
1444
- /**
1445
- * Applies any options if provided, then removes any extraneous indents from a multi-line template string.
1446
- *
1447
- * You can pass a template string directly by doing:
1448
- *
1449
- * ```typescript
1450
- * normalizeIndents`Template string here
1451
- * with a new line
1452
- * and another new line`.
1453
- * ```
1454
- *
1455
- * You may also pass the options first, then invoke the resulting function with a template string:
1456
- *
1457
- * ```typescript
1458
- * normalizeIndents({ preserveTabs: false })`Template string here
1459
- * with a new line
1460
- * and another new line`.
1461
- * ```
1462
- *
1463
- * @param first - The strings from the template to process, or the options to apply.
1464
- * @param args - An array of all interpolations from the template.
1465
- *
1466
- * @returns An additional function to invoke, or a new string with the strings and interpolations from the template applied, and extraneous indents removed.
1467
- */
1468
- const normalizeIndents = normaliseIndents;
1469
- var normaliseIndents_default = normaliseIndents;
1470
-
1471
1586
  //#endregion
1472
1587
  //#region src/functions/versioning/parseVersion.ts
1473
1588
  /**
@@ -1561,4 +1676,4 @@ function incrementVersion(version, incrementType, options) {
1561
1676
  var incrementVersion_default = incrementVersion;
1562
1677
 
1563
1678
  //#endregion
1564
- export { APIError_default as APIError, DataError_default as DataError, Env, FILE_PATH_REGEX_default as FILE_PATH_REGEX, 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, encryptWithKey_default as encryptWithKey, fillArray_default as fillArray, formatDateAndTime_default as formatDateAndTime, getIndividualVersionNumbers_default as getIndividualVersionNumbers, getInterpolations_default as getInterpolations, getPublicAndPrivateKey_default as getPublicAndPrivateKey, 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, parseFilePath_default as parseFilePath, parseFormData_default as parseFormData, parseIntStrict_default as parseIntStrict, parseVersion_default as parseVersion, parseVersionType_default as parseVersionType, parseZodSchema_default as parseZodSchema, parseZodSchemaAsync_default as parseZodSchemaAsync, randomiseArray_default as randomiseArray, range_default as range, removeDuplicates_default as removeDuplicates, removeUndefinedFromObject_default as removeUndefinedFromObject, stringListToArray_default as stringListToArray, stringifyDotenv_default as stringifyDotenv, truncate_default as truncate, wait_default as wait };
1679
+ export { APIError_default as APIError, DataError_default as DataError, Env, FILE_PATH_REGEX_default as FILE_PATH_REGEX, 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, encryptWithKey_default as encryptWithKey, fillArray_default as fillArray, formatDateAndTime_default as formatDateAndTime, getIndividualVersionNumbers_default as getIndividualVersionNumbers, getInterpolations_default as getInterpolations, getPublicAndPrivateKey_default as getPublicAndPrivateKey, 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, parseFilePath_default as parseFilePath, parseFormData_default as parseFormData, parseIntStrict_default as parseIntStrict, parseVersion_default as parseVersion, parseVersionType_default as parseVersionType, parseZodSchema_default as parseZodSchema, parseZodSchemaAsync_default as parseZodSchemaAsync, randomiseArray_default as randomiseArray, range_default as range, removeDuplicates_default as removeDuplicates, removeUndefinedFromObject_default as removeUndefinedFromObject, sayHello_default as sayHello, stringListToArray_default as stringListToArray, stringifyDotenv_default as stringifyDotenv, 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.12.3",
3
+ "version": "4.13.0",
4
4
  "description": "Helpful utility functions.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,10 +27,12 @@
27
27
  "alex-c-line": "^1.22.1",
28
28
  "dotenv-cli": "^11.0.0",
29
29
  "eslint": "^9.39.2",
30
+ "execa": "^9.6.1",
30
31
  "globals": "^17.2.0",
31
32
  "husky": "^9.1.7",
32
33
  "jsdom": "^27.4.0",
33
34
  "prettier": "^3.8.1",
35
+ "tempy": "^3.2.0",
34
36
  "tsdown": "^0.20.1",
35
37
  "typedoc": "^0.28.16",
36
38
  "typescript": "^5.9.3",
@@ -38,7 +40,7 @@
38
40
  "vitest": "^4.0.18"
39
41
  },
40
42
  "engines": {
41
- "node": ">=22.0.0"
43
+ "node": ">=22.3.0"
42
44
  },
43
45
  "scripts": {
44
46
  "build": "tsdown",