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

monowrap

v1.0.4

Published

Intelligently wrap monospaced text.

Downloads

39

Readme

monowrap

Intelligently wrap monospaced text.

Usage

usage.txt


Usage:	foo  --bar --baz --bing --ring

Options:
	--foo	Is a simple test of how well the wrapping works.
	--bar	blah blah blah blah

And some fairly long text with a tab	which should make it wrap to the end of that tab.

 1)	testing one two three four

example.js

var fs = require('fs');
var monowrap = require('monowrap');

var text = fs.readFileSync('usage.txt');

var output = monowrap(text, {
	
	// Wrap text to this many columns. Defaults to no wrapping. If you're going
	// to print out to a terminal from Node, you can get the current width of
	// the terminal from `process.stdout.columns`.
	width: 26,

	// Set width of a tab character. Defaults to 4.
	tabWidth: 4,

	// Treat multiple spaces as if they are a tab stop for indenting purposes.
	// Defaults to off. Zero, negative numbers, false, and non-numeric values
	// are equivalent and will turn off the feature. True and 1 are equivalent
	// to 2. The number is the number of spaces needed to be seen as a tab stop.
	spacedTabStop: 2,

	// Override line ending detection.
	eol: "\n",

	// Ensure that the output begins with exactly this many line breaks.
	top: 0,

	// Ensure that the output ends with exactly this many line breaks.
	bottom: 1

});

console.log(output);

output

Usage:  foo  --bar --baz
             --bing --ring

Options:
    --foo   Is a simple
            test of how
            well the
            wrapping
            works.
    --bar   blah blah blah
            blah

And some fairly long text
with a tab  which should
            make it wrap
            to the end of
            that tab.

 1) testing one two three
    four

If you just want to wrap text to a specific width, leaving all the other options at their default values, you can pass a number as the second parameter instead of an options map.

monowrap(text, 80);
// Is the same as...
monowrap(text, { width: 80 });

Notes

Line endings are always normalized. The type will be automatically detected unless overridden by setting the "eol" option.

Tabs will be replaced with spaces.

Indentation is maintained to the last tab stop.