-
Notifications
You must be signed in to change notification settings - Fork 33
/
index.d.ts
executable file
·95 lines (87 loc) · 2.4 KB
/
index.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
// Type definitions
export interface FeedEntry {
/**
* id, guid, or generated identifier for the entry
*/
id: string;
link?: string;
title?: string;
description?: string;
published?: string;
}
export interface FeedData {
link?: string;
title?: string;
description?: string;
generator?: string;
language?: string;
published?: string;
entries?: Array<FeedEntry>;
}
export interface ProxyConfig {
target?: string;
headers?: any;
}
export interface ReaderOptions {
/**
* normalize feed data or keep original
* default: true
*/
normalization?: boolean;
/**
* convert datetime to ISO format
* default: true
*/
useISODateFormat?: boolean;
/**
* to truncate description
* default: 210
*/
descriptionMaxLen?: number;
/**
* fast-xml-parser options
* https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/docs/v4/2.XMLparseOptions.md
*/
xmlParserOptions?: any;
/**
* fill in the baseurl when it does not exist in the link
* default: ''
*/
baseUrl?: string;
/**
* merge extra feed fields in result
*/
getExtraFeedFields?: (feedData: object) => object;
/**
* merge extra entry fields in result
*/
getExtraEntryFields?: (entryData: object) => object;
}
export interface FetchOptions {
// Definitions by: Ryan Graham <https://github.com/ryan-codingintrigue>
method?: "GET" | "POST" | "DELETE" | "PATCH" | "PUT" | "HEAD" | "OPTIONS" | "CONNECT";
headers?: any;
body?: any;
mode?: "cors" | "no-cors" | "same-origin";
credentials?: "omit" | "same-origin" | "include";
cache?: "default" | "no-store" | "reload" | "no-cache" | "force-cache" | "only-if-cached";
redirect?: "follow" | "error" | "manual";
referrer?: string;
referrerPolicy?: "referrer" | "no-referrer-when-downgrade" | "origin" | "origin-when-cross-origin" | "unsafe-url";
integrity?: any;
proxy?: ProxyConfig;
/**
* http proxy agent
* default: null
*/
agent?: object;
/**
* signal to terminate request
* default: null
*/
signal?: object;
}
export function extractFromXml(xml: string, options?: ReaderOptions): FeedData;
export function extractFromJson(json: string, options?: ReaderOptions): FeedData;
export function extract(url: string, options?: ReaderOptions, fetchOptions?: FetchOptions): Promise<FeedData>;
export function read(url: string, options?: ReaderOptions, fetchOptions?: FetchOptions): Promise<FeedData>;