Skip to content
Get maximum line length of a string
JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.editorconfig
.gitattributes
.gitignore
.travis.yml
LICENSE
README.md
appveyor.yml
bower.json
max-line-length-cjs.js
max-line-length.js
package.json
test.js

README.md

max-line-length.js

NPM version Bower version Build Status Build status Coverage Status Dependency Status devDependency Status

Get maximum line length of a string

maxLineLength('aaaaaaaa\naaaaaaaaaaaaaaaaaa\r\naaaa\n'); //=> 18

Installation

Package managers

npm

npm install max-line-length

Bower

bower install max-line-length

Standalone

Download the script file and its dependency.

API

maxLineLength(string)

string: String
Return: Array of Number

It returns length of the longest line in a string. "Line" means each part of a string splitted by \n and \r\n.

maxLineLength('one\nanother'); //=> 7
maxLineLength('\r\n'); //=> 0
maxLineLength(''); //=> 0

License

The Unlicense

Something went wrong with that request. Please try again.