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

emoji-space-shim

v0.1.3

Published

shim console.log to fix emoji space render issues across terminals

Readme

emoji-space-shim

shim console.log to fix emoji space render issues across terminals.

problem

some emojis render incorrectly across different terminals due to character width inconsistencies. for example, the beaver emoji (🦫) may appear to "eat" the space after it in VS Code's terminal, while it renders correctly in other terminals.

before (without shim)

// vscode terminal - space after emoji is "eaten"
console.log('🦫 beaver')
→ 🦫beaver        ← space disappeared!

// other terminals - renders correctly
console.log('🦫 beaver')
→ 🦫 beaver       ← space preserved

after (with shim)

// vscode terminal - shim adds extra space to compensate
console.log('🦫 beaver')
→ 🦫 beaver       ← looks correct!

// other terminals - no adjustment needed
console.log('🦫 beaver')
→ 🦫 beaver       ← still correct

solution

this package provides a shim that automatically adjusts space after emojis based on the detected terminal. this ensures consistent visual output.

install

npm install emoji-space-shim

usage

basic usage

import { shimConsoleLog } from 'emoji-space-shim';

// apply the shim (auto-detects terminal)
const shim = shimConsoleLog();

// console.log now adjusts emoji space automatically
console.log('🦫 hello world');

// restore original behavior when done
shim.restore();

explicit terminal

import { shimConsoleLog } from 'emoji-space-shim';

// specify terminal explicitly
const shim = shimConsoleLog({ terminal: 'vscode' });

console.log('🦫 hello world'); // outputs: "🦫  hello world" (extra space added)

scoped usage with automatic cleanup

import { withEmojiSpaceShim } from 'emoji-space-shim';

// shim is applied for duration of logic, then automatically restored
const result = await withEmojiSpaceShim({
  logic: async () => {
    console.log('🦫 hello world'); // emoji space adjusted
    return await doWork();
  },
});

// console.log is restored to original behavior here
console.log('normal log'); // no emoji adjustment

this is useful when you want to:

  • ensure the shim is always cleaned up (even if errors occur)
  • scope the shim to a specific block of code
  • avoid manual restore() calls

terminal support

| terminal | detection | | -------- | ----------------------------------- | | vscode | TERM_PROGRAM === 'vscode' | | xterm | TERM.includes('xterm') | | gnome | TERM_PROGRAM === 'gnome-terminal' | | default | fallback |

extend the registry

you can extend the emoji registry for custom emoji support:

import { EMOJI_SPACE_REGISTRY, shimConsoleLog } from 'emoji-space-shim';

// add custom emoji rules
EMOJI_SPACE_REGISTRY['🎉'] = { vscode: 1, default: 0 };

// now shim will handle this emoji too
const shim = shimConsoleLog();
console.log('🎉 celebration');

exports

| export | description | | ----------------------------- | ---------------------------------- | | shimConsoleLog | main shim function | | withEmojiSpaceShim | scoped wrapper with auto-cleanup | | TerminalChoice | type for terminal variants | | EMOJI_SPACE_REGISTRY | emoji space rules dictionary | | detectTerminalChoice | terminal detection function | | computeSpaceAdjustment | space calculation function | | transformMessageForTerminal | message transform function |

how it works

  1. detectTerminalChoice() determines the current terminal from environment variables
  2. computeSpaceAdjustment() looks up the required space for each emoji in the registry
  3. transformMessageForTerminal() applies the space adjustments to strings
  4. shimConsoleLog() wraps console.log to automatically transform all string arguments