-
Notifications
You must be signed in to change notification settings - Fork 140
/
index.d.ts
90 lines (78 loc) · 1.94 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
// Type definitions
import { IOptions as SanitizeOptions } from "sanitize-html";
export interface Transformation {
patterns: Array<RegExp>,
pre?: (document: Document) => Document
post?: (document: Document) => Document
}
export function addTransformations(transformations: Array<Transformation>): Number;
export function removeTransformations(options: Array<RegExp>): Number;
export function getSanitizeHtmlOptions(): SanitizeOptions;
export function setSanitizeHtmlOptions(options: SanitizeOptions): void;
/**
* @param input url or html
*/
export interface ParserOptions {
/**
* to estimate time to read.
* Default: 300
*/
wordsPerMinute?: number
/**
* max num of chars generated for description
* Default: 210
*/
descriptionTruncateLen?: number
/**
* min num of chars required for description
* Default: 180
*/
descriptionLengthThreshold?: number
/**
* min num of chars required for content
* Default: 200
*/
contentLengthThreshold?: number
}
export interface ProxyConfig {
target?: string;
headers?: Record<string, string>;
}
export interface FetchOptions {
/**
* list of request headers
* default: null
*/
headers?: Record<string, string>;
/**
* the values to configure proxy
* default: null
*/
proxy?: ProxyConfig;
/**
* http proxy agent
* default: null
*/
agent?: object;
/**
* signal to terminate request
* default: null
*/
signal?: object;
}
export interface ArticleData {
url?: string;
links?: string[];
title?: string;
description?: string;
image?: string;
favicon?: string;
author?: string;
content?: string;
source?: string;
published?: string;
ttr?: number;
type?: string;
}
export function extract(input: string, parserOptions?: ParserOptions, fetchOptions?: FetchOptions): Promise<ArticleData|null>;
export function extractFromHtml(html: string, url?: string, parserOptions?: ParserOptions): Promise<ArticleData|null>;