widest-line

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

MIT 9 个版本
安装
npm install widest-line
yarn add widest-line
pnpm add widest-line
bun add widest-line
README

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
版本列表
6.0.0 2026-01-24
5.0.0 2023-10-28
4.0.1 2021-10-12
4.0.0 2021-04-21
3.1.0 2019-03-31
3.0.0 2019-03-18
2.0.1 2018-10-16
2.0.0 2017-11-30
1.0.0 2015-11-04