UNPKG

crawler-ts

Version:

Lightweight crawler written in TypeScript using ES6 generators.

26 lines (25 loc) 1.25 kB
import { Logger } from './crawl'; export declare type Filter<T> = ({ location }: { location: T; }) => boolean; export declare type ToString<T> = (location: T) => string; export declare const toString: ToString<any>; export declare function chain<A>(...fns: Array<(a: A) => boolean>): (a: A) => boolean; export declare function chain<A, B>(...fns: Array<(a: A, b: B) => boolean>): (a: A, b: B) => boolean; /** * Create a filter that allows specific extensions. */ export declare const allowExtensions: <T>(strFn?: ToString<T>) => (allowedExtensions: string[], logger?: Logger | undefined) => Filter<T>; /** * Create a filter that allows values matching the given regexes. */ export declare const allowRegex: <T>(strFn?: ToString<T>) => (allowUrls: RegExp[], logger?: Logger | undefined) => Filter<T>; /** * Create a filter that ignores values matching the given regexes. */ export declare const ignoreRegex: <T>(strFn?: ToString<T>) => (ignoredUrls: RegExp[], logger?: Logger | undefined) => Filter<T>; /** * Create a filter that ignores doubles. */ export declare const ignoreDoubles: <T>(strFn?: ToString<T>) => (logger?: Logger | undefined) => Filter<T>; export declare const cache: <T>(strFn?: ToString<T>) => (fn: Filter<T>) => Filter<T>;