UNPKG

dead-or-alive

Version:
121 lines 3.01 kB
/** * Check if a url is dead or alive. * * ###### Notes * * To improve performance, * decrease `maxRetries` and/or decrease the value used * for `sleep`. * The normal behavior is to assume connections might be flakey and to sleep a * while and retry a couple times. * * If you do not care about HTML redirects, * whether anchors work, * and what further URLs are used on, * you can pass `checkAnchor: false`, * `findUrls: false`, * and `followMetaHttpEquiv: false`, * which enables a fast path without parsing HTML. * * @param {Readonly<URL> | string} href * URL. * @param {Readonly<Options> | null | undefined} [options] * Configuration (optional). * @returns {Promise<Result>} * Result. */ export function deadOrAlive(href: Readonly<URL> | string, options?: Readonly<Options> | null | undefined): Promise<Result>; /** * Calculate miliseconds to sleep between tries. * * The function is defined as `x ** 3 * 1000`, * so the first sleep is `1 ** 3 * 1000` is 1s, * 2nd is 8s, * 3rd is 27s, * etc. * * @param {number} retries * Try. * @returns {number} * Miliseconds to sleep. */ export function defaultSleep(retries: number): number; /** * Allow certain anchors. * * This currently allows text fragments everywhere. * * @type {ReadonlyArray<Readonly<AnchorAllow>>} */ export const defaultAnchorAllowlist: ReadonlyArray<Readonly<AnchorAllow>>; /** * State. */ export type State = { /** * Allow anchors. */ anchorAllowlist: ReadonlyArray<Readonly<AnchorAllow>>; /** * Check whether URL hashes point to elements. */ checkAnchor: boolean; /** * Find links in the final resource. */ findUrls: boolean; /** * Follow HTML redirects. */ followMetaHttpEquiv: boolean; /** * Maximum redirects to follow, inclusive. */ maxRedirects: number; /** * Maximum number to try again on failures, inclusive. */ maxRetries: number; /** * Collected messages. */ messages: Array<VFileMessage>; /** * Whether all redirects were permanent. */ permanent: boolean | undefined; /** * Accept `user-content-` prefix in `id` on elements. */ resolveClobberPrefix: boolean; /** * Number of redirects. */ redirects: number; /** * Number of retries. */ retries: number; /** * Calculate miliseconds to sleep between tries. */ sleep: Sleep; /** * Timeout for HTTP request in miliseconds. */ timeout: number; /** * Further URLs, if `findUrls: true`. */ urls: Set<string> | undefined; /** * User agent. */ userAgent: string; }; import type { Options } from 'dead-or-alive'; import type { Result } from 'dead-or-alive'; import type { AnchorAllow } from 'dead-or-alive'; import { VFileMessage } from 'vfile-message'; import type { Sleep } from 'dead-or-alive'; //# sourceMappingURL=index.d.ts.map