wrap-ansi 5.1.0 → 6.0.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.js +8 -11
  2. package/package.json +6 -6
  3. package/readme.md +13 -24
package/index.js CHANGED
@@ -21,7 +21,7 @@ const wordLengths = string => string.split(' ').map(character => stringWidth(cha
21
21
  const wrapWord = (rows, word, columns) => {
22
22
  const characters = [...word];
23
23
 
24
- let insideEscape = false;
24
+ let isInsideEscape = false;
25
25
  let visible = stringWidth(stripAnsi(rows[rows.length - 1]));
26
26
 
27
27
  for (const [index, character] of characters.entries()) {
@@ -35,13 +35,13 @@ const wrapWord = (rows, word, columns) => {
35
35
  }
36
36
 
37
37
  if (ESCAPES.has(character)) {
38
- insideEscape = true;
39
- } else if (insideEscape && character === 'm') {
40
- insideEscape = false;
38
+ isInsideEscape = true;
39
+ } else if (isInsideEscape && character === 'm') {
40
+ isInsideEscape = false;
41
41
  continue;
42
42
  }
43
43
 
44
- if (insideEscape) {
44
+ if (isInsideEscape) {
45
45
  continue;
46
46
  }
47
47
 
@@ -80,11 +80,9 @@ const stringVisibleTrimSpacesRight = str => {
80
80
  return words.slice(0, last).join(' ') + words.slice(last).join('');
81
81
  };
82
82
 
83
- // The wrap-ansi module can be invoked
84
- // in either 'hard' or 'soft' wrap mode
83
+ // The wrap-ansi module can be invoked in either 'hard' or 'soft' wrap mode
85
84
  //
86
- // 'hard' will never allow a string to take up more
87
- // than columns characters
85
+ // 'hard' will never allow a string to take up more than columns characters
88
86
  //
89
87
  // 'soft' allows long words to expand past the column length
90
88
  const exec = (string, columns, options = {}) => {
@@ -119,8 +117,7 @@ const exec = (string, columns, options = {}) => {
119
117
  }
120
118
  }
121
119
 
122
- // In 'hard' wrap mode, the length of a line is
123
- // never allowed to extend past 'columns'
120
+ // In 'hard' wrap mode, the length of a line is never allowed to extend past 'columns'
124
121
  if (options.hard && lengths[index] > columns) {
125
122
  const remainingColumns = (columns - rowLength);
126
123
  const breaksStartingThisLine = 1 + Math.floor((lengths[index] - remainingColumns - 1) / columns);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wrap-ansi",
3
- "version": "5.1.0",
3
+ "version": "6.0.0",
4
4
  "description": "Wordwrap a string with ANSI escape codes",
5
5
  "license": "MIT",
6
6
  "repository": "chalk/wrap-ansi",
@@ -10,7 +10,7 @@
10
10
  "url": "sindresorhus.com"
11
11
  },
12
12
  "engines": {
13
- "node": ">=6"
13
+ "node": ">=8"
14
14
  },
15
15
  "scripts": {
16
16
  "test": "xo && nyc ava"
@@ -46,16 +46,16 @@
46
46
  "text"
47
47
  ],
48
48
  "dependencies": {
49
- "ansi-styles": "^3.2.0",
50
- "string-width": "^3.0.0",
49
+ "ansi-styles": "^4.0.0",
50
+ "string-width": "^4.1.0",
51
51
  "strip-ansi": "^5.0.0"
52
52
  },
53
53
  "devDependencies": {
54
- "ava": "^1.2.1",
54
+ "ava": "^2.1.0",
55
55
  "chalk": "^2.4.2",
56
56
  "coveralls": "^3.0.3",
57
57
  "has-ansi": "^3.0.0",
58
- "nyc": "^13.3.0",
58
+ "nyc": "^14.1.1",
59
59
  "xo": "^0.24.0"
60
60
  }
61
61
  }
package/readme.md CHANGED
@@ -24,28 +24,14 @@ console.log(wrapAnsi(input, 20));
24
24
 
25
25
  <img width="331" src="screenshot.png">
26
26
 
27
- ---
28
-
29
- <div align="center">
30
- <b>
31
- <a href="https://tidelift.com/subscription/pkg/npm-wrap_ansi?utm_source=npm-wrap-ansi&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
32
- </b>
33
- <br>
34
- <sub>
35
- Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
36
- </sub>
37
- </div>
38
-
39
- ---
40
-
41
27
 
42
28
  ## API
43
29
 
44
- ### wrapAnsi(input, columns, [options])
30
+ ### wrapAnsi(string, columns, options?)
45
31
 
46
32
  Wrap words to the specified column width.
47
33
 
48
- #### input
34
+ #### string
49
35
 
50
36
  Type: `string`
51
37
 
@@ -59,7 +45,7 @@ Number of columns to wrap the text to.
59
45
 
60
46
  #### options
61
47
 
62
- Type: `Object`
48
+ Type: `object`
63
49
 
64
50
  ##### hard
65
51
 
@@ -98,11 +84,14 @@ Whitespace on all lines is removed by default. Set this option to `false` if you
98
84
  - [Benjamin Coe](https://github.com/bcoe)
99
85
 
100
86
 
101
- ## Security
102
-
103
- To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
104
-
105
-
106
- ## License
87
+ ---
107
88
 
108
- MIT
89
+ <div align="center">
90
+ <b>
91
+ <a href="https://tidelift.com/subscription/pkg/npm-wrap_ansi?utm_source=npm-wrap-ansi&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
92
+ </b>
93
+ <br>
94
+ <sub>
95
+ Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
96
+ </sub>
97
+ </div>