JSON Model-to-Model Projection (JM2MP) Documentation

JSON Model-to-Model Projection (JM2MP) Documentation

Module

jm2mp/modules/helpers

The module helpers implements helper functions related with JM2MP projection modules.

Source

Members

staticconstant

ROOT_TEMPLATE_NAMEstring

The name of the root template of any JM2MP projection. Its value is '$'.

Type

  • string

Source

Methods

static

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

  • boolean

    true whenever module is valid as a projection module; false otherwise.

Source

static

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>

    true whenever moduleName can be import'ed; false otherwise.

Source

static

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

  • object

    The projection module built using rootProjection's value as its root projection.

Source

static

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

  • object

    The projection module built using rootProjection's value as its root projection and namedTemplates as the rest of templates.

Source