UNPKG

recrawl

Version:

[![npm](https://img.shields.io/npm/v/recrawl.svg)](https://www.npmjs.com/package/recrawl) [![ci](https://github.com/aleclarson/recrawl/actions/workflows/release.yml/badge.svg)](https://github.com/aleclarson/recrawl/actions/workflows/release.yml) [![codeco

31 lines (26 loc) 925 B
import { FileAdapter } from './fs' export type DirFilter = (dir: string, depth: number) => boolean export type FileFilter = (file: string, name: string) => boolean export type LinkFilter = (link: string, depth: number) => boolean export type RecrawlOptions = Options type Options = { only?: (string | RegExp)[] skip?: (string | RegExp)[] deep?: boolean depth?: number enter?: DirFilter filter?: FileFilter follow?: boolean | number | LinkFilter adapter?: FileAdapter absolute?: boolean } export type EachArg = (file: string, link: string | null) => void export type FilesArg = FileMap | string[] export type FileMap = { [name: string]: string | boolean } export interface Crawler<T extends Options> { (root: string): Promise< T['follow'] extends true | LinkFilter ? FileMap : string[] > (root: string, each: EachArg): Promise<void> <T extends FilesArg>(root: string, files: T): Promise<T> }