UNPKG

@typescript-package/affix

Version:

A lightweight TypeScript library for different kind of affixes.

2 lines (1 loc) 332 B
export type SplitAt<S extends string, Position extends number, Counted extends any[] = [], First extends string = '', Second extends string = S> = Counted['length'] extends Position ? [First, Second] : Second extends `${infer Head}${infer Tail}` ? SplitAt<S, Position, [any, ...Counted], `${First}${Head}`, Tail> : [First, Second];