From c20aa7fe7a00f0e8f4c561a274f11b97612b5bff Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Wed, 17 Oct 2018 01:15:13 +0700 Subject: [PATCH] Require Node.js 6 --- .gitattributes | 3 +- .travis.yml | 2 +- index.js | 6 ++- package.json | 103 ++++++++++++++++++++++++------------------------- test.js | 10 ++--- 5 files changed, 63 insertions(+), 61 deletions(-) diff --git a/.gitattributes b/.gitattributes index 391f0a4..6313b56 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1 @@ -* text=auto -*.js text eol=lf +* text=auto eol=lf diff --git a/.travis.yml b/.travis.yml index 7d69d74..2ae9d62 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: node_js node_js: + - '10' - '8' - '6' - - '4' diff --git a/index.js b/index.js index a9865d0..c98a4ae 100644 --- a/index.js +++ b/index.js @@ -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; }; diff --git a/package.json b/package.json index 36e155b..4578af2 100644 --- a/package.json +++ b/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" + } } diff --git a/test.js b/test.js index d77b905..52308b9 100644 --- a/test.js +++ b/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); });