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

ansi-wordwrap

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ansi-wordwrap

Word wraps text while ignoring ANSI codes

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.5K
increased by98.4%
Maintainers
1
Weekly downloads
 
Created
Source

ansi-wordwrap

Have you ever needed to word wrap text that had ANSI color codes in it? Did you want to ignore the ANSI color codes? If you answered "heck yeah" to any of those questions then you've come to the right web site.

Installation

npm install ansi-wordwrap

Examples

const wrap = require('ansi-wordwrap')

// use default options
wrap(someLongString)

// specify options
wrap(someLongString, {width: 80, patterns: [/@[A-Z]+@/g]})

Options

The optional second argument is an options object.

width

The width to wrap each line to, defaults to 80.

ignoreAnsi

When set to false this will disable the default pattern for matching ANSI codes, which is /\u001b.*?m/g Defaults to true. Useful if I've done a terrible job of defining this regex.

patterns

An array of regexes representing the patterns that should be ignored. For example, to ignore tokens of the form @TOKEN@, you could do:

wrap(str, {patterns: [/@[A-Z]+@/g]})

Keywords

FAQs

Package last updated on 31 Oct 2018

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