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
|
// HELPERS
"use strict";
// In Firefox, there is no console.log in PromiseWorker, but there is worker.log.
// In Thunderbird, you can’t access to console directly. So it’s required to pass a log function.
var funcOutput = null;
var helpers = {
setLogOutput: function (func) {
try {
funcOutput = func;
}
catch (e) {
func(e);
console.error(e);
}
},
echo: function (obj) {
if (funcOutput !== null) {
funcOutput(obj);
} else {
console.log(obj);
}
return true;
},
logerror: function (e, bStack=false) {
let sMsg = "\n" + e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message;
if (bStack) {
sMsg += "\n--- Stack ---\n" + e.stack;
}
if (funcOutput !== null) {
funcOutput(sMsg);
} else {
console.error(sMsg);
}
},
inspect: function (o) {
let sMsg = "__inspect__: " + typeof o;
|
>
>
|
|
|
<
<
|
<
<
<
<
<
|
|
|
|
|
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
|
// HELPERS
"use strict";
var helpers = {
// In Firefox, there is no console.log in PromiseWorker, but there is worker.log.
// In Thunderbird, you can’t access to console directly. So it’s required to pass a log function.
funcOutput: null,
setLogOutput: function (func) {
this.funcOutput = func;
},
echo: function (obj) {
if (this.funcOutput !== null) {
this.funcOutput(obj);
} else {
console.log(obj);
}
return true;
},
logerror: function (e, bStack=false) {
let sMsg = "\n" + e.fileName + "\n" + e.name + "\nline: " + e.lineNumber + "\n" + e.message;
if (bStack) {
sMsg += "\n--- Stack ---\n" + e.stack;
}
if (this.funcOutput !== null) {
this.funcOutput(sMsg);
} else {
console.error(sMsg);
}
},
inspect: function (o) {
let sMsg = "__inspect__: " + typeof o;
|
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
obj[k] = v;
}
return obj;
}
}
if (typeof(exports) !== 'undefined') {
exports.setLogOutput = helpers.setLogOutput;
exports.echo = helpers.echo;
exports.logerror = helpers.logerror;
exports.inspect = helpers.inspect;
exports.loadFile = helpers.loadFile;
exports.objectToMap = helpers.objectToMap;
exports.mapToObject = helpers.mapToObject;
}
|
<
>
|
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
obj[k] = v;
}
return obj;
}
}
if (typeof(exports) !== 'undefined') {
export.funcOutput = helpers.funcOutput;
exports.setLogOutput = helpers.setLogOutput;
exports.echo = helpers.echo;
exports.logerror = helpers.logerror;
exports.inspect = helpers.inspect;
exports.loadFile = helpers.loadFile;
exports.objectToMap = helpers.objectToMap;
exports.mapToObject = helpers.mapToObject;
}
|