Members
ROOT_TEMPLATE_NAMEstring
The name of the root template of any JM2MP projection.
Its value is '$'.
Type
-
string
Source
Methods
isModule(module) → {boolean}
It tests if the module JSON value can be used (considered) as a
projection module or not.
A JSON value can be used as a projection module if:
- It is an object.
- It is not
null. - It is not an array.
Parameters
-
module
*The actual JSON value to test as a valid projection module.
Returns
-
booleantruewhenevermoduleis valid as a projection module;falseotherwise.
Source
isPackagedEsmModuleAvailable(moduleName) → {Promise.<boolean>}
It detects if a package (ESM module) can be imported dynamically.
It is usefull for skip tests whenever an optional dependency is not installed.
Parameters
-
moduleName
string
Returns
-
Promise.<boolean>truewhenevermoduleNamecan be import'ed;falseotherwise.
Source
moduleOf(rootProjection) → {object}
It builds a simple projection module starting from the root template, neither adding options, schema nor named templates.
It is usually used as part of unit and integrations tests.
Parameters
-
rootProjection
*The JSON value for the root projection of the projection module built by this function.
Returns
-
objectThe projection module built using
rootProjection's value as its root projection.
Source
moduleWith(rootProjection, namedTemplatesopt) → {object}
It builds a projection module using rootProjection's value as its
root projection and namedTemplates as the rest of templates.
If namedTemplates also contains a root projection it will be
lost, overriden by rootProjection.
Parameters
-
rootProjection
*The JSON value for the root projection of the projection module built by this function.
-
namedTemplates
object<optional>
Other named templates to be added to the resulting projection module.
Returns
-
objectThe projection module built using
rootProjection's value as its root projection andnamedTemplatesas the rest of templates.
Source
ThrowsValidationErrorWhenIsNotAModule(module)
It throws an ValidationError
whenever module is not a valid module.
Parameters
-
module
*The actual JSON value to test as a valid projection module.
Throws
-
Raised whenever
moduleis not a valid module.