src/typedefs.jsdoc

/**
 * Functions for converting information extracted from a web page into the information used to render links.
 * @callback dataTransformer
 * @param {module:page-data.PageData} pData - The web page data to be transrormed to link data.
 * @returns {module:link-data.LinkData} The link information derived from the page data.
 */

/**
 * Functions for filtering template field values before their use to render links. Arbitrarily many of these functions can be added to a template in order to filter individual fields, or all fields.
 * @callback templateFieldFilterFunction
 * @param {string} originalString - the original value for the field to be filtered.
 * @returns {string} the filtered version of the original string.
 */

/**
 * A function that can optionally be added to a template to facilitate the extraction of exta data fields from web pages that can then be utilised by the template to render the link.
 * @callback extraFieldExtractorFunction
 * @param {module:cheerio} pageDOM - the parsed webpage content
 * @returns {Object.<string, string>}
 */

/**
 * A page metadata object. Each key represents one of the standard or pseudo-standard HTML metadata fields.
 * @typedef {Object<string, string>} pageMetadataObject
 * @property {string} author
 * @property {string} creator
 * @property {string} description
 * @property {string[]} keywords
 * @property {string} publisher
 * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/meta/name} for relevant documentation from the Mozilla Developer Network (MDN).
 */

/**
 * A tupple (array of length exactly two) for assigning a field filter to a template.
 * @typedef {Array} templateFieldFilterTuple
 * @property {"all"|"url"|"text"|"description"} 0 - the property the filter should be applied to.
 * @property {templateFieldFilterFunction} 1 - the filter function to apply.
 */

/**
 * A plain object represeting the information about about link that can get utilised in a template.
 *
 * Note that the `uri` could contain more fields - it's initialised with output from the `URI.parse()` function from the `URI` module.
 * @typedef {Object} plainLinkInformationObject
 * @property {string} url - the URL for the link.
 * @property {string} text - the text for the link.
 * @property {string} description - a description for the link.
 * @property {Object.<string, string>} extraFields - any extra fields extracted from the page source.
 * @property {Object} uri - the URL's components
 * @property {string} uri.hostname - the hostname part of the URL.
 * @property {string} uri.path - the path part of the UL, `/` for an empty path.
 * @property {boolean} uri.hasPath - whether or not the URL has a path, note that `/` is considered no path.
 * @see {@link https://medialize.github.io/URI.js/docs.html#static-parse}
 */

/**
 * A plain object representing the infomration extracted from a web page.
 * 
 * Note that the `uri` could contain more fields - it's initialised with output from the `URI.parse()` function from the `URI` module.
 * @typedef {Object} plainPageInformationObject
 * @property {string} url - the page's URL.
 * @property {string} title - the page's title.
 * @property {pageMetadataObject} metadata - the metadata extracted from the `<meta>` tags in the page's `<head>` tag.
 * @property {string[]} topLevelHeadings - the text from the page's `<h1>` tags.
 * @property {string[]} secondaryHeadings - text from the page's `<h2>` tags.
 * @property {string} mainHeading - the text from the most semantically important heading that exists in the page.
 * @property {Object.<string, string>} extraFields - any extra fields extracted from the page source.
 * @property {Object} uri - the URL's components
 * @property {string} uri.hostname - the hostname part of the URL.
 * @property {string} uri.path - the path part of the UL, `/` for an empty path.
 * @property {boolean} uri.hasPath - whether or not the URL has a path, note that `/` is considered no path.
 * @see {@link https://medialize.github.io/URI.js/docs.html#static-parse}
 */

/**
 * A plain object containing configuration information for customising Linkifier objects and commandline interface (CLI) options.
 * @typedef {Object} configurationObject
 * @property {module:linkifier-class.Linkifier} [linkifier] a configured linkifier.
 * @property {Object} [options] values for the options accepted by the CLI's `generate` command.
 * @see {@link module:cli}
 */