This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Utility | |
type GetFirstCharacter<Text extends string> = Text extends `${infer First}${infer Rest}` ? First : never; | |
type StringStartsWith<Source extends string, Char extends string> = Source extends `${infer First}${infer Rest}` | |
? First extends Char | |
? true | |
: false | |
: false; | |
type SliceStringFirst<Source extends string> = Source extends `${infer First}${infer Rest}` | |
? Rest | |
: never; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type StringToArray<str extends string> = str extends `${infer First}${infer Rest}` | |
? [ First, ...StringToArray<Rest> ] | |
: [] | |
type NewArray<length extends number, arr extends any[] = []> = arr["length"] extends length | |
? arr | |
: NewArray<length, [ ...arr, any ]>; | |
type New2DArray<length extends number, arr extends any[][] = []> = arr["length"] extends length | |
? arr |