Skip to content

Commit

Permalink
Add Typescript definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
cheeplusplus committed Dec 11, 2017
1 parent a6ab9a7 commit 1f2d452
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
27 changes: 27 additions & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
declare namespace scrapeIt {
export interface ScrapeOptions {
[key: string]: string | ScrapeOptionList | ScrapeOptionElement;
}

export interface ScrapeOptionElement {
selector?: string;
convert?: (value: any) => any;
how?: string | ((element: CheerioSelector) => any);
attr?: string;
trim?: boolean;
closest?: string;
eq?: number;
texteq?: number;
}

export interface ScrapeOptionList {
listItem: string;
data: ScrapeOptions;
}

export function scrapeHTML<T>(body: CheerioStatic | string, options: ScrapeOptions): T;
}

declare function scrapeIt<T>(url: string | object, opts: scrapeIt.ScrapeOptions): Promise<T>;
declare function scrapeIt<T>(url: string | object, opts: scrapeIt.ScrapeOptions, cb: (err: any, res: T) => void): void;
export = scrapeIt;
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"license": "MIT",
"version": "4.1.0",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"test": "node test"
},
Expand Down Expand Up @@ -42,6 +43,7 @@
"typpy": "^2.3.9"
},
"devDependencies": {
"@types/cheerio": "^0.22.6",
"lien": "^1.0.1",
"tester": "^1.4.1"
},
Expand Down

0 comments on commit 1f2d452

Please sign in to comment.