word-wrap
Wrap words to a specified length.
Install
Install with npm
npm i word-wrap --save
Usage
var wrap = require('word-wrap');
var str = 'A project without documentation is like a project that doesn\'t exist. Verb solves this by making it dead simple to generate project documentation, using simple markdown templates, with zero configuration required.';
console.log(wrap(str));
Results in:
A project without documentation is like a project
that doesn't exist. Verb solves this by making it
dead simple to generate project documentation,
using simple markdown templates, with zero
configuration required.
Options
trim
Type: Boolean
Default: false
Trim trailing whitespace from the returned string.
Example:
wrap(str, {trim: true});
width
Type: Number
Default: 50
The width of the text before wrapping to a new line.
Example:
wrap(str, {width: 60});
indent
Type: String
Default:
(two spaces)
The string to use at the beginning of each line.
Example:
wrap(str, {indent: ' '});
newline
Type: String
Default: \n
The string to use at the end of each line.
Example:
wrap(str, {newline: '\n\n'});
Author
Jon Schlinkert
License
Copyright (c) 2014 Jon Schlinkert
Released under the , licenses
This file was generated by verb on December 04, 2014.