Skip to content
Permalink
Browse files
Add TypeScript definition (#5)
  • Loading branch information
BendingBender authored and sindresorhus committed Mar 18, 2019
1 parent c20aa7f commit 1a5ac930102a6ddebcf3ccfbab4e8fc2ce467421
Showing with 19 additions and 6 deletions.
  1. +4 −0 index.d.ts
  2. +4 −1 index.js
  3. +4 −0 index.test-d.ts
  4. +7 −5 package.json
@@ -0,0 +1,4 @@
/**
Get the visual width of the widest line in a string - the number of columns required to display it.
*/
export default function widestLine(input: string): number;
@@ -1,7 +1,7 @@
'use strict';
const stringWidth = require('string-width');

module.exports = input => {
const widestLine = input => {
let max = 0;

for (const line of input.split('\n')) {
@@ -10,3 +10,6 @@ module.exports = input => {

return max;
};

module.exports = widestLine;
module.exports.default = widestLine;
@@ -0,0 +1,4 @@
import {expectType} from 'tsd-check';
import widestLine from '.';

expectType<number>(widestLine('古\n\u001B[1m@\u001B[22m'));
@@ -13,10 +13,11 @@
"node": ">=6"
},
"scripts": {
"test": "xo && ava"
"test": "xo && ava && tsd-check"
},
"files": [
"index.js"
"index.js",
"index.d.ts"
],
"keywords": [
"string",
@@ -44,10 +45,11 @@
"fixed-width"
],
"dependencies": {
"string-width": "^2.1.1"
"string-width": "^3.1.0"
},
"devDependencies": {
"ava": "^0.25.0",
"xo": "^0.23.0"
"ava": "^1.3.1",
"tsd-check": "^0.5.0",
"xo": "^0.24.0"
}
}

0 comments on commit 1a5ac93

Please sign in to comment.