UNPKG

rivo

Version:

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

27 lines (24 loc) • 592 B
import type { Args, Fn } from "../HKT"; import type { SDigit } from "../Num"; import type { AssertBool } from "../helpers"; /** * Check if a string is a digit (i.e. 0-9). * * Sig: `(s: string) => boolean` */ export type IsDigit<S extends string> = AssertBool< string extends S ? boolean : S extends `${infer C}` ? C extends SDigit ? true : false : false >; /** * [Fn] Check if a string is a digit (i.e. 0-9). * * Sig: `(s: string) => boolean` */ export default interface IsDigitFn extends Fn<[string], boolean> { def: ([s]: Args<this>) => IsDigit<typeof s>; }