Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danilosampaio/longest-length
Get the longest word length in text. It also correctly calculate the length of the words containing ansi escape codes.
https://github.com/danilosampaio/longest-length
ansi-escape-codes longest-word
Last synced: about 1 month ago
JSON representation
Get the longest word length in text. It also correctly calculate the length of the words containing ansi escape codes.
- Host: GitHub
- URL: https://github.com/danilosampaio/longest-length
- Owner: danilosampaio
- License: mit
- Created: 2015-07-24T00:00:08.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-11-30T14:26:27.000Z (about 8 years ago)
- Last Synced: 2024-10-30T14:44:16.860Z (about 2 months ago)
- Topics: ansi-escape-codes, longest-word
- Language: JavaScript
- Size: 6.84 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# longest-length [![Build Status](https://travis-ci.org/danilosampaio/longest-length.svg?branch=master)](https://travis-ci.org/danilosampaio/longest-length)
> 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
```js
var longestLength = require('longest-length');longestLength('Supercalifragilisticexpialidocious is long word')
//=> 34longestLength('\u001b[1mthis\u001b[22m is a dummy text')
//=> 5longestLength('π¦πΊπ¦')
//=> 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](http://github.org/danilosampaio)