333
schangxiang@126.com
2025-09-19 18966e02fb573c7e2bb0c6426ed792b38b910940
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
export interface HeaderValue {
    value: string;
    params?: { [key: string]: string };
}
 
export interface ParsedHeaderValue extends HeaderValue {
    params: { [key: string]: string };
}
 
export interface ParsedHeaderParam {
    key: string;
    value: string;
}
 
/** Checks if a value is plaintext string (uses only printable 7bit chars) */
export function isPlainText(value: string): boolean;
 
/**
 * Checks if a multi line string containes lines longer than the selected value.
 *
 * Useful when detecting if a mail message needs any processing at all –
 * if only plaintext characters are used and lines are short, then there is
 * no need to encode the values in any way. If the value is plaintext but has
 * longer lines then allowed, then use format=flowed
 */
export function hasLongerLines(str: string, lineLength: number): boolean;
 
/** Encodes a string or an Buffer to an UTF-8 MIME Word (rfc2047) */
export function encodeWord(data: Buffer | string, mimeWordEncoding?: 'Q' | 'B', maxLength?: number): string;
 
/** Finds word sequences with non ascii text and converts these to mime words */
export function encodeWords(value: string, mimeWordEncoding?: 'Q' | 'B', maxLength?: number): string;
 
/**
 * Joins parsed header value together as 'value; param1=value1; param2=value2'
 * PS: We are following RFC 822 for the list of special characters that we need to keep in quotes.
 *      Refer: https://www.w3.org/Protocols/rfc1341/4_Content-Type.html
 */
export function buildHeaderValue(structured: HeaderValue): string;
 
/**
 * Encodes a string or an Buffer to an UTF-8 Parameter Value Continuation encoding (rfc2231)
 * Useful for splitting long parameter values.
 *
 * For example
 * ```
 *     title="unicode string"
 * ```
 * becomes
 * ```
 *     title*0*=utf-8''unicode
 *     title*1*=%20string
 * ```
 */
export function buildHeaderParam(key: string, data: Buffer | string, maxLength?: number): ParsedHeaderParam[];
 
/**
 * Parses a header value with key=value arguments into a structured
 * object.
 *
 * ```
 *   parseHeaderValue('content-type: text/plain; CHARSET='UTF-8') ->
 *   {
 *     'value': 'text/plain',
 *     'params': {
 *       'charset': 'UTF-8'
 *     }
 *   }
 * ```
 */
export function parseHeaderValue(str: string): ParsedHeaderValue;
 
/** Returns file extension for a content type string. If no suitable extensions are found, 'bin' is used as the default extension */
export function detectExtension(mimeType: string): string;
 
/** Returns content type for a file extension. If no suitable content types are found, 'application/octet-stream' is used as the default content type */
export function detectMimeType(extension: string): string;
 
/** Folds long lines, useful for folding header lines (afterSpace=false) and flowed text (afterSpace=true) */
export function foldLines(str: string, lineLength?: number, afterSpace?: boolean): string;
 
/** Splits a mime encoded string. Needed for dividing mime words into smaller chunks */
export function splitMimeEncodedString(str: string, maxlen?: number): string[];
 
export function encodeURICharComponent(chr: string): string;
 
export function safeEncodeURIComponent(str: string): string;