Module: format

API to work with formatters that can be used to format result of search.
Each formatter is a function that should return string representing result of search. The following parameters are passed to the format function:
  • object that is result of search
  • object that represents format settings; the following settings can be used (name - type - description):
    • queryList - Array - list of names/strings that were checked/searched
    • verbose - boolean - whether basic or detailed result should be returned

Methods


<static> exists(name)

Check whether formatter with specified name exists.
Parameters:
Name Type Description
name String Name that should be checked.
See:
Returns:
true if there is a formatter with the specified name, false if no one of formatters has the specified name.
Type
Boolean

<static> format(data, name [, settings])

Format result of search by using specified formatter.
Parameters:
Name Type Argument Description
data Object Result of search.
name String Name of formatter that should be used.
settings Object <optional>
Format settings. Default values for settings are the following:
  • queryList - extracted from data parameter
  • verbose - false
Returns:
Result returned by specified formatter or empty string if no one of formatters has the specified name.
Type
String

<static> get(name)

Return formatter with specified name.
Parameters:
Name Type Description
name String Name of formatter that should be returned.
Returns:
Function that represents formatter or null if no one of formatters has the specified name.
Type
function | null

<static> getMap()

Return object that represents all available formatters.
Returns:
Object that represents all available formatters. Fields are names of formatters, values are corresponding formatters.
Type
Object

<static> getNameList()

Return list containing names of all available formatters.
Returns:
List containing names of all available formatters.
Type
Array

<static> remove(name)

Remove formatter with specified name.
Parameters:
Name Type Description
name String Name of formatter.
Returns:
Function that represents formatter or null if no one of formatters has the specified name.
Type
function | null

<static> set(name, format)

Set formatter with specified name.
Parameters:
Name Type Description
name String Name of formatter.
format function | null Function that represents formatter.
Throws:
Will throw an error if format is not a function.
Returns:
Object that represents module exports.
Type
Object