-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjsutils.js
executable file
·89 lines (59 loc) · 2.6 KB
/
jsutils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
if (typeof exports !== 'undefined') {
if (typeof module !== 'undefined' && module.exports) {
// nodejs support
var _global = require("./utils/Global.js");
module.exports = function () {
var _module = {
Object: require("./utils/Object.js"),
Array: require("./utils/Array.js"),
Template: require("./utils/Template.js"),
NPM: require("./utils/NPM.js"),
Task: require("./utils/Task.js"),
// require libxmljs in case of enable
// XML: require("./utils/XML.js"),
init: function (config) {
if (config) {
if ('log' in config) {
_global.set("log", config.log);
}
}
},
testlog: function () {
require("./utils/Logger.js").log(".... testing the log... ");
}
};
return _module;
}();
}
} else {
define(["jsutilsObjectModule", "jsutilsArrayModule", "jsutilsTemplateModule"], function (obj, arr, tpl) {
var _jsutils = function() {
var __jsutils = {};
return {
init: function(obj, arr, tpl) {
__jsutils.jsutilsObject = obj;
__jsutils.jsutilsArray = arr;
__jsutils.jsutilsTemplate = tpl;
__jsutils.listen = function(jsutilsOnReady) {
var jsutilsOnReadyListener,
jsutilsOnReadyDefaultListener = function () {
console.log("js.utils is ready (jsutilsReady callback can be overriden [e.g. jsutilsOnReady=function(obj, arr, tpl){}]");
};
if (typeof jsutilsOnReady !== "undefined") {
jsutilsOnReadyListener = jsutilsOnReady;
} else {
jsutilsOnReadyListener = jsutilsOnReadyDefaultListener;
}
jsutilsOnReadyListener.call(jsutils, obj, arr, tpl);
};
},
getJSUtils: function() {
return __jsutils;
}
}
},
jsutilsh = new _jsutils();
jsutilsh.init(obj, arr, tpl);
return jsutilsh;
});
}