A recursive greedy algorithm implementation for the word wrap process.
npm install greedy-wrap> A recursive greedy algorithm implementation for the word wrap process.
> It also correctly calculates the width of the words containing ANSI escape codes and astral symbols.
```
$ npm install --save greedy-wrap
`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('Supercalifragilisticexpialidocious', {width: 10, autoWidth: true});
//=> Result:
Supercalifragilisticexpialidocious
greedyWrap('\u001b1mthis\u001b[22m is a text with only \u001b[1mshort\u001b[22m words.', {width: 10})
//=> Result:
this is a
text with
only short
words.
greedyWrap('Ayo Silver! 🦄🦄🦄', {width: 15})
//=> Result:
Ayo Silver! 🦄🦄🦄
`
#### input
Required
Type: string
#### options
##### width
Type: integer34
Default:
The width of the text.
##### autoWidth
Type: booleanfalse`
Default:
Override the width to the longest word length.
MIT © [Danilo Sampaio