Methods
createNameSpace(nameSpaceString)
Create global namespace. This namespace is available how goblal variable on window object.
If parents of base namespace not exists, it's created.
Parameters:
Name | Type | Description |
---|---|---|
nameSpaceString |
String | full namespace |
- Source:
getObjectFromString(namespace) → {Object}
Get object from namespace by string
Parameters:
Name | Type | Description |
---|---|---|
namespace |
String | String namespace |
- Source:
Returns:
object
- Type
- Object
include(path)
Is similar to req function, but this create node script and append into head document
Parameters:
Name | Type | Description |
---|---|---|
path |
'String' | path script |
- Source:
inherits(ctor, superCtor)
Simulate inheritance how other languages
Parameters:
Name | Type | Description |
---|---|---|
ctor |
Object | class |
superCtor |
Object | Class to extend |
- Source:
readOnlyDirectories(directorypath) → {Array.<String>}
Return only folders from path. This can be relative or absolute path.
Parameters:
Name | Type | Description |
---|---|---|
directorypath |
String | folder string |
- Source:
Returns:
Names of folders
- Type
- Array.<String>
req(filepath) → {Object}
Work how require nodejs function. Get file and create object with content, but only that exported by module.exports or exports variable
Parameters:
Name | Type | Description |
---|---|---|
filepath |
String | file module path |
- Source:
Returns:
module export object
- Type
- Object
Examples
mymodule.js
function foo(a,b){ return a + b}
function bar(a,b){ return a - b}
module.exports = { publicfunction : foo }
main.js
var util = new Util();
var mymodule = util.req('mymodule.js');
mymodule.publicfunction(1,2);
// return 3
singleton(Library) → {Object}
With this function apply singleton pattern. Get library by argument and return object that
only has a function (getInstance). This function return instance class and if not exists create it.
Parameters:
Name | Type | Description |
---|---|---|
Library |
Object | Module class |
- Source:
Returns:
Cbject class with getInstance function.
- Type
- Object
uniqueId() → {String}
Generate unique id with numbers and letters.
- Source:
Returns:
UID
- Type
- String