UNPKG

1.28 kBTypeScriptView Raw
1// Type definitions for align-text 1.0
2// Project: https://github.com/jonschlinkert/align-text
3// Definitions by: Claas Ahlrichs <https://github.com/claasahl>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5// TypeScript Version: 2.1
6
7interface TransformResult {
8 /**
9 * the amount of indentation to use. Default is 0 when an object is returned.
10 */
11 indent: number;
12 /**
13 * the character to use for indentation. Default is '' (empty string) when an object is returned.
14 */
15 character: string;
16 /**
17 * leading characters to use at the beginning of each line. '' (empty string) when an object is returned.
18 */
19 prefix: string;
20}
21
22interface Callback {
23 /**
24 * @param len the length of the "current" line
25 * @param longest the length of the longest line
26 * @param line the current line (string) being aligned
27 * @param lines the array of all lines
28 * @param idx the index of the current line
29 */
30 (len: number, longest: number, line: string, lines: string[], idx: number):
31 | number
32 | TransformResult;
33}
34
35declare function align_text(text: string, fn?: number | Callback): string;
36declare function align_text(text: any[], fn?: number | Callback): string[];
37
38export = align_text;