Skip to content

Commit 89dc7f6

Browse files
BendingBendersindresorhus
authored andcommittedMar 18, 2019
Add TypeScript definition (#28)
1 parent 5cb7e20 commit 89dc7f6

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed
 

‎index.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
Strip [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code).
3+
*/
4+
export default function stripAnsi(str: string): string;

‎index.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
'use strict';
22
const ansiRegex = require('ansi-regex');
33

4-
module.exports = input => typeof input === 'string' ? input.replace(ansiRegex(), '') : input;
4+
const stripAnsi = input => typeof input === 'string' ? input.replace(ansiRegex(), '') : input;
5+
6+
module.exports = stripAnsi;
7+
module.exports.default = stripAnsi;

‎index.test-d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import {expectType} from 'tsd-check';
2+
import stripAnsi from '.';
3+
4+
expectType<string>(stripAnsi('\u001b[4mcake\u001b[0m'));

‎package.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
"node": ">=6"
1414
},
1515
"scripts": {
16-
"test": "xo && ava"
16+
"test": "xo && ava && tsd-check"
1717
},
1818
"files": [
19-
"index.js"
19+
"index.js",
20+
"index.d.ts"
2021
],
2122
"keywords": [
2223
"strip",
@@ -46,7 +47,8 @@
4647
"ansi-regex": "^4.1.0"
4748
},
4849
"devDependencies": {
49-
"ava": "^0.25.0",
50-
"xo": "^0.23.0"
50+
"ava": "^1.3.1",
51+
"tsd-check": "^0.5.0",
52+
"xo": "^0.24.0"
5153
}
5254
}

0 commit comments

Comments
 (0)
Please sign in to comment.