Socket
Socket
Sign inDemoInstall

smartwrap

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smartwrap

Textwrap for javascript/nodejs. Correctly handles wide characters (宽字符) and emojis (😃). Automatically breaks long words.


Version published
Weekly downloads
544K
decreased by-14.09%
Maintainers
1
Weekly downloads
 
Created
Source

smartwrap

Build Status Dependency Status NPM version

Textwrap for javascript/nodejs. Correctly handles wide characters (宽字符) and emojis (😃). Automatically breaks long words.

Why?

I needed a javascript package to correctly wrap wide characters - which have a "length" property value of 1 but occupy 2 or more spaces in the terminal.

Example Usages:

Terminal:

npm i -g smartwrap
echo somestring you want to wrap | smartwrap --width=3 --paddingLeft=1
Output:
 so
 me
 st
 ri
 ng
 yo
 u
 wa
 nt
 to
 wr
 ap

Node module:

var Smartwrap = require('smartwrap');
var exampleText1 = '宽字符';
console.log(Smartwrap(exampleText1,{
  width: 2
}));
Output:
宽
字
符

Options

  --minWidth      Never change this unless you are certin you are not using
                  wide characters and you want a column 1 space wide. Then
                  change to 1.                   [choices: 1, 2] [default: 2]
  --paddingLeft   Set the left padding of the output             [default: 0]
  --paddingRight  Set the right padding of the output            [default: 0]
  --splitAt       Characters at which to split input    [default: [" ","\t"]]
  --trim          Trim the whitespace from end of input       [default: true]
  --width, -w     Set the line width of the output (in spaces)
                                                     [required] [default: 10]

Compatibility

node 4.0 <

License

GPL 2.0

Keywords

FAQs

Package last updated on 28 Aug 2019

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