@alextheman/utility 5.19.2 → 5.21.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 +165 -55
- package/dist/index.d.cts +266 -188
- package/dist/index.d.ts +266 -188
- package/dist/index.js +160 -56
- package/dist/internal/index.cjs +98 -47
- package/dist/internal/index.js +98 -47
- package/dist/node/index.cjs +55 -4
- package/dist/node/index.js +55 -4
- package/dist/v6/index.cjs +60 -5
- package/dist/v6/index.js +60 -5
- package/package.json +12 -12
package/dist/index.d.cts
CHANGED
|
@@ -402,6 +402,18 @@ declare function createFormData<DataType extends Record<PropertyKey, unknown>>(d
|
|
|
402
402
|
*/
|
|
403
403
|
declare function getRandomNumber(lowerBound: number, upperBound: number): number;
|
|
404
404
|
//#endregion
|
|
405
|
+
//#region src/root/functions/miscellaneous/identity.d.ts
|
|
406
|
+
/**
|
|
407
|
+
* Gives back the original input.
|
|
408
|
+
*
|
|
409
|
+
* @template InputType - The input type.
|
|
410
|
+
*
|
|
411
|
+
* @param input - The input value.
|
|
412
|
+
*
|
|
413
|
+
* @returns The original input value.
|
|
414
|
+
*/
|
|
415
|
+
declare function identity<InputType>(input: InputType): InputType;
|
|
416
|
+
//#endregion
|
|
405
417
|
//#region src/root/functions/miscellaneous/isOrdered.d.ts
|
|
406
418
|
/**
|
|
407
419
|
* Checks to see if the given array is sorted in ascending order.
|
|
@@ -424,6 +436,215 @@ declare function isOrdered(array: ReadonlyArray<number>): boolean;
|
|
|
424
436
|
*/
|
|
425
437
|
declare function sayHello(): string;
|
|
426
438
|
//#endregion
|
|
439
|
+
//#region src/root/types/CreateEnumType.d.ts
|
|
440
|
+
/**
|
|
441
|
+
* Get the value types from a const object so the object can behave similarly to an enum.
|
|
442
|
+
*
|
|
443
|
+
* @category Types
|
|
444
|
+
*
|
|
445
|
+
* @template ObjectType - The type of the object to get the value types for.
|
|
446
|
+
*/
|
|
447
|
+
type CreateEnumType<ObjectType extends Record<PropertyKey, unknown>> = ObjectType[keyof ObjectType];
|
|
448
|
+
//#endregion
|
|
449
|
+
//#region src/root/types/SortDirection.d.ts
|
|
450
|
+
declare const SortDirection: {
|
|
451
|
+
readonly DESC: "desc";
|
|
452
|
+
readonly ASC: "asc";
|
|
453
|
+
};
|
|
454
|
+
type SortDirection = CreateEnumType<typeof SortDirection>;
|
|
455
|
+
//#endregion
|
|
456
|
+
//#region src/root/types/VersionNumber.d.ts
|
|
457
|
+
/**
|
|
458
|
+
* Options to apply to the stringification of the version number.
|
|
459
|
+
*
|
|
460
|
+
* @category Class Options
|
|
461
|
+
*/
|
|
462
|
+
interface FormatOptionsBase {
|
|
463
|
+
/** Whether you want to omit the "v" prefix or not (defaults to false). */
|
|
464
|
+
omitPrefix?: boolean;
|
|
465
|
+
}
|
|
466
|
+
interface FormatOptionsIncludeMinor extends FormatOptionsBase {
|
|
467
|
+
/** Whether you want to omit the minor version or not */
|
|
468
|
+
omitMinor?: false;
|
|
469
|
+
/** Whether you want to omit the patch version or not */
|
|
470
|
+
omitPatch?: boolean;
|
|
471
|
+
}
|
|
472
|
+
interface FormatOptionsOmitMinor extends FormatOptionsBase {
|
|
473
|
+
/** Whether you want to omit the minor version or not */
|
|
474
|
+
omitMinor?: true;
|
|
475
|
+
/** Whether you want to omit the patch version or not */
|
|
476
|
+
omitPatch?: never;
|
|
477
|
+
}
|
|
478
|
+
type FormatStringOptions = FormatOptionsIncludeMinor | FormatOptionsOmitMinor;
|
|
479
|
+
/**
|
|
480
|
+
* Represents a software version number, considered to be made up of a major, minor, and patch part.
|
|
481
|
+
*
|
|
482
|
+
* @category Types
|
|
483
|
+
*/
|
|
484
|
+
declare class VersionNumber {
|
|
485
|
+
private static readonly NON_NEGATIVE_TUPLE_ERROR;
|
|
486
|
+
/** The major number. Increments when a feature is removed or changed in a way that is not backwards-compatible with the previous release. */
|
|
487
|
+
readonly major: number;
|
|
488
|
+
/** The minor number. Increments when a new feature is added/deprecated and is expected to be backwards-compatible with the previous release. */
|
|
489
|
+
readonly minor: number;
|
|
490
|
+
/** The patch number. Increments when the next release is fixing a bug or doing a small refactor that should not be noticeable in practice. */
|
|
491
|
+
readonly patch: number;
|
|
492
|
+
/**
|
|
493
|
+
* @param input - The input to create a new instance of `VersionNumber` from.
|
|
494
|
+
*/
|
|
495
|
+
constructor(input: string | [number, number, number] | VersionNumber);
|
|
496
|
+
/**
|
|
497
|
+
* Gets the current version type of the current instance of `VersionNumber`.
|
|
498
|
+
*
|
|
499
|
+
* @returns Either `"major"`, `"minor"`, or `"patch"`, depending on the version type.
|
|
500
|
+
*/
|
|
501
|
+
get type(): VersionType;
|
|
502
|
+
private static formatString;
|
|
503
|
+
/**
|
|
504
|
+
* Checks if the provided version numbers have the exact same major, minor, and patch numbers.
|
|
505
|
+
*
|
|
506
|
+
* @param firstVersion - The first version number to compare.
|
|
507
|
+
* @param secondVersion - The second version number to compare.
|
|
508
|
+
*
|
|
509
|
+
* @returns `true` if the provided version numbers have exactly the same major, minor, and patch numbers, and returns `false` otherwise.
|
|
510
|
+
*/
|
|
511
|
+
static isEqual(firstVersion: VersionNumber, secondVersion: VersionNumber): boolean;
|
|
512
|
+
/**
|
|
513
|
+
* Get a formatted string representation of the current version number
|
|
514
|
+
*
|
|
515
|
+
* @param options - Options to apply to the string formatting.
|
|
516
|
+
*
|
|
517
|
+
* @returns A formatted string representation of the current version number with the options applied.
|
|
518
|
+
*/
|
|
519
|
+
format(options?: FormatStringOptions): string;
|
|
520
|
+
/**
|
|
521
|
+
* Increments the current version number by the given increment type, returning the result as a new reference in memory.
|
|
522
|
+
*
|
|
523
|
+
* @param incrementType - The type of increment. Can be one of the following:
|
|
524
|
+
* - `"major"`: Change the major version `v1.2.3` → `v2.0.0`
|
|
525
|
+
* - `"minor"`: Change the minor version `v1.2.3` → `v1.3.0`
|
|
526
|
+
* - `"patch"`: Change the patch version `v1.2.3` → `v1.2.4`
|
|
527
|
+
* @param incrementAmount - The amount to increment by (defaults to 1).
|
|
528
|
+
*
|
|
529
|
+
* @returns A new instance of `VersionNumber` with the increment applied.
|
|
530
|
+
*/
|
|
531
|
+
increment(incrementType: VersionType, incrementAmount?: number): VersionNumber;
|
|
532
|
+
/**
|
|
533
|
+
* Ensures that the VersionNumber behaves correctly when attempted to be coerced to a string.
|
|
534
|
+
*
|
|
535
|
+
* @param hint - Not used as of now, but generally used to help with numeric coercion, I think (which we most likely do not need for version numbers).
|
|
536
|
+
*
|
|
537
|
+
* @returns A stringified representation of the current version number, prefixed with `v`.
|
|
538
|
+
*/
|
|
539
|
+
[Symbol.toPrimitive](hint: "default" | "string" | "number"): string;
|
|
540
|
+
/**
|
|
541
|
+
* Ensures that the VersionNumber behaves correctly when attempted to be converted to JSON.
|
|
542
|
+
*
|
|
543
|
+
* @returns A stringified representation of the current version number, prefixed with `v`.
|
|
544
|
+
*/
|
|
545
|
+
toJSON(): string;
|
|
546
|
+
/**
|
|
547
|
+
* Get a string representation of the current version number.
|
|
548
|
+
*
|
|
549
|
+
* @returns A stringified representation of the current version number with the prefix.
|
|
550
|
+
*/
|
|
551
|
+
toString(): string;
|
|
552
|
+
}
|
|
553
|
+
declare const zodVersionNumber: z.ZodType<VersionNumber>;
|
|
554
|
+
//#endregion
|
|
555
|
+
//#region src/root/types/ArrayElement.d.ts
|
|
556
|
+
/**
|
|
557
|
+
* Gets the individual element types from an array type.
|
|
558
|
+
*
|
|
559
|
+
* @category Types
|
|
560
|
+
*
|
|
561
|
+
* @template ArrayType - The type of the array itself.
|
|
562
|
+
*/
|
|
563
|
+
type ArrayElement<ArrayType extends ReadonlyArray<unknown>> = ArrayType extends ReadonlyArray<infer ElementType> ? ElementType : never;
|
|
564
|
+
//#endregion
|
|
565
|
+
//#region src/root/types/CallReturnType.d.ts
|
|
566
|
+
type CallReturnType<Function, Arguments> = Function extends ((arg: Arguments) => infer Return) ? Return : never;
|
|
567
|
+
//#endregion
|
|
568
|
+
//#region src/root/types/DisallowUndefined.d.ts
|
|
569
|
+
/**
|
|
570
|
+
* Resolves to an error message type if the type argument could potentially be undefined.
|
|
571
|
+
*
|
|
572
|
+
* @category Types
|
|
573
|
+
*
|
|
574
|
+
* @template InputType - The type to disallow undefined on.
|
|
575
|
+
*/
|
|
576
|
+
type DisallowUndefined<InputType> = undefined extends InputType ? ["Error: Generic type cannot include undefined"] : InputType;
|
|
577
|
+
//#endregion
|
|
578
|
+
//#region src/root/types/IgnoreCase.d.ts
|
|
579
|
+
/**
|
|
580
|
+
* Allows case-insensitive variants of a known string type.
|
|
581
|
+
*
|
|
582
|
+
* @category Types
|
|
583
|
+
*
|
|
584
|
+
* @template StringType - The input string type.
|
|
585
|
+
*/
|
|
586
|
+
type IgnoreCase<StringType extends string> = string extends StringType ? string : StringType extends `${infer FirstCharacter}${infer SecondCharacter}${infer Remainder}` ? `${Uppercase<FirstCharacter> | Lowercase<FirstCharacter>}${Uppercase<SecondCharacter> | Lowercase<SecondCharacter>}${IgnoreCase<Remainder>}` : StringType extends `${infer FirstCharacter}${infer Remainder}` ? `${Uppercase<FirstCharacter> | Lowercase<FirstCharacter>}${IgnoreCase<Remainder>}` : "";
|
|
587
|
+
//#endregion
|
|
588
|
+
//#region src/root/types/IsTypeArgumentString.d.ts
|
|
589
|
+
type IsTypeArgumentString<Argument extends string> = Argument;
|
|
590
|
+
//#endregion
|
|
591
|
+
//#region src/root/types/NonNull.d.ts
|
|
592
|
+
/**
|
|
593
|
+
* Removes `null` from a type.
|
|
594
|
+
*
|
|
595
|
+
* @category Types
|
|
596
|
+
*
|
|
597
|
+
* @template InputType - The type to check.
|
|
598
|
+
*/
|
|
599
|
+
type NonNull<InputType> = InputType extends null ? never : InputType;
|
|
600
|
+
//#endregion
|
|
601
|
+
//#region src/root/types/NonUndefined.d.ts
|
|
602
|
+
/**
|
|
603
|
+
* Removes `undefined` from a type.
|
|
604
|
+
*
|
|
605
|
+
* @category Types
|
|
606
|
+
*
|
|
607
|
+
* @template InputType - The type to check.
|
|
608
|
+
*/
|
|
609
|
+
type NonUndefined<InputType> = InputType extends undefined ? never : InputType;
|
|
610
|
+
//#endregion
|
|
611
|
+
//#region src/root/types/NullableOnCondition.d.ts
|
|
612
|
+
/**
|
|
613
|
+
* Resolves to the given type if the first type is `true`, otherwise resolves to `null`
|
|
614
|
+
*
|
|
615
|
+
* @category Types
|
|
616
|
+
*
|
|
617
|
+
* @param Condition - The condition to check.
|
|
618
|
+
* @param ResolvedTypeIfTrue - The type to resolve to if the condition may be `true`.
|
|
619
|
+
*/
|
|
620
|
+
type NullableOnCondition<Condition extends boolean, ResolvedTypeIfTrue> = Condition extends true ? ResolvedTypeIfTrue : ResolvedTypeIfTrue | null;
|
|
621
|
+
//#endregion
|
|
622
|
+
//#region src/root/types/OptionalOnCondition.d.ts
|
|
623
|
+
/**
|
|
624
|
+
* Resolves to the given type if the first type is `true`, otherwise resolves to `undefined`
|
|
625
|
+
*
|
|
626
|
+
* @category Types
|
|
627
|
+
*
|
|
628
|
+
* @param Condition - The condition to check.
|
|
629
|
+
* @param ResolvedTypeIfTrue - The type to resolve to if the condition may be `true`.
|
|
630
|
+
*/
|
|
631
|
+
type OptionalOnCondition<Condition extends boolean, ResolvedTypeIfTrue> = Condition extends true ? ResolvedTypeIfTrue : ResolvedTypeIfTrue | undefined;
|
|
632
|
+
//#endregion
|
|
633
|
+
//#region src/root/functions/miscellaneous/sortBy.d.ts
|
|
634
|
+
type SortFunction<ItemType> = (first: ItemType, second: ItemType) => number;
|
|
635
|
+
/**
|
|
636
|
+
* Provides a function to pass to the `sort` or `toSorted` methods on arrays, which will allow those methods to sort the items by the chosen value in the chosen direction.
|
|
637
|
+
*
|
|
638
|
+
* @template ItemType - The type of each array item.
|
|
639
|
+
* @template SortValue - The type of the value to sort by.
|
|
640
|
+
*
|
|
641
|
+
* @param selector - A function that takes the item and returns the value to sort by.
|
|
642
|
+
* @param direction - The sort direction.
|
|
643
|
+
*
|
|
644
|
+
* @returns A function to pass into the `.sort()` or `.toSorted()` methods on arrays.
|
|
645
|
+
*/
|
|
646
|
+
declare function sortBy<ItemType, SortValue extends string | number | Date>(selector: (item: ItemType) => SortValue, direction?: SortDirection): SortFunction<ItemType>;
|
|
647
|
+
//#endregion
|
|
427
648
|
//#region src/root/functions/miscellaneous/stringifyDotenv.d.ts
|
|
428
649
|
type QuoteStyle = "double" | "single" | "none";
|
|
429
650
|
interface StringifyDotenvOptions {
|
|
@@ -941,234 +1162,91 @@ declare function normaliseIndents(strings: TemplateStringsArray, ...interpolatio
|
|
|
941
1162
|
*/
|
|
942
1163
|
declare const normalizeIndents: typeof normaliseIndents;
|
|
943
1164
|
//#endregion
|
|
944
|
-
//#region src/root/
|
|
1165
|
+
//#region src/root/functions/typeAssertions/assertNotNull.d.ts
|
|
945
1166
|
/**
|
|
946
|
-
*
|
|
947
|
-
*
|
|
948
|
-
* @category Class Options
|
|
949
|
-
*/
|
|
950
|
-
interface FormatOptionsBase {
|
|
951
|
-
/** Whether you want to omit the "v" prefix or not (defaults to false). */
|
|
952
|
-
omitPrefix?: boolean;
|
|
953
|
-
}
|
|
954
|
-
interface FormatOptionsIncludeMinor extends FormatOptionsBase {
|
|
955
|
-
/** Whether you want to omit the minor version or not */
|
|
956
|
-
omitMinor?: false;
|
|
957
|
-
/** Whether you want to omit the patch version or not */
|
|
958
|
-
omitPatch?: boolean;
|
|
959
|
-
}
|
|
960
|
-
interface FormatOptionsOmitMinor extends FormatOptionsBase {
|
|
961
|
-
/** Whether you want to omit the minor version or not */
|
|
962
|
-
omitMinor?: true;
|
|
963
|
-
/** Whether you want to omit the patch version or not */
|
|
964
|
-
omitPatch?: never;
|
|
965
|
-
}
|
|
966
|
-
type FormatStringOptions = FormatOptionsIncludeMinor | FormatOptionsOmitMinor;
|
|
967
|
-
/**
|
|
968
|
-
* Represents a software version number, considered to be made up of a major, minor, and patch part.
|
|
1167
|
+
* Asserts that a given input is not `null`, and throws a DataError if it does.
|
|
969
1168
|
*
|
|
970
|
-
*
|
|
971
|
-
*/
|
|
972
|
-
declare class VersionNumber {
|
|
973
|
-
private static readonly NON_NEGATIVE_TUPLE_ERROR;
|
|
974
|
-
/** The major number. Increments when a feature is removed or changed in a way that is not backwards-compatible with the previous release. */
|
|
975
|
-
readonly major: number;
|
|
976
|
-
/** The minor number. Increments when a new feature is added/deprecated and is expected to be backwards-compatible with the previous release. */
|
|
977
|
-
readonly minor: number;
|
|
978
|
-
/** The patch number. Increments when the next release is fixing a bug or doing a small refactor that should not be noticeable in practice. */
|
|
979
|
-
readonly patch: number;
|
|
980
|
-
/**
|
|
981
|
-
* @param input - The input to create a new instance of `VersionNumber` from.
|
|
982
|
-
*/
|
|
983
|
-
constructor(input: string | [number, number, number] | VersionNumber);
|
|
984
|
-
/**
|
|
985
|
-
* Gets the current version type of the current instance of `VersionNumber`.
|
|
986
|
-
*
|
|
987
|
-
* @returns Either `"major"`, `"minor"`, or `"patch"`, depending on the version type.
|
|
988
|
-
*/
|
|
989
|
-
get type(): VersionType;
|
|
990
|
-
private static formatString;
|
|
991
|
-
/**
|
|
992
|
-
* Checks if the provided version numbers have the exact same major, minor, and patch numbers.
|
|
993
|
-
*
|
|
994
|
-
* @param firstVersion - The first version number to compare.
|
|
995
|
-
* @param secondVersion - The second version number to compare.
|
|
996
|
-
*
|
|
997
|
-
* @returns `true` if the provided version numbers have exactly the same major, minor, and patch numbers, and returns `false` otherwise.
|
|
998
|
-
*/
|
|
999
|
-
static isEqual(firstVersion: VersionNumber, secondVersion: VersionNumber): boolean;
|
|
1000
|
-
/**
|
|
1001
|
-
* Get a formatted string representation of the current version number
|
|
1002
|
-
*
|
|
1003
|
-
* @param options - Options to apply to the string formatting.
|
|
1004
|
-
*
|
|
1005
|
-
* @returns A formatted string representation of the current version number with the options applied.
|
|
1006
|
-
*/
|
|
1007
|
-
format(options?: FormatStringOptions): string;
|
|
1008
|
-
/**
|
|
1009
|
-
* Increments the current version number by the given increment type, returning the result as a new reference in memory.
|
|
1010
|
-
*
|
|
1011
|
-
* @param incrementType - The type of increment. Can be one of the following:
|
|
1012
|
-
* - `"major"`: Change the major version `v1.2.3` → `v2.0.0`
|
|
1013
|
-
* - `"minor"`: Change the minor version `v1.2.3` → `v1.3.0`
|
|
1014
|
-
* - `"patch"`: Change the patch version `v1.2.3` → `v1.2.4`
|
|
1015
|
-
* @param incrementAmount - The amount to increment by (defaults to 1).
|
|
1016
|
-
*
|
|
1017
|
-
* @returns A new instance of `VersionNumber` with the increment applied.
|
|
1018
|
-
*/
|
|
1019
|
-
increment(incrementType: VersionType, incrementAmount?: number): VersionNumber;
|
|
1020
|
-
/**
|
|
1021
|
-
* Ensures that the VersionNumber behaves correctly when attempted to be coerced to a string.
|
|
1022
|
-
*
|
|
1023
|
-
* @param hint - Not used as of now, but generally used to help with numeric coercion, I think (which we most likely do not need for version numbers).
|
|
1024
|
-
*
|
|
1025
|
-
* @returns A stringified representation of the current version number, prefixed with `v`.
|
|
1026
|
-
*/
|
|
1027
|
-
[Symbol.toPrimitive](hint: "default" | "string" | "number"): string;
|
|
1028
|
-
/**
|
|
1029
|
-
* Ensures that the VersionNumber behaves correctly when attempted to be converted to JSON.
|
|
1030
|
-
*
|
|
1031
|
-
* @returns A stringified representation of the current version number, prefixed with `v`.
|
|
1032
|
-
*/
|
|
1033
|
-
toJSON(): string;
|
|
1034
|
-
/**
|
|
1035
|
-
* Get a string representation of the current version number.
|
|
1036
|
-
*
|
|
1037
|
-
* @returns A stringified representation of the current version number with the prefix.
|
|
1038
|
-
*/
|
|
1039
|
-
toString(): string;
|
|
1040
|
-
}
|
|
1041
|
-
declare const zodVersionNumber: z.ZodType<VersionNumber>;
|
|
1042
|
-
//#endregion
|
|
1043
|
-
//#region src/root/types/ArrayElement.d.ts
|
|
1044
|
-
/**
|
|
1045
|
-
* Gets the individual element types from an array type.
|
|
1169
|
+
* If no error is thrown from this, the input type gets narrowed down to not include `null`.
|
|
1046
1170
|
*
|
|
1047
|
-
* @category
|
|
1171
|
+
* @category Type Assertions
|
|
1048
1172
|
*
|
|
1049
|
-
* @template
|
|
1050
|
-
*/
|
|
1051
|
-
type ArrayElement<ArrayType extends ReadonlyArray<unknown>> = ArrayType extends ReadonlyArray<infer ElementType> ? ElementType : never;
|
|
1052
|
-
//#endregion
|
|
1053
|
-
//#region src/root/types/CallReturnType.d.ts
|
|
1054
|
-
type CallReturnType<Function, Arguments> = Function extends ((arg: Arguments) => infer Return) ? Return : never;
|
|
1055
|
-
//#endregion
|
|
1056
|
-
//#region src/root/types/CreateEnumType.d.ts
|
|
1057
|
-
/**
|
|
1058
|
-
* Get the value types from a const object so the object can behave similarly to an enum.
|
|
1173
|
+
* @template InputType The type of the input.
|
|
1059
1174
|
*
|
|
1060
|
-
* @
|
|
1175
|
+
* @param input - The input to assert against
|
|
1061
1176
|
*
|
|
1062
|
-
* @
|
|
1177
|
+
* @throws {DataError} If the input is `null`.
|
|
1063
1178
|
*/
|
|
1064
|
-
|
|
1179
|
+
declare function assertNotNull<InputType>(input: InputType): asserts input is NonNull<InputType>;
|
|
1065
1180
|
//#endregion
|
|
1066
|
-
//#region src/root/
|
|
1181
|
+
//#region src/root/functions/typeAssertions/assertNotNullable.d.ts
|
|
1067
1182
|
/**
|
|
1068
|
-
*
|
|
1069
|
-
*
|
|
1070
|
-
* @category Types
|
|
1183
|
+
* Asserts that a given input is not `undefined` or `null`, and throws a DataError if it does.
|
|
1071
1184
|
*
|
|
1072
|
-
*
|
|
1073
|
-
*/
|
|
1074
|
-
type DisallowUndefined<InputType> = undefined extends InputType ? ["Error: Generic type cannot include undefined"] : InputType;
|
|
1075
|
-
//#endregion
|
|
1076
|
-
//#region src/root/types/IgnoreCase.d.ts
|
|
1077
|
-
/**
|
|
1078
|
-
* Allows case-insensitive variants of a known string type.
|
|
1185
|
+
* If no error is thrown from this, the input type gets narrowed down to not include `undefined` or `null`.
|
|
1079
1186
|
*
|
|
1080
|
-
* @category
|
|
1187
|
+
* @category Type Assertions
|
|
1081
1188
|
*
|
|
1082
|
-
* @template
|
|
1083
|
-
*/
|
|
1084
|
-
type IgnoreCase<StringType extends string> = string extends StringType ? string : StringType extends `${infer FirstCharacter}${infer SecondCharacter}${infer Remainder}` ? `${Uppercase<FirstCharacter> | Lowercase<FirstCharacter>}${Uppercase<SecondCharacter> | Lowercase<SecondCharacter>}${IgnoreCase<Remainder>}` : StringType extends `${infer FirstCharacter}${infer Remainder}` ? `${Uppercase<FirstCharacter> | Lowercase<FirstCharacter>}${IgnoreCase<Remainder>}` : "";
|
|
1085
|
-
//#endregion
|
|
1086
|
-
//#region src/root/types/IsTypeArgumentString.d.ts
|
|
1087
|
-
type IsTypeArgumentString<Argument extends string> = Argument;
|
|
1088
|
-
//#endregion
|
|
1089
|
-
//#region src/root/types/NonNull.d.ts
|
|
1090
|
-
/**
|
|
1091
|
-
* Removes `null` from a type.
|
|
1189
|
+
* @template InputType The type of the input.
|
|
1092
1190
|
*
|
|
1093
|
-
* @
|
|
1191
|
+
* @param input - The input to assert against.
|
|
1094
1192
|
*
|
|
1095
|
-
* @
|
|
1193
|
+
* @throws {DataError} If the input is `undefined` or `null`.
|
|
1096
1194
|
*/
|
|
1097
|
-
|
|
1195
|
+
declare function assertNotNullable<InputType>(input: InputType): asserts input is NonNullable<InputType>;
|
|
1098
1196
|
//#endregion
|
|
1099
|
-
//#region src/root/
|
|
1197
|
+
//#region src/root/functions/typeAssertions/assertNotUndefined.d.ts
|
|
1100
1198
|
/**
|
|
1101
|
-
*
|
|
1102
|
-
*
|
|
1103
|
-
* @category Types
|
|
1199
|
+
* Asserts that a given input is not `undefined`, and throws a DataError if it does.
|
|
1104
1200
|
*
|
|
1105
|
-
*
|
|
1106
|
-
*/
|
|
1107
|
-
type NonUndefined<InputType> = InputType extends undefined ? never : InputType;
|
|
1108
|
-
//#endregion
|
|
1109
|
-
//#region src/root/types/NullableOnCondition.d.ts
|
|
1110
|
-
/**
|
|
1111
|
-
* Resolves to the given type if the first type is `true`, otherwise resolves to `null`
|
|
1201
|
+
* If no error is thrown from this, the input type gets narrowed down to not include `undefined`.
|
|
1112
1202
|
*
|
|
1113
|
-
* @category
|
|
1203
|
+
* @category Type Assertions
|
|
1114
1204
|
*
|
|
1115
|
-
* @
|
|
1116
|
-
* @param ResolvedTypeIfTrue - The type to resolve to if the condition may be `true`.
|
|
1117
|
-
*/
|
|
1118
|
-
type NullableOnCondition<Condition extends boolean, ResolvedTypeIfTrue> = Condition extends true ? ResolvedTypeIfTrue : ResolvedTypeIfTrue | null;
|
|
1119
|
-
//#endregion
|
|
1120
|
-
//#region src/root/types/OptionalOnCondition.d.ts
|
|
1121
|
-
/**
|
|
1122
|
-
* Resolves to the given type if the first type is `true`, otherwise resolves to `undefined`
|
|
1205
|
+
* @template InputType The type of the input.
|
|
1123
1206
|
*
|
|
1124
|
-
* @
|
|
1207
|
+
* @param input - The input to assert against.
|
|
1125
1208
|
*
|
|
1126
|
-
* @
|
|
1127
|
-
* @param ResolvedTypeIfTrue - The type to resolve to if the condition may be `true`.
|
|
1209
|
+
* @throws {DataError} If the input is `undefined`.
|
|
1128
1210
|
*/
|
|
1129
|
-
|
|
1211
|
+
declare function assertNotUndefined<InputType>(input: InputType): asserts input is NonUndefined<InputType>;
|
|
1130
1212
|
//#endregion
|
|
1131
|
-
//#region src/root/
|
|
1213
|
+
//#region src/root/functions/typeAssertions/containsKeys.d.ts
|
|
1132
1214
|
/**
|
|
1133
|
-
*
|
|
1215
|
+
* Determines if the given input is a non-nullable object, and if that object contains all of the keys provided.
|
|
1134
1216
|
*
|
|
1135
|
-
*
|
|
1217
|
+
* @category Type Assertions
|
|
1136
1218
|
*
|
|
1137
|
-
* @
|
|
1219
|
+
* @param input - The input to check.
|
|
1220
|
+
* @param keys - The keys expected to be in the input if it's an object.
|
|
1138
1221
|
*
|
|
1139
|
-
* @
|
|
1140
|
-
*
|
|
1141
|
-
* @throws {DataError} If the input is `null`.
|
|
1222
|
+
* @returns `true` if the input is an object containing all provided keys, and `false` otherwise. The input type will also be narrowed down to be a record with the provided keys, each with an unknown value type.
|
|
1142
1223
|
*/
|
|
1143
|
-
declare function
|
|
1224
|
+
declare function containsKeys<Key extends PropertyKey = string>(input: unknown, keys: Key | ReadonlyArray<Key>): input is Record<Key, unknown>;
|
|
1144
1225
|
//#endregion
|
|
1145
|
-
//#region src/root/
|
|
1226
|
+
//#region src/root/functions/typeAssertions/isNonNullableObject.d.ts
|
|
1146
1227
|
/**
|
|
1147
|
-
*
|
|
1228
|
+
* Determines if the given input is a non-nullable object, narrowing the type down as such if it is
|
|
1148
1229
|
*
|
|
1149
|
-
*
|
|
1230
|
+
* @category Type Assertions
|
|
1150
1231
|
*
|
|
1151
|
-
* @
|
|
1152
|
-
*
|
|
1153
|
-
* @param input - The input to assert against.
|
|
1232
|
+
* @param input - The input to check
|
|
1154
1233
|
*
|
|
1155
|
-
* @
|
|
1234
|
+
* @returns `true` if the input is a non-nullable object, and `false` otherwise. The input type will also be narrowed down to be a non-nullable object.
|
|
1156
1235
|
*/
|
|
1157
|
-
declare function
|
|
1236
|
+
declare function isNonNullableObject(input: unknown): input is NonNullable<object>;
|
|
1158
1237
|
//#endregion
|
|
1159
|
-
//#region src/root/
|
|
1238
|
+
//#region src/root/functions/typeAssertions/objectContainsKeys.d.ts
|
|
1160
1239
|
/**
|
|
1161
|
-
*
|
|
1240
|
+
* Determines if the given object contains all of the keys provided.
|
|
1162
1241
|
*
|
|
1163
|
-
*
|
|
1164
|
-
*
|
|
1165
|
-
* @template InputType The type of the input.
|
|
1242
|
+
* @category Type Assertions
|
|
1166
1243
|
*
|
|
1167
|
-
* @param input - The input to
|
|
1244
|
+
* @param input - The input object to check.
|
|
1245
|
+
* @param keys - The keys expected to be in the input object.
|
|
1168
1246
|
*
|
|
1169
|
-
* @
|
|
1247
|
+
* @returns `true` if the input object contains all provided keys, and `false` otherwise. The input type will also be narrowed down to be a record with the provided keys with an unknown value type.
|
|
1170
1248
|
*/
|
|
1171
|
-
declare function
|
|
1249
|
+
declare function objectContainsKeys<Key extends PropertyKey = string>(input: object, keys: Key | ReadonlyArray<Key>): input is Record<Key, unknown>;
|
|
1172
1250
|
//#endregion
|
|
1173
1251
|
//#region src/v6/CodeError.d.ts
|
|
1174
1252
|
interface ExpectErrorOptions<ErrorCode extends string = string> {
|
|
@@ -1379,4 +1457,4 @@ interface ZodParsingErrorData {
|
|
|
1379
1457
|
issues: Array<z.core.$ZodIssue>;
|
|
1380
1458
|
}
|
|
1381
1459
|
//#endregion
|
|
1382
|
-
export { APIError, type ArrayElement, type CallReturnType, type CamelToKebabOptions, type CreateEnumType, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, DataError, type DisallowUndefined, Env, FILE_PATH_PATTERN, FILE_PATH_REGEX, type FormDataArrayResolutionStrategy, type FormDataNullableResolutionStrategy, type HTTPErrorCode, type IgnoreCase, type IsTypeArgumentString, type KebabToCamelOptions, type NonNull, type NonUndefined, type NormaliseIndentsFunction, type NormaliseIndentsOptions, type NormalizeIndentsFunction, type NormalizeIndentsOptions, type NullableOnCondition, ONE_DAY_IN_MILLISECONDS, type OptionalOnCondition, type ParallelTuple, type RecordKey, type RemoveUndefined, type StringListToArrayOptions, type ToTitleCaseOptions, UUID_PATTERN, UUID_REGEX, VERSION_NUMBER_PATTERN, VERSION_NUMBER_REGEX, VersionNumber, type FormatOptionsBase as VersionNumberToStringOptions, VersionType, type ZodParsingErrorData, addDaysToDate, appendSemicolon, assertNotNull, assertNotNullable, assertNotUndefined, az, calculateMonthlyDifference, camelToKebab, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, escapeRegexPattern, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, stringListToArray, stringifyDotenv, toTitleCase, truncate, wait, zodVersionNumber };
|
|
1460
|
+
export { APIError, type ArrayElement, type CallReturnType, type CamelToKebabOptions, type CreateEnumType, type CreateFormDataOptions, type CreateFormDataOptionsNullableResolution, type CreateFormDataOptionsUndefinedOrNullResolution, DataError, type DisallowUndefined, Env, FILE_PATH_PATTERN, FILE_PATH_REGEX, type FormDataArrayResolutionStrategy, type FormDataNullableResolutionStrategy, type HTTPErrorCode, type IgnoreCase, type IsTypeArgumentString, type KebabToCamelOptions, type NonNull, type NonUndefined, type NormaliseIndentsFunction, type NormaliseIndentsOptions, type NormalizeIndentsFunction, type NormalizeIndentsOptions, type NullableOnCondition, ONE_DAY_IN_MILLISECONDS, type OptionalOnCondition, type ParallelTuple, type RecordKey, type RemoveUndefined, SortDirection, type StringListToArrayOptions, type ToTitleCaseOptions, UUID_PATTERN, UUID_REGEX, VERSION_NUMBER_PATTERN, VERSION_NUMBER_REGEX, VersionNumber, type FormatOptionsBase as VersionNumberToStringOptions, VersionType, type ZodParsingErrorData, addDaysToDate, appendSemicolon, assertNotNull, assertNotNullable, assertNotUndefined, az, calculateMonthlyDifference, camelToKebab, containsKeys, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, escapeRegexPattern, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, identity, interpolate, interpolateObjects, isAnniversary, isLeapYear, isMonthlyMultiple, isNonNullableObject, isOrdered, isSameDate, isTemplateStringsArray, kebabToCamel, normaliseIndents, normalizeIndents, objectContainsKeys, omitProperties, paralleliseArrays, parseBoolean, parseEnv, parseFormData, parseIntStrict, parseUUID, parseVersionType, parseZodSchema, parseZodSchemaAsync, randomiseArray, range, removeDuplicates, removeUndefinedFromObject, sayHello, sortBy, stringListToArray, stringifyDotenv, toTitleCase, truncate, wait, zodVersionNumber };
|