Module: format

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
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 from data parameter
  • verbose - 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 or null 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 or null 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 module exports.
Type
Object
Copyright (c) 2014 Denis Sikuler
Documentation generated by JSDoc 3.2.2 on Sun Jul 13 2014 23:52:09 GMT+0400 (MSK) using the DocStrap template.