@alextheman/utility 5.19.2 → 5.20.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 +115 -55
- package/dist/index.d.cts +233 -189
- package/dist/index.d.ts +232 -188
- package/dist/index.js +113 -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 +10 -10
package/dist/index.d.ts
CHANGED
|
@@ -536,6 +536,193 @@ declare function removeUndefinedFromObject<RecordType extends Record<PropertyKey
|
|
|
536
536
|
*/
|
|
537
537
|
declare function parseBoolean(inputString: string): boolean;
|
|
538
538
|
//#endregion
|
|
539
|
+
//#region src/root/types/VersionNumber.d.ts
|
|
540
|
+
/**
|
|
541
|
+
* Options to apply to the stringification of the version number.
|
|
542
|
+
*
|
|
543
|
+
* @category Class Options
|
|
544
|
+
*/
|
|
545
|
+
interface FormatOptionsBase {
|
|
546
|
+
/** Whether you want to omit the "v" prefix or not (defaults to false). */
|
|
547
|
+
omitPrefix?: boolean;
|
|
548
|
+
}
|
|
549
|
+
interface FormatOptionsIncludeMinor extends FormatOptionsBase {
|
|
550
|
+
/** Whether you want to omit the minor version or not */
|
|
551
|
+
omitMinor?: false;
|
|
552
|
+
/** Whether you want to omit the patch version or not */
|
|
553
|
+
omitPatch?: boolean;
|
|
554
|
+
}
|
|
555
|
+
interface FormatOptionsOmitMinor extends FormatOptionsBase {
|
|
556
|
+
/** Whether you want to omit the minor version or not */
|
|
557
|
+
omitMinor?: true;
|
|
558
|
+
/** Whether you want to omit the patch version or not */
|
|
559
|
+
omitPatch?: never;
|
|
560
|
+
}
|
|
561
|
+
type FormatStringOptions = FormatOptionsIncludeMinor | FormatOptionsOmitMinor;
|
|
562
|
+
/**
|
|
563
|
+
* Represents a software version number, considered to be made up of a major, minor, and patch part.
|
|
564
|
+
*
|
|
565
|
+
* @category Types
|
|
566
|
+
*/
|
|
567
|
+
declare class VersionNumber {
|
|
568
|
+
private static readonly NON_NEGATIVE_TUPLE_ERROR;
|
|
569
|
+
/** The major number. Increments when a feature is removed or changed in a way that is not backwards-compatible with the previous release. */
|
|
570
|
+
readonly major: number;
|
|
571
|
+
/** The minor number. Increments when a new feature is added/deprecated and is expected to be backwards-compatible with the previous release. */
|
|
572
|
+
readonly minor: number;
|
|
573
|
+
/** The patch number. Increments when the next release is fixing a bug or doing a small refactor that should not be noticeable in practice. */
|
|
574
|
+
readonly patch: number;
|
|
575
|
+
/**
|
|
576
|
+
* @param input - The input to create a new instance of `VersionNumber` from.
|
|
577
|
+
*/
|
|
578
|
+
constructor(input: string | [number, number, number] | VersionNumber);
|
|
579
|
+
/**
|
|
580
|
+
* Gets the current version type of the current instance of `VersionNumber`.
|
|
581
|
+
*
|
|
582
|
+
* @returns Either `"major"`, `"minor"`, or `"patch"`, depending on the version type.
|
|
583
|
+
*/
|
|
584
|
+
get type(): VersionType;
|
|
585
|
+
private static formatString;
|
|
586
|
+
/**
|
|
587
|
+
* Checks if the provided version numbers have the exact same major, minor, and patch numbers.
|
|
588
|
+
*
|
|
589
|
+
* @param firstVersion - The first version number to compare.
|
|
590
|
+
* @param secondVersion - The second version number to compare.
|
|
591
|
+
*
|
|
592
|
+
* @returns `true` if the provided version numbers have exactly the same major, minor, and patch numbers, and returns `false` otherwise.
|
|
593
|
+
*/
|
|
594
|
+
static isEqual(firstVersion: VersionNumber, secondVersion: VersionNumber): boolean;
|
|
595
|
+
/**
|
|
596
|
+
* Get a formatted string representation of the current version number
|
|
597
|
+
*
|
|
598
|
+
* @param options - Options to apply to the string formatting.
|
|
599
|
+
*
|
|
600
|
+
* @returns A formatted string representation of the current version number with the options applied.
|
|
601
|
+
*/
|
|
602
|
+
format(options?: FormatStringOptions): string;
|
|
603
|
+
/**
|
|
604
|
+
* Increments the current version number by the given increment type, returning the result as a new reference in memory.
|
|
605
|
+
*
|
|
606
|
+
* @param incrementType - The type of increment. Can be one of the following:
|
|
607
|
+
* - `"major"`: Change the major version `v1.2.3` → `v2.0.0`
|
|
608
|
+
* - `"minor"`: Change the minor version `v1.2.3` → `v1.3.0`
|
|
609
|
+
* - `"patch"`: Change the patch version `v1.2.3` → `v1.2.4`
|
|
610
|
+
* @param incrementAmount - The amount to increment by (defaults to 1).
|
|
611
|
+
*
|
|
612
|
+
* @returns A new instance of `VersionNumber` with the increment applied.
|
|
613
|
+
*/
|
|
614
|
+
increment(incrementType: VersionType, incrementAmount?: number): VersionNumber;
|
|
615
|
+
/**
|
|
616
|
+
* Ensures that the VersionNumber behaves correctly when attempted to be coerced to a string.
|
|
617
|
+
*
|
|
618
|
+
* @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).
|
|
619
|
+
*
|
|
620
|
+
* @returns A stringified representation of the current version number, prefixed with `v`.
|
|
621
|
+
*/
|
|
622
|
+
[Symbol.toPrimitive](hint: "default" | "string" | "number"): string;
|
|
623
|
+
/**
|
|
624
|
+
* Ensures that the VersionNumber behaves correctly when attempted to be converted to JSON.
|
|
625
|
+
*
|
|
626
|
+
* @returns A stringified representation of the current version number, prefixed with `v`.
|
|
627
|
+
*/
|
|
628
|
+
toJSON(): string;
|
|
629
|
+
/**
|
|
630
|
+
* Get a string representation of the current version number.
|
|
631
|
+
*
|
|
632
|
+
* @returns A stringified representation of the current version number with the prefix.
|
|
633
|
+
*/
|
|
634
|
+
toString(): string;
|
|
635
|
+
}
|
|
636
|
+
declare const zodVersionNumber: z$1.ZodType<VersionNumber>;
|
|
637
|
+
//#endregion
|
|
638
|
+
//#region src/root/types/ArrayElement.d.ts
|
|
639
|
+
/**
|
|
640
|
+
* Gets the individual element types from an array type.
|
|
641
|
+
*
|
|
642
|
+
* @category Types
|
|
643
|
+
*
|
|
644
|
+
* @template ArrayType - The type of the array itself.
|
|
645
|
+
*/
|
|
646
|
+
type ArrayElement<ArrayType extends ReadonlyArray<unknown>> = ArrayType extends ReadonlyArray<infer ElementType> ? ElementType : never;
|
|
647
|
+
//#endregion
|
|
648
|
+
//#region src/root/types/CallReturnType.d.ts
|
|
649
|
+
type CallReturnType<Function, Arguments> = Function extends ((arg: Arguments) => infer Return) ? Return : never;
|
|
650
|
+
//#endregion
|
|
651
|
+
//#region src/root/types/CreateEnumType.d.ts
|
|
652
|
+
/**
|
|
653
|
+
* Get the value types from a const object so the object can behave similarly to an enum.
|
|
654
|
+
*
|
|
655
|
+
* @category Types
|
|
656
|
+
*
|
|
657
|
+
* @template ObjectType - The type of the object to get the value types for.
|
|
658
|
+
*/
|
|
659
|
+
type CreateEnumType<ObjectType extends Record<PropertyKey, unknown>> = ObjectType[keyof ObjectType];
|
|
660
|
+
//#endregion
|
|
661
|
+
//#region src/root/types/DisallowUndefined.d.ts
|
|
662
|
+
/**
|
|
663
|
+
* Resolves to an error message type if the type argument could potentially be undefined.
|
|
664
|
+
*
|
|
665
|
+
* @category Types
|
|
666
|
+
*
|
|
667
|
+
* @template InputType - The type to disallow undefined on.
|
|
668
|
+
*/
|
|
669
|
+
type DisallowUndefined<InputType> = undefined extends InputType ? ["Error: Generic type cannot include undefined"] : InputType;
|
|
670
|
+
//#endregion
|
|
671
|
+
//#region src/root/types/IgnoreCase.d.ts
|
|
672
|
+
/**
|
|
673
|
+
* Allows case-insensitive variants of a known string type.
|
|
674
|
+
*
|
|
675
|
+
* @category Types
|
|
676
|
+
*
|
|
677
|
+
* @template StringType - The input string type.
|
|
678
|
+
*/
|
|
679
|
+
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>}` : "";
|
|
680
|
+
//#endregion
|
|
681
|
+
//#region src/root/types/IsTypeArgumentString.d.ts
|
|
682
|
+
type IsTypeArgumentString<Argument extends string> = Argument;
|
|
683
|
+
//#endregion
|
|
684
|
+
//#region src/root/types/NonNull.d.ts
|
|
685
|
+
/**
|
|
686
|
+
* Removes `null` from a type.
|
|
687
|
+
*
|
|
688
|
+
* @category Types
|
|
689
|
+
*
|
|
690
|
+
* @template InputType - The type to check.
|
|
691
|
+
*/
|
|
692
|
+
type NonNull<InputType> = InputType extends null ? never : InputType;
|
|
693
|
+
//#endregion
|
|
694
|
+
//#region src/root/types/NonUndefined.d.ts
|
|
695
|
+
/**
|
|
696
|
+
* Removes `undefined` from a type.
|
|
697
|
+
*
|
|
698
|
+
* @category Types
|
|
699
|
+
*
|
|
700
|
+
* @template InputType - The type to check.
|
|
701
|
+
*/
|
|
702
|
+
type NonUndefined<InputType> = InputType extends undefined ? never : InputType;
|
|
703
|
+
//#endregion
|
|
704
|
+
//#region src/root/types/NullableOnCondition.d.ts
|
|
705
|
+
/**
|
|
706
|
+
* Resolves to the given type if the first type is `true`, otherwise resolves to `null`
|
|
707
|
+
*
|
|
708
|
+
* @category Types
|
|
709
|
+
*
|
|
710
|
+
* @param Condition - The condition to check.
|
|
711
|
+
* @param ResolvedTypeIfTrue - The type to resolve to if the condition may be `true`.
|
|
712
|
+
*/
|
|
713
|
+
type NullableOnCondition<Condition extends boolean, ResolvedTypeIfTrue> = Condition extends true ? ResolvedTypeIfTrue : ResolvedTypeIfTrue | null;
|
|
714
|
+
//#endregion
|
|
715
|
+
//#region src/root/types/OptionalOnCondition.d.ts
|
|
716
|
+
/**
|
|
717
|
+
* Resolves to the given type if the first type is `true`, otherwise resolves to `undefined`
|
|
718
|
+
*
|
|
719
|
+
* @category Types
|
|
720
|
+
*
|
|
721
|
+
* @param Condition - The condition to check.
|
|
722
|
+
* @param ResolvedTypeIfTrue - The type to resolve to if the condition may be `true`.
|
|
723
|
+
*/
|
|
724
|
+
type OptionalOnCondition<Condition extends boolean, ResolvedTypeIfTrue> = Condition extends true ? ResolvedTypeIfTrue : ResolvedTypeIfTrue | undefined;
|
|
725
|
+
//#endregion
|
|
539
726
|
//#region src/root/functions/parsers/parseEnv.d.ts
|
|
540
727
|
/**
|
|
541
728
|
* Represents the three common development environments.
|
|
@@ -941,234 +1128,91 @@ declare function normaliseIndents(strings: TemplateStringsArray, ...interpolatio
|
|
|
941
1128
|
*/
|
|
942
1129
|
declare const normalizeIndents: typeof normaliseIndents;
|
|
943
1130
|
//#endregion
|
|
944
|
-
//#region src/root/
|
|
945
|
-
/**
|
|
946
|
-
* Options to apply to the stringification of the version number.
|
|
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;
|
|
1131
|
+
//#region src/root/functions/typeAssertions/assertNotNull.d.ts
|
|
967
1132
|
/**
|
|
968
|
-
*
|
|
1133
|
+
* Asserts that a given input is not `null`, and throws a DataError if it does.
|
|
969
1134
|
*
|
|
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$1.ZodType<VersionNumber>;
|
|
1042
|
-
//#endregion
|
|
1043
|
-
//#region src/root/types/ArrayElement.d.ts
|
|
1044
|
-
/**
|
|
1045
|
-
* Gets the individual element types from an array type.
|
|
1135
|
+
* If no error is thrown from this, the input type gets narrowed down to not include `null`.
|
|
1046
1136
|
*
|
|
1047
|
-
* @category
|
|
1137
|
+
* @category Type Assertions
|
|
1048
1138
|
*
|
|
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.
|
|
1139
|
+
* @template InputType The type of the input.
|
|
1059
1140
|
*
|
|
1060
|
-
* @
|
|
1141
|
+
* @param input - The input to assert against
|
|
1061
1142
|
*
|
|
1062
|
-
* @
|
|
1143
|
+
* @throws {DataError} If the input is `null`.
|
|
1063
1144
|
*/
|
|
1064
|
-
|
|
1145
|
+
declare function assertNotNull<InputType>(input: InputType): asserts input is NonNull<InputType>;
|
|
1065
1146
|
//#endregion
|
|
1066
|
-
//#region src/root/
|
|
1147
|
+
//#region src/root/functions/typeAssertions/assertNotNullable.d.ts
|
|
1067
1148
|
/**
|
|
1068
|
-
*
|
|
1069
|
-
*
|
|
1070
|
-
* @category Types
|
|
1149
|
+
* Asserts that a given input is not `undefined` or `null`, and throws a DataError if it does.
|
|
1071
1150
|
*
|
|
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.
|
|
1151
|
+
* If no error is thrown from this, the input type gets narrowed down to not include `undefined` or `null`.
|
|
1079
1152
|
*
|
|
1080
|
-
* @category
|
|
1153
|
+
* @category Type Assertions
|
|
1081
1154
|
*
|
|
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.
|
|
1155
|
+
* @template InputType The type of the input.
|
|
1092
1156
|
*
|
|
1093
|
-
* @
|
|
1157
|
+
* @param input - The input to assert against.
|
|
1094
1158
|
*
|
|
1095
|
-
* @
|
|
1159
|
+
* @throws {DataError} If the input is `undefined` or `null`.
|
|
1096
1160
|
*/
|
|
1097
|
-
|
|
1161
|
+
declare function assertNotNullable<InputType>(input: InputType): asserts input is NonNullable<InputType>;
|
|
1098
1162
|
//#endregion
|
|
1099
|
-
//#region src/root/
|
|
1163
|
+
//#region src/root/functions/typeAssertions/assertNotUndefined.d.ts
|
|
1100
1164
|
/**
|
|
1101
|
-
*
|
|
1102
|
-
*
|
|
1103
|
-
* @category Types
|
|
1165
|
+
* Asserts that a given input is not `undefined`, and throws a DataError if it does.
|
|
1104
1166
|
*
|
|
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`
|
|
1167
|
+
* If no error is thrown from this, the input type gets narrowed down to not include `undefined`.
|
|
1112
1168
|
*
|
|
1113
|
-
* @category
|
|
1169
|
+
* @category Type Assertions
|
|
1114
1170
|
*
|
|
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`
|
|
1171
|
+
* @template InputType The type of the input.
|
|
1123
1172
|
*
|
|
1124
|
-
* @
|
|
1173
|
+
* @param input - The input to assert against.
|
|
1125
1174
|
*
|
|
1126
|
-
* @
|
|
1127
|
-
* @param ResolvedTypeIfTrue - The type to resolve to if the condition may be `true`.
|
|
1175
|
+
* @throws {DataError} If the input is `undefined`.
|
|
1128
1176
|
*/
|
|
1129
|
-
|
|
1177
|
+
declare function assertNotUndefined<InputType>(input: InputType): asserts input is NonUndefined<InputType>;
|
|
1130
1178
|
//#endregion
|
|
1131
|
-
//#region src/root/
|
|
1179
|
+
//#region src/root/functions/typeAssertions/containsKeys.d.ts
|
|
1132
1180
|
/**
|
|
1133
|
-
*
|
|
1181
|
+
* Determines if the given input is a non-nullable object, and if that object contains all of the keys provided.
|
|
1134
1182
|
*
|
|
1135
|
-
*
|
|
1136
|
-
*
|
|
1137
|
-
* @template InputType The type of the input.
|
|
1183
|
+
* @category Type Assertions
|
|
1138
1184
|
*
|
|
1139
|
-
* @param input - The input to
|
|
1185
|
+
* @param input - The input to check.
|
|
1186
|
+
* @param keys - The keys expected to be in the input if it's an object.
|
|
1140
1187
|
*
|
|
1141
|
-
* @
|
|
1188
|
+
* @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
1189
|
*/
|
|
1143
|
-
declare function
|
|
1190
|
+
declare function containsKeys<Key extends PropertyKey = string>(input: unknown, keys: Key | ReadonlyArray<Key>): input is Record<Key, unknown>;
|
|
1144
1191
|
//#endregion
|
|
1145
|
-
//#region src/root/
|
|
1192
|
+
//#region src/root/functions/typeAssertions/isNonNullableObject.d.ts
|
|
1146
1193
|
/**
|
|
1147
|
-
*
|
|
1148
|
-
*
|
|
1149
|
-
* If no error is thrown from this, the input type gets narrowed down to not include `undefined` or `null`.
|
|
1194
|
+
* Determines if the given input is a non-nullable object, narrowing the type down as such if it is
|
|
1150
1195
|
*
|
|
1151
|
-
* @
|
|
1196
|
+
* @category Type Assertions
|
|
1152
1197
|
*
|
|
1153
|
-
* @param input - The input to
|
|
1198
|
+
* @param input - The input to check
|
|
1154
1199
|
*
|
|
1155
|
-
* @
|
|
1200
|
+
* @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
1201
|
*/
|
|
1157
|
-
declare function
|
|
1202
|
+
declare function isNonNullableObject(input: unknown): input is NonNullable<object>;
|
|
1158
1203
|
//#endregion
|
|
1159
|
-
//#region src/root/
|
|
1204
|
+
//#region src/root/functions/typeAssertions/objectContainsKeys.d.ts
|
|
1160
1205
|
/**
|
|
1161
|
-
*
|
|
1206
|
+
* Determines if the given object contains all of the keys provided.
|
|
1162
1207
|
*
|
|
1163
|
-
*
|
|
1164
|
-
*
|
|
1165
|
-
* @template InputType The type of the input.
|
|
1208
|
+
* @category Type Assertions
|
|
1166
1209
|
*
|
|
1167
|
-
* @param input - The input to
|
|
1210
|
+
* @param input - The input object to check.
|
|
1211
|
+
* @param keys - The keys expected to be in the input object.
|
|
1168
1212
|
*
|
|
1169
|
-
* @
|
|
1213
|
+
* @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
1214
|
*/
|
|
1171
|
-
declare function
|
|
1215
|
+
declare function objectContainsKeys<Key extends PropertyKey = string>(input: object, keys: Key | ReadonlyArray<Key>): input is Record<Key, unknown>;
|
|
1172
1216
|
//#endregion
|
|
1173
1217
|
//#region src/v6/CodeError.d.ts
|
|
1174
1218
|
interface ExpectErrorOptions<ErrorCode extends string = string> {
|
|
@@ -1379,4 +1423,4 @@ interface ZodParsingErrorData {
|
|
|
1379
1423
|
issues: Array<z$1.core.$ZodIssue>;
|
|
1380
1424
|
}
|
|
1381
1425
|
//#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 };
|
|
1426
|
+
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, containsKeys, convertFileToBase64, createFormData, createTemplateStringsArray, deepCopy, deepFreeze, escapeRegexPattern, fillArray, formatDateAndTime, getRandomNumber, getRecordKeys, getStringsAndInterpolations, httpErrorCodeLookup, 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, stringListToArray, stringifyDotenv, toTitleCase, truncate, wait, zodVersionNumber };
|