@wider/registry

A framework for all $wider bundles but also a tracker for different modules of the same name being loaded by different packages of the same

creates

global.$wider = { 
    // container for other wider globals
}

Classes

loggedError

Methods

inner bundle(entries, sectionopt)

Merge one or more objects that do not register themselves, for example because they are a third party package

Care needs to be taken when you act as proxy to register other packages in case different parts of your solution try to register the same third party package. If the risks remain despite your care, check in global.$wider before calling register.

Parameters:
Name Type Attributes Description
entries Array | Object

If this is an array, then it is a collection of objects, each to be registered individually. Each object must contain the property $moduleName, and optionally may contain $objectName, both as defined in registry.register(). If you are registering as proxy, you will need to add these properties to each object before registering them.

section NCName <optional>

if provided then

inner find(moduleName) → {*}

Parameters:
Name Type Description
moduleName String

the module name to be found

Returns:
* -

the result of the search being undefined if the moduleName is unknown, or the

inner loaded() → {String}

Generate a report of the items that have been loaded and how long into the run session it was when they are loaded. NB not all loaded items are published.

Returns:
String -

a tabular report of items loaded

inner merge(moduleNameopt, entries, mergeIdopt)

Merges designated properties in a pre-existing registered object. Often used to add CONSTANTS or CONFIG values

Parameters:
Name Type Attributes Description
moduleName String <optional>

as per registry.register() - if the name is null, then the entries are added at the root of $wider oir the section if provided

entries Dictionary
mergeId NCName <optional>

optional name of the merge for documentary purposes

Throws:

if either the existing module does not exist or if you try to revise an entry that already exists

Type
loggedError

inner published() → {String}

A report of the structure in the object that is published via the common object

Returns:
String -

a tabular report of items published

inner register(moduleNameopt, valueopt, objectNameopt, sectionopt) → {Dictionary}

Registers an object typically as it is being constructed via require or import. The purpose being to ensure that multiple packages within your runtime on a given cluster do not load the same module more than once - as can happen when a package is a dependency of several other packages. This function should only only be called from within the module level code of the module that is registering itself

Parameters:
Name Type Attributes Description
moduleName String <optional>

the name of the item to be registered. The string should be the same as used as might be used as id in require or import, or as used in npm install

If moduleName is an object it is treated as a dictionary of registrations where the keyName is the moduleName and the associated value is an object with the properties value and objectName. It may also contain ***section^^^ which if present will override the section parameter of the call to .register()

If moduleName is absent then nothing is registered and the only action is to return the output Dictionary bundle

value * <optional>

if present then the moduleName must be supplied and this value is added to the bundle.

If absent, then the moduleName, if provided, is registered in the dictionary and nothing is added to the bundle.

If this is an object (class, function, json, plain object) then it should have a $moduleName static property which is the same as the parameter moduleName. It may also have a property $objectName

  • if this is a string then it must be the same as the objectName in this request
  • if this is the value of registry.MERGE then moduleName must already have been registered and the value shall be a dictionary of entries according to section, none of which may pre-exist
objectName NCName <optional>

if objectName is present, then value must be supplied and the value is stored in the response of this @wider/registry response under this name available for direct use by any other module without use of require or import. If objectName is not provided then it will be assumed to be the same as moduleName

section NCName <optional>

if absent then the value is saved under objectName at the top level of the output Dictionary, otherwise this defines the section name in the dictionary under which the value is filed

Throws:

an extension of the javascript `Error`` object. It is thrown when a registration is rejected

Type
loggedError
Returns:
Dictionary -

containing all registered items under their objectname and section.