-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse.d.ts
More file actions
46 lines (39 loc) · 1019 Bytes
/
parse.d.ts
File metadata and controls
46 lines (39 loc) · 1019 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import type { BookmarkAttrs, FolderAttrs, AllAttrKeys } from '../attrs.d.ts'
export type Bookmark = BookmarkAttrs & {
title: string
description?: string
}
export type Folder<T = Bookmark> = FolderAttrs & {
title: string
items: (Folder | T)[]
}
type WithId<T> = T & {
id: string
pid?: string
}
export type BookmarkWithId = WithId<Bookmark>
export type FolderWithId<T = BookmarkWithId> = WithId<
Omit<Folder, 'items'> & {
items: (FolderWithId | T)[]
}
>
export type Truthy<V> = V extends null | undefined | false | 0 | "" ? never : V
// Overload signatures.
export function parse<T = Bookmark>(
text: string,
options?: Partial<{
excludeAttrs: AllAttrKeys[]
withId: false
transform: (bookmark: Bookmark) => T
noEmpty: boolean
}>
): Folder<Truthy<T>>
export function parse<T = BookmarkWithId>(
text: string,
options: {
excludeAttrs?: AllAttrKeys[]
withId: true
transform?: (bookmark: BookmarkWithId) => T
noEmpty?: boolean
}
): FolderWithId<Truthy<T>>