Home Identifier Source Test Repository
public class | source

Checker

Extends:

src/base~Base → Checker

Static Member Summary

Static Public Members
public static get

Returns application constants model

public static get

Returns application default options

Constructor Summary

Public Constructor
public

constructor(options: Object)

Constructor

Member Summary

Public Members
public get

Returns instance of LinkAnalyzer class

public get

logger: Logger: *

Returns logger instance

public get

model: Model: *

Returns model instance

public get

options: BasedOptions: *

Getter function for options

public get

Returns instance of Statistic class

Private Members
private
private

_model: *

private

_options: BasedOptions

Checker options

private

Method Summary

Public Methods
public

Sets linkAnalyzer instance

public

Sets model instance

public

Sets Statistic instance

public

start(url: String)

Start to crawl pages for given url

Protected Methods
protected

onDone(statistic: Statistic): *

onDone callback function

protected

Processes loaded document

Private Methods
private

_addToQueue(url: String, advanced: Object)

Adds item to check queue

private

Checks given external link item

private

Check all collected external links

private

_checkInternalLink(url: String, advanced: Object, attempt: Number)

Makes request to given external url

private

_getRequestOptions(): {encoding: string, headers: *, timeout: *}

Returns request options hash

private

Function which called after request to given url will be finished

Static Public Members

public static get CONSTANTS: Object: * source

Returns application constants model

Return:

Object

public static get DEFAULT: Object: * source

Returns application default options

Return:

Object

Public Constructors

public constructor(options: Object) source

Constructor

Params:

NameTypeAttributeDescription
options Object
  • optional

— configuration object

options.mode String
  • optional

mode of checking ("website", "section" or "page")

options.concurrent Number
  • optional

— number of concurrent requests

options.requestHeaders Object
  • optional

— set custom request headers for crawler requests

options.requestRetriesAmount Number
  • optional

number of attempts for request if it fails at first

options.requestTimeout Number
  • optional

request timeout (in milliseconds)

options.onDone Function
  • optional

set custom done handler function

options.acceptedSchemes String[]
  • optional

— set array of accepted request acceptedSchemes

options.checkExternalUrls Boolean
  • optional

— set true for check outer links

options.excludeLinkPatterns RegExp[]
  • optional

array of regular expressions. Urls that matches for this regular expressions would be excluded from verification

Public Members

public get linkAnalyzer: LinkAnalyzer: * source

Returns instance of LinkAnalyzer class

Return:

LinkAnalyzer

linkAnalyzer

public get logger: Logger: * source

Returns logger instance

Return:

Logger

logger

public get model: Model: * source

Returns model instance

Return:

Model

model

public get options: BasedOptions: * source

Getter function for options

Return:

BasedOptions

public get statistic: Statistic: * source

Returns instance of Statistic class

Return:

Statistic

statistic

Private Members

private _linkAnalyzer: * source

private _model: * source

private _options: BasedOptions source

Checker options

private _statistic: * source

Public Methods

public initLinkAnalyzer(linkAnalyzer: LinkAnalyzer): Checker source

Sets linkAnalyzer instance

Params:

NameTypeAttributeDescription
linkAnalyzer LinkAnalyzer

Return:

Checker

public initModel(model: Model): Checker source

Sets model instance

Params:

NameTypeAttributeDescription
model Model

instance

Return:

Checker

public initStatistic(statistic: Statistic): Checker source

Sets Statistic instance

Params:

NameTypeAttributeDescription
statistic Statistic

Return:

Checker

public start(url: String) source

Start to crawl pages for given url

Params:

NameTypeAttributeDescription
url String

initial site url for start

Throw:

*

Error

Protected Methods

protected onDone(statistic: Statistic): * source

onDone callback function

Params:

NameTypeAttributeDescription
statistic Statistic

model instance

Return:

*

protected processLoadedDocument(document: Document) source

Processes loaded document

Params:

NameTypeAttributeDescription
document Document

document model

document.url String

request url

document.res HttpResponse | HttpsResponse

response object

Private Methods

private _addToQueue(url: String, advanced: Object) source

Adds item to check queue

Params:

NameTypeAttributeDescription
url String

link url

advanced Object

object with advanced data

Checks given external link item

Params:

NameTypeAttributeDescription
item Object

external link item object

item.url String

external link url

item.advanced Object

external link advanced meta data object

attempt Number

number of request attempt

Return:

Promise

Check all collected external links

Return:

Promise

Makes request to given external url

Params:

NameTypeAttributeDescription
url String

external url (url that should be requested)

advanced Object

object with advanced data

attempt Number

number of request attempt

private _getRequestOptions(): {encoding: string, headers: *, timeout: *} source

Returns request options hash

Return:

{encoding: string, headers: *, timeout: *}

private _onFinishLoad(url: String): * source

Function which called after request to given url will be finished

Params:

NameTypeAttributeDescription
url String

which was requested

Return:

*