Module: resource/util

Helper functions.

Classes

FailedHttpRequestError
IncorrectResponseError

Methods


<static> decodeHtmlEntity(str)

Decode HTML entities in given string.
Parameters:
Name Type Description
str String String that should be processed.
Returns:
Decoded string.
Type
String

<static> getHttpRequestError(err, response)

Return object that represents data about error of HTTP request.
If err parameter is set then it will be returned. Otherwise instance of FailedHttpRequestError will be returned.
Parameters:
Name Type Description
err Error Represents data about error.
response http.IncomingMessage Represents data about response.
Returns:
Error object.
Type
Error

<static> getLimit( [settings] [, defaultValue] [, maxValue])

Return value of limit setting. Default value will be returned if limit field is not present in settings parameter.
Parameters:
Name Type Argument Description
settings Object <optional>
Operation settings. The object can have numeric limit field which value will be returned if the value is positive number and not greater than maximum value. Otherwise value of defaultValue parameter will be returned.
defaultValue Number <optional>
Default value of limit. maxValue is used when parameter value is not passed or 0.
maxValue Number <optional>
Maximum value of limit. Number.MAX_VALUE is used when parameter value is not passed.
Returns:
Value that corresponds to limit setting.
Type
Number

<static> getRequestSettings( [settings] [, json])

Return request settings.
Parameters:
Name Type Argument Default Description
settings Object <optional>
Operation settings. The following settings are used to form request settings (name - type - description):
  • requestTimeout - Integer - Number of milliseconds to wait for a response before aborting a data request
json Boolean <optional>
true Whether the setting to process response as JSON should be added.
Returns:
Request settings.
Type
Object

<static> isRealSearchSet( [settings])

Determine whether search should be made instead of check according to operation settings.
Parameters:
Name Type Argument Description
settings Object <optional>
Operation settings. The following settings are used to specify real search (name - type - description):
  • search - Boolean - Whether search should be made instead of check
Returns:
true if real search should be made according to settings, false otherwise.
Type
Boolean

<static> isSearchSet( [settings])

Check whether search should be made according to operation settings.
Parameters:
Name Type Argument Description
settings Object <optional>
Operation settings. The following settings are used to specify search (name - type - description):
  • caseSensitive - Boolean - Whether case-sensitive check/search should be used
  • partialMatch - Integer - Allow partial matching: 0 - disallow (by default), 1 - allow at the beginning of matching strings, 2 - allow substring matching
  • search - Boolean - Whether search should be made instead of check
Returns:
true if search should be made according to settings, false otherwise.
Type
Boolean

<static> isStringMatch(value, searchValue [, settings])

Check whether one of given strings is similar to the searched string.
Parameters:
Name Type Argument Description
value Array | String String or array of strings that should be checked.
searchValue String Value that is searched for.
settings Object <optional>
Operation settings. The following settings are supported (name - type - description):
  • caseSensitive - Boolean - Whether case-sensitive check should be used
  • partialMatch - Integer - Allow partial matching: 0 - disallow (by default), 1 - allow at the beginning of matching strings, 2 - allow substring matching
  • search - Boolean - Whether search should be made instead of check
Returns:
true if one of given strings is similar to the searched string according to settings, false otherwise.
Type
Boolean