Constructor
new Storage(separatoropt, panicopt)
Creates a new instance of Storage.
Parameters
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
separator |
string |
<optional> |
/ | Namespace separator. |
panic |
boolean |
<optional> |
true | Indicates whether it needs to throw an error when module not found. |
Methods
clear(namespaceopt) → {Storage}
Clears a storage.
If namespace name is passed - clears a namespace by a given name.
Parameters
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
namespace |
string |
<optional> |
null | Namespace name to clear. |
contains(path) → {boolean}
Determines whether a module exists by a given path.
Parameters
Name | Type | Description |
---|---|---|
path |
string | Module full path. |
Returns
Value that determines whether a module exists by a given path.
- Type
- boolean
forEachIn(namespace) → {Storage}
Iterates over modules in a given namespace.
Parameters
Name | Type | Description |
---|---|---|
namespace |
string | Namespace name. |
Throws
- Error
- If panic="true" and namespace not found.
getItem(fullPath) → {Module}
Finds a module by a given path.
Parameters
Name | Type | Description |
---|---|---|
fullPath |
string | Module full path. |
Throws
- Error
- If panic="true" and module not found.
namespaces(parentopt) → {Array}
Returns an array of registered namespaces.
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
parent |
string |
<optional> |
Parent namespace. |
Returns
An array of registered namespaces.
- Type
- Array
size(namespaceopt) → {number}
Returns size of a storage or namespace.
If namespace was given, count of items inside this namespace will be returned.
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
namespace |
string |
<optional> |
Namespace name |
Returns
Size of a storage/namespace.
- Type
- number