Skip to content

Commit

Permalink
Require Node.js 6
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Oct 16, 2018
1 parent 11fc924 commit c20aa7f
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 61 deletions.
3 changes: 1 addition & 2 deletions .gitattributes
@@ -1,2 +1 @@
* text=auto
*.js text eol=lf
* text=auto eol=lf
2 changes: 1 addition & 1 deletion .travis.yml
@@ -1,5 +1,5 @@
language: node_js
node_js:
- '10'
- '8'
- '6'
- '4'
6 changes: 5 additions & 1 deletion index.js
Expand Up @@ -3,6 +3,10 @@ const stringWidth = require('string-width');

module.exports = input => {
let max = 0;
for (const s of input.split('\n')) max = Math.max(max, stringWidth(s));

for (const line of input.split('\n')) {
max = Math.max(max, stringWidth(line));
}

return max;
};
103 changes: 51 additions & 52 deletions package.json
@@ -1,54 +1,53 @@
{
"name": "widest-line",
"version": "2.0.1",
"description": "Get the visual width of the widest line in a string - the number of columns required to display it",
"license": "MIT",
"repository": "sindresorhus/widest-line",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"string",
"str",
"character",
"char",
"unicode",
"width",
"visual",
"column",
"columns",
"fullwidth",
"full-width",
"full",
"ansi",
"escape",
"codes",
"cli",
"command-line",
"terminal",
"console",
"cjk",
"chinese",
"japanese",
"korean",
"fixed-width"
],
"dependencies": {
"string-width": "^2.1.1"
},
"devDependencies": {
"ava": "*",
"xo": "*"
}
"name": "widest-line",
"version": "2.0.1",
"description": "Get the visual width of the widest line in a string - the number of columns required to display it",
"license": "MIT",
"repository": "sindresorhus/widest-line",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=6"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"string",
"character",
"char",
"unicode",
"width",
"visual",
"column",
"columns",
"fullwidth",
"full-width",
"full",
"ansi",
"escape",
"codes",
"cli",
"command-line",
"terminal",
"console",
"cjk",
"chinese",
"japanese",
"korean",
"fixed-width"
],
"dependencies": {
"string-width": "^2.1.1"
},
"devDependencies": {
"ava": "^0.25.0",
"xo": "^0.23.0"
}
}
10 changes: 5 additions & 5 deletions test.js
@@ -1,8 +1,8 @@
import test from 'ava';
import m from '.';
import widestLine from '.';

test(t => {
t.is(m('a'), 1);
t.is(m('a\nbe'), 2);
t.is(m('古\n\u001B[1m@\u001B[22m'), 2);
test('main', t => {
t.is(widestLine('a'), 1);
t.is(widestLine('a\nbe'), 2);
t.is(widestLine('古\n\u001B[1m@\u001B[22m'), 2);
});

0 comments on commit c20aa7f

Please sign in to comment.