Constructor
new Namespace(storage, nameopt, separatoropt)
Creates a new instance of Namespace.
Parameters
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
storage |
Storage | Modules storage. | ||
name |
string |
<optional> |
Namespace name. | |
separator |
string |
<optional> |
/ | Namespace separator. |
Methods
const(name, definition) → {Namespace}
Register a value, such as a string, a number, an array, an object or a function.
Parameters
Name | Type | Description |
---|---|---|
name |
string | Module name. |
definition |
string | number | object | array | function | Module value. |
factory(name, dependenciesopt, definition) → {Namespace}
Registers a factory of a singleton.
Parameters
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
name |
string | Module name. | ||
dependencies |
array |
<optional> |
[] | Module dependencies. |
definition |
function | Module factory. |
namespace(name) → {Namespace}
Returns a sub namespace.
Parameters
Name | Type | Description |
---|---|---|
name |
string | Name of a sub namespace. |
service(name, dependenciesopt, definition) → {Namespace}
Registers a constructor of a singleton.
Given function will be invoked with a `new` keyword when it gets resolved.
Parameters
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
name |
string | Module name. | ||
dependencies |
array |
<optional> |
[] | Module dependencies. |
definition |
function | Module constructor that will be instantiated. |
value(name, dependenciesopt, definition) → {Namespace}
Registers a value, such as a string, a number, an array, an object or a function.
If passed value is a function, it will be invoked
with a `new` keyword everytime when it gets resolved.
Parameters
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
name |
string | Module name. | ||
dependencies |
array |
<optional> |
[] | Module dependencies. |
definition |
string | number | object | array | function | Module value. |