🚀 Socket Launch Week 🚀 Day 5: Introducing Socket Fix.Learn More
Socket
Sign inDemoInstall
Socket

widest-line

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

widest-line - npm Package Compare versions

Comparing version

to
4.0.0

29

index.d.ts

@@ -1,21 +0,12 @@

declare const widestLine: {
/**
Get the visual width of the widest line in a string - the number of columns required to display it.
/**
Get the visual width of the widest line in a string - the number of columns required to display it.
@example
```
import widestLine = require('widest-line');
@example
```
import widestLine from 'widest-line';
widestLine('古\n\u001B[1m@\u001B[22m');
//=> 2
```
*/
(input: string): number;
// TODO: remove this in the next major version, refactor definition to:
// declare function widestLine(input: string): number;
// export = widestLine;
default: typeof widestLine;
};
export = widestLine;
widestLine('古\n\u001B[1m@\u001B[22m');
//=> 2
```
*/
export default function widestLine(string: string): number;

@@ -1,16 +0,11 @@

'use strict';
const stringWidth = require('string-width');
import stringWidth from 'string-width';
const widestLine = input => {
let max = 0;
export default function widestLine(string) {
let lineWidth = 0;
for (const line of input.split('\n')) {
max = Math.max(max, stringWidth(line));
for (const line of string.split('\n')) {
lineWidth = Math.max(lineWidth, stringWidth(line));
}
return max;
};
module.exports = widestLine;
// TODO: remove this in the next major version
module.exports.default = widestLine;
return lineWidth;
}
{
"name": "widest-line",
"version": "3.1.0",
"version": "4.0.0",
"description": "Get the visual width of the widest line in a string - the number of columns required to display it",
"license": "MIT",
"repository": "sindresorhus/widest-line",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {

@@ -12,4 +13,6 @@ "name": "Sindre Sorhus",

},
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=8"
"node": ">=12"
},

@@ -48,9 +51,9 @@ "scripts": {

"dependencies": {
"string-width": "^4.0.0"
"string-width": "^5.0.0"
},
"devDependencies": {
"ava": "^1.4.1",
"tsd": "^0.7.1",
"xo": "^0.24.0"
"ava": "^3.15.0",
"tsd": "^0.14.0",
"xo": "^0.39.1"
}
}

@@ -1,2 +0,2 @@

# widest-line [![Build Status](https://travis-ci.org/sindresorhus/widest-line.svg?branch=master)](https://travis-ci.org/sindresorhus/widest-line)
# widest-line

@@ -9,3 +9,2 @@ > Get the visual width of the widest line in a string - the number of columns required to display it

## Install

@@ -17,7 +16,6 @@

## Usage
```js
const widestLine = require('widest-line');
import widestLine from 'widest-line';

@@ -28,10 +26,4 @@ widestLine('古\n\u001B[1m@\u001B[22m');

## Related
- [string-width](https://github.com/sindresorhus/string-width) - Get the visual width of a string
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)

Sorry, the diff of this file is not supported yet