Skip to content

Commit

Permalink
fix: update Typescript types (#643)
Browse files Browse the repository at this point in the history
  • Loading branch information
xxRockOnxx committed Jun 15, 2023
1 parent e5ad93d commit c6e84b9
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions packages/metascraper/src/index.d.ts
@@ -1,13 +1,15 @@
declare module 'metascraper' {
export default function MetaParser(rules: Rule[]): Scraper;
export default function MetaParser(rules: RuleSet[]): Scraper;

type Scraper = (options: ScrapOptions) => Promise<Metadata>;

interface ScrapOptions {
url: string;
html?: string;
rules?: Rule[];
rules?: RuleSet[];
validateUrl?: boolean;
}

interface Metadata {
author: string;
date: string;
Expand All @@ -17,17 +19,21 @@ declare module 'metascraper' {
title: string;
url: string;
}

type RuleSet = {
[C in keyof Metadata]?: Array<Check>;
};
} & {
test?: (options: CheckOptions) => boolean;
}

type Check = (options: CheckOptions) => string | null | undefined;

interface CheckOptions {
htmlDom: typeof import('cheerio');
htmlDom: import('cheerio').CheerioAPI;
url: string
}
type Rule = () => RuleSet;
}

declare module 'metascraper-*' {
export default function rules(): import('metascraper').Rule;
export default function rules(): import('metascraper').RuleSet;
}

0 comments on commit c6e84b9

Please sign in to comment.