Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require Node.js 8, add TypeScript definition #30

Merged
merged 1 commit into from
May 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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