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

greedy-wrap

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

greedy-wrap

A recursive greedy algorithm implementation for the word wrap process.

  • 0.1.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

greedy-wrap Build Status

A recursive greedy algorithm implementation for the word wrap process. It also correctly calculate the width of the words containing ansi escape codes.

Install

$ npm install --save greedy-wrap

Usage

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('\u001b[1mthis\u001b[22m is a text with only \u001b[1mshort\u001b[22m words.', {width: 10})

//=> Result:

this is a 
text with 
only short
words.

API

greedyWrap(input, [options])

input

Required
Type: string

options
width

Type: integer Default: 34

The width of the text.

autoWidth

Type: boolean Default: false

Override the width to the longest word length.

License

MIT © Danilo Sampaio

Keywords

FAQs

Package last updated on 04 Aug 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