Grammalecte  Check-in [4f87f76619]

Overview
Comment:[core][js] helpers: funcOutput as private attribute
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core | webext2
Files: files | file ages | folders
SHA3-256: 4f87f766195d198b3fdae197743ca84d777fcd8af4bdf4c09e6ffeef63433806
User & Date: olr on 2017-07-31 17:00:16
Other Links: branch diff | manifest | tags
Context
2017-07-31
19:30
[core][js] cregex as object + revert previous commit check-in: baa88da03c user: olr tags: core, webext2
17:00
[core][js] helpers: funcOutput as private attribute check-in: 4f87f76619 user: olr tags: core, webext2
16:35
[core][js] mfsp as object check-in: 47815bc2dc user: olr tags: core, webext2
Changes

Modified gc_core/js/helpers.js from [c3386dc3e8] to [1057b5fe4e].

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
..
89
90
91
92
93
94
95
96
97

98
99
100
101
102
103
104
105

// 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;
................................................................................
            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;
}





>
>
|
|
|

<

<
|
<
<
<
<
<



|
|











|
|







 







<

>








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
..
84
85
86
87
88
89
90

91
92
93
94
95
96
97
98
99
100

// 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;
................................................................................
            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;
}