import type { Digit } from './numbers.js'; export type AutoCompletableString = string & {}; export type EmptyString = ''; export type Space = ' '; export type AlphaCharacter = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z'; export type NumericCharacter = `${Digit}`; export type AlphanumericCharacter = AlphaCharacter | Capitalize | NumericCharacter; export type MaybePlural = T | `${T}s`; export type StripWhitespace = string extends Type ? Type : Type extends `${infer First}${infer Rest}` ? First extends Space ? StripWhitespace : `${First}${StripWhitespace}` : EmptyString; export type AlphanumericOnly = Type extends EmptyString ? EmptyString : Type extends `${infer First}${infer Rest}` ? First extends AlphanumericCharacter | Space ? `${First}${AlphanumericOnly}` : Rest extends EmptyString ? Rest : `${Space}${AlphanumericOnly}` : never; export type Replace = Type extends `${infer First}${infer Rest}` ? First extends Remove ? `${Replacement}${Replace}` : `${First}${Replace}` : EmptyString; export type Strip = Replace; export type FirstChar = Type extends `${infer First}${infer _Rest}` ? First : never; export type AddSpaceAroundNumbers = Type extends `${infer First}${infer Rest}` ? Rest extends EmptyString ? First : First extends AlphaCharacter | Capitalize ? FirstChar extends NumericCharacter ? `${First}${Space}${AddSpaceAroundNumbers}` : `${First}${AddSpaceAroundNumbers}` : First extends NumericCharacter ? FirstChar extends AlphaCharacter | Capitalize ? `${First}${Space}${AddSpaceAroundNumbers}` : `${First}${AddSpaceAroundNumbers}` : `${First}${AddSpaceAroundNumbers}` : never; export type CamelCase = Type extends `${infer Left}${Delimiter}${infer Right}` ? `${Left}${CamelCase, Delimiter>}` : Type; export type PascalCase = string extends Type ? Capitalize : Capitalize>>, Delimiter>>; export type StringLength = string extends Type ? never : Type extends `${infer _}${infer Rest}` ? StringLength : Accumulator['length'];