
Security News
NVD Concedes Inability to Keep Pace with Surging CVE Disclosures in 2025
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
fast-string-width
Advanced tools
A fast function for calculating the visual width of a string once printed to the terminal.
A fast function for calculating the visual width of a string once printed to the terminal.
See fast-string-truncated-width
for a lower-level version of this.
npm install fast-string-width
import fastStringWidth from 'fast-string-width';
// The width of various classes of characters is configurable
const options = {
ansiWidth: 0,
controlWidth: 0,
tabWidth: 8,
ambiguousWidth: 1,
emojiWidth: 2,
fullWidthWidth: 2,
regularWidth: 1,
wideWidth: 2
};
// Calculating the visual width of some strings
fastStringWidth ( 'hello', options ); // => 5
fastStringWidth ( '\x1b[31mhello', options ); // => 5
fastStringWidth ( '👨👩👧👦', options ); // => 2
fastStringWidth ( 'hello👨👩👧👦', options ); // => 7
// Calculating the visual width while tweaking the width of emojis
fastStringWidth ( '👶👶🏽', { ...options, emojiWidth: 1.5 } ); // => 3
MIT © Fabio Spampinato
FAQs
A fast function for calculating the visual width of a string once printed to the terminal.
The npm package fast-string-width receives a total of 14,644 weekly downloads. As such, fast-string-width popularity was classified as popular.
We found that fast-string-width demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
Security Fundamentals
Attackers use obfuscation to hide malware in open source packages. Learn how to spot these techniques across npm, PyPI, Maven, and more.
Security News
Join Socket for exclusive networking events, rooftop gatherings, and one-on-one meetings during BSidesSF and RSA 2025 in San Francisco.