Class LinkFinder

Collects visited links that satisfy predicate

Example

const itemLinkFinder = new LinkFinder((link) => link.rel.includes('item'));

await entity.accept(itemLinkFinder);

if (!itemLinkFinder.isEmpty) {
const firstItemLink = itemLinkFinder.links[0];
entity = await follow(firstItemLink).then(parse);
}

// reset the link finder and do it again
itemLinkFinder.reset();
await entity.accept(itemLinkFinder);

Hierarchy

Constructors

Properties

_links: Link[] = []
predicate: ((link: Link) => boolean)

Type declaration

    • (link: Link): boolean
    • Parameters

      Returns boolean

Accessors

  • get isEmpty(): boolean
  • Indicates whether any visited links have satisfied predicate

    Returns boolean

  • List of visited links that have satisfied predicate

    Returns readonly Link[]

Methods

  • Resets this visitor, forgetting all visited links

    Returns void

Generated using TypeDoc