@esposter/shared 2.34.1 → 2.35.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.d.ts CHANGED
@@ -37,16 +37,11 @@ declare const RoutePath: {
37
37
  readonly About: "/about";
38
38
  readonly Achievements: "/achievements";
39
39
  readonly Anime: "/anime";
40
- readonly Calendar: "/calendar";
41
40
  readonly Calls: (id: string) => string;
42
41
  readonly CallsIndex: "/calls";
43
42
  readonly Clicker: "/clicker";
44
- readonly Dashboard: "/dashboard";
45
- readonly DashboardEditor: "/dashboard/editor";
46
43
  readonly Docs: "/docs";
47
44
  readonly Dungeons: "/dungeons";
48
- readonly EmailEditor: "/email-editor";
49
- readonly FlowchartEditor: "/flowchart-editor";
50
45
  readonly FluidSimulator: "/fluid-simulator";
51
46
  readonly Github: "https://github.com/Esposter/Esposter";
52
47
  readonly Index: "/";
@@ -61,22 +56,24 @@ declare const RoutePath: {
61
56
  readonly PostCreate: "/post/create";
62
57
  readonly PostUpdate: (id: string) => string;
63
58
  readonly PrivacyPolicy: "/privacy-policy";
64
- readonly Survey: (id: string) => string;
65
- readonly Surveyer: "/surveyer";
66
- readonly TableEditor: "/table-editor";
59
+ readonly Resource: (id: string) => string;
60
+ readonly Resources: "/resources";
61
+ readonly ResourcesAll: "/resources/all";
62
+ readonly ResourcesCreate: "/resources/create";
63
+ readonly ResourcesCreateType: (type: string) => string;
67
64
  readonly UserSettings: "/user/settings";
68
- readonly WebpageEditor: "/webpage-editor";
65
+ readonly View: (type: string, id: string) => string;
69
66
  };
70
67
  type RoutePath = typeof RoutePath;
71
68
  type GetArrayProps<T extends unknown[], P extends string, D extends unknown[], R extends boolean> = (D extends [unknown, ...infer Rest] ? GetProperties<T[number], R extends true ? `${P}[number]` : `${P}.[number]`, Rest, false> : never) | {
72
69
  path: R extends true ? "length" : `${P}.length`;
73
70
  value: T["length"];
74
71
  };
75
- type KnownKeys<T> = { [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K] };
72
+ type KnownKeys<T> = { [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K]; };
76
73
  type GetObjectProps<T, P extends string, D extends unknown[], R extends boolean> = { [K in keyof KnownKeys<T> & (number | string)]: K extends `${number}` ? never : NonNullable<T[K]> extends Function ? never : (D extends [unknown, ...infer Rest] ? GetProperties<T[K], R extends true ? `${K}` : `${P}.${K}`, Rest, false> : never) | {
77
74
  path: R extends true ? `${K}` : `${P}.${K}`;
78
75
  value: T[K];
79
- } }[keyof KnownKeys<T> & (number | string)];
76
+ }; }[keyof KnownKeys<T> & (number | string)];
80
77
  type GetPrimitiveProps<T, P extends string, D extends unknown[], R extends boolean> = T extends string ? {
81
78
  path: R extends true ? "length" : `${P}.length`;
82
79
  value: number;
@@ -84,11 +81,11 @@ type GetPrimitiveProps<T, P extends string, D extends unknown[], R extends boole
84
81
  path: R extends true ? "description" : `${P}.description`;
85
82
  value: string | undefined;
86
83
  } : never;
87
- type GetProperties<T, P extends string = "", D extends unknown[] = [unknown, unknown, unknown, unknown, unknown], R extends boolean = true> = [T] extends [never] ? never : D extends [] ? never : NonNullable<T> extends infer O ? O extends unknown[] ? GetArrayProps<O, P, D, R> : O extends object ? GetObjectProps<O, P, D, R> : GetPrimitiveProps<O, P, D, R> : never;
88
- type GetPaths<T> = GetProperties<T> extends infer U ? (U extends {
84
+ type GetProperties<T, P extends string = "", D extends unknown[] = [unknown, unknown, unknown, unknown, unknown], R extends boolean = true> = [T] extends [never] ? never : D extends [] ? never : NonNullable<T> extends (infer O) ? O extends unknown[] ? GetArrayProps<O, P, D, R> : O extends object ? GetObjectProps<O, P, D, R> : GetPrimitiveProps<O, P, D, R> : never;
85
+ type GetPaths<T> = GetProperties<T> extends (infer U) ? (U extends {
89
86
  path: infer Path;
90
87
  } ? Path : never) : never;
91
- type PropertyNames<T> = { [P in GetPaths<T>]: P };
88
+ type PropertyNames<T> = { [P in GetPaths<T>]: P; };
92
89
  interface ItemEntityType<T extends string> {
93
90
  type: T;
94
91
  }
@@ -233,8 +230,8 @@ const update2: UpdateOperation<User> = {
233
230
  @category Utilities
234
231
  */
235
232
  type OptionalKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
236
- ? (keyof { [Key in keyof Type as IsOptionalKeyOf<Type, Key> extends false ? never : Key]: never }) & keyof Type // Intersect with `keyof Type` to ensure result of `OptionalKeysOf<Type>` is always assignable to `keyof Type`
237
- : never;
233
+ ? (keyof { [Key in keyof Type as IsOptionalKeyOf<Type, Key> extends false ? never : Key]: never; }) & keyof Type // Intersect with `keyof Type` to ensure result of `OptionalKeysOf<Type>` is always assignable to `keyof Type`
234
+ : never; // Should never happen
238
235
  /**
239
236
  Extract all required keys from the given type.
240
237
 
@@ -266,7 +263,7 @@ const validator3 = createValidation<User>('luckyNumber', value => value > 0);
266
263
  @category Utilities
267
264
  */
268
265
  type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
269
- ? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
266
+ ? Exclude<keyof Type, OptionalKeysOf<Type>> : never; // Should never happen
270
267
  /**
271
268
  Returns a boolean for whether the given type is `never`.
272
269
 
@@ -457,16 +454,16 @@ An if-else-like type that resolves depending on whether the given type is `any`
457
454
 
458
455
  @example
459
456
  ```
460
- // When `T` is a NOT `any` or `never` (like `string`) => Returns `IfNotAnyOrNever` branch
461
- type A = IfNotAnyOrNever<string, 'VALID', 'IS_ANY', 'IS_NEVER'>;
457
+ // When `T` is neither `any` nor `never` (like `string`) => Returns `IfNot` branch
458
+ type A = IfNotAnyOrNever<string, {ifNot: 'VALID'; ifAny: 'IS_ANY'; ifNever: 'IS_NEVER'}>;
462
459
  //=> 'VALID'
463
460
 
464
461
  // When `T` is `any` => Returns `IfAny` branch
465
- type B = IfNotAnyOrNever<any, 'VALID', 'IS_ANY', 'IS_NEVER'>;
462
+ type B = IfNotAnyOrNever<any, {ifNot: 'VALID'; ifAny: 'IS_ANY'; ifNever: 'IS_NEVER'}>;
466
463
  //=> 'IS_ANY'
467
464
 
468
465
  // When `T` is `never` => Returns `IfNever` branch
469
- type C = IfNotAnyOrNever<never, 'VALID', 'IS_ANY', 'IS_NEVER'>;
466
+ type C = IfNotAnyOrNever<never, {ifNot: 'VALID'; ifAny: 'IS_ANY'; ifNever: 'IS_NEVER'}>;
470
467
  //=> 'IS_NEVER'
471
468
  ```
472
469
 
@@ -479,7 +476,7 @@ import type {StringRepeat} from 'type-fest';
479
476
  type NineHundredNinetyNineSpaces = StringRepeat<' ', 999>;
480
477
 
481
478
  // The following implementation is not tail recursive
482
- type TrimLeft<S extends string> = IfNotAnyOrNever<S, S extends ` ${infer R}` ? TrimLeft<R> : S>;
479
+ type TrimLeft<S extends string> = IfNotAnyOrNever<S, {ifNot: S extends ` ${infer R}` ? TrimLeft<R> : S}>;
483
480
 
484
481
  // Hence, instantiations with long strings will fail
485
482
  // @ts-expect-error
@@ -488,7 +485,7 @@ type T1 = TrimLeft<NineHundredNinetyNineSpaces>;
488
485
  // Error: Type instantiation is excessively deep and possibly infinite.
489
486
 
490
487
  // To fix this, move the recursion into a helper type
491
- type TrimLeftOptimised<S extends string> = IfNotAnyOrNever<S, _TrimLeftOptimised<S>>;
488
+ type TrimLeftOptimised<S extends string> = IfNotAnyOrNever<S, {ifNot: _TrimLeftOptimised<S>}>;
492
489
 
493
490
  type _TrimLeftOptimised<S extends string> = S extends ` ${infer R}` ? _TrimLeftOptimised<R> : S;
494
491
 
@@ -496,7 +493,11 @@ type T2 = TrimLeftOptimised<NineHundredNinetyNineSpaces>;
496
493
  //=> ''
497
494
  ```
498
495
  */
499
- type IfNotAnyOrNever<T, IfNotAnyOrNever, IfAny = any, IfNever = never> = If<IsAny<T>, IfAny, If<IsNever<T>, IfNever, IfNotAnyOrNever>>;
496
+ type IfNotAnyOrNever<T, Cases extends {
497
+ ifNot: unknown;
498
+ ifAny?: unknown;
499
+ ifNever?: unknown;
500
+ }> = IsAny<T> extends true ? 'ifAny' extends keyof Cases ? Cases['ifAny'] : any : IsNever<T> extends true ? 'ifNever' extends keyof Cases ? Cases['ifNever'] : never : Cases['ifNot'];
500
501
  /**
501
502
  Indicates the value of `exactOptionalPropertyTypes` compiler option.
502
503
  */
@@ -532,22 +533,25 @@ type B = CollapseRestElement<[string?, string?, ...number[]]>;
532
533
  //=> [string | undefined, string | undefined, number]
533
534
  ```
534
535
  */
535
- type CollapseRestElement<TArray extends UnknownArray> = IfNotAnyOrNever<TArray, _CollapseRestElement<TArray>>;
536
+ type CollapseRestElement<TArray extends UnknownArray> = IfNotAnyOrNever<TArray, {
537
+ ifNot: _CollapseRestElement<TArray>;
538
+ }>;
536
539
  type _CollapseRestElement<TArray extends UnknownArray, ForwardAccumulator extends UnknownArray = [], BackwardAccumulator extends UnknownArray = []> = TArray extends UnknownArray // For distributing `TArray`
537
- ? keyof TArray & `${number}` extends never // Enters this branch, if `TArray` is empty (e.g., []),
540
+ ? keyof TArray & `${number}` extends never ?
541
+ // Enters this branch, if `TArray` is empty (e.g., []),
538
542
  // or `TArray` contains no non-rest elements preceding the rest element (e.g., `[...string[]]` or `[...string[], string]`).
539
- ? TArray extends readonly [...infer Rest, infer Last] ? _CollapseRestElement<Rest, ForwardAccumulator, [Last, ...BackwardAccumulator]> // Accumulate elements that are present after the rest element.
540
- : TArray extends readonly [] ? [...ForwardAccumulator, ...BackwardAccumulator] : [...ForwardAccumulator, TArray[number], ...BackwardAccumulator] // Add the rest element between the accumulated elements.
541
- : TArray extends readonly [(infer First)?, ...infer Rest] ? _CollapseRestElement<Rest, [...ForwardAccumulator, '0' extends OptionalKeysOf<TArray> ? If<IsExactOptionalPropertyTypesEnabled, First, First | undefined> // Add `| undefined` for optional elements, if `exactOptionalPropertyTypes` is disabled.
542
- : First], BackwardAccumulator> : never // Should never happen, since `[(infer First)?, ...infer Rest]` is a top-type for arrays.
543
- : never; // Should never happen
544
- type Whitespace = '\u{9}' // '\t'
545
- | '\u{A}' // '\n'
546
- | '\u{B}' // '\v'
547
- | '\u{C}' // '\f'
548
- | '\u{D}' // '\r'
549
- | '\u{20}' // ' '
550
- | '\u{85}' | '\u{A0}' | '\u{1680}' | '\u{2000}' | '\u{2001}' | '\u{2002}' | '\u{2003}' | '\u{2004}' | '\u{2005}' | '\u{2006}' | '\u{2007}' | '\u{2008}' | '\u{2009}' | '\u{200A}' | '\u{2028}
' | '\u{2029}
' | '\u{202F}' | '\u{205F}' | '\u{3000}' | '\u{FEFF}';
543
+ TArray extends readonly [...infer Rest, infer Last] ? _CollapseRestElement<Rest, ForwardAccumulator, [Last, ...BackwardAccumulator]> // Accumulate elements that are present after the rest element.
544
+ : TArray extends readonly [] ? [...ForwardAccumulator, ...BackwardAccumulator] : [...ForwardAccumulator, TArray[number], ...BackwardAccumulator] // Add the rest element between the accumulated elements.
545
+ : TArray extends readonly [(infer First)?, ...infer Rest] ? _CollapseRestElement<Rest, [...ForwardAccumulator, '0' extends OptionalKeysOf<TArray> ? If<IsExactOptionalPropertyTypesEnabled, First, First | undefined> // Add `| undefined` for optional elements, if `exactOptionalPropertyTypes` is disabled.
546
+ : First], BackwardAccumulator> : never // Should never happen, since `[(infer First)?, ...infer Rest]` is a top-type for arrays.
547
+ : never; // Should never happen
548
+ type Whitespace = '\t' // '\t'
549
+ | '\n' // '\n'
550
+ | '\v' // '\v'
551
+ | '\f' // '\f'
552
+ | '\r' // '\r'
553
+ | ' ' // ' '
554
+ | '…' | ' ' | ' ' | ' ' | ' ' | ' ' | ' ' | ' ' | ' ' | ' ' | ' ' | ' ' | ' ' | ' ' | '
' | '
' | ' ' | ' ' | ' ' | '';
551
555
  type WordSeparators = '-' | '_' | Whitespace;
552
556
  type AsciiPunctuation = '!' | '"' | '#' | '$' | '%' | '&' | '\'' | '(' | ')' | '*' | '+' | ',' | '-' | '.' | '/' | ':' | ';' | '<' | '=' | '>' | '?' | '@' | '[' | '\\' | ']' | '^' | '_' | '`' | '{' | '|' | '}' | '~';
553
557
  declare const tag: unique symbol;
@@ -555,7 +559,7 @@ declare const tag: unique symbol;
555
559
  type TagContainer<Token> = {
556
560
  readonly [tag]: Token;
557
561
  };
558
- type Tag<Token extends PropertyKey, TagMetadata> = TagContainer<{ [K in Token]: TagMetadata }>;
562
+ type Tag<Token extends PropertyKey, TagMetadata> = TagContainer<{ [K in Token]: TagMetadata; }>;
559
563
  /**
560
564
  Create a [tagged type](https://medium.com/@KevinBGreene/surviving-the-typescript-ecosystem-branding-and-type-tagging-6cf6e516523d) that can support [multiple tags](https://github.com/sindresorhus/type-fest/issues/665) and [per-tag metadata](https://medium.com/@ethanresnick/advanced-typescript-tagged-types-improved-with-type-level-metadata-5072fc125fcf).
561
565
 
@@ -646,81 +650,7 @@ type WontWork = UnwrapTagged<string>;
646
650
  @category Type
647
651
  */
648
652
  type UnwrapTagged<TaggedType extends Tag<PropertyKey, any>> = RemoveAllTags<TaggedType>;
649
- type RemoveAllTags<T> = T extends Tag<PropertyKey, any> ? { [ThisTag in keyof T[typeof tag]]: T extends Tagged<infer Type, ThisTag, T[typeof tag][ThisTag]> ? RemoveAllTags<Type> : never }[keyof T[typeof tag]] : T;
650
- /**
651
- Note: The `Opaque` type is deprecated in favor of `Tagged`.
652
-
653
- Attach a "tag" to an arbitrary type. This allows you to create distinct types, that aren't assignable to one another, for runtime values that would otherwise have the same type. (See examples.)
654
-
655
- The generic type parameters can be anything.
656
-
657
- Note that `Opaque` is somewhat of a misnomer here, in that, unlike [some alternative implementations](https://github.com/microsoft/TypeScript/issues/4895#issuecomment-425132582), the original, untagged type is not actually hidden. (E.g., functions that accept the untagged type can still be called with the "opaque" version -- but not vice-versa.)
658
-
659
- Also note that this implementation is limited to a single tag. If you want to allow multiple tags, use `Tagged` instead.
660
-
661
- [Read more about tagged types.](https://medium.com/@KevinBGreene/surviving-the-typescript-ecosystem-branding-and-type-tagging-6cf6e516523d)
662
-
663
- There have been several discussions about adding similar features to TypeScript. Unfortunately, nothing has (yet) moved forward:
664
- - [Microsoft/TypeScript#202](https://github.com/microsoft/TypeScript/issues/202)
665
- - [Microsoft/TypeScript#15408](https://github.com/Microsoft/TypeScript/issues/15408)
666
- - [Microsoft/TypeScript#15807](https://github.com/Microsoft/TypeScript/issues/15807)
667
-
668
- @example
669
- ```
670
- import type {Opaque} from 'type-fest';
671
-
672
- type AccountNumber = Opaque<number, 'AccountNumber'>;
673
- type AccountBalance = Opaque<number, 'AccountBalance'>;
674
-
675
- // The `Token` parameter allows the compiler to differentiate between types, whereas "unknown" will not. For example, consider the following structures:
676
- type ThingOne = Opaque<string>;
677
- type ThingTwo = Opaque<string>;
678
-
679
- // To the compiler, these types are allowed to be cast to each other as they have the same underlying type. They are both `string & { __opaque__: unknown }`.
680
- // To avoid this behaviour, you would instead pass the "Token" parameter, like so.
681
- type NewThingOne = Opaque<string, 'ThingOne'>;
682
- type NewThingTwo = Opaque<string, 'ThingTwo'>;
683
-
684
- // Now they're completely separate types, so the following will fail to compile.
685
- function createNewThingOne(): NewThingOne {
686
- // As you can see, casting from a string is still allowed. However, you may not cast NewThingOne to NewThingTwo, and vice versa.
687
- return 'new thing one' as NewThingOne;
688
- }
689
-
690
- // This will fail to compile, as they are fundamentally different types.
691
- // @ts-expect-error
692
- const thingTwo = createNewThingOne() as NewThingTwo;
693
-
694
- // Here's another example of opaque typing.
695
- function createAccountNumber(): AccountNumber {
696
- return 2 as AccountNumber;
697
- }
698
-
699
- declare function getMoneyForAccount(accountNumber: AccountNumber): AccountBalance;
700
-
701
- // This will compile successfully.
702
- getMoneyForAccount(createAccountNumber());
703
-
704
- // But this won't, because it has to be explicitly passed as an `AccountNumber` type.
705
- // @ts-expect-error
706
- getMoneyForAccount(2);
707
-
708
- // You can use opaque values like they aren't opaque too.
709
- const accountNumber = createAccountNumber();
710
-
711
- // This will compile successfully.
712
- const newAccountNumber = accountNumber + 2;
713
-
714
- // As a side note, you can (and should) use recursive types for your opaque types to make them stronger and hopefully easier to type.
715
- type Person = {
716
- id: Opaque<number, Person>;
717
- name: string;
718
- };
719
- ```
720
-
721
- @category Type
722
- @deprecated Use {@link Tagged} instead
723
- */
653
+ type RemoveAllTags<T> = T extends Tag<PropertyKey, any> ? { [ThisTag in keyof T[typeof tag]]: T extends Tagged<infer Type, ThisTag, T[typeof tag][ThisTag]> ? RemoveAllTags<Type> : never; }[keyof T[typeof tag]] : T;
724
654
  /**
725
655
  Returns a boolean for whether the given type is a `string` [literal type](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#literal-types).
726
656
 
@@ -777,8 +707,13 @@ type L2 = Length<`${number}`>;
777
707
  @category Type Guard
778
708
  @category Utilities
779
709
  */
780
- type IsStringLiteral<S> = IfNotAnyOrNever<S, _IsStringLiteral<CollapseLiterals<S extends TagContainer<any> ? UnwrapTagged<S> : S>>, false, false>;
781
- type _IsStringLiteral<S> = // If `T` is an infinite string type (e.g., `on${string}`), `Record<T, never>` produces an index signature,
710
+ type IsStringLiteral<S> = IfNotAnyOrNever<S, {
711
+ ifNot: _IsStringLiteral<CollapseLiterals<S extends TagContainer<any> ? UnwrapTagged<S> : S>>;
712
+ ifAny: false;
713
+ ifNever: false;
714
+ }>;
715
+ type _IsStringLiteral<S> =
716
+ // If `T` is an infinite string type (e.g., `on${string}`), `Record<T, never>` produces an index signature,
782
717
  // and since `{}` extends index signatures, the result becomes `false`.
783
718
  S extends string ? {} extends Record<S, never> ? false : true : false;
784
719
  /**
@@ -805,34 +740,6 @@ type Example = Trim<' foo '>;
805
740
  */
806
741
  type Trim<V extends string> = TrimLeft<TrimRight<V>>;
807
742
  /**
808
- Returns a boolean for whether the given string `S` starts with the given string `SearchString`.
809
-
810
- @example
811
- ```
812
- type A = StartsWith<'abcde', 'abc'>;
813
- //=> true
814
-
815
- type B = StartsWith<'abcde', 'bc'>;
816
- //=> false
817
-
818
- type C = StartsWith<string, 'bc'>;
819
- //=> never
820
-
821
- type D = StartsWith<'abcde', string>;
822
- //=> never
823
- ```
824
-
825
- @category String
826
- @category Template literal
827
- */
828
- type StartsWith<S extends string, SearchString extends string> = string extends S | SearchString ? never : S extends `${SearchString}${infer T}` ? true : false;
829
- /**
830
- Returns a boolean for whether the string is numeric.
831
-
832
- This type is a workaround for [Microsoft/TypeScript#46109](https://github.com/microsoft/TypeScript/issues/46109#issuecomment-930307987).
833
- */
834
- type IsNumeric<T extends string> = T extends `${number}` ? Trim<T> extends T ? true : false : false;
835
- /**
836
743
  Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
837
744
 
838
745
  @example
@@ -890,7 +797,7 @@ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface`
890
797
  @see {@link SimplifyDeep}
891
798
  @category Object
892
799
  */
893
- type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
800
+ type Simplify<T> = { [KeyType in keyof T]: T[KeyType]; } & {};
894
801
  /**
895
802
  Returns a boolean for whether the two given types are equal.
896
803
 
@@ -1011,7 +918,7 @@ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
1011
918
  @see {@link PickIndexSignature}
1012
919
  @category Object
1013
920
  */
1014
- type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
921
+ type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType]; };
1015
922
  /**
1016
923
  Pick only index signatures from the given object type, leaving out all explicitly defined properties.
1017
924
 
@@ -1057,9 +964,9 @@ type ExampleIndexSignature = PickIndexSignature<Example>;
1057
964
  @see {@link OmitIndexSignature}
1058
965
  @category Object
1059
966
  */
1060
- type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
967
+ type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType]; };
1061
968
  // Merges two objects without worrying about index signatures.
1062
- type SimpleMerge<Destination, Source> = Simplify<{ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source>;
969
+ type SimpleMerge<Destination, Source> = Simplify<{ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key]; } & Source>;
1063
970
  /**
1064
971
  Merge two types into a new type. Keys of the second type overrides keys of the first type.
1065
972
 
@@ -1123,10 +1030,9 @@ Note: If you want a merge type that more accurately reflects the runtime behavio
1123
1030
  @category Object
1124
1031
  */
1125
1032
  type Merge<Destination, Source> = Destination extends unknown // For distributing `Destination`
1126
- ? Source extends unknown // For distributing `Source`
1127
- ? If<IsEqual<Destination, Source>, Destination, _Merge<Destination, Source>> : never // Should never happen
1128
- : never;
1129
- // Should never happen
1033
+ ? Source extends unknown // For distributing `Source`
1034
+ ? If<IsEqual<Destination, Source>, Destination, _Merge<Destination, Source>> : never // Should never happen
1035
+ : never; // Should never happen
1130
1036
  type _Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
1131
1037
  /**
1132
1038
  Merges user specified options with default options.
@@ -1180,9 +1086,9 @@ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOp
1180
1086
  // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
1181
1087
  ```
1182
1088
  */
1183
- type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = _ApplyDefaultOptions<Options, Defaults, SpecifiedOptions> extends infer Result extends Required<Options> // `extends Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
1184
- ? Result : never;
1185
- type _ApplyDefaultOptions<Options, Defaults, SpecifiedOptions> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever<SpecifiedOptions>, Defaults, Merge<Defaults, { [Key in keyof SpecifiedOptions as undefined extends Required<Options>[Key & keyof Options] ? Key : undefined extends SpecifiedOptions[Key] ? never : Key]: SpecifiedOptions[Key] }>>>;
1089
+ type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = _ApplyDefaultOptions<Options, Defaults, SpecifiedOptions> extends (infer Result extends Required<Options> // `extends Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
1090
+ ) ? Result : never;
1091
+ type _ApplyDefaultOptions<Options, Defaults, SpecifiedOptions> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever<SpecifiedOptions>, Defaults, Merge<Defaults, { [Key in keyof SpecifiedOptions as undefined extends Required<Options>[Key & keyof Options] ? Key : undefined extends SpecifiedOptions[Key] ? never : Key]: SpecifiedOptions[Key]; }>>>;
1186
1092
  /**
1187
1093
  Collapses literal types in a union into their corresponding primitive types, when possible. For example, `CollapseLiterals<'foo' | 'bar' | (string & {})>` returns `string`.
1188
1094
 
@@ -1210,33 +1116,42 @@ type E = CollapseLiterals<LiteralUnion<'foo' | 'bar', string> | null | undefined
1210
1116
  //=> string | null | undefined
1211
1117
  ```
1212
1118
  */
1213
- type CollapseLiterals<T> = {} extends T ? T : T extends infer U & {} ? U : T;
1119
+ type CollapseLiterals<T> = {} extends T ? T : T extends (infer U) & {} ? U : T;
1214
1120
  /**
1215
1121
  @see {@link SomeExtend}
1216
1122
  */
1217
1123
  type SomeExtendOptions = {
1218
1124
  /**
1219
- Consider `never` elements to match the target type only if the target type itself is `never` (or `any`).
1220
- - When set to `true` (default), `never` is _not_ treated as a bottom type, instead, it is treated as a type that matches only itself (or `any`).
1221
- - When set to `false`, `never` is treated as a bottom type, and behaves as it normally would.
1222
- @default true
1223
- @example
1224
- ```
1225
- import type {SomeExtend} from 'type-fest';
1226
- type A = SomeExtend<[1, 2, never], string, {strictNever: true}>;
1227
- //=> false
1228
- type B = SomeExtend<[1, 2, never], string, {strictNever: false}>;
1229
- //=> true
1230
- type C = SomeExtend<[1, never], never, {strictNever: true}>;
1231
- //=> true
1232
- type D = SomeExtend<[1, never], never, {strictNever: false}>;
1233
- //=> true
1234
- type E = SomeExtend<[never], any, {strictNever: true}>;
1235
- //=> true
1236
- type F = SomeExtend<[never], any, {strictNever: false}>;
1237
- //=> true
1238
- ```
1239
- */
1125
+ Consider `never` elements to match the target type only if the target type itself is `never` (or `any`).
1126
+
1127
+ - When set to `true` (default), `never` is _not_ treated as a bottom type, instead, it is treated as a type that matches only itself (or `any`).
1128
+ - When set to `false`, `never` is treated as a bottom type, and behaves as it normally would.
1129
+
1130
+ @default true
1131
+
1132
+ @example
1133
+ ```
1134
+ import type {SomeExtend} from 'type-fest';
1135
+
1136
+ type A = SomeExtend<[1, 2, never], string, {strictNever: true}>;
1137
+ //=> false
1138
+
1139
+ type B = SomeExtend<[1, 2, never], string, {strictNever: false}>;
1140
+ //=> true
1141
+
1142
+ type C = SomeExtend<[1, never], never, {strictNever: true}>;
1143
+ //=> true
1144
+
1145
+ type D = SomeExtend<[1, never], never, {strictNever: false}>;
1146
+ //=> true
1147
+
1148
+ type E = SomeExtend<[never], any, {strictNever: true}>;
1149
+ //=> true
1150
+
1151
+ type F = SomeExtend<[never], any, {strictNever: false}>;
1152
+ //=> true
1153
+ ```
1154
+ */
1240
1155
  strictNever?: boolean;
1241
1156
  };
1242
1157
  type DefaultSomeExtendOptions = {
@@ -1289,8 +1204,13 @@ type B = SomeExtend<[1?, 2?, '3'?], string | undefined>;
1289
1204
  @category Array
1290
1205
  */
1291
1206
  type SomeExtend<TArray extends UnknownArray, Type, Options extends SomeExtendOptions = {}> = _SomeExtend<CollapseRestElement<TArray>, Type, ApplyDefaultOptions<SomeExtendOptions, DefaultSomeExtendOptions, Options>>;
1292
- type _SomeExtend<TArray extends UnknownArray, Type, Options extends Required<SomeExtendOptions>> = IfNotAnyOrNever<TArray, TArray extends readonly [infer First, ...infer Rest] ? IsNever<First> extends true ? Or<Or<IsNever<Type>, IsAny<Type>>, Not<Options['strictNever']>> extends true // If target `Type` is also `never`, or is `any`, or `strictNever` is disabled, return `true`.
1293
- ? true : _SomeExtend<Rest, Type, Options> : First extends Type ? true : _SomeExtend<Rest, Type, Options> : false, false, false>;
1207
+ type _SomeExtend<TArray extends UnknownArray, Type, Options extends Required<SomeExtendOptions>> = IfNotAnyOrNever<TArray, {
1208
+ ifNot: TArray extends readonly [infer First, ...infer Rest] ? IsNever<First> extends true ? Or<Or<IsNever<Type>, IsAny<Type>>, Not<Options['strictNever']>> extends true ?
1209
+ // If target `Type` is also `never`, or is `any`, or `strictNever` is disabled, return `true`.
1210
+ true : _SomeExtend<Rest, Type, Options> : First extends Type ? true : _SomeExtend<Rest, Type, Options> : false;
1211
+ ifAny: false;
1212
+ ifNever: false;
1213
+ }>;
1294
1214
  /**
1295
1215
  Returns a boolean for whether any of the given elements is `true`.
1296
1216
 
@@ -1439,35 +1359,74 @@ type G = Or<never, never>;
1439
1359
  */
1440
1360
  type Or<A extends boolean, B extends boolean> = OrAll<[A, B]>;
1441
1361
  /**
1362
+ Returns a boolean for whether the given string `S` starts with the given string `SearchString`.
1363
+
1364
+ @example
1365
+ ```
1366
+ type A = StartsWith<'abcde', 'abc'>;
1367
+ //=> true
1368
+
1369
+ type B = StartsWith<'abcde', 'bc'>;
1370
+ //=> false
1371
+
1372
+ type C = StartsWith<string, 'bc'>;
1373
+ //=> never
1374
+
1375
+ type D = StartsWith<'abcde', string>;
1376
+ //=> never
1377
+ ```
1378
+
1379
+ @category String
1380
+ @category Template literal
1381
+ */
1382
+ type StartsWith<S extends string, SearchString extends string> = string extends S | SearchString ? never : S extends `${SearchString}${infer T}` ? true : false;
1383
+ /**
1384
+ Returns a boolean for whether the string is numeric.
1385
+
1386
+ This type is a workaround for [Microsoft/TypeScript#46109](https://github.com/microsoft/TypeScript/issues/46109#issuecomment-930307987).
1387
+ */
1388
+ type IsNumeric<T extends string> = T extends `${number}` ? Trim<T> extends T ? true : false : false;
1389
+ /**
1442
1390
  @see {@link AllExtend}
1443
1391
  */
1444
1392
  type AllExtendOptions = {
1445
1393
  /**
1446
- Consider `never` elements to match the target type only if the target type itself is `never` (or `any`).
1447
- - When set to `true` (default), `never` is _not_ treated as a bottom type, instead, it is treated as a type that matches only itself (or `any`).
1448
- - When set to `false`, `never` is treated as a bottom type, and behaves as it normally would.
1449
- @default true
1450
- @example
1451
- ```
1452
- import type {AllExtend} from 'type-fest';
1453
- type A = AllExtend<[1, 2, never], number, {strictNever: true}>;
1454
- //=> false
1455
- type B = AllExtend<[1, 2, never], number, {strictNever: false}>;
1456
- //=> true
1457
- type C = AllExtend<[never, never], never, {strictNever: true}>;
1458
- //=> true
1459
- type D = AllExtend<[never, never], never, {strictNever: false}>;
1460
- //=> true
1461
- type E = AllExtend<['a', 'b', never], any, {strictNever: true}>;
1462
- //=> true
1463
- type F = AllExtend<['a', 'b', never], any, {strictNever: false}>;
1464
- //=> true
1465
- type G = AllExtend<[never, 1], never, {strictNever: true}>;
1466
- //=> false
1467
- type H = AllExtend<[never, 1], never, {strictNever: false}>;
1468
- //=> false
1469
- ```
1470
- */
1394
+ Consider `never` elements to match the target type only if the target type itself is `never` (or `any`).
1395
+
1396
+ - When set to `true` (default), `never` is _not_ treated as a bottom type, instead, it is treated as a type that matches only itself (or `any`).
1397
+ - When set to `false`, `never` is treated as a bottom type, and behaves as it normally would.
1398
+
1399
+ @default true
1400
+
1401
+ @example
1402
+ ```
1403
+ import type {AllExtend} from 'type-fest';
1404
+
1405
+ type A = AllExtend<[1, 2, never], number, {strictNever: true}>;
1406
+ //=> false
1407
+
1408
+ type B = AllExtend<[1, 2, never], number, {strictNever: false}>;
1409
+ //=> true
1410
+
1411
+ type C = AllExtend<[never, never], never, {strictNever: true}>;
1412
+ //=> true
1413
+
1414
+ type D = AllExtend<[never, never], never, {strictNever: false}>;
1415
+ //=> true
1416
+
1417
+ type E = AllExtend<['a', 'b', never], any, {strictNever: true}>;
1418
+ //=> true
1419
+
1420
+ type F = AllExtend<['a', 'b', never], any, {strictNever: false}>;
1421
+ //=> true
1422
+
1423
+ type G = AllExtend<[never, 1], never, {strictNever: true}>;
1424
+ //=> false
1425
+
1426
+ type H = AllExtend<[never, 1], never, {strictNever: false}>;
1427
+ //=> false
1428
+ ```
1429
+ */
1471
1430
  strictNever?: boolean;
1472
1431
  };
1473
1432
  type DefaultAllExtendOptions = {
@@ -1520,8 +1479,13 @@ type B = AllExtend<[1?, 2?, 3?], number | undefined>;
1520
1479
  @category Array
1521
1480
  */
1522
1481
  type AllExtend<TArray extends UnknownArray, Type, Options extends AllExtendOptions = {}> = _AllExtend<CollapseRestElement<TArray>, Type, ApplyDefaultOptions<AllExtendOptions, DefaultAllExtendOptions, Options>>;
1523
- type _AllExtend<TArray extends UnknownArray, Type, Options extends Required<AllExtendOptions>> = IfNotAnyOrNever<TArray, TArray extends readonly [infer First, ...infer Rest] ? IsNever<First> extends true ? Or<Or<IsNever<Type>, IsAny<Type>>, Not<Options['strictNever']>> extends true // If target `Type` is also `never`, or is `any`, or `strictNever` is disabled, recurse further.
1524
- ? _AllExtend<Rest, Type, Options> : false : First extends Type ? _AllExtend<Rest, Type, Options> : false : true, false, false>;
1482
+ type _AllExtend<TArray extends UnknownArray, Type, Options extends Required<AllExtendOptions>> = IfNotAnyOrNever<TArray, {
1483
+ ifNot: TArray extends readonly [infer First, ...infer Rest] ? IsNever<First> extends true ? Or<Or<IsNever<Type>, IsAny<Type>>, Not<Options['strictNever']>> extends true ?
1484
+ // If target `Type` is also `never`, or is `any`, or `strictNever` is disabled, recurse further.
1485
+ _AllExtend<Rest, Type, Options> : false : First extends Type ? _AllExtend<Rest, Type, Options> : false : true;
1486
+ ifAny: false;
1487
+ ifNever: false;
1488
+ }>;
1525
1489
  /**
1526
1490
  Filter out keys from an object.
1527
1491
 
@@ -1552,10 +1516,12 @@ type Filtered = Filter<'bar', 'foo'>;
1552
1516
  type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
1553
1517
  type ExceptOptions = {
1554
1518
  /**
1555
- Disallow assigning non-specified properties.
1556
- Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
1557
- @default false
1558
- */
1519
+ Disallow assigning non-specified properties.
1520
+
1521
+ Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
1522
+
1523
+ @default false
1524
+ */
1559
1525
  requireExactProps?: boolean;
1560
1526
  };
1561
1527
  type DefaultExceptOptions = {
@@ -1617,7 +1583,7 @@ type PostPayloadFixed = Except<UserData, 'email'>;
1617
1583
  @category Object
1618
1584
  */
1619
1585
  type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {}> = _Except<ObjectType, KeysType, ApplyDefaultOptions<ExceptOptions, DefaultExceptOptions, Options>>;
1620
- type _Except<ObjectType, KeysType extends keyof ObjectType, Options extends Required<ExceptOptions>> = { [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType] } & (Options['requireExactProps'] extends true ? Partial<Record<KeysType, never>> : {});
1586
+ type _Except<ObjectType, KeysType extends keyof ObjectType, Options extends Required<ExceptOptions>> = { [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType]; } & (Options['requireExactProps'] extends true ? Partial<Record<KeysType, never>> : {});
1621
1587
  /**
1622
1588
  Create a type that represents either the value or the value wrapped in `PromiseLike`.
1623
1589
 
@@ -1704,29 +1670,36 @@ Words options.
1704
1670
  */
1705
1671
  type WordsOptions = {
1706
1672
  /**
1707
- Split on numeric sequence.
1708
- @default true
1709
- @example
1710
- ```
1711
- import type {Words} from 'type-fest';
1712
- type Example1 = Words<'p2pNetwork', {splitOnNumbers: true}>;
1713
- //=> ['p', '2', 'p', 'Network']
1714
- type Example2 = Words<'p2pNetwork', {splitOnNumbers: false}>;
1715
- //=> ['p2p', 'Network']
1716
- ```
1717
- */
1673
+ Split on numeric sequence.
1674
+
1675
+ @default true
1676
+
1677
+ @example
1678
+ ```
1679
+ import type {Words} from 'type-fest';
1680
+
1681
+ type Example1 = Words<'p2pNetwork', {splitOnNumbers: true}>;
1682
+ //=> ['p', '2', 'p', 'Network']
1683
+
1684
+ type Example2 = Words<'p2pNetwork', {splitOnNumbers: false}>;
1685
+ //=> ['p2p', 'Network']
1686
+ ```
1687
+ */
1718
1688
  splitOnNumbers?: boolean;
1719
1689
  /**
1720
- Split on {@link AsciiPunctuation | punctuation characters} (e.g., `#`, `&`, `*`, `:`, `?`, `@`, `~`).
1721
- @example
1722
- ```
1723
- import type {Words} from 'type-fest';
1724
- type Example1 = Words<'hello:world', {splitOnPunctuation: true}>;
1725
- //=> ['hello', 'world']
1726
- type Example2 = Words<'hello:world', {splitOnPunctuation: false}>;
1727
- //=> ['hello', ':world']
1728
- ```
1729
- */
1690
+ Split on {@link AsciiPunctuation | punctuation characters} (e.g., `#`, `&`, `*`, `:`, `?`, `@`, `~`).
1691
+
1692
+ @example
1693
+ ```
1694
+ import type {Words} from 'type-fest';
1695
+
1696
+ type Example1 = Words<'hello:world', {splitOnPunctuation: true}>;
1697
+ //=> ['hello', 'world']
1698
+
1699
+ type Example2 = Words<'hello:world', {splitOnPunctuation: false}>;
1700
+ //=> ['hello', ':world']
1701
+ ```
1702
+ */
1730
1703
  splitOnPunctuation?: boolean;
1731
1704
  };
1732
1705
  type _DefaultWordsOptions = {
@@ -1777,19 +1750,31 @@ type Words8 = Words<'hello::world', {splitOnPunctuation: true}>;
1777
1750
  @category Template literal
1778
1751
  */
1779
1752
  type Words<Sentence extends string, Options extends WordsOptions = {}> = WordsImplementation<Sentence, ApplyDefaultOptions<WordsOptions, _DefaultWordsOptions, Options>>;
1780
- type WordsImplementation<Sentence extends string, Options extends Required<WordsOptions>, LastCharacter extends string = '', CurrentWord extends string = ''> = Sentence extends `${infer FirstCharacter}${infer RemainingCharacters}` ? FirstCharacter extends WordSeparators | (Options['splitOnPunctuation'] extends true ? AsciiPunctuation : never) // Skip word separator
1781
- ? [...SkipEmptyWord<CurrentWord>, ...WordsImplementation<RemainingCharacters, Options>] : LastCharacter extends '' // Fist char of word
1782
- ? WordsImplementation<RemainingCharacters, Options, FirstCharacter, FirstCharacter> // Case change: non-numeric to numeric
1783
- : [false, true] extends [IsNumeric<LastCharacter>, IsNumeric<FirstCharacter>] ? Options['splitOnNumbers'] extends true // Split on number: push word
1784
- ? [...SkipEmptyWord<CurrentWord>, ...WordsImplementation<RemainingCharacters, Options, FirstCharacter, FirstCharacter>] // No split on number: concat word
1785
- : WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${CurrentWord}${FirstCharacter}`> // Case change: numeric to non-numeric
1786
- : [true, false] extends [IsNumeric<LastCharacter>, IsNumeric<FirstCharacter>] ? Options['splitOnNumbers'] extends true // Split on number: push word
1787
- ? [...SkipEmptyWord<CurrentWord>, ...WordsImplementation<RemainingCharacters, Options, FirstCharacter, FirstCharacter>] // No split on number: concat word
1788
- : WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${CurrentWord}${FirstCharacter}`> // No case change: concat word
1789
- : [true, true] extends [IsNumeric<LastCharacter>, IsNumeric<FirstCharacter>] ? WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${CurrentWord}${FirstCharacter}`> // Case change: lower to upper, push word
1790
- : [true, true] extends [IsLowercase<LastCharacter>, IsUppercase<FirstCharacter>] ? [...SkipEmptyWord<CurrentWord>, ...WordsImplementation<RemainingCharacters, Options, FirstCharacter, FirstCharacter>] // Case change: upper to lower, brings back the last character, push word
1791
- : [true, true] extends [IsUppercase<LastCharacter>, IsLowercase<FirstCharacter>] ? [...RemoveLastCharacter<CurrentWord, LastCharacter>, ...WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${LastCharacter}${FirstCharacter}`>] // No case change: concat word
1792
- : WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${CurrentWord}${FirstCharacter}`> : [...SkipEmptyWord<CurrentWord>];
1753
+ type WordsImplementation<Sentence extends string, Options extends Required<WordsOptions>, LastCharacter extends string = '', CurrentWord extends string = ''> = Sentence extends `${infer FirstCharacter}${infer RemainingCharacters}` ? FirstCharacter extends WordSeparators | (Options['splitOnPunctuation'] extends true ? AsciiPunctuation : never) ?
1754
+ // Skip word separator
1755
+ [...SkipEmptyWord<CurrentWord>, ...WordsImplementation<RemainingCharacters, Options>] : LastCharacter extends '' ?
1756
+ // Fist char of word
1757
+ WordsImplementation<RemainingCharacters, Options, FirstCharacter, FirstCharacter> :
1758
+ // Case change: non-numeric to numeric
1759
+ [false, true] extends [IsNumeric<LastCharacter>, IsNumeric<FirstCharacter>] ? Options['splitOnNumbers'] extends true ?
1760
+ // Split on number: push word
1761
+ [...SkipEmptyWord<CurrentWord>, ...WordsImplementation<RemainingCharacters, Options, FirstCharacter, FirstCharacter>] :
1762
+ // No split on number: concat word
1763
+ WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${CurrentWord}${FirstCharacter}`> :
1764
+ // Case change: numeric to non-numeric
1765
+ [true, false] extends [IsNumeric<LastCharacter>, IsNumeric<FirstCharacter>] ? Options['splitOnNumbers'] extends true ?
1766
+ // Split on number: push word
1767
+ [...SkipEmptyWord<CurrentWord>, ...WordsImplementation<RemainingCharacters, Options, FirstCharacter, FirstCharacter>] :
1768
+ // No split on number: concat word
1769
+ WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${CurrentWord}${FirstCharacter}`> :
1770
+ // No case change: concat word
1771
+ [true, true] extends [IsNumeric<LastCharacter>, IsNumeric<FirstCharacter>] ? WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${CurrentWord}${FirstCharacter}`> :
1772
+ // Case change: lower to upper, push word
1773
+ [true, true] extends [IsLowercase<LastCharacter>, IsUppercase<FirstCharacter>] ? [...SkipEmptyWord<CurrentWord>, ...WordsImplementation<RemainingCharacters, Options, FirstCharacter, FirstCharacter>] :
1774
+ // Case change: upper to lower, brings back the last character, push word
1775
+ [true, true] extends [IsUppercase<LastCharacter>, IsLowercase<FirstCharacter>] ? [...RemoveLastCharacter<CurrentWord, LastCharacter>, ...WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${LastCharacter}${FirstCharacter}`>] :
1776
+ // No case change: concat word
1777
+ WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${CurrentWord}${FirstCharacter}`> : [...SkipEmptyWord<CurrentWord>];
1793
1778
  type _DefaultDelimiterCaseOptions = Merge<_DefaultWordsOptions, {
1794
1779
  splitOnNumbers: false;
1795
1780
  }>;
@@ -1838,7 +1823,7 @@ const rawCliOptions: OddlyCasedProperties<SomeOptions> = {
1838
1823
  @category Template literal
1839
1824
  */
1840
1825
  type DelimiterCase<Value, Delimiter extends string, Options extends WordsOptions = {}> = Value extends string ? Delimiter extends string // For distributing `Delimiter`
1841
- ? IsStringLiteral<Value> extends false ? Value : Lowercase<DelimiterCaseFromArray<Words<Value, ApplyDefaultOptions<WordsOptions, _DefaultDelimiterCaseOptions, Options>>, Delimiter>> : never : Value;
1826
+ ? IsStringLiteral<Value> extends false ? Value : Lowercase<DelimiterCaseFromArray<Words<Value, ApplyDefaultOptions<WordsOptions, _DefaultDelimiterCaseOptions, Options>>, Delimiter>> : never : Value;
1842
1827
  /**
1843
1828
  Convert a string literal to kebab-case.
1844
1829
 
@@ -1877,8 +1862,8 @@ const rawCliOptions: KebabCasedProperties<CliOptions> = {
1877
1862
  @category Template literal
1878
1863
  */
1879
1864
  type KebabCase<Value, Options extends WordsOptions = {}> = DelimiterCase<Value, '-', ApplyDefaultOptions<WordsOptions, _DefaultDelimiterCaseOptions, Options>>;
1880
- type DeepOmit<T, TKey extends PropertyKey> = [T] extends [Date | Function | Primitive] ? T : [Record<string, unknown>] extends [T] ? T : T extends object ? T extends unknown[] ? T extends readonly unknown[] ? { [K in keyof T]: DeepOmit<T[K], TKey> } : DeepOmit<T[number], TKey>[] : { [P in keyof T as P extends TKey ? never : P]: DeepOmit<T[P], TKey> } : T;
1881
- type DeepOptionalUndefined<T> = T extends Date | Function | Primitive ? T : T extends unknown[] ? { [K in keyof T]: DeepOptionalUndefined<T[K]> } : T extends object ? { [K in keyof T as undefined extends T[K] ? K : never]?: DeepOptionalUndefined<T[K]> } & { [K in keyof T as undefined extends T[K] ? never : K]: DeepOptionalUndefined<T[K]> } extends infer O ? { [K in keyof O]: O[K] } : never : T;
1865
+ type DeepOmit<T, TKey extends PropertyKey> = [T] extends [Date | Function | Primitive] ? T : [Record<string, unknown>] extends [T] ? T : T extends object ? T extends unknown[] ? T extends readonly unknown[] ? { [K in keyof T]: DeepOmit<T[K], TKey>; } : DeepOmit<T[number], TKey>[] : { [P in keyof T as P extends TKey ? never : P]: DeepOmit<T[P], TKey>; } : T;
1866
+ type DeepOptionalUndefined<T> = T extends Date | Function | Primitive ? T : T extends unknown[] ? { [K in keyof T]: DeepOptionalUndefined<T[K]>; } : T extends object ? { [K in keyof T as undefined extends T[K] ? K : never]?: DeepOptionalUndefined<T[K]>; } & { [K in keyof T as undefined extends T[K] ? never : K]: DeepOptionalUndefined<T[K]>; } extends (infer O) ? { [K in keyof O]: O[K]; } : never : T;
1882
1867
  type ToData<T> = DeepOptionalUndefined<DeepOmit<T, "toJSON">>;
1883
1868
  interface WithMetadata<TBase extends Class<NonNullable<unknown>>> {
1884
1869
  new (...args: ConstructorParameters<TBase>): InstanceType<TBase> & ItemMetadata;
@@ -1886,6 +1871,7 @@ interface WithMetadata<TBase extends Class<NonNullable<unknown>>> {
1886
1871
  }
1887
1872
  declare const MAX_READ_LIMIT = 1000;
1888
1873
  declare const SITE_NAME = "Esposter";
1874
+ declare const createExponentialBackoff: (baseDelayMs: number, maxDelayMs: number) => (<T>(operation: () => Promise<T>) => Promise<T>);
1889
1875
  interface ErrorConfig {
1890
1876
  withStackTrace: boolean;
1891
1877
  }
@@ -1934,10 +1920,10 @@ declare type UnwrapAsync<T> = IsLiteralArray<T> extends 1 ? Writable<T> extends
1934
1920
  declare type TraverseAsync<T, Depth extends number = 5> = IsLiteralArray<T> extends 1 ? Combine<T, Depth> extends [infer Oks, infer Errs] ? ResultAsync<EmptyArrayToNever<Oks>, MembersToUnion<Errs>> : never : T extends Array<infer I> ? Combine<MemberListOf<I>, Depth> extends [infer Oks, infer Errs] ? Oks extends unknown[] ? Errs extends unknown[] ? ResultAsync<EmptyArrayToNever<Oks[number][]>, MembersToUnion<Errs[number][]>> : ResultAsync<EmptyArrayToNever<Oks[number][]>, Errs> : Errs extends unknown[] ? ResultAsync<Oks, MembersToUnion<Errs[number][]>> : ResultAsync<Oks, Errs> : never : never;
1935
1921
  declare type TraverseWithAllErrorsAsync<T, Depth extends number = 5> = TraverseAsync<T, Depth> extends ResultAsync<infer Oks, infer Errs> ? ResultAsync<Oks, Errs[]> : never;
1936
1922
  declare type Writable<T> = T extends ReadonlyArray<unknown> ? [...T] : T;
1937
- declare type ExtractOkTypes<T extends readonly Result<unknown, unknown>[]> = { [idx in keyof T]: T[idx] extends Result<infer U, unknown> ? U : never };
1938
- declare type ExtractOkAsyncTypes<T extends readonly ResultAsync<unknown, unknown>[]> = { [idx in keyof T]: T[idx] extends ResultAsync<infer U, unknown> ? U : never };
1939
- declare type ExtractErrTypes<T extends readonly Result<unknown, unknown>[]> = { [idx in keyof T]: T[idx] extends Result<unknown, infer E> ? E : never };
1940
- declare type ExtractErrAsyncTypes<T extends readonly ResultAsync<unknown, unknown>[]> = { [idx in keyof T]: T[idx] extends ResultAsync<unknown, infer E> ? E : never };
1923
+ declare type ExtractOkTypes<T extends readonly Result<unknown, unknown>[]> = { [idx in keyof T]: T[idx] extends Result<infer U, unknown> ? U : never; };
1924
+ declare type ExtractOkAsyncTypes<T extends readonly ResultAsync<unknown, unknown>[]> = { [idx in keyof T]: T[idx] extends ResultAsync<infer U, unknown> ? U : never; };
1925
+ declare type ExtractErrTypes<T extends readonly Result<unknown, unknown>[]> = { [idx in keyof T]: T[idx] extends Result<unknown, infer E> ? E : never; };
1926
+ declare type ExtractErrAsyncTypes<T extends readonly ResultAsync<unknown, unknown>[]> = { [idx in keyof T]: T[idx] extends ResultAsync<unknown, infer E> ? E : never; };
1941
1927
  declare type InferOkTypes<R> = R extends Result<infer T, unknown> ? T : never;
1942
1928
  declare type InferErrTypes<R> = R extends Result<unknown, infer E> ? E : never;
1943
1929
  declare type InferAsyncOkTypes<R> = R extends ResultAsync<infer T, unknown> ? T : never;
@@ -2170,7 +2156,7 @@ declare type CollectResults<T, Collected extends unknown[] = [], Depth extends n
2170
2156
  declare type Transpose<A, Transposed extends unknown[][] = [], Depth extends number = 10> = A extends [infer T, ...infer Rest] ? T extends [infer L, infer R] ? Transposed extends [infer PL, infer PR] ? PL extends unknown[] ? PR extends unknown[] ? Transpose<Rest, [[...PL, L], [...PR, R]], Prev[Depth]> : never : never : Transpose<Rest, [[L], [R]], Prev[Depth]> : Transposed : Transposed;
2171
2157
  declare type Combine<T, Depth extends number = 5> = Transpose<CollectResults<T>, [], Depth> extends [infer L, infer R] ? [UnknownMembersToNever<L>, UnknownMembersToNever<R>] : Transpose<CollectResults<T>, [], Depth> extends [] ? [[], []] : never;
2172
2158
  declare type Dedup<T> = T extends Result<infer RL, infer RR> ? [unknown] extends [RL] ? Err<RL, RR> : Ok<RL, RR> : T;
2173
- declare type MemberListOf<T> = ((T extends unknown ? (t: T) => T : never) extends infer U ? (U extends unknown ? (u: U) => unknown : never) extends ((v: infer V) => unknown) ? V : never : never) extends ((_: unknown) => infer W) ? [...MemberListOf<Exclude<T, W>>, W] : [];
2159
+ declare type MemberListOf<T> = ((T extends unknown ? (t: T) => T : never) extends (infer U) ? (U extends unknown ? (u: U) => unknown : never) extends ((v: infer V) => unknown) ? V : never : never) extends ((_: unknown) => infer W) ? [...MemberListOf<Exclude<T, W>>, W] : [];
2174
2160
  declare type EmptyArrayToNever<T, NeverArrayToNever extends number = 0> = T extends [] ? never : NeverArrayToNever extends 1 ? T extends [never, ...infer Rest] ? [EmptyArrayToNever<Rest>] extends [never] ? never : T : T : T;
2175
2161
  declare type UnknownMembersToNever<T> = T extends [infer H, ...infer R] ? [[unknown] extends [H] ? never : H, ...UnknownMembersToNever<R>] : T;
2176
2162
  declare type MembersToUnion<T> = T extends unknown[] ? T[number] : never;
@@ -2194,6 +2180,7 @@ declare const MENTION_TYPE_ATTRIBUTE = "data-type";
2194
2180
  declare const MENTION_TYPE = "mention";
2195
2181
  declare const MENTION_HERE_ID = "@here";
2196
2182
  declare const MENTION_EVERYONE_ID = "@everyone";
2183
+ //#region src/void-tag.d.ts
2197
2184
  declare class VoidTag {
2198
2185
  addClosingSlash: boolean;
2199
2186
  private voidTags;
@@ -2201,16 +2188,20 @@ declare class VoidTag {
2201
2188
  formatNode(tag: string, attrs: string, innerHTML: string): string;
2202
2189
  isVoidElement(tag: string): boolean;
2203
2190
  }
2191
+ //#endregion
2192
+ //#region src/nodes/type.d.ts
2204
2193
  declare enum NodeType {
2205
2194
  ELEMENT_NODE = 1,
2206
2195
  TEXT_NODE = 3,
2207
2196
  COMMENT_NODE = 8
2208
2197
  }
2198
+ //#endregion
2199
+ //#region src/nodes/node.d.ts
2209
2200
  /**
2210
2201
  * Node Class as base class for TextNode and HTMLElement.
2211
2202
  */
2212
2203
  declare abstract class Node {
2213
- parentNode: HTMLElement;
2204
+ parentNode: HTMLElement | null;
2214
2205
  abstract rawTagName: string;
2215
2206
  abstract nodeType: NodeType;
2216
2207
  childNodes: Node[];
@@ -2219,7 +2210,7 @@ declare abstract class Node {
2219
2210
  abstract rawText: string;
2220
2211
  abstract toString(): string;
2221
2212
  abstract clone(): Node;
2222
- constructor(parentNode?: HTMLElement, range?: [number, number]);
2213
+ constructor(parentNode?: HTMLElement | null, range?: [number, number]);
2223
2214
  /**
2224
2215
  * Remove current node
2225
2216
  */
@@ -2228,6 +2219,8 @@ declare abstract class Node {
2228
2219
  get textContent(): string;
2229
2220
  set textContent(val: string);
2230
2221
  }
2222
+ //#endregion
2223
+ //#region src/nodes/html.d.ts
2231
2224
  interface KeyAttributes {
2232
2225
  id?: string;
2233
2226
  class?: string;
@@ -2251,7 +2244,7 @@ declare class DOMTokenList {
2251
2244
  toggle(c: string): void;
2252
2245
  contains(c: string): boolean;
2253
2246
  get length(): number;
2254
- values(): IterableIterator<string>;
2247
+ values(): SetIterator<string>;
2255
2248
  get value(): string[];
2256
2249
  toString(): string;
2257
2250
  }
@@ -2290,7 +2283,7 @@ declare class HTMLElement extends Node {
2290
2283
  *
2291
2284
  * @memberof HTMLElement
2292
2285
  */
2293
- constructor(tagName: string, keyAttrs: KeyAttributes, rawAttrs?: string, parentNode?: HTMLElement, range?: [number, number], voidTag?: VoidTag, _parseOptions?: Partial<Options>);
2286
+ constructor(tagName: string, keyAttrs: KeyAttributes, rawAttrs?: string, parentNode?: HTMLElement | null, range?: [number, number], voidTag?: VoidTag, _parseOptions?: Partial<Options>);
2294
2287
  /**
2295
2288
  * Remove Child element from childNodes array
2296
2289
  * @param {HTMLElement} node node to remove
@@ -2489,17 +2482,17 @@ declare const getMentions: (message: string) => HTMLElement[];
2489
2482
  declare const css: typeof String.raw;
2490
2483
  declare const html: typeof String.raw;
2491
2484
  declare const sanitizeHtml: (...[html, options]: Parameters<typeof baseSanitizeHtml>) => string;
2492
- declare const sanitizeMessageHtml: (html: string) => string;
2485
+ declare const sanitizeTextHtml: (html: string) => string;
2493
2486
  declare const applyItemMetadataMixin: <TBase extends Class<NonNullable<unknown>>>(Base: TBase) => WithMetadata<TBase>;
2494
- declare const SURVEY_DISPLAY_NAME = "Surveyer";
2495
2487
  declare const takeOne: TakeOne;
2496
2488
  declare const getIsServer: () => boolean;
2497
2489
  declare const noop: () => void;
2498
2490
  declare const ID_SEPARATOR = "|";
2491
+ declare const getOrCreate: <TKey, TValue>(map: Map<TKey, TValue>, key: TKey, create: () => TValue) => TValue;
2499
2492
  declare const checkIsPlainObject: (data: unknown) => data is object;
2500
2493
  declare const getPropertyNames: <T>() => PropertyNames<T>;
2501
2494
  declare const jsonDateParse: <T = any>(text: string) => T;
2502
- type MergeObjectsStrict<T extends object[]> = T extends [infer TFirst, infer TSecond, ...infer TRemaining] ? TSecond extends { [K in keyof TSecond]: K extends keyof TFirst ? never : TSecond[K] } ? TRemaining extends object[] ? MergeObjectsStrict<[TSecond, ...TRemaining]> & TFirst : TFirst & TSecond : never : T extends [infer TFirst] ? TFirst : never;
2495
+ type MergeObjectsStrict<T extends object[]> = T extends [infer TFirst, infer TSecond, ...infer TRemaining] ? TSecond extends { [K in keyof TSecond]: K extends keyof TFirst ? never : TSecond[K]; } ? TRemaining extends object[] ? MergeObjectsStrict<[TSecond, ...TRemaining]> & TFirst : TFirst & TSecond : never : T extends [infer TFirst] ? TFirst : never;
2503
2496
  declare const mergeObjectsStrict: <T extends object[]>(...objects: T) => MergeObjectsStrict<T>;
2504
2497
  declare const getRawData: <T>(data: T) => T;
2505
2498
  declare const toRawDeep: <T extends object>(data: T) => T;
@@ -2512,8 +2505,9 @@ declare const truncate: (string: string, length: number) => string;
2512
2505
  declare const uncapitalize: <T extends string>(string: T) => Uncapitalize<T>;
2513
2506
  declare const hrtime: (previousHrTime?: [number, number]) => [number, number];
2514
2507
  declare const now: () => string;
2508
+ declare const sleep: (durationMs: number) => Promise<void>;
2515
2509
  type BuildTuple<N extends number, T = unknown, R extends unknown[] = []> = R["length"] extends N ? R : BuildTuple<N, T, [...R, T]>;
2516
- type FunctionProperties<T> = { [K in keyof T]: T[K] extends Function ? K : never };
2510
+ type FunctionProperties<T> = { [K in keyof T]: T[K] extends Function ? K : never; };
2517
2511
  type ExcludeFunctionProperties<T> = Except<T, FunctionProperties<T>[keyof T]>;
2518
2512
  type MapValue<BaseType> = BaseType extends Map<unknown, infer ValueType> ? ValueType : never;
2519
2513
  type TupleSplit<T extends unknown[], N extends number> = T extends [...BuildTuple<N>, ...infer R] ? [T extends [...infer H, ...R] ? H : BuildTuple<N, T[number]>, R] : [T, []];
@@ -2526,7 +2520,6 @@ declare const exhaustiveGuard: (value: never) => never;
2526
2520
  type CreateUniqueArraySchema = (<TOutput extends object, TInput, TSchema extends z.ZodType<TOutput, TInput>>(schema: TSchema, key: UniqueArraySchemaKey<TSchema>) => z.ZodArray<TSchema>) & (<TSchema extends z.ZodType>(schema: TSchema) => z.ZodArray<TSchema>);
2527
2521
  type UniqueArraySchemaKey<TSchema extends z.ZodType> = TSchema extends z.ZodObject ? keyof TSchema["shape"] & string : keyof z.output<TSchema> & string;
2528
2522
  declare const createUniqueArraySchema: CreateUniqueArraySchema;
2529
- declare const NIL = "00000000-0000-0000-0000-000000000000";
2530
2523
  declare const UUIDV4_REGEX: RegExp;
2531
2524
  declare const uuidValidateV4: (uuid: string) => boolean;
2532
- export { AllSpecialValues, BuildTuple, ClassifiedMentions, CreateUniqueArraySchema, DeepOmit, DeepOptionalUndefined, ExcludeFunctionProperties, ForbiddenError, FunctionProperties, GetArrayProps, GetObjectProps, GetPaths, GetPrimitiveProps, GetProperties, ID_SEPARATOR, InvalidOperationError, ItemEntityType, ItemEntityTypePropertyNames, ItemMetadata, ItemMetadataPropertyNames, KnownKeys, MAX_READ_LIMIT, MENTION_EVERYONE_ID, MENTION_HERE_ID, MENTION_ID_ATTRIBUTE, MENTION_ITEM_TYPE_ATTRIBUTE, MENTION_LABEL_ATTRIBUTE, MENTION_TYPE, MENTION_TYPE_ATTRIBUTE, MapValue, MentionType, MergeObjectsStrict, NIL, NotFoundError, NotInitializedError, Operation, PropertyNames, RoutePath, SITE_NAME, SURVEY_DISPLAY_NAME, Serializable, SkipFirst, TakeFirst, TakeOne, ToData, TupleSlice, TupleSplit, TupleSplitHead, TupleSplitTail, UUIDV4_REGEX, UniqueArraySchemaKey, WithMetadata, applyItemMetadataMixin, capitalize, checkIsPlainObject, classifyMentions, createItemEntityTypeSchema, createNormalizedStringSchema, createUniqueArraySchema, css, exhaustiveGuard, getIsServer, getMentions, getPropertyNames, getRawData, getResult, getResultAsync, hrtime, html, itemMetadataSchema, jsonDateParse, mergeObjectsStrict, noop, normalizeString, now, sanitizeHtml, sanitizeMessageHtml, streamToText, takeOne, toAppError, toKebabCase, toRawDeep, truncate, uncapitalize, uuidValidateV4, withFinalizer, withFinalizerAsync };
2525
+ export { AllSpecialValues, BuildTuple, ClassifiedMentions, CreateUniqueArraySchema, DeepOmit, DeepOptionalUndefined, ExcludeFunctionProperties, ForbiddenError, FunctionProperties, GetArrayProps, GetObjectProps, GetPaths, GetPrimitiveProps, GetProperties, ID_SEPARATOR, InvalidOperationError, ItemEntityType, ItemEntityTypePropertyNames, ItemMetadata, ItemMetadataPropertyNames, KnownKeys, MAX_READ_LIMIT, MENTION_EVERYONE_ID, MENTION_HERE_ID, MENTION_ID_ATTRIBUTE, MENTION_ITEM_TYPE_ATTRIBUTE, MENTION_LABEL_ATTRIBUTE, MENTION_TYPE, MENTION_TYPE_ATTRIBUTE, MapValue, MentionType, MergeObjectsStrict, NotFoundError, NotInitializedError, Operation, PropertyNames, RoutePath, SITE_NAME, Serializable, SkipFirst, TakeFirst, TakeOne, ToData, TupleSlice, TupleSplit, TupleSplitHead, TupleSplitTail, UUIDV4_REGEX, UniqueArraySchemaKey, WithMetadata, applyItemMetadataMixin, capitalize, checkIsPlainObject, classifyMentions, createExponentialBackoff, createItemEntityTypeSchema, createNormalizedStringSchema, createUniqueArraySchema, css, exhaustiveGuard, getIsServer, getMentions, getOrCreate, getPropertyNames, getRawData, getResult, getResultAsync, hrtime, html, itemMetadataSchema, jsonDateParse, mergeObjectsStrict, noop, normalizeString, now, sanitizeHtml, sanitizeTextHtml, sleep, streamToText, takeOne, toAppError, toKebabCase, toRawDeep, truncate, uncapitalize, uuidValidateV4, withFinalizer, withFinalizerAsync };