Skip to content

fabiospampinato/fast-string-width

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fast String Width

A fast function for calculating the visual width of a string once printed to the terminal.

Install

npm install --save fast-string-width

Usage

import fastStringWidth from 'fast-string-width';

// Calculating the visual width of some strings

fastStringWidth ( 'hello' ); // => 5
fastStringWidth ( '\x1b[31mhello' ); // => 5
fastStringWidth ( '👨‍👩‍👧‍👦' ); // => 2
fastStringWidth ( 'hello👨‍👩‍👧‍👦' ); // => 7

// Calculating the visual width while tweaking the width of emojis

fastStringWidth ( '👶👶🏽', { emojiWidth: 1.5 } ); // => 3

License

MIT © Fabio Spampinato

About

A fast function for calculating the visual width of a string once printed to the terminal.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 51.0%
  • TypeScript 49.0%