npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

smartwrap

v2.0.2

Published

Textwrap for javascript/nodejs. Correctly handles wide characters (宽字符) and emojis (😃). Wraps strings with option to break on words.

Downloads

3,157,474

Readme

smartwrap

Build Status Dependency Status NPM version

Textwrap for javascript/nodejs. Correctly handles wide characters (宽字符) and emojis (😃). Optionally break words when wrapping strings.

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:

Wide Character Wrapping

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

String Wrapping

let exampleText2 = "break at word"

console.log(smartwrap(exampleText2,{
  width: 10,
  breakword: false //default
}))
  • Output:
break at
word

Breaking Words When Wrapping Strings

console.log(smartwrap(exampleText2,{
  width: 10,
  breakword: true
}))
  • Output:
break at w
ord

Options

--breakword       Choose whether or not to break words when wrapping a string
                                                                 [default: false]
--errorChar       Placeholder for wide characters when minWidth < 2
                                                                 [default: �]
--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 6.0 <

License

MIT