Skip to content

Commit

Permalink
Require Node.js 8, add TypeScript definition (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
BendingBender authored and sindresorhus committed May 3, 2019
1 parent 7daf6f3 commit ac8e847
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: node_js
node_js:
- '12'
- '10'
- '8'
- '6'
34 changes: 34 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import words = require('./words.json');

declare const superb: {
/**
All the words in alphabetical order.
@example
```
import superb = require('superb');
superb.all;
//=> ['ace', 'amazing', …]
```
*/
readonly all: Readonly<typeof words>;

/**
Random word.
@example
```
import superb = require('superb');
superb.random();
//=> 'legendary'
superb.random();
//=> 'awesome'
```
*/
random(): string;
};

export = superb;
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 superb = require('.');

expectType<readonly string[]>(superb.all);
expectType<string>(superb.random());
17 changes: 12 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
"url": "sindresorhus.com"
},
"engines": {
"node": ">=6"
"node": ">=8"
},
"scripts": {
"test": "xo && ava"
"test": "xo && ava && tsd"
},
"files": [
"index.js",
"index.d.ts",
"words.json"
],
"keywords": [
Expand All @@ -29,10 +30,16 @@
"random"
],
"dependencies": {
"unique-random-array": "^1.0.0"
"unique-random-array": "^2.0.0"
},
"devDependencies": {
"ava": "*",
"xo": "*"
"ava": "^1.4.1",
"tsd": "^0.7.2",
"xo": "^0.24.0"
},
"tsd": {
"compilerOptions": {
"resolveJsonModule": true
}
}
}
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ superb.random();
//=> 'awesome'

superb.all;
//=> ['superb', 'legendary', …]
//=> ['ace', 'amazing', …]
```

## API

### .all

Type: `Array`
Type: `string[]`

All the words in alphabetical order.

Expand Down

0 comments on commit ac8e847

Please sign in to comment.