1. widest-line
Get the visual width of the widest line in a string - the number of columns required to display it
widest-line
Package: widest-line
Created by: sindresorhus
Last modified: Wed, 12 Apr 2023 02:45:55 GMT
Version: 4.0.1
License: MIT
Downloads: 55,634,461
Repository: https://github.com/sindresorhus/widest-line

Install

npm install widest-line
yarn add widest-line

widest-line

Get the visual width of the widest line in a string - the number of columns required to display it

Some Unicode characters are fullwidth and use double the normal width. ANSI escape codes are stripped and doesn't affect the width.

Useful to be able to know the maximum width a string will take up in the terminal.

Install

 npm install widest-line

Usage

 import widestLine from 'widest-line';

widestLine('古\n\u001B[1m@\u001B[22m');
//=> 2

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code