JSON Model-to-Model Projection (JM2MP) Documentation

JSON Model-to-Model Projection (JM2MP) Documentation

Module

jm2mp/modules/loaders

The module loaders implements predefined loader functions related with JM2MP projection modules.

All loaders must implement the interface (contract): (name: string) => Promise<object>.

All loaders must be agnostic about query language adapters and just load the corresponding projection module as a JSON value.

Predefined loader functions are:

  • createStringLoader: it loads a projection module directly from memory; it is usefull for testing.
  • createFileLoader: it loads a projection module from the filesystem; it uses Node.js file system module, so it can be used only in applications and not in web browsers.
  • createUrlLoader: it loads a projection module using the Fetch API; it can be used within both web browsers and Node.js v18+ applications.

Source

Methods

static

createFileLoader(optionsopt) → {FileLoaderResult}

Loader based on filesystem, so only on Node.js applications can be used, and not as part of client contexts in web browsers.

Every name will be interpreted as a relative path to baseDir, or as an absolute path.

It dynamically imports node:fs/promises and node:path modules to avoid breaks web browser's use context.

Parameters

  • options object <optional>

    .

    Properties

    • baseDir string <optional>

      It specifies the base directory for relative paths. By default process.cwd() is used.

    • encoding string <optional>
      "utf8"

      By default, it uses UTF-8 encoding.

Returns

  • FileLoaderResult

    The just created FileLoaderResult.

Throws

Whenever 'stringMap' is not an object or is null.

Type
module:jm2mp/modules/LookupAddress.TypeError

Source

static

createStringLoader(stringMap) → {StringLoaderResult}

Loader based on a simple (in memory) map of names and serialized JSON values.

It is usefull for testing purposes or when the projection modules are actually integrated into the code.

Parameters

  • stringMap Object.<string, string>

    The map of names and serialized JSON values.

Returns

  • StringLoaderResult

    The just created StringLoaderResult.

Throws

Whenever 'stringMap' is not an object or is null.

Type
module:jm2mp/modules/LookupAddress.TypeError

Source

static

createUrlLoader(optionsopt) → {UrlLoaderResult}

Loader based on the Fetch API feature, available in modern web browser and as part of Node.js v18+ applications.

Every name is interpreted as an absolute URL, or relative to baseUrl if provided.

Parameters

  • options object <optional>

    .

    Properties

    • baseUrl string <optional>

      It specifies the base URL for relative addresses.

    • fetchOptions RequestInit <optional>

      It allows to specify options for fetch (like headers, credentials, ...).

Returns

  • UrlLoaderResult

    The just created UrlLoaderResult.

Throws

Whenever 'stringMap' is not an object or is null.

Type
module:jm2mp/modules/LookupAddress.TypeError

Source

Type Definitions

FileLoaderResult()

*typedef {Promise<(name: string) => Promise>} FileLoaderResult

Source

StringLoaderResult()

*typedef {(name: string) => Promise} StringLoaderResult

Source

UrlLoaderResult()

*typedef {(name: string) => Promise} UrlLoaderResult

Source

Copyright © 2026 Luis María CÁMARA ROSSI.
Trademark ™ Copyright © 2026 Universidad Nacional de Educación a Distancia (U.N.E.D.).
The JM2MP syntax and this library JM2MP.JS are licensed under BSD-3-Clause [1] [2] license.
See LICENSE.txt for more info.

Documentation generated using JSDoc 3.6.11 and tidy-jsdoc 1.4.1 on 2026-08-26T15:45:19.732Z