All Projects → jonschlinkert → Word Wrap

jonschlinkert / Word Wrap

Licence: mit
Wrap words to a specified length.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Word Wrap

Crossline
A small, self-contained, zero-config, MIT licensed, cross-platform, readline and libedit replacement.
Stars: ✭ 53 (-50.47%)
Mutual labels:  cli, terminal, command-line, console
Tooling
Advancing Node.js as a framework for writing great tools
Stars: ✭ 98 (-8.41%)
Mutual labels:  cli, terminal, command-line, console
Nnn
n³ The unorthodox terminal file manager
Stars: ✭ 13,138 (+12178.5%)
Mutual labels:  cli, terminal, command-line, console
Mandown
man-page inspired Markdown viewer
Stars: ✭ 173 (+61.68%)
Mutual labels:  cli, terminal, command-line, console
Window Size
Reliable way to to get the height and width of the terminal/console in a node.js environment.
Stars: ✭ 79 (-26.17%)
Mutual labels:  cli, terminal, command-line, console
Laravel Zero
A PHP framework for console artisans
Stars: ✭ 2,821 (+2536.45%)
Mutual labels:  cli, terminal, command-line, console
Wonders
🌈 Declarative JavaScript framework to build command-line applications.
Stars: ✭ 34 (-68.22%)
Mutual labels:  cli, terminal, command-line, console
Cointop
A fast and lightweight interactive terminal based UI application for tracking cryptocurrencies 🚀
Stars: ✭ 2,912 (+2621.5%)
Mutual labels:  cli, terminal, command-line, console
Ascii
👾 ASCII Roulette :: ascii art video chat on the cli
Stars: ✭ 202 (+88.79%)
Mutual labels:  cli, terminal, command-line, console
Jquery.terminal
jQuery Terminal Emulator - JavaScript library for creating web-based terminals with custom commands
Stars: ✭ 2,623 (+2351.4%)
Mutual labels:  cli, terminal, command-line, console
Rang
A Minimal, Header only Modern c++ library for terminal goodies 💄✨
Stars: ✭ 1,080 (+909.35%)
Mutual labels:  cli, terminal, command-line, console
Termtools
Customize your terminal using JavaScript. With themes, extra alias and functions, we combine the power from both JavaScript and Bash.
Stars: ✭ 42 (-60.75%)
Mutual labels:  cli, terminal, console
Ed
A modern UNIX ed (line editor) clone written in Go
Stars: ✭ 44 (-58.88%)
Mutual labels:  cli, terminal, command-line
Lucid
A simple mock-application for programs that work with child processes
Stars: ✭ 45 (-57.94%)
Mutual labels:  cli, terminal, command-line
Langterm
🕹️ WebGL-based VT220 emulator, made as a learning example and frontend for a text adventure
Stars: ✭ 35 (-67.29%)
Mutual labels:  cli, terminal, console
Colorette
Easily set the color and style of text in the terminal.
Stars: ✭ 1,047 (+878.5%)
Mutual labels:  cli, terminal, console
Simple Console
Add an elegant command-line interface to any page
Stars: ✭ 107 (+0%)
Mutual labels:  cli, command-line, console
Video To Ascii
It is a simple python package to play videos in the terminal using characters as pixels
Stars: ✭ 960 (+797.2%)
Mutual labels:  cli, terminal, console
Fsq
A tool for querying the file system with a SQL-like language.
Stars: ✭ 60 (-43.93%)
Mutual labels:  cli, terminal, command-line
Ginseng
C++ REPL Tool Builder
Stars: ✭ 65 (-39.25%)
Mutual labels:  cli, terminal, console

word-wrap NPM version NPM monthly downloads NPM total downloads Linux Build Status

Wrap words to a specified length.

Install

Install with npm:

$ npm install --save word-wrap

Usage

var wrap = require('word-wrap');

wrap('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.');

Results in:

  Lorem ipsum dolor sit amet, consectetur adipiscing
  elit, sed do eiusmod tempor incididunt ut labore
  et dolore magna aliqua. Ut enim ad minim veniam,
  quis nostrud exercitation ullamco laboris nisi ut
  aliquip ex ea commodo consequat.

Options

image

options.width

Type: Number

Default: 50

The width of the text before wrapping to a new line.

Example:

wrap(str, {width: 60});

options.indent

Type: String

Default: `` (none)

The string to use at the beginning of each line.

Example:

wrap(str, {indent: '      '});

options.newline

Type: String

Default: \n

The string to use at the end of each line.

Example:

wrap(str, {newline: '\n\n'});

options.escape

Type: function

Default: function(str){return str;}

An escape function to run on each line after splitting them.

Example:

var xmlescape = require('xml-escape');
wrap(str, {
  escape: function(string){
    return xmlescape(string);
  }
});

options.trim

Type: Boolean

Default: false

Trim trailing whitespace from the returned string. This option is included since .trim() would also strip the leading indentation from the first line.

Example:

wrap(str, {trim: true});

options.cut

Type: Boolean

Default: false

Break a word between any two letters when the word is longer than the specified width.

Example:

wrap(str, {cut: true});

About

Related projects

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Contributors

Commits Contributor
43 jonschlinkert
2 lordvlad
2 hildjj
1 danilosampaio
1 2fd
1 toddself
1 wolfgang42
1 zachhale

Building docs

(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)

To generate the readme, run the following command:

$ npm install -g verbose/verb#dev verb-generate-readme && verb

Running tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

$ npm install && npm test

Author

Jon Schlinkert

License

Copyright © 2017, Jon Schlinkert. Released under the MIT License.


This file was generated by verb-generate-readme, v0.6.0, on June 02, 2017.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].