UNPKG

unionpedia-extractor

Version:

Extract incoming and outgoing relations for a concept from unionpedia.org

28 lines (27 loc) 1.12 kB
import LRU from 'lru-cache'; import { CheerioAPI as CheerIOAPI } from 'cheerio'; export declare type Concept = { title: string; href: string; description: string; }; interface CheerioAPI extends CheerIOAPI { exists: boolean; } export default class Unionpedia { private readonly BASE; private readonly CACHE; private readonly CACHE_OUTGOING; private readonly CACHE_INCOMING; private readonly CACHE_HTML; constructor(url?: string, cacheOptions?: LRU.Options<string, Concept | Concept[] | CheerioAPI>, objectCacheOptions?: LRU.Options<string, Concept>, outgoingRelationsCacheOptions?: LRU.Options<string, Concept[]>, incomingRelationsCacheOptions?: LRU.Options<string, Concept[]>, htmlCacheOptions?: LRU.Options<string, CheerioAPI>); private getConceptDescription; private getConceptTitle; private getLinks; private fetchAndParseHTML; private checkForValidConcept; getConceptObject(concept: string): Promise<Concept>; getOutgoingRelations(concept: string): Promise<Concept[]>; getIncomingRelations(concept: string): Promise<Concept[]>; } export {};