UNPKG

2.35 kBMarkdownView Raw
1# Installation
2> `npm install --save @types/wordwrap`
3
4# Summary
5This package contains type definitions for wordwrap (https://github.com/substack/node-wordwrap#readme).
6
7# Details
8Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/wordwrap.
9## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/wordwrap/index.d.ts)
10````ts
11// Type definitions for wordwrap 1.0
12// Project: https://github.com/substack/node-wordwrap#readme
13// Definitions by: ark120202 <https://github.com/ark120202>
14// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
15
16type Wrap = (text: string) => string;
17
18/**
19 * Wrap lines until column `stop`. If a word is longer than `stop` characters
20 * it will overflow.
21 */
22declare function wordwrap(stop: number, params?: { mode?: wordwrap.Mode | undefined }): Wrap;
23
24/**
25 * Pad out lines with spaces out to column `start` and then wrap until column
26 * `stop`. If a word is longer than `stop - start` characters it will overflow.
27 */
28declare function wordwrap(start: number, stop: number, params?: { mode?: wordwrap.Mode | undefined }): Wrap;
29
30/**
31 * Pad out lines with spaces out to column `start` and then wrap until column
32 * `stop`. If a word is longer than `stop - start` characters it will overflow.
33 */
34declare function wordwrap(params: wordwrap.Options): Wrap;
35
36declare namespace wordwrap {
37 interface Options {
38 stop: number;
39 start: number;
40 mode?: Mode | undefined;
41 }
42
43 /**
44 * Wrap lines until column `stop`. Break up chunks longer than `stop`.
45 */
46 function hard(stop: number): Wrap;
47
48 /**
49 * Wrap lines until column `stop`. Break up chunks longer than `stop - start`.
50 */
51 function hard(start: number, stop: number): Wrap; // tslint:disable-line:unified-signatures
52
53 /**
54 * In "soft" mode, split chunks by `/(\S+\s+/` and don't break up chunks
55 * which are longer than `stop - start`, in "hard" mode, split chunks with
56 * `/\b/` and break up chunks longer than `stop - start`.
57 */
58 type Mode = "soft" | "hard";
59}
60
61export = wordwrap;
62
63````
64
65### Additional Details
66 * Last updated: Fri, 02 Jul 2021 18:05:56 GMT
67 * Dependencies: none
68 * Global values: none
69
70# Credits
71These definitions were written by [ark120202](https://github.com/ark120202).
72
\No newline at end of file