Utility:
this module exports some utility functions.
- Source:
Methods
(static) cloneToObject(eventnon-null, optionsopt) → {object}
Clone the given CloudEvent in a plain object.
Clone the given CloudEvent in a plain object.
Note that depending on the clone method chosen, a shallow clone could be done
(usually it is, even for performance reasons),
so pay attention using the skipExtensions option in that case.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
event |
object | the CloudEvent to clone | ||
options |
object |
<optional> |
{} | optional attributes: - strict (boolean, default null so no override) to validate it in a more strict way (if null it will be used strict mode in the given event), - onlyValid (boolean, default false) to return it only if it's a valid instance, - printDebugInfo (boolean, default false) to print some debug info to the console, - skipExtensions (boolean, default false) to skip all non-standard (so extensions) properties, |
- Source:
Throws:
-
-
if event is not a CloudEvent instance or subclass
- Type
- TypeError
-
-
-
if event is undefined or null, or an option is undefined/null/wrong
- Type
- Error
-
Returns:
the event, as a plain object
- Type
- object
(inner) createFromObject(objnon-null, optionsopt) → {object}
Create and return a CloudEvent from the given object and options.
Create and return a CloudEvent from the given object and options.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
obj |
object | the plain object instance to use (its properties will be used) | ||
options |
object |
<optional> |
{} | optional attributes: - strict (boolean, default null so no override) to validate it in a more strict way (if null it will be used strict mode in the given event), - onlyValid (boolean, default false) to return it only if it's a valid instance, - printDebugInfo (boolean, default false) to print some debug info to the console, - skipExtensions (boolean, default false) to skip all non-standard (so extensions) properties, |
- Source:
Throws:
-
-
if object is not a plain object instance
- Type
- TypeError
-
-
-
if object is undefined or null, or an option is undefined/null/wrong, or is not possible to create a CloudEvent instance
- Type
- Error
-
Returns:
the created CloudEvent instance
- Type
- object