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 #9

Merged
merged 1 commit into from
May 2, 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'
84 changes: 84 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import yes = require('./yes.json');
import no = require('./no.json');

declare const yesNoWords: {
/**
Yes like words.

@example
```
import yesNoWords = require('yes-no-words');

yesNoWords.yes;
//=> ['Absolutely', 'Ack', …]
```
*/
readonly yes: Readonly<typeof yes>;

/**
No like words.

@example
```
import yesNoWords = require('yes-no-words');

yesNoWords.no;
//=> ['Absolutely not', 'Ahhh nah', …]
```
*/
readonly no: Readonly<typeof no>;

/**
Both yes and no like words.

@example
```
import yesNoWords = require('yes-no-words');

yesNoWords.all;
//=> ['Absolutely', 'Absolutely not', 'Ack', …]
```
*/
readonly all: Readonly<typeof yes> & Readonly<typeof no>;

/**
Random yes like words.

@example
```
import yesNoWords = require('yes-no-words');

yesNoWords.yesRandom();
//=> 'Yisss'
```
*/
yesRandom(): string;

/**
Random no like words.

@example
```
import yesNoWords = require('yes-no-words');

yesNoWords.noRandom();
//=> 'Forget it'
```
*/
noRandom(): string;

/**
Random yes or no like words.

@example
```
import yesNoWords = require('yes-no-words');

yesNoWords.allRandom();
//=> 'NEIN NEIN NEIN'
```
*/
allRandom(): string;
};

export = yesNoWords;
9 changes: 9 additions & 0 deletions index.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {expectType} from 'tsd';
import yesNoWords = require('.');

expectType<readonly string[]>(yesNoWords.yes);
expectType<readonly string[]>(yesNoWords.no);
expectType<readonly string[]>(yesNoWords.all);
expectType<string>(yesNoWords.yesRandom());
expectType<string>(yesNoWords.noRandom());
expectType<string>(yesNoWords.allRandom());
17 changes: 12 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
"yes-no": "cli.js"
},
"engines": {
"node": ">=6"
"node": ">=8"
},
"scripts": {
"test": "xo && ava"
"test": "xo && ava && tsd"
},
"files": [
"index.js",
"index.d.ts",
"cli.js",
"yes.json",
"no.json"
Expand All @@ -44,10 +45,16 @@
],
"dependencies": {
"meow": "^5.0.0",
"unique-random-array": "^1.0.0"
"unique-random-array": "^2.0.0"
},
"devDependencies": {
"ava": "^0.25.0",
"xo": "^0.23.0"
"ava": "^1.4.1",
"tsd": "^0.7.2",
"xo": "^0.24.0"
},
"tsd": {
"compilerOptions": {
"resolveJsonModule": true
}
}
}
12 changes: 6 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,37 +28,37 @@ yesNoWords.yesRandom();

### .yes

Type: `array`
Type: `string[]`

Yes like words.

### .no

Type: `array`
Type: `string[]`

No like words.

### .all

Type: `array`
Type: `string[]`

Both yes and no like words.

### .yesRandom()

Type: `function`
Type: `Function`

Random yes like words.

### .noRandom()

Type: `function`
Type: `Function`

Random no like words.

### .allRandom()

Type: `function`
Type: `Function`

Random yes or no like words.

Expand Down