Skip to content

Commit 3483a30

Browse files
committedJul 21, 2017
Require Node.js 4 and meta tweaks
1 parent 02ad690 commit 3483a30

10 files changed

+183
-197
lines changed
 

‎.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ charset = utf-8
77
trim_trailing_whitespace = true
88
insert_final_newline = true
99

10-
[{package.json,*.yml}]
10+
[*.yml]
1111
indent_style = space
1212
indent_size = 2

‎.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
* text=auto
2+
*.js text eol=lf

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
2+
yarn.lock
23
.nyc_output

‎.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

‎.travis.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
language: node_js
22
node_js:
3+
- '8'
34
- '6'
45
- '4'
5-
- '0.12'
6-
- '0.10'
76
after_success: npm run coveralls

‎index.js

+78-83
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,56 @@
11
'use strict';
2-
var stringWidth = require('string-width');
3-
var stripAnsi = require('strip-ansi');
2+
const stringWidth = require('string-width');
3+
const stripAnsi = require('strip-ansi');
44

5-
var ESCAPES = [
6-
'\u001b',
7-
'\u009b'
5+
const ESCAPES = [
6+
'\u001B',
7+
'\u009B'
88
];
99

10-
var END_CODE = 39;
11-
12-
var ESCAPE_CODES = {
13-
0: 0,
14-
1: 22,
15-
2: 22,
16-
3: 23,
17-
4: 24,
18-
7: 27,
19-
8: 28,
20-
9: 29,
21-
30: 39,
22-
31: 39,
23-
32: 39,
24-
33: 39,
25-
34: 39,
26-
35: 39,
27-
36: 39,
28-
37: 39,
29-
90: 39,
30-
40: 49,
31-
41: 49,
32-
42: 49,
33-
43: 49,
34-
44: 49,
35-
45: 49,
36-
46: 49,
37-
47: 49
38-
};
39-
40-
function wrapAnsi(code) {
41-
return ESCAPES[0] + '[' + code + 'm';
42-
}
43-
44-
// calculate the length of words split on ' ', ignoring
45-
// the extra characters added by ansi escape codes.
46-
function wordLengths(str) {
47-
return str.split(' ').map(function (s) {
48-
return stringWidth(s);
49-
});
50-
}
51-
52-
// wrap a long word across multiple rows.
53-
// ansi escape codes do not count towards length.
10+
const END_CODE = 39;
11+
12+
const ESCAPE_CODES = new Map([
13+
[0, 0],
14+
[1, 22],
15+
[2, 22],
16+
[3, 23],
17+
[4, 24],
18+
[7, 27],
19+
[8, 28],
20+
[9, 29],
21+
[30, 39],
22+
[31, 39],
23+
[32, 39],
24+
[33, 39],
25+
[34, 39],
26+
[35, 39],
27+
[36, 39],
28+
[37, 39],
29+
[90, 39],
30+
[40, 49],
31+
[41, 49],
32+
[42, 49],
33+
[43, 49],
34+
[44, 49],
35+
[45, 49],
36+
[46, 49],
37+
[47, 49]
38+
]);
39+
40+
const wrapAnsi = code => `${ESCAPES[0]}[${code}m`;
41+
42+
// Calculate the length of words split on ' ', ignoring
43+
// the extra characters added by ansi escape codes
44+
const wordLengths = str => str.split(' ').map(s => stringWidth(s));
45+
46+
// Wrap a long word across multiple rows
47+
// Ansi escape codes do not count towards length
5448
function wrapWord(rows, word, cols) {
55-
var insideEscape = false;
56-
var visible = stripAnsi(rows[rows.length - 1]).length;
49+
let insideEscape = false;
50+
let visible = stripAnsi(rows[rows.length - 1]).length;
5751

58-
for (var i = 0; i < word.length; i++) {
59-
var x = word[i];
52+
for (let i = 0; i < word.length; i++) {
53+
const x = word[i];
6054

6155
rows[rows.length - 1] += x;
6256

@@ -79,41 +73,41 @@ function wrapWord(rows, word, cols) {
7973
}
8074
}
8175

82-
// it's possible that the last row we copy over is only
83-
// ansi escape characters, handle this edge-case.
76+
// It's possible that the last row we copy over is only
77+
// ansi escape characters, handle this edge-case
8478
if (!visible && rows[rows.length - 1].length > 0 && rows.length > 1) {
8579
rows[rows.length - 2] += rows.pop();
8680
}
8781
}
8882

89-
// the wrap-ansi module can be invoked
90-
// in either 'hard' or 'soft' wrap mode.
83+
// The wrap-ansi module can be invoked
84+
// in either 'hard' or 'soft' wrap mode
9185
//
9286
// 'hard' will never allow a string to take up more
93-
// than cols characters.
87+
// than cols characters
9488
//
95-
// 'soft' allows long words to expand past the column length.
89+
// 'soft' allows long words to expand past the column length
9690
function exec(str, cols, opts) {
97-
var options = opts || {};
91+
const options = opts || {};
9892

99-
var pre = '';
100-
var ret = '';
101-
var escapeCode;
93+
let pre = '';
94+
let ret = '';
95+
let escapeCode;
10296

103-
var lengths = wordLengths(str);
104-
var words = str.split(' ');
105-
var rows = [''];
97+
const lengths = wordLengths(str);
98+
const words = str.split(' ');
99+
const rows = [''];
106100

107-
for (var i = 0, word; (word = words[i]) !== undefined; i++) {
108-
var rowLength = stringWidth(rows[rows.length - 1]);
101+
for (let i = 0, word; (word = words[i]) !== undefined; i++) {
102+
let rowLength = stringWidth(rows[rows.length - 1]);
109103

110104
if (rowLength) {
111105
rows[rows.length - 1] += ' ';
112106
rowLength++;
113107
}
114108

115-
// in 'hard' wrap mode, the length of a line is
116-
// never allowed to extend past 'cols'.
109+
// In 'hard' wrap mode, the length of a line is
110+
// never allowed to extend past 'cols'
117111
if (lengths[i] > cols && options.hard) {
118112
if (rowLength) {
119113
rows.push('');
@@ -139,23 +133,23 @@ function exec(str, cols, opts) {
139133
rows[rows.length - 1] += word;
140134
}
141135

142-
pre = rows.map(function (r) {
143-
return r.trim();
144-
}).join('\n');
136+
pre = rows.map(x => x.trim()).join('\n');
145137

146-
for (var j = 0; j < pre.length; j++) {
147-
var y = pre[j];
138+
for (let j = 0; j < pre.length; j++) {
139+
const y = pre[j];
148140

149141
ret += y;
150142

151143
if (ESCAPES.indexOf(y) !== -1) {
152-
var code = parseFloat(/[0-9][^m]*/.exec(pre.slice(j, j + 4)));
144+
const code = parseFloat(/\d[^m]*/.exec(pre.slice(j, j + 4)));
153145
escapeCode = code === END_CODE ? null : code;
154146
}
155147

156-
if (escapeCode && ESCAPE_CODES[escapeCode]) {
148+
const code = ESCAPE_CODES.get(parseInt(escapeCode, 10));
149+
150+
if (escapeCode && code) {
157151
if (pre[j + 1] === '\n') {
158-
ret += wrapAnsi(ESCAPE_CODES[escapeCode]);
152+
ret += wrapAnsi(code);
159153
} else if (y === '\n') {
160154
ret += wrapAnsi(escapeCode);
161155
}
@@ -165,9 +159,10 @@ function exec(str, cols, opts) {
165159
return ret;
166160
}
167161

168-
// for each line break, invoke the method separately.
169-
module.exports = function (str, cols, opts) {
170-
return String(str).split('\n').map(function (substr) {
171-
return exec(substr, cols, opts);
172-
}).join('\n');
162+
// For each newline, invoke the method separately
163+
module.exports = (str, cols, opts) => {
164+
return String(str)
165+
.split('\n')
166+
.map(line => exec(line, cols, opts))
167+
.join('\n');
173168
};

‎license

+4-16
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
1-
The MIT License (MIT)
1+
MIT License
22

33
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
44

5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
116

12-
The above copyright notice and this permission notice shall be included in
13-
all copies or substantial portions of the Software.
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
148

15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21-
THE SOFTWARE.
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

‎package.json

+60-66
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,62 @@
11
{
2-
"name": "wrap-ansi",
3-
"version": "2.1.0",
4-
"description": "Wordwrap a string with ANSI escape codes",
5-
"license": "MIT",
6-
"repository": "chalk/wrap-ansi",
7-
"author": {
8-
"name": "Sindre Sorhus",
9-
"email": "sindresorhus@gmail.com",
10-
"url": "sindresorhus.com"
11-
},
12-
"maintainers": [
13-
"Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)",
14-
"Joshua Appelman <jappelman@xebia.com> (jbnicolai.com)",
15-
"JD Ballard <i.am.qix@gmail.com> (github.com/qix-)",
16-
"Benjamin Coe <ben@npmjs.com> (github.com/bcoe)"
17-
],
18-
"engines": {
19-
"node": ">=0.10.0"
20-
},
21-
"scripts": {
22-
"test": "xo && nyc ava",
23-
"coveralls": "nyc report --reporter=text-lcov | coveralls"
24-
},
25-
"files": [
26-
"index.js"
27-
],
28-
"keywords": [
29-
"wrap",
30-
"break",
31-
"wordwrap",
32-
"wordbreak",
33-
"linewrap",
34-
"ansi",
35-
"styles",
36-
"color",
37-
"colour",
38-
"colors",
39-
"terminal",
40-
"console",
41-
"cli",
42-
"string",
43-
"tty",
44-
"escape",
45-
"formatting",
46-
"rgb",
47-
"256",
48-
"shell",
49-
"xterm",
50-
"log",
51-
"logging",
52-
"command-line",
53-
"text"
54-
],
55-
"dependencies": {
56-
"string-width": "^1.0.1",
57-
"strip-ansi": "^3.0.1"
58-
},
59-
"devDependencies": {
60-
"ava": "^0.17.0",
61-
"chalk": "^1.1.0",
62-
"coveralls": "^2.11.4",
63-
"has-ansi": "^2.0.0",
64-
"nyc": "^6.2.1",
65-
"strip-ansi": "^3.0.0",
66-
"xo": "^0.16.0"
67-
}
2+
"name": "wrap-ansi",
3+
"version": "2.1.0",
4+
"description": "Wordwrap a string with ANSI escape codes",
5+
"license": "MIT",
6+
"repository": "chalk/wrap-ansi",
7+
"author": {
8+
"name": "Sindre Sorhus",
9+
"email": "sindresorhus@gmail.com",
10+
"url": "sindresorhus.com"
11+
},
12+
"engines": {
13+
"node": ">=4"
14+
},
15+
"scripts": {
16+
"test": "xo && nyc ava",
17+
"coveralls": "nyc report --reporter=text-lcov | coveralls"
18+
},
19+
"files": [
20+
"index.js"
21+
],
22+
"keywords": [
23+
"wrap",
24+
"break",
25+
"wordwrap",
26+
"wordbreak",
27+
"linewrap",
28+
"ansi",
29+
"styles",
30+
"color",
31+
"colour",
32+
"colors",
33+
"terminal",
34+
"console",
35+
"cli",
36+
"string",
37+
"tty",
38+
"escape",
39+
"formatting",
40+
"rgb",
41+
"256",
42+
"shell",
43+
"xterm",
44+
"log",
45+
"logging",
46+
"command-line",
47+
"text"
48+
],
49+
"dependencies": {
50+
"string-width": "^2.1.1",
51+
"strip-ansi": "^4.0.0"
52+
},
53+
"devDependencies": {
54+
"ava": "^0.21.0",
55+
"chalk": "^2.0.1",
56+
"coveralls": "^2.11.4",
57+
"has-ansi": "^3.0.0",
58+
"nyc": "^11.0.3",
59+
"strip-ansi": "^4.0.0",
60+
"xo": "^0.18.2"
61+
}
6862
}

‎readme.md

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# wrap-ansi [![Build Status](https://travis-ci.org/chalk/wrap-ansi.svg?branch=master)](https://travis-ci.org/chalk/wrap-ansi) [![Coverage Status](https://coveralls.io/repos/github/chalk/wrap-ansi/badge.svg?branch=master)](https://coveralls.io/github/chalk/wrap-ansi?branch=master)
22

3-
> Wordwrap a string with [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles)
3+
> Wordwrap a string with [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles)
44
55

66
## Install
77

88
```
9-
$ npm install --save wrap-ansi
9+
$ npm install wrap-ansi
1010
```
1111

1212

@@ -45,6 +45,8 @@ Number of columns to wrap the text to.
4545

4646
#### options
4747

48+
Type: `Object`
49+
4850
##### hard
4951

5052
Type: `boolean`<br>
@@ -68,6 +70,13 @@ By default, an attempt is made to split words at spaces, ensuring that they don'
6870
- [jsesc](https://github.com/mathiasbynens/jsesc) - Generate ASCII-only output from Unicode strings. Useful for creating test fixtures.
6971

7072

73+
## Maintainers
74+
75+
- [Sindre Sorhus](https://github.com/sindresorhus)
76+
- [Josh Junon](https://github.com/qix-)
77+
- [Benjamin Coe](https://github.com/bcoe)
78+
79+
7180
## License
7281

73-
MIT © [Sindre Sorhus](https://sindresorhus.com)
82+
MIT

‎test.js

+24-26
Original file line numberDiff line numberDiff line change
@@ -2,98 +2,96 @@ import test from 'ava';
22
import chalk from 'chalk';
33
import hasAnsi from 'has-ansi';
44
import stripAnsi from 'strip-ansi';
5-
import fn from './';
5+
import m from '.';
66

77
chalk.enabled = true;
88

9-
// when "hard" is false
9+
// When "hard" is false
1010

1111
const fixture = 'The quick brown ' + chalk.red('fox jumped over ') + 'the lazy ' + chalk.green('dog and then ran away with the unicorn.');
1212
const fixture2 = '12345678\n901234567890';
1313
const fixture3 = '12345678\n901234567890 12345';
1414

1515
test('wraps string at 20 characters', t => {
16-
const res20 = fn(fixture, 20);
16+
const res20 = m(fixture, 20);
1717

18-
t.is(res20, 'The quick brown \u001b[31mfox\u001b[39m\n\u001b[31mjumped over \u001b[39mthe lazy\n\u001b[32mdog and then ran\u001b[39m\n\u001b[32maway with the\u001b[39m\n\u001b[32municorn.\u001b[39m');
18+
t.is(res20, 'The quick brown \u001B[31mfox\u001B[39m\n\u001B[31mjumped over \u001B[39mthe lazy\n\u001B[32mdog and then ran\u001B[39m\n\u001B[32maway with the\u001B[39m\n\u001B[32municorn.\u001B[39m');
1919
t.true(stripAnsi(res20).split('\n').every(x => x.length <= 20));
2020
});
2121

2222
test('wraps string at 30 characters', t => {
23-
const res30 = fn(fixture, 30);
23+
const res30 = m(fixture, 30);
2424

25-
t.is(res30, 'The quick brown \u001b[31mfox jumped\u001b[39m\n\u001b[31mover \u001b[39mthe lazy \u001b[32mdog and then ran\u001b[39m\n\u001b[32maway with the unicorn.\u001b[39m');
26-
t.true(stripAnsi(res30).split('\n').every(function (x) {
27-
return x.length <= 30;
28-
}));
25+
t.is(res30, 'The quick brown \u001B[31mfox jumped\u001B[39m\n\u001B[31mover \u001B[39mthe lazy \u001B[32mdog and then ran\u001B[39m\n\u001B[32maway with the unicorn.\u001B[39m');
26+
t.true(stripAnsi(res30).split('\n').every(x => x.length <= 30));
2927
});
3028

3129
test('does not break strings longer than "cols" characters', t => {
32-
const res5 = fn(fixture, 5, {hard: false});
30+
const res5 = m(fixture, 5, {hard: false});
3331

34-
t.is(res5, 'The\nquick\nbrown\n\u001b[31mfox\u001b[39m\n\u001b[31mjumped\u001b[39m\n\u001b[31mover\u001b[39m\n\u001b[31m\u001b[39mthe\nlazy\n\u001b[32mdog\u001b[39m\n\u001b[32mand\u001b[39m\n\u001b[32mthen\u001b[39m\n\u001b[32mran\u001b[39m\n\u001b[32maway\u001b[39m\n\u001b[32mwith\u001b[39m\n\u001b[32mthe\u001b[39m\n\u001b[32municorn.\u001b[39m');
32+
t.is(res5, 'The\nquick\nbrown\n\u001B[31mfox\u001B[39m\n\u001B[31mjumped\u001B[39m\n\u001B[31mover\u001B[39m\n\u001B[31m\u001B[39mthe\nlazy\n\u001B[32mdog\u001B[39m\n\u001B[32mand\u001B[39m\n\u001B[32mthen\u001B[39m\n\u001B[32mran\u001B[39m\n\u001B[32maway\u001B[39m\n\u001B[32mwith\u001B[39m\n\u001B[32mthe\u001B[39m\n\u001B[32municorn.\u001B[39m');
3533
t.true(stripAnsi(res5).split('\n').filter(x => x.length > 5).length > 0);
3634
});
3735

3836
test('handles colored string that wraps on to multiple lines', t => {
39-
const res = fn(chalk.green('hello world') + ' hey!', 5, {hard: false});
37+
const res = m(chalk.green('hello world') + ' hey!', 5, {hard: false});
4038
const lines = res.split('\n');
4139
t.true(hasAnsi(lines[0]));
4240
t.true(hasAnsi(lines[1]));
4341
t.false(hasAnsi(lines[2]));
4442
});
4543

4644
test('does not prepend newline if first string is greater than "cols"', t => {
47-
const res = fn(chalk.green('hello') + '-world', 5, {hard: false});
45+
const res = m(chalk.green('hello') + '-world', 5, {hard: false});
4846
t.is(res.split('\n').length, 1);
4947
});
5048

51-
// when "hard" is true
49+
// When "hard" is true
5250

5351
test('breaks strings longer than "cols" characters', t => {
54-
const res5 = fn(fixture, 5, {hard: true});
52+
const res5 = m(fixture, 5, {hard: true});
5553

56-
t.is(res5, 'The\nquick\nbrown\n\u001b[31mfox\u001b[39m\n\u001b[31mjumpe\u001b[39m\n\u001b[31md\u001b[39m\n\u001b[31mover\u001b[39m\n\u001b[31m\u001b[39mthe\nlazy\n\u001b[32mdog\u001b[39m\n\u001b[32mand\u001b[39m\n\u001b[32mthen\u001b[39m\n\u001b[32mran\u001b[39m\n\u001b[32maway\u001b[39m\n\u001b[32mwith\u001b[39m\n\u001b[32mthe\u001b[39m\n\u001b[32munico\u001b[39m\n\u001b[32mrn.\u001b[39m');
54+
t.is(res5, 'The\nquick\nbrown\n\u001B[31mfox\u001B[39m\n\u001B[31mjumpe\u001B[39m\n\u001B[31md\u001B[39m\n\u001B[31mover\u001B[39m\n\u001B[31m\u001B[39mthe\nlazy\n\u001B[32mdog\u001B[39m\n\u001B[32mand\u001B[39m\n\u001B[32mthen\u001B[39m\n\u001B[32mran\u001B[39m\n\u001B[32maway\u001B[39m\n\u001B[32mwith\u001B[39m\n\u001B[32mthe\u001B[39m\n\u001B[32munico\u001B[39m\n\u001B[32mrn.\u001B[39m');
5755
t.true(stripAnsi(res5).split('\n').every(x => x.length <= 5));
5856
});
5957

6058
test('removes last row if it contained only ansi escape codes', t => {
61-
const res = fn(chalk.green('helloworld'), 2, {hard: true});
59+
const res = m(chalk.green('helloworld'), 2, {hard: true});
6260
t.true(stripAnsi(res).split('\n').every(x => x.length === 2));
6361
});
6462

6563
test('does not prepend newline if first word is split', t => {
66-
const res = fn(chalk.green('hello') + 'world', 5, {hard: true});
64+
const res = m(chalk.green('hello') + 'world', 5, {hard: true});
6765
t.is(res.split('\n').length, 2);
6866
});
6967

7068
test('takes into account line returns inside input', t => {
71-
const res20 = fn(fixture2, 10, {hard: true});
69+
const res20 = m(fixture2, 10, {hard: true});
7270
t.is(res20, '12345678\n9012345678\n90');
7371
});
7472

7573
test('word wrapping', t => {
76-
const res = fn(fixture3, 15);
74+
const res = m(fixture3, 15);
7775
t.is(res, '12345678\n901234567890\n12345');
7876
});
7977

8078
test('no word-wrapping', t => {
81-
const res = fn(fixture3, 15, {wordWrap: false});
79+
const res = m(fixture3, 15, {wordWrap: false});
8280
t.is(res, '12345678\n901234567890 12\n345');
8381

84-
const res2 = fn(fixture3, 5, {wordWrap: false});
82+
const res2 = m(fixture3, 5, {wordWrap: false});
8583
t.is(res2, '12345\n678\n90123\n45678\n90 12\n345');
8684

87-
const res3 = fn(fixture, 5, {wordWrap: false});
88-
t.is(res3, 'The q\nuick\nbrown\n[31mfox j[39m\n[31mumped[39m\n[31mover[39m\n[31m[39mthe l\nazy [32md[39m\n[32mog an[39m\n[32md the[39m\n[32mn ran[39m\n[32maway[39m\n[32mwith[39m\n[32mthe u[39m\n[32mnicor[39m\n[32mn.[39m');
85+
const res3 = m(fixture, 5, {wordWrap: false});
86+
t.is(res3, 'The q\nuick\nbrown\n\u001B[31mfox j\u001B[39m\n\u001B[31mumped\u001B[39m\n\u001B[31mover\u001B[39m\n\u001B[31m\u001B[39mthe l\nazy \u001B[32md\u001B[39m\n\u001B[32mog an\u001B[39m\n\u001B[32md the\u001B[39m\n\u001B[32mn ran\u001B[39m\n\u001B[32maway\u001B[39m\n\u001B[32mwith\u001B[39m\n\u001B[32mthe u\u001B[39m\n\u001B[32mnicor\u001B[39m\n\u001B[32mn.\u001B[39m');
8987
});
9088

9189
// https://github.com/chalk/wrap-ansi/issues/10
9290
test.failing('supports fullwidth characters', t => {
93-
t.is(fn('안녕하세', 4, {hard: true}), '안녕\n하세');
91+
t.is(m('안녕하세', 4, {hard: true}), '안녕\n하세');
9492
});
9593

9694
// https://github.com/chalk/wrap-ansi/issues/11
9795
test.failing('supports unicode surrogate pairs', t => {
98-
t.is(fn('a\ud83c\ude00bc', 2, {hard: true}), 'a\n\ud83c\ude00\nbc');
96+
t.is(m('a\ud83c\ude00bc', 2, {hard: true}), 'a\n\ud83c\ude00\nbc');
9997
});

0 commit comments

Comments
 (0)
Please sign in to comment.