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 🙏

© 2026 – Pkg Stats / Ryan Hefner

pad-without-control-characters

v1.0.0

Published

Works like padStart/padEnd, but accounts for terminal/VT control characters

Readme

pad-without-control-characters

Maintenance status: Maintained. This project is AI-free and bans all AI contributions.

When using String#padStart or String#padEnd with strings that are formatted for terminal display (eg. adding color), you'll quickly discover that the resulting padding length is... not quite right. This happens because terminal styling works with 'control characters' that the terminal doesn't display, but that are still part of the string. It's kind of like the terminal equivalent of HTML tags.

But because JS isn't a terminal and so it doesn't do anything terminal-specific, padEnd and padStart (correctly!) count these 'invisible' characters as normal, and so it believes the string to be longer than it really is. So, it doesn't pad it as much as it should. This makes sense from a JS perspective, but it's really annoying when you're trying to do things like drawing boxes and borders in the terminal!

So, this module fixes that with a variant of padStart and padEnd that doesn't count control characters in the original string's length. It doesn't remove them - they'll still be there in the resulting string. It just adds a different amount of padding.

The semantics of these functions should be the same as those of String#padStart and String#padEnd. If this is not the case, please file a bug!

A note on styling of the padding

NOTE: This module intentionally does not try to understand the meaning of the control characters, and so it doesn't modify them. Because of how these control codes work, that means that padding at the end may be styled (depending on your styling implementation), but padding at the start won't be styled. If you need an entire string including the padding to be styled, you should always make sure to do the padding before the styling, and not the other way around. So:

styleText("red", padWithoutCC.start("your string goes here", 80)) // correct!
// ... instead of ...
padWithoutCC.start(styleText("red", "your string goes here"), 80) // wrong!

Usage example

const { styleText } = require("node:util");
const padWithoutCC = require("pad-without-control-characters");

let style = ["bgGreen", "black", "bold"];

// filled out to 80 columns on the right (but always 2 columns of padding on the other side):
console.log(styleText(style, padWithoutCC.end("  this is your string!  ", 80)));
// and on the left:
console.log(styleText(style, padWithoutCC.start("  this is your string!  ", 80)));

Changelog

1.0.0 (August 20, 2026)

Initial release.