UNPKG

1.65 kBTypeScriptView Raw
1import * as mdurl from 'mdurl';
2// import ucmicro from 'uc.micro';
3
4interface Utils {
5 lib: {
6 mdurl: typeof mdurl;
7 };
8
9 /**
10 * Merge objects
11 */
12 assign(target: any, ...sources: any[]): any;
13
14 /**
15 * Check if the type is string or not
16 */
17 isString(obj: any): obj is string;
18
19 /**
20 * has own property
21 */
22 has(obj: any, key: keyof any): boolean;
23
24 unescapeMd(str: string): string;
25 unescapeAll(str: string): string;
26
27 isValidEntityCode(code: number): boolean;
28 fromCodePoint(code: number): string;
29 escapeHtml(str: string): string;
30
31 /**
32 * Remove element from array and put another array at those position.
33 * Useful for some operations with tokens.
34 * Return a new array.
35 */
36 arrayReplaceAt<T>(src: T[], pos: number, newElements: T[]): T[];
37
38 isSpace(code: number): boolean;
39
40 /**
41 * Zs (unicode class) || [\t\f\v\r\n]
42 */
43 isWhiteSpace(code: number): boolean;
44
45 /**
46 * Markdown ASCII punctuation characters.
47 *
48 * !, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, or ~
49 * http://spec.commonmark.org/0.15/#ascii-punctuation-character
50 *
51 * Don't confuse with unicode punctuation !!! It lacks some chars in ascii range.
52 */
53 isMdAsciiPunct(code: number): boolean;
54
55 /**
56 * Currently without astral characters support.
57 */
58 isPunctChar(ch: string): boolean;
59
60 escapeRE(str: string): string;
61
62 /**
63 * Hepler to unify [reference labels].
64 */
65 normalizeReference(str: string): string;
66}
67
68declare const utils: Utils;
69
70export = utils;