<commit_before># greedy-wrap [![Build Status](https://travis-ci.org/danilosampaio/greedy-wrap.svg?branch=master)](https://travis-ci.org/danilosampaio/greedy-wrap)

> A recursive greedy algorithm implementation for the word wrap process.
> It also correctly calculate the width of the words containing ansi escape codes.


## Install

```
$ npm install --save greedy-wrap
```


## Usage

```js
var greedyWrap = require('greedy-wrap');

greedyWrap('  this is a dummy text that overflows the max width. New lines \nmust be considered.', {width: 20});

//=> Result:

this is a dummy 
text that overflows 
the max width. New 
lines 
must be considered.


greedyWrap('Supercalifragilisticexpialidocious', {width: 10});

//=> Result:

Supercalif
ragilistic
expialidoc
ious


greedyWrap('\u001b[1mthis\u001b[22m is a text with only \u001b[1mshort\u001b[22m words.', {width: 10})

//=> Result:

**this** is a 
text with 
only **short**
words.
```


## API

### greedyWrap(input, [options])

#### input

*Required*  
Type: `string`


#### options

##### width
<commit_msg>Readme tweaks<commit_after># greedy-wrap [![Build Status](https://travis-ci.org/danilosampaio/greedy-wrap.svg?branch=master)](https://travis-ci.org/danilosampaio/greedy-wrap)

> A recursive greedy algorithm implementation for the word wrap process.
> It also correctly calculate the width of the words containing ansi escape codes.


## Install

```
$ npm install --save greedy-wrap
```


## Usage

```js
var greedyWrap = require('greedy-wrap');

greedyWrap('  this is a dummy text that overflows the max width. New lines \nmust be considered.', {width: 20});

//=> Result:

this is a dummy 
text that overflows 
the max width. New 
lines 
must be considered.


greedyWrap('Supercalifragilisticexpialidocious', {width: 10});

//=> Result:

Supercalif
ragilistic
expialidoc
ious


greedyWrap('\u001b[1mthis\u001b[22m is a text with only \u001b[1mshort\u001b[22m words.', {width: 10})

//=> Result:

this is a 
text with 
only short
words.
```


## API

### greedyWrap(input, [options])

#### input

*Required*  
Type: `string`


#### options

##### width

{'fraction_non_alphanumeric': 0.14366729678638943, 'fraction_numerical': 0.022684310018903593, 'mean_word_length': 4.319095477386934, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4681966', 'n_tokens_mistral': 806, 'n_tokens_neox': 719, 'n_words': 215}