Skip to content

Trim #375

Open
Open
Trim#375
@lhp96

Description

@lhp96
// 实现Trim 处理字符串前后的空格、换行
type Trim<S extends string> = 
  S extends `${' ' | '\n' | '\t'}${infer T}` | `${infer T}${' ' | '\n' | '\t'}` 
    ? Trim<T> 
    : S


type trimmed = Trim<'  Hello World  '> // expected to be 'Hello World'
type c = Trim<'   \n\t foo bar \t'>  // 'foo bar'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions