Container

Container

Represents a container for registered modules.

Constructor

new Container(paramsopt, paramsopt)

Creates a new instance of Container.
Parameters
Name Type Attributes Default Description
params string <optional>
"/" Namespace separator.
params object <optional>
null Container settings.
Properties
Name Type Attributes Default Description
separator string <optional>
"/" Namespace separator.
panic boolean <optional>
false Indicates whether it needs to throw an error when module not found.

Methods

(static) map(namespaces, separatoropt) → {function}

Converts object/array to a function chain that's help to use namespaces.
Parameters
Name Type Attributes Default Description
namespaces Object | Array.<any> An object or an array of nested namespace names.
separator string <optional>
/ Namespace separator.
Returns
Chain of functions that converts a module name into a full module path.
Type
function

clear(namespaceopt) → {Container}

Clears a container or a given namespace. If namespace name is passed - removes all modules in the namespace.
Parameters
Name Type Attributes Default Description
namespace Namespace | string <optional>
undefine Namespace or namespace name
Returns
Returns current instance of Container.
Type
Container

contains(fullPath) → {boolean}

Determines whether a module exists by a given path.
Parameters
Name Type Description
fullPath string Module full path.
Returns
Value that determines whether a module exists by a given path.
Type
boolean

resolve(fullPath) → {any}

Resolves a module by a given full path.
Parameters
Name Type Description
fullPath string Module's full path.
Returns
Module value.
Type
any

resolveAll(namespace, nestedopt) → {Map.<string, (any|Array.<any>)>}

Resolves all modules from a given namespace.
Parameters
Name Type Attributes Default Description
namespace Namespace | string Namespace or namespace name
nested boolean <optional>
false Value that detects whether it needs to resolve modules from nested namespaces. If 'true', all resolved values will be put into an array.
Returns
Map of module values, where key is a module name.
Type
Map.<string, (any|Array.<any>)>

size(namespaceopt) → {number}

Returns size of whole container or a namespace. If namespace was given, count of items inside this namespace will be returned.
Parameters
Name Type Attributes Default Description
namespace Namespace | string <optional>
undefine Namespace or namespace name
Returns
Size of a container/namespace.
Type
number