Package Exports
- wordwrapjs
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (wordwrapjs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
wordwrapjs
Word wrapping, with a few features. Namely the capability to ignore certain text patterns when wrapping (e.g. to prevent ansi escape sequences breaking layout in the terminal.)
Example
Wrap some sick bars in a 20 character column.
> wrap = require("wordwrapjs")
> bars = "I'm rapping. I'm rapping. I'm rap rap rapping. I'm rap rap rap rap rappity rapping."
> result = wrap(bars, { width: 20 })result now looks like this:
I'm rapping. I'm
rapping. I'm rap rap
rapping. I'm rap rap
rap rap rappity
rapping.
wrap(text, [options]) ⇒ string ⏏
Kind: Exported function
| Param | Type | Default | Description |
|---|---|---|---|
| text | string |
the input text to wrap | |
| [options] | object |
optional config | |
| [options.width] | number |
30 |
the max column width in characters |
| [options.ignore] | RegExp | Array.<RegExp> |
one or more patterns to be ignored when sizing the newly wrapped lines. For example ignore: /\u001b.*?m/g will ignore unprintable ansi escape sequences. |
|
| [options.newLine] | string |
"os.EOL" |
the desired new line character to use, defaults to os.EOL. |
© 2015 Lloyd Brookes <75pound@gmail.com>. Documented by jsdoc-to-markdown.