-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
18 lines (16 loc) · 626 Bytes
/
types.ts
File metadata and controls
18 lines (16 loc) · 626 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
export type ValueOf<T> = T[keyof T];
export type Simplify<T> = {[KeyType in keyof T]: T[KeyType]} & {};
export type Split<
S extends string,
Delimiter extends string,
> = S extends `${infer Head}${Delimiter}${infer Tail}`
? [Head, ...Split<Tail, Delimiter>]
: S extends Delimiter
? []
: [S];
type TrimLeftSlash<S extends string> = S extends `/${infer T}` ? TrimLeftSlash<T> : S
type TrimRightSlash<S extends string> = S extends `${infer T}/` ? TrimRightSlash<T> : S
/**
* Removes `/` from start and end of a endpoint.
*/
export type TrimSlash<T extends string> = TrimLeftSlash<TrimRightSlash<T>>