Skip to content

Commit

Permalink
feat: add typings to package (#16)
Browse files Browse the repository at this point in the history
* feat: add typings to package

* fix: add missing declare keyword

* fix: request.callback should be IncomingMessage

* chore: add comma for linting

* fix: copy some options to top level
  • Loading branch information
unional committed Feb 15, 2020
1 parent b1462ee commit 1241063
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
29 changes: 29 additions & 0 deletions index.d.ts
@@ -0,0 +1,29 @@
import { EventEmitter } from 'events'
import { ClientRequest, IncomingMessage } from 'http'

declare const wget: {
download(src: string, output: string, options?: wget.DownloadOptions): EventEmitter,
request(options: wget.RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest,
}

declare namespace wget {
type RequestOptions = {
gunzip?: boolean,
} | DownloadOptions

type DownloadOptions = {
protocol?: string,
host?: string,
path?: string,
proxy?: {
protocol?: string,
host?: string,
port?: number,
proxyAuth?: string,
headers?: Record<string, string>,
} | string,
method?: string,
}
}

export = wget
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -24,6 +24,7 @@
"bin": {
"nwget": "./bin/nwget"
},
"typings": "index.d.ts",
"dependencies": {
"minimist": "1.2.0",
"tunnel": "0.0.6"
Expand Down
3 changes: 2 additions & 1 deletion test/test.js
@@ -1,9 +1,10 @@
// @ts-check
let crypto = require('crypto');
let fs = require('fs');
let expect = require('chai').expect;
let request = require('request');

let wget = require('../lib/wget');
let wget = require('..');

let baseHTTP = 'http://localhost:8884';
let metadata = {};
Expand Down

0 comments on commit 1241063

Please sign in to comment.