We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
题目链接:TrimLeft,Trim,TrimRight
实现 TrimLeft,满足以下要求
TrimLeft
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<TrimLeft<'str'>, 'str'>>, Expect<Equal<TrimLeft<' str'>, 'str'>>, Expect<Equal<TrimLeft<' str'>, 'str'>>, Expect<Equal<TrimLeft<' str '>, 'str '>>, Expect<Equal<TrimLeft<' \n\t foo bar '>, 'foo bar '>>, Expect<Equal<TrimLeft<''>, ''>>, Expect<Equal<TrimLeft<' \n\t'>, ''>>, ]
type Space = `${" " | "\t" | "\n"}`; type TrimLeft<T extends string> = T extends `${Space}${infer R}` ? TrimLeft<R> : T;
type TrimLeft<T extends string> = T extends ` ${infer R}` ? TrimLeft<R> : T extends `\t${infer R}` ? TrimLeft<R> : T extends `\n${infer R}` ? TrimLeft<R> : T;
type Space = `${" " | "\t" | "\n"}`; type Trim<T extends string> = T extends | `${Space}${infer R}` | `${infer R}${Space}` ? Trim<R> : T;
type Space = `${" " | "\t" | "\n"}`; type TrimRight<T extends string> = T extends `${infer R}${Space}` ? TrimRight<R> : T;
The text was updated successfully, but these errors were encountered:
No branches or pull requests
题目
题目链接:TrimLeft,Trim,TrimRight
实现
TrimLeft
,满足以下要求答案
方法一
方法二
实现 Trim,TrimRight
Trim
TrimRight
The text was updated successfully, but these errors were encountered: