Members
(static, readonly) timezoneOffsetMsec :number
Utility variable that returns the timezone offset value, in msec.
Type:
- number
- Source:
Methods
(static) dumpObject(obj, nameopt) → {string}
Utility function that return a dump of the given object.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
obj |
object | Map | Set | the object to dump | ||
name |
string |
<optional> |
'noname' | the name to assign in the returned string, or 'noname' as default value |
- Source:
Returns:
- Type
- string
(static) errorToData(errnon-null, optionsopt) → {object}
Utility function that map an Error into an object (compatible with the CloudEvent standard), to fill its 'data' attribute.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
err |
Error | the Error to transform | ||
options |
object |
<optional> |
{} | transformation options: - includeStackTrace flag (default false) to add the StackTrace into the object to return, - addStatus flag (default true) to add a 'status' attribute into the object to return, - addTimestamp flag (default false) to add the current 'timestamp' as attribute into the object to return, |
- Source:
Throws:
-
if err is undefined or null, or is not an Error instance
- Type
- TypeError
Returns:
- Type
- object
(static) mergeObjects(basenon-null, …others) → {object}
Utility function that merge the given objects (at least one base and another) and returns the new one (but with the prototype of the first).
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
base |
object | the first object to merge | |
others |
object |
<repeatable> |
all other(s) object to merge (at least one) |
- Source:
Throws:
-
if base is undefined or null, or is not an object
- Type
- TypeError
Returns:
- Type
- object
(static) processInfoToData() → {object}
Utility function that get some process-related info and wrap into an object (compatible with the CloudEvent standard), to fill its 'data' attribute.
- Source:
Returns:
- Type
- object
(static) stringFromBase64(objnullable) → {string}
Utility function that decodes a base64 string into a normal string using 'utf8' encoding (compatible with the CloudEvent standard).
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
string |
<nullable> |
the string to decode, or '' if not defined or null |
- Source:
Throws:
-
if str is not a string instance
- Type
- TypeError
Returns:
- Type
- string
(static) stringToBase64(objnullable) → {string}
Utility function that encodes a string in base64 (compatible with the CloudEvent standard).
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
string |
<nullable> |
the string to encode, or '' if not defined or null |
- Source:
Throws:
-
if str is not a string instance
- Type
- TypeError
Returns:
- Type
- string
(static) timestampFromNumber(objnon-null, timezoneOffsetopt) → {object}
Utility function that parse a number representation of the given timestamp (Date) and returns it (if possible).
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
obj |
number | the timestamp/date to parse (as a number) | ||
timezoneOffset |
number |
<optional> |
0 | a timezone offset to add (in msec, default 0) |
- Source:
Throws:
-
if obj is undefined or null, or is not a number
- Type
- TypeError
Returns:
- Type
- object
(static) timestampFromString(objnon-null, timezoneOffsetopt) → {object}
Utility function that parse a string representation (compatible with the CloudEvent standard) of the given timestamp (Date) and returns it (if possible).
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
obj |
string | the timestamp/date to parse (as a string) | ||
timezoneOffset |
number |
<optional> |
0 | a timezone offset to add (in msec, default 0) |
- Source:
Throws:
-
if obj is undefined or null, or is not a string
- Type
- TypeError
Returns:
- Type
- object
(static) timestampToNumber(objnullable) → {number}
Utility function that return a number representation of the given timestamp (Date), or the current one will be used.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
object |
<nullable> |
the timestamp/date to convert, or the current one if not defined or null |
- Source:
Throws:
-
if obj is not a Date instance
- Type
- TypeError
Returns:
- Type
- number
(static) timestampToString(objnullable) → {string}
Utility function that return a string representation (compatible with the CloudEvent standard) of the given timestamp (Date), or the current one will be used.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
obj |
object |
<nullable> |
the timestamp/date to convert, or the current one if not defined or null |
- Source:
Throws:
-
if obj is undefined or null, or is not a Date instance
- Type
- TypeError
Returns:
- Type
- string
(static) uriStripArguments(urlnon-null, optionsopt) → {string}
Utility function that strip all arguments (if any) from the given URI/URL string and returns the string without them.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
url |
string | the URI/URL (as a string) | ||
options |
object |
<optional> |
{} | containing: strict (boolean, default false) to check it in a more strict way |
- Source:
Throws:
-
if url is undefined or null, or is not a string
- Type
- TypeError
Returns:
- Type
- string