import { If } from "../boolean"; import { Length as ListLength } from "../list"; import { IsLiteral } from "."; /** * gets the length of a string literal */ type _Length = S extends '' ? ListLength : S extends `${infer H}${infer T}` ? _Length : number; /** * gets the length of a string as the number of characters. * * @warning unicode symbols may count as 2 characters, as code points are not distinguished. * * @since 0.0.2 * * @example * type e0 = Length // number * type e1 = Length<`${number}`> // number * type e2 = Length<'foo'> // 3 * type e3 = Length<`foo${string}`> // number * type e4 = Length<`${string}foo`> // number * type e5 = Length<`foo${string}bar`> // number * * // string consisting of 512 "0" characters * type t6 = '00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' * type e6 = Length // 512 * * type w0 = Length<'✅'> // 1 * type s1 = Length<'🔥'> // 2 * */ export type Length = If, _Length, number>; export {}; //# sourceMappingURL=length.d.ts.map