'a'
mh-two-thousand-and-two
2024-04-12 44d2c92345cd156a59fc327b3060292a282d2893
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
var extend = require('./extend');
var toArr = require('./toArr');
var inherits = require('./inherits');
var safeGet = require('./safeGet');
var isMiniProgram = require('./isMiniProgram');
exports = function(methods, statics) {
    return Base.extend(methods, statics);
};
function makeClass(parent, methods, statics) {
    statics = statics || {};
    var className =
        methods.className || safeGet(methods, 'initialize.name') || '';
    delete methods.className;
    var ctor = function() {
        var args = toArr(arguments);
        return this.initialize
            ? this.initialize.apply(this, args) || this
            : this;
    };
    if (!isMiniProgram) {
        try {
            ctor = new Function(
                'toArr',
                'return function ' +
                    className +
                    '()' +
                    '{' +
                    'var args = toArr(arguments);' +
                    'return this.initialize ? this.initialize.apply(this, args) || this : this;' +
                    '};'
            )(toArr);
        } catch (e) {}
    }
    inherits(ctor, parent);
    ctor.prototype.constructor = ctor;
    ctor.extend = function(methods, statics) {
        return makeClass(ctor, methods, statics);
    };
    ctor.inherits = function(Class) {
        inherits(ctor, Class);
    };
    ctor.methods = function(methods) {
        extend(ctor.prototype, methods);
        return ctor;
    };
    ctor.statics = function(statics) {
        extend(ctor, statics);
        return ctor;
    };
    ctor.methods(methods).statics(statics);
    return ctor;
}
var Base = (exports.Base = makeClass(Object, {
    className: 'Base',
    callSuper: function(parent, name, args) {
        var superMethod = parent.prototype[name];
        return superMethod.apply(this, args);
    },
    toString: function() {
        return this.constructor.name;
    }
}));
 
module.exports = exports;