danilosampaio / longest-length

Get the longest word length in text. It also correctly calculate the length of the words containing ansi escape codes.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

longest-length Build Status

Get the length of the longest word in a string. It also correctly calculates the length of the words containing ANSI escape codes and astral symbols.

Install

$ npm install --save longest-length

Usage

var longestLength = require('longest-length');

longestLength('Supercalifragilisticexpialidocious is long word')
//=> 34


longestLength('\u001b[1mthis\u001b[22m is a dummy text')
//=> 5

longestLength('🦄🍺🦄')
//=> 3

API

longestLength(input, [options])

input

Required
Type: string

options

stripAnsiCodes

Type: boolean
Default: true

Get the real length of a string.

splitRegex

Type: regex
Default: /\S+/g

Regex used to split text in words.

License

MIT © Danilo Sampaio

About

Get the longest word length in text. It also correctly calculate the length of the words containing ansi escape codes.

License:MIT License


Languages

Language:JavaScript 100.0%