Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fair-lines

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fair-lines

Word wrapping with both greedy and balanced (Minimum raggedness) implementations.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

fair-lines

Word wrapping with both greedy and balanced (Minimum raggedness) implementations.

Install with npm

$ npm install fair-lines --save

Usage

Greedy wrapping (basic)

var wrap = require('fair-lines');

var text = "On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, they cannot foresee the pain and trouble that are bound to ensue."
var result = wrap.basic(text, { width: 35 });

Results in:

  On the other hand, we denounce with
  righteous indignation and dislike
  men who are so beguiled and
  demoralized by the charms of
  pleasure of the moment, so blinded
  by desire, they cannot foresee the
  pain and trouble that are bound to
  ensue.

Minimum raggedness (balanced)

var wrap = require('fair-lines');

var text = "On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, they cannot foresee the pain and trouble that are bound to ensue."
var result = wrap.balanced(text, { width: 35 });

Results in:

  On the other hand, we denounce
  with righteous indignation and
  dislike men who are so beguiled
  and demoralized by the charms
  of pleasure of the moment, so
  blinded by desire, they cannot
  foresee the pain and trouble
  that are bound to ensue.

Options

options.width

Type: Number

Default: 30

The line wrapping length

Example:

wrap.balanced(text, {width: 50});

options.indent

Type: Number

Default: 0

The indentation width at the beginning of each line.

Example:

wrap.balanced(text, {indent: 10});

options.respectNL

Type: Boolean

Default: false

Whether or not to respect new line breaks of the text in the output.

Example:

wrap.balanced(text, {respectNL: true});

License

Copyright © 2015 Moustafa Badawy Released under the MIT license.

Keywords

FAQs

Package last updated on 07 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc