Skip to content
Get 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
line-length-cjs.js
line-length.js
package.json
test.js

README.md

line-length.js

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

Get line length of a string

lineLength('aaaaaaaa\naaaaaaaaaaaaaaaaaaaa\r\naaaaaa\n'); //=> [8, 20, 6, 0]

Installation

Package managers

npm

npm install line-length

Bower

bower install line-length

Duo

const lineLength = require('shinnn/line-length.js');

Standalone

Download the script file directly.

API

lineLength(string)

string: String
Return: Array of Number

It returns an array of line length. "Line" means each part of a string splitted by \n and \r\n.

lineLength('foo'); //=> [3]
lineLength('\n'); //=> [0, 0]
lineLength(''); //=> [0]

License

Copyright (c) 2014 - 2015 Shinnosuke Watanabe

Licensed under the MIT License.

Something went wrong with that request. Please try again.