wrap-ansi 8.0.0 → 8.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.d.ts +41 -0
  2. package/index.js +1 -1
  3. package/package.json +16 -11
package/index.d.ts ADDED
@@ -0,0 +1,41 @@
1
+ export type Options = {
2
+ /**
3
+ By default the wrap is soft, meaning long words may extend past the column width. Setting this to `true` will make it hard wrap at the column width.
4
+
5
+ @default false
6
+ */
7
+ readonly hard?: boolean;
8
+
9
+ /**
10
+ By default, an attempt is made to split words at spaces, ensuring that they don't extend past the configured columns. If wordWrap is `false`, each column will instead be completely filled splitting words as necessary.
11
+
12
+ @default true
13
+ */
14
+ readonly wordWrap?: boolean;
15
+
16
+ /**
17
+ Whitespace on all lines is removed by default. Set this option to `false` if you don't want to trim.
18
+
19
+ @default true
20
+ */
21
+ readonly trim?: boolean;
22
+ };
23
+
24
+ /**
25
+ Wrap words to the specified column width.
26
+
27
+ @param string - String with ANSI escape codes. Like one styled by [`chalk`](https://github.com/chalk/chalk). Newline characters will be normalized to `\n`.
28
+ @param columns - Number of columns to wrap the text to.
29
+
30
+ @example
31
+ ```
32
+ import chalk from 'chalk';
33
+ import wrapAnsi from 'wrap-ansi';
34
+
35
+ const input = 'The quick brown ' + chalk.red('fox jumped over ') +
36
+ 'the lazy ' + chalk.green('dog and then ran away with the unicorn.');
37
+
38
+ console.log(wrapAnsi(input, 20));
39
+ ```
40
+ */
41
+ export default function wrapAnsi(string: string, columns: number, options?: Options): string;
package/index.js CHANGED
@@ -4,7 +4,7 @@ import ansiStyles from 'ansi-styles';
4
4
 
5
5
  const ESCAPES = new Set([
6
6
  '\u001B',
7
- '\u009B'
7
+ '\u009B',
8
8
  ]);
9
9
 
10
10
  const END_CODE = 39;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wrap-ansi",
3
- "version": "8.0.0",
3
+ "version": "8.1.0",
4
4
  "description": "Wordwrap a string with ANSI escape codes",
5
5
  "license": "MIT",
6
6
  "repository": "chalk/wrap-ansi",
@@ -11,15 +11,19 @@
11
11
  "url": "https://sindresorhus.com"
12
12
  },
13
13
  "type": "module",
14
- "exports": "./index.js",
14
+ "exports": {
15
+ "types": "./index.d.ts",
16
+ "default": "./index.js"
17
+ },
15
18
  "engines": {
16
19
  "node": ">=12"
17
20
  },
18
21
  "scripts": {
19
- "test": "xo && nyc ava"
22
+ "test": "xo && nyc ava && tsd"
20
23
  },
21
24
  "files": [
22
- "index.js"
25
+ "index.js",
26
+ "index.d.ts"
23
27
  ],
24
28
  "keywords": [
25
29
  "wrap",
@@ -49,16 +53,17 @@
49
53
  "text"
50
54
  ],
51
55
  "dependencies": {
52
- "ansi-styles": "^6.0.0",
53
- "string-width": "^5.0.0",
54
- "strip-ansi": "^7.0.0"
56
+ "ansi-styles": "^6.1.0",
57
+ "string-width": "^5.0.1",
58
+ "strip-ansi": "^7.0.1"
55
59
  },
56
60
  "devDependencies": {
57
61
  "ava": "^3.15.0",
58
- "chalk": "^4.1.0",
59
- "coveralls": "^3.1.0",
60
- "has-ansi": "^5.0.0",
62
+ "chalk": "^4.1.2",
63
+ "coveralls": "^3.1.1",
64
+ "has-ansi": "^5.0.1",
61
65
  "nyc": "^15.1.0",
62
- "xo": "^0.38.2"
66
+ "tsd": "^0.25.0",
67
+ "xo": "^0.44.0"
63
68
  }
64
69
  }