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:
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/searchedverbose
-boolean
- whether basic or detailed result should be returned
- Source:
Methods
-
<static> exists(name) → {Boolean}
-
Check whether formatter with specified name exists.
Parameters:
Name Type Description name
String Name that should be checked. - Source:
- 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) → {String}
-
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 fromdata
parameterverbose
-false
- Source:
Returns:
Result returned by specified formatter or empty string if no one of formatters has the specified name.- Type
- String
-
<static> get(name) → {function|null}
-
Return formatter with specified name.
Parameters:
Name Type Description name
String Name of formatter that should be returned. - Source:
Returns:
Function that represents formatter ornull
if no one of formatters has the specified name.- Type
- function | null
-
<static> getMap() → {Object}
-
Return object that represents all available formatters.
- Source:
Returns:
Object that represents all available formatters. Fields are names of formatters, values are corresponding formatters.- Type
- Object
-
<static> getNameList() → {Array}
-
Return list containing names of all available formatters.
- Source:
Returns:
List containing names of all available formatters.- Type
- Array
-
<static> remove(name) → {function|null}
-
Remove formatter with specified name.
Parameters:
Name Type Description name
String Name of formatter. - Source:
Returns:
Function that represents formatter ornull
if no one of formatters has the specified name.- Type
- function | null
-
<static> set(name, format) → {Object}
-
Set formatter with specified name.
Parameters:
Name Type Description name
String Name of formatter. format
function | null Function that represents formatter. - Source:
Throws:
Will throw an error if format is not a function.Returns:
Object that represents moduleexports
.- Type
- Object