Skip to content

Commit

Permalink
Add types, target Node.js 18 (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
tommy-mitchell authored Jul 10, 2024
1 parent a285373 commit 121565b
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 12 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ jobs:
fail-fast: false
matrix:
node-version:
- 14
- 12
- 21
- 20
- 18
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install
Expand Down
15 changes: 15 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
Check if a string has [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code).
@example
```
import hasAnsi from 'has-ansi';
hasAnsi('\u001B[4mUnicorn\u001B[0m');
//=> true
hasAnsi('cake');
//=> false
```
*/
export default function hasAnsi(string: string): boolean;
5 changes: 5 additions & 0 deletions index.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {expectType} from 'tsd';
import hasAnsi from './index.js';

expectType<boolean>(hasAnsi('foo\u001B[4mcake\u001B[0m'));
expectType<boolean>(hasAnsi('cake'));
17 changes: 11 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"exports": {
"default": "./index.js",
"types": "./index.d.ts"
},
"engines": {
"node": ">=12"
"node": ">=18"
},
"scripts": {
"test": "xo && ava"
"test": "xo && ava && tsd"
},
"files": [
"index.js"
"index.js",
"index.d.ts"
],
"keywords": [
"ansi",
Expand Down Expand Up @@ -48,7 +52,8 @@
"ansi-regex": "^6.0.1"
},
"devDependencies": {
"ava": "^3.15.0",
"xo": "^0.44.0"
"ava": "^6.1.3",
"tsd": "^0.31.1",
"xo": "^0.58.0"
}
}
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
## Install

```
$ npm install has-ansi
```sh
npm install has-ansi
```

## Usage
Expand Down

0 comments on commit 121565b

Please sign in to comment.