fast-string-width
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

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

Package Sidebar

Install

npm i fast-string-width

Weekly Downloads

16,363

Version

1.0.5

License

none

Unpacked Size

4.35 kB

Total Files

9

Last publish

Collaborators

  • fabiospampinato