Skip to main content

type Tokenize<P,Token,Res>

Converts a path string into separate tokens in a string array.

Definition

type Tokenize<P extends string, Token extends string = '', Res extends string[] = []> = P extends '' ? Path.Internal.AppendIfNotEmpty<Res, Token> : P extends `[${infer Index}]${infer Rest}` ? Tokenize<Rest, '', [
      ...Path.Internal.AppendIfNotEmpty<Res, Token>,`<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`Index`<br/>&nbsp;&nbsp;&nbsp;&nbsp;`]> : P extends `?.${infer Rest}` ? Tokenize<Rest, '', [
      ...Path.Internal.AppendIfNotEmpty<Res, Token>,`<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`'?.'`<br/>&nbsp;&nbsp;&nbsp;&nbsp;`]> : P extends `.${infer Rest}` ? Tokenize<Rest, '', [...Path.Internal.AppendIfNotEmpty<Res, Token>, '.']> : P extends `${infer First}${infer Rest}` ? Tokenize`<Rest, ${Token}${First}, Res> : never```;