UNPKG

1.22 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 */
29 (len: number, longest: number, line: string, lines: string[]):
30 | number
31 | TransformResult;
32}
33
34declare function align_text(text: string, fn?: number | Callback): string;
35declare function align_text(text: any[], fn?: number | Callback): string[];
36
37export = align_text;