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

leftpad-everything

v1.0.1

Published

Left-pads everything, including strings, functions, events, promises, and more.

Readme

Left-Pad Everything

A comprehensive library that left-pads everything, including strings, numbers, arrays, dates, promises, functions, errors and so forth. This library is a reflection of the infamous left-pad incident in 2016, which demonstrated the fragility of relying on third-party libraries.

Install via NPM: npm install leftpad-everything

Features

  • String Padding: Left-pad strings with specified characters
  • Number Padding: Left-pad numbers with zeros or custom characters
  • Array Padding: Left-pad arrays with specified values
  • Date Padding: Add padding to date timestamps
  • Boolean Padding: Left-pad boolean values (because why not?)
  • BigInt Padding: Left-pad big integers with zeros or custom characters
  • Multiline Padding: Left-pad each line of a multiline string
  • Event Queue Padding: Left-pad events with priority-based execution
  • Promise Padding: Delay promise resolution
  • Function Padding: Prepend arguments to functions
  • Error Padding: Add padding to error messages
  • Object Padding: Add prefixes to object keys
  • Time Padding: Format time components with leading zeros

Usage

Importing

// CommonJS
const { LeftPad } = require('leftpad-everything');

// ES Modules
import { LeftPad } from 'leftpad-everything';

Examples

String Padding

LeftPad.string('test', 10);          // '      test'
LeftPad.string('test', 10, '0');      // '000000test'

Number Padding

LeftPad.number(42, 5);                // '00042'
LeftPad.number(42, 5, 'x');           // 'xxx42'

Array Padding

LeftPad.array([1, 2, 3], 5);          // [undefined, undefined, 1, 2, 3]
LeftPad.array([1, 2, 3], 5, 0);       // [0, 0, 1, 2, 3]

Date Padding

const now = new Date();
LeftPad.date(now, 1000);              // Date object 1 second in the future

Boolean Padding

LeftPad.boolean(true, 10);            // '       true'
LeftPad.boolean(false, 10);           // '      false'

BigInt Padding

LeftPad.bigint(12345n, 10);           // '0000012345'

Multiline Padding

const multiline = 'Hello\nWorld';
LeftPad.multiline(multiline, 10);     // '     Hello\n     World'

Event Queue Padding

let dismissEvent = void 0;
for (let i = 0; i < 10; i++) {
    const eventFunc = () => console.log(`Event ${i}`);
    if (i === 5) dismissEvent = eventFunc;
    LeftPad.event(eventFunc, Number(i % 2));
}
LeftPad.events.off(dismissEvent);     // Dismisses the specific event
LeftPad.invoke();                     // Executes events in priority order

Promise Padding

const promise = new Promise(resolve => resolve('Done'));
LeftPad.promise(promise, 1000).then(console.log); // Delays resolution by 1 second

Function Padding

const add = (a, b) => a + b;
const paddedAdd = LeftPad.function(add, 10);
paddedAdd(5);                         // Returns 15 (10 + 5)

Error Padding

try {
  LeftPad.error(new Error('Test error'), '  ');
} catch (err) {
  console.log(err.message);            // '  Test error'
}

Object Padding

const obj = { a: 1, b: 2 };
LeftPad.object(obj, 'prefix_');       // { prefix_a: 1, prefix_b: 2 }

Time Padding

LeftPad.time(9, 5, 3);                // '09:05:03'
LeftPad.time(12, 30, 45);             // '12:30:45'

License

MIT