Skip to content

Commit

Permalink
Merge branch 'add-ts-declaration' of https://github.com/AndrewNeo/scr…
Browse files Browse the repository at this point in the history
…ape-it into new-version
  • Loading branch information
IonicaBizau committed Dec 23, 2017
2 parents 76215f4 + 1f2d452 commit f31aa53
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.1",
"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 f31aa53

Please sign in to comment.