line-length

Get line length of a string

MIT 2 个版本
安装
npm install line-length
yarn add line-length
pnpm add line-length
bun add line-length
README

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.

版本列表
1.0.1 2015-05-28
1.0.0 2014-11-20