UNPKG

rivo

Version:

🤖 The ultimate library you need for composable type-level programming in TypeScript, powered by HKT.

16 lines (13 loc) • 523 B
import type { Args, Fn } from "../HKT"; import type { Nat } from "../Num"; import type { Dec } from "../Num/Int/Dec"; import type { AssertStr } from "../helpers"; export type Repeat<N extends Nat, S extends string> = AssertStr< Nat extends N ? string : N extends 0 ? "" : // @ts-ignore - Type instantiation is excessively deep and possibly infinite. `${S}${Repeat<Dec<N>, S>}` >; export default interface RepeatFn extends Fn<[Nat, string], string> { def: ([n, s]: Args<this>) => Repeat<typeof n, typeof s>; }