Socket
Socket
Sign inDemoInstall

widest-line

Package Overview
Dependencies
5
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    widest-line

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


Version published
Weekly downloads
13M
increased by1.7%
Maintainers
1
Install size
125 kB
Created
Weekly downloads
 

Package description

What is widest-line?

The widest-line npm package is designed to find and return the length of the longest line in a string, taking into account and handling ANSI escape codes which are often used for coloring or styling terminal output. This can be particularly useful when trying to format console output or determine the necessary width for a text-based UI component.

What are widest-line's main functionalities?

Get the length of the longest line in a string

This feature allows you to determine the length of the longest line in a given multi-line string, which can be useful for formatting console output or for creating text-based UI components that need to accommodate variable-length content.

"const widestLine = require('widest-line');

const text = 'Some string with\nseveral lines\nand varying lengths.';
const longestLineLength = widestLine(text);
console.log(longestLineLength); // Outputs the length of the widest line"

Other packages similar to widest-line

Readme

Source

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
  • string-width - Get the visual width of a string

Keywords

FAQs

Last updated on 12 Oct 2021

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc