generated from actions/typescript-action
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjssoup.d.ts
121 lines (98 loc) · 2.98 KB
/
jssoup.d.ts
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// thanks to @AmonDeShir
declare module 'jssoup' {
class TreeBuilder {
canBeEmptyElement(name: string): boolean
}
export class SoupElement {
parent?: SoupTag
previousElement?: SoupTag
nextElement?: SoupTag
constructor(
parent?: SoupTag,
previousElement?: SoupTag,
nextElement?: SoupTag
)
get nextSibling(): SoupTag | undefined
get previousSibling(): SoupTag | undefined
get nextSiblings(): SoupTag | undefined
get previousSiblings(): SoupTag | undefined
get text(): string
/** remove item from dom tree */
extract(): void
insert(index: number, newElement: SoupElement | string): void
replaceWith(newElement: SoupElement | string): this | undefined
}
export class SoupString extends SoupElement {
constructor(
text: string,
parent?: SoupElement,
previousElement?: SoupElement,
nextElement?: SoupElement
)
toString(): string
}
type Attributes =
| string
| string[]
| {class: string}
| {class: string[]}
| {[attribute: string]: string}
export class SoupTag extends SoupElement {
name: string
builder: TreeBuilder
attrs: {[attribute: string]: string}
/** contains direct children of current element */
contents: SoupTag[]
constructor(
name: string,
builder: TreeBuilder,
attrs: {[attribute: string]: string}
)
get string(): SoupString
/** includes all elements of which current element is the ancestor of */
get descendants(): SoupElement[]
find<T extends SoupElement>(
name?: string,
attrs?: Attributes,
string?: string
): T | undefined
/** like find_all in BeautifulSoup */
findAll<T extends SoupElement>(
name?: string,
attrs?: Attributes,
string?: string
): T[]
findPreviousSibling<T extends SoupElement>(
name?: string,
attrs?: Attributes,
string?: string
): T | undefined
findPreviousSiblings<T extends SoupElement>(
name?: string,
attrs?: Attributes,
string?: string
): T[]
findNextSibling<T extends SoupElement>(
name?: string,
attrs?: Attributes,
string?: string
): T | undefined
findNextSiblings<T extends SoupElement>(
name?: string,
attrs?: Attributes,
string?: string
): T[]
getText(separator?: string): string
prettify(indent?: string, breakline?: string): string
toString(): string
append(item: SoupElement): void
/** @param expression - a CSS expression like "div > .class1"*/
select<T extends SoupElement>(expression: string): T[]
/** @param expression - a CSS expression like "div > .class1"*/
selectOne<T extends SoupElement>(expression: string): T | undefined
}
export default class JSSoup extends SoupTag {
/** The text element only contains whitespace will be ignored by default. To disable this feature, set "ignoreWhitespace" to true. */
constructor(text: string, ignoreWhitespace?: boolean)
}
}